summaryrefslogtreecommitdiff
path: root/gr-qtgui/lib
diff options
context:
space:
mode:
Diffstat (limited to 'gr-qtgui/lib')
-rw-r--r--gr-qtgui/lib/ConstellationDisplayPlot.cc313
-rw-r--r--gr-qtgui/lib/DisplayPlot.cc552
-rw-r--r--gr-qtgui/lib/FrequencyDisplayPlot.cc998
-rw-r--r--gr-qtgui/lib/HistogramDisplayPlot.cc639
-rw-r--r--gr-qtgui/lib/SpectrumGUIClass.cc636
-rw-r--r--gr-qtgui/lib/TimeDomainDisplayPlot.cc964
-rw-r--r--gr-qtgui/lib/TimeRasterDisplayPlot.cc812
-rw-r--r--gr-qtgui/lib/VectorDisplayPlot.cc736
-rw-r--r--gr-qtgui/lib/WaterfallDisplayPlot.cc898
-rw-r--r--gr-qtgui/lib/ber_sink_b_impl.cc605
-rw-r--r--gr-qtgui/lib/ber_sink_b_impl.h128
-rw-r--r--gr-qtgui/lib/const_sink_c_impl.cc856
-rw-r--r--gr-qtgui/lib/const_sink_c_impl.h192
-rw-r--r--gr-qtgui/lib/constellationdisplayform.cc288
-rw-r--r--gr-qtgui/lib/displayform.cc518
-rw-r--r--gr-qtgui/lib/edit_box_msg_impl.cc747
-rw-r--r--gr-qtgui/lib/edit_box_msg_impl.h99
-rw-r--r--gr-qtgui/lib/freq_sink_c_impl.cc1131
-rw-r--r--gr-qtgui/lib/freq_sink_c_impl.h269
-rw-r--r--gr-qtgui/lib/freq_sink_f_impl.cc1169
-rw-r--r--gr-qtgui/lib/freq_sink_f_impl.h269
-rw-r--r--gr-qtgui/lib/freqcontrolpanel.cc483
-rw-r--r--gr-qtgui/lib/freqdisplayform.cc917
-rw-r--r--gr-qtgui/lib/histogram_sink_f_impl.cc705
-rw-r--r--gr-qtgui/lib/histogram_sink_f_impl.h152
-rw-r--r--gr-qtgui/lib/histogramdisplayform.cc265
-rw-r--r--gr-qtgui/lib/number_sink_impl.cc498
-rw-r--r--gr-qtgui/lib/number_sink_impl.h142
-rw-r--r--gr-qtgui/lib/numberdisplayform.cc670
-rw-r--r--gr-qtgui/lib/plot_raster.cc286
-rw-r--r--gr-qtgui/lib/plot_waterfall.cc162
-rw-r--r--gr-qtgui/lib/qtgui_util.cc88
-rw-r--r--gr-qtgui/lib/sink_c_impl.cc593
-rw-r--r--gr-qtgui/lib/sink_c_impl.h159
-rw-r--r--gr-qtgui/lib/sink_f_impl.cc594
-rw-r--r--gr-qtgui/lib/sink_f_impl.h127
-rw-r--r--gr-qtgui/lib/spectrumUpdateEvents.cc616
-rw-r--r--gr-qtgui/lib/spectrumdisplayform.cc1151
-rw-r--r--gr-qtgui/lib/timeRasterGlobalData.cc236
-rw-r--r--gr-qtgui/lib/time_raster_sink_b_impl.cc828
-rw-r--r--gr-qtgui/lib/time_raster_sink_b_impl.h169
-rw-r--r--gr-qtgui/lib/time_raster_sink_f_impl.cc804
-rw-r--r--gr-qtgui/lib/time_raster_sink_f_impl.h167
-rw-r--r--gr-qtgui/lib/time_sink_c_impl.cc1068
-rw-r--r--gr-qtgui/lib/time_sink_c_impl.h225
-rw-r--r--gr-qtgui/lib/time_sink_f_impl.cc1010
-rw-r--r--gr-qtgui/lib/time_sink_f_impl.h221
-rw-r--r--gr-qtgui/lib/timecontrolpanel.cc339
-rw-r--r--gr-qtgui/lib/timedisplayform.cc891
-rw-r--r--gr-qtgui/lib/timerasterdisplayform.cc365
-rw-r--r--gr-qtgui/lib/vector_sink_f_impl.cc637
-rw-r--r--gr-qtgui/lib/vector_sink_f_impl.h182
-rw-r--r--gr-qtgui/lib/vectordisplayform.cc240
-rw-r--r--gr-qtgui/lib/waterfallGlobalData.cc276
-rw-r--r--gr-qtgui/lib/waterfall_sink_c_impl.cc926
-rw-r--r--gr-qtgui/lib/waterfall_sink_c_impl.h210
-rw-r--r--gr-qtgui/lib/waterfall_sink_f_impl.cc964
-rw-r--r--gr-qtgui/lib/waterfall_sink_f_impl.h230
-rw-r--r--gr-qtgui/lib/waterfalldisplayform.cc463
59 files changed, 14280 insertions, 16598 deletions
diff --git a/gr-qtgui/lib/ConstellationDisplayPlot.cc b/gr-qtgui/lib/ConstellationDisplayPlot.cc
index 9d290e08e3..5400b341d3 100644
--- a/gr-qtgui/lib/ConstellationDisplayPlot.cc
+++ b/gr-qtgui/lib/ConstellationDisplayPlot.cc
@@ -30,237 +30,214 @@
#include <QColor>
#include <iostream>
-class ConstellationDisplayZoomer: public QwtPlotZoomer
+class ConstellationDisplayZoomer : public QwtPlotZoomer
{
public:
#if QWT_VERSION < 0x060100
- ConstellationDisplayZoomer(QwtPlotCanvas* canvas)
-#else /* QWT_VERSION < 0x060100 */
- ConstellationDisplayZoomer(QWidget* canvas)
+ ConstellationDisplayZoomer(QwtPlotCanvas* canvas)
+#else /* QWT_VERSION < 0x060100 */
+ ConstellationDisplayZoomer(QWidget* canvas)
#endif /* QWT_VERSION < 0x060100 */
- : QwtPlotZoomer(canvas)
- {
- setTrackerMode(QwtPicker::AlwaysOn);
- }
-
- virtual ~ConstellationDisplayZoomer(){
+ : QwtPlotZoomer(canvas)
+ {
+ setTrackerMode(QwtPicker::AlwaysOn);
+ }
- }
+ virtual ~ConstellationDisplayZoomer() {}
- virtual void updateTrackerText(){
- updateDisplay();
- }
+ virtual void updateTrackerText() { updateDisplay(); }
protected:
- using QwtPlotZoomer::trackerText;
- virtual QwtText trackerText( const QPoint& p ) const
- {
- QwtDoublePoint dp = QwtPlotZoomer::invTransform(p);
- QwtText t(QString("(%1, %2)").arg(dp.x(), 0, 'f', 4).
- arg(dp.y(), 0, 'f', 4));
- return t;
- }
+ using QwtPlotZoomer::trackerText;
+ virtual QwtText trackerText(const QPoint& p) const
+ {
+ QwtDoublePoint dp = QwtPlotZoomer::invTransform(p);
+ QwtText t(QString("(%1, %2)").arg(dp.x(), 0, 'f', 4).arg(dp.y(), 0, 'f', 4));
+ return t;
+ }
};
ConstellationDisplayPlot::ConstellationDisplayPlot(int nplots, QWidget* parent)
- : DisplayPlot(nplots, parent)
+ : DisplayPlot(nplots, parent)
{
- resize(parent->width(), parent->height());
+ resize(parent->width(), parent->height());
- d_numPoints = 1024;
- d_pen_size = 5;
+ d_numPoints = 1024;
+ d_pen_size = 5;
- d_zoomer = new ConstellationDisplayZoomer(canvas());
+ d_zoomer = new ConstellationDisplayZoomer(canvas());
#if QWT_VERSION < 0x060000
- d_zoomer->setSelectionFlags(QwtPicker::RectSelection | QwtPicker::DragSelection);
+ d_zoomer->setSelectionFlags(QwtPicker::RectSelection | QwtPicker::DragSelection);
#endif
- d_zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
- Qt::RightButton, Qt::ControlModifier);
- d_zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
- Qt::RightButton);
+ d_zoomer->setMousePattern(
+ QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier);
+ d_zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
- const QColor c(Qt::darkRed);
- d_zoomer->setRubberBandPen(c);
- d_zoomer->setTrackerPen(c);
+ const QColor c(Qt::darkRed);
+ d_zoomer->setRubberBandPen(c);
+ d_zoomer->setTrackerPen(c);
- d_magnifier->setAxisEnabled(QwtPlot::xBottom, true);
- d_magnifier->setAxisEnabled(QwtPlot::yLeft, true);
+ d_magnifier->setAxisEnabled(QwtPlot::xBottom, true);
+ d_magnifier->setAxisEnabled(QwtPlot::yLeft, true);
- setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine);
- set_xaxis(-2.0, 2.0);
- setAxisTitle(QwtPlot::xBottom, "In-phase");
+ setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine);
+ set_xaxis(-2.0, 2.0);
+ setAxisTitle(QwtPlot::xBottom, "In-phase");
- setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine);
- set_yaxis(-2.0, 2.0);
- setAxisTitle(QwtPlot::yLeft, "Quadrature");
- updateAxes();
+ setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine);
+ set_yaxis(-2.0, 2.0);
+ setAxisTitle(QwtPlot::yLeft, "Quadrature");
+ updateAxes();
- QList<QColor> 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);
+ QList<QColor> 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);
- // Setup dataPoints and plot vectors
- // Automatically deleted when parent is deleted
- for(unsigned int i = 0; i < d_nplots; ++i) {
- d_real_data.push_back(new double[d_numPoints]);
- d_imag_data.push_back(new double[d_numPoints]);
- memset(d_real_data[i], 0x0, d_numPoints*sizeof(double));
- memset(d_imag_data[i], 0x0, d_numPoints*sizeof(double));
+ // Setup dataPoints and plot vectors
+ // Automatically deleted when parent is deleted
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ d_real_data.push_back(new double[d_numPoints]);
+ d_imag_data.push_back(new double[d_numPoints]);
+ memset(d_real_data[i], 0x0, d_numPoints * sizeof(double));
+ memset(d_imag_data[i], 0x0, d_numPoints * sizeof(double));
- d_plot_curve.push_back(new QwtPlotCurve(QString("Data %1").arg(i)));
- d_plot_curve[i]->attach(this);
- d_plot_curve[i]->setPen(QPen(colors[i]));
+ d_plot_curve.push_back(new QwtPlotCurve(QString("Data %1").arg(i)));
+ d_plot_curve[i]->attach(this);
+ d_plot_curve[i]->setPen(QPen(colors[i]));
- QwtSymbol *symbol = new QwtSymbol(QwtSymbol::NoSymbol, QBrush(colors[i]),
- QPen(colors[i]), QSize(7,7));
+ QwtSymbol* symbol = new QwtSymbol(
+ QwtSymbol::NoSymbol, QBrush(colors[i]), QPen(colors[i]), QSize(7, 7));
#if QWT_VERSION < 0x060000
- d_plot_curve[i]->setRawData(d_real_data[i], d_imag_data[i], d_numPoints);
- d_plot_curve[i]->setSymbol(*symbol);
+ d_plot_curve[i]->setRawData(d_real_data[i], d_imag_data[i], d_numPoints);
+ d_plot_curve[i]->setSymbol(*symbol);
#else
- d_plot_curve[i]->setRawSamples(d_real_data[i], d_imag_data[i], d_numPoints);
- d_plot_curve[i]->setSymbol(symbol);
+ d_plot_curve[i]->setRawSamples(d_real_data[i], d_imag_data[i], d_numPoints);
+ d_plot_curve[i]->setSymbol(symbol);
#endif
- setLineStyle(i, Qt::NoPen);
- setLineMarker(i, QwtSymbol::Ellipse);
- }
+ setLineStyle(i, Qt::NoPen);
+ setLineMarker(i, QwtSymbol::Ellipse);
+ }
}
ConstellationDisplayPlot::~ConstellationDisplayPlot()
{
- for(unsigned int i = 0; i < d_nplots; ++i) {
- delete [] d_real_data[i];
- delete [] d_imag_data[i];
- }
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ delete[] d_real_data[i];
+ delete[] d_imag_data[i];
+ }
- // d_plot_curves deleted when parent deleted
- // d_zoomer and d_panner deleted when parent deleted
+ // d_plot_curves deleted when parent deleted
+ // d_zoomer and d_panner deleted when parent deleted
}
-void
-ConstellationDisplayPlot::set_xaxis(double min, double max)
-{
- setXaxis(min, max);
-}
+void ConstellationDisplayPlot::set_xaxis(double min, double max) { setXaxis(min, max); }
-void
-ConstellationDisplayPlot::set_yaxis(double min, double max)
-{
- setYaxis(min, max);
-}
+void ConstellationDisplayPlot::set_yaxis(double min, double max) { setYaxis(min, max); }
-void
-ConstellationDisplayPlot::set_axis(double xmin, double xmax,
- double ymin, double ymax)
+void ConstellationDisplayPlot::set_axis(double xmin,
+ double xmax,
+ double ymin,
+ double ymax)
{
- set_xaxis(xmin, xmax);
- set_yaxis(ymin, ymax);
+ set_xaxis(xmin, xmax);
+ set_yaxis(ymin, ymax);
}
-void
-ConstellationDisplayPlot::set_pen_size(int size)
+void ConstellationDisplayPlot::set_pen_size(int size)
{
- if(size > 0 && size < 30){
- d_pen_size = size;
- for(unsigned int i = 0; i < d_nplots; ++i) {
- d_plot_curve[i]->setPen(QPen(Qt::blue, d_pen_size, Qt::SolidLine,
- Qt::RoundCap, Qt::RoundJoin));
+ if (size > 0 && size < 30) {
+ d_pen_size = size;
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ d_plot_curve[i]->setPen(
+ QPen(Qt::blue, d_pen_size, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
+ }
}
- }
}
-void
-ConstellationDisplayPlot::replot()
-{
- QwtPlot::replot();
-}
+void ConstellationDisplayPlot::replot() { QwtPlot::replot(); }
-void
-ConstellationDisplayPlot::plotNewData(const std::vector<double*> realDataPoints,
- const std::vector<double*> imagDataPoints,
- const int64_t numDataPoints,
- const double timeInterval)
+void ConstellationDisplayPlot::plotNewData(const std::vector<double*> realDataPoints,
+ const std::vector<double*> imagDataPoints,
+ const int64_t numDataPoints,
+ const double timeInterval)
{
- if(!d_stop) {
- if((numDataPoints > 0)) {
- if(numDataPoints != d_numPoints) {
- d_numPoints = numDataPoints;
+ if (!d_stop) {
+ if ((numDataPoints > 0)) {
+ if (numDataPoints != d_numPoints) {
+ d_numPoints = numDataPoints;
- for(unsigned int i = 0; i < d_nplots; ++i) {
- delete [] d_real_data[i];
- delete [] d_imag_data[i];
- d_real_data[i] = new double[d_numPoints];
- d_imag_data[i] = new double[d_numPoints];
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ delete[] d_real_data[i];
+ delete[] d_imag_data[i];
+ d_real_data[i] = new double[d_numPoints];
+ d_imag_data[i] = new double[d_numPoints];
#if QWT_VERSION < 0x060000
- d_plot_curve[i]->setRawData(d_real_data[i], d_imag_data[i], d_numPoints);
+ d_plot_curve[i]->setRawData(
+ d_real_data[i], d_imag_data[i], d_numPoints);
#else
- d_plot_curve[i]->setRawSamples(d_real_data[i], d_imag_data[i], d_numPoints);
+ d_plot_curve[i]->setRawSamples(
+ d_real_data[i], d_imag_data[i], d_numPoints);
#endif
- }
- }
-
- for(unsigned int i = 0; i < d_nplots; ++i) {
- memcpy(d_real_data[i], realDataPoints[i], numDataPoints*sizeof(double));
- memcpy(d_imag_data[i], imagDataPoints[i], numDataPoints*sizeof(double));
- }
-
- if(d_autoscale_state) {
- double bottom=1e20, top=-1e20;
- for(unsigned int n = 0; n < d_nplots; ++n) {
- for(int64_t point = 0; point < numDataPoints; point++) {
- double b = std::min(realDataPoints[n][point], imagDataPoints[n][point]);
- double t = std::max(realDataPoints[n][point], imagDataPoints[n][point]);
- if(b < bottom) {
- bottom = b;
- }
- if(t > top) {
- top = t;
- }
- }
- }
- _autoScale(bottom, top);
- }
-
- replot();
-
+ }
+ }
+
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ memcpy(d_real_data[i], realDataPoints[i], numDataPoints * sizeof(double));
+ memcpy(d_imag_data[i], imagDataPoints[i], numDataPoints * sizeof(double));
+ }
+
+ if (d_autoscale_state) {
+ double bottom = 1e20, top = -1e20;
+ for (unsigned int n = 0; n < d_nplots; ++n) {
+ for (int64_t point = 0; point < numDataPoints; point++) {
+ double b =
+ std::min(realDataPoints[n][point], imagDataPoints[n][point]);
+ double t =
+ std::max(realDataPoints[n][point], imagDataPoints[n][point]);
+ if (b < bottom) {
+ bottom = b;
+ }
+ if (t > top) {
+ top = t;
+ }
+ }
+ }
+ _autoScale(bottom, top);
+ }
+
+ replot();
+ }
}
- }
}
-void
-ConstellationDisplayPlot::plotNewData(const double* realDataPoints,
- const double* imagDataPoints,
- const int64_t numDataPoints,
- const double timeInterval)
+void ConstellationDisplayPlot::plotNewData(const double* realDataPoints,
+ const double* imagDataPoints,
+ const int64_t numDataPoints,
+ const double timeInterval)
{
- std::vector<double*> vecRealDataPoints;
- std::vector<double*> vecImagDataPoints;
- vecRealDataPoints.push_back((double*)realDataPoints);
- vecImagDataPoints.push_back((double*)imagDataPoints);
- plotNewData(vecRealDataPoints, vecImagDataPoints,
- numDataPoints, timeInterval);
+ std::vector<double*> vecRealDataPoints;
+ std::vector<double*> vecImagDataPoints;
+ vecRealDataPoints.push_back((double*)realDataPoints);
+ vecImagDataPoints.push_back((double*)imagDataPoints);
+ plotNewData(vecRealDataPoints, vecImagDataPoints, numDataPoints, timeInterval);
}
-void
-ConstellationDisplayPlot::_autoScale(double bottom, double top)
+void ConstellationDisplayPlot::_autoScale(double bottom, double top)
{
- // Auto scale the x- and y-axis with a margin of 20%
- double b = bottom - fabs(bottom)*0.20;
- double t = top + fabs(top)*0.20;
- set_axis(b, t, b, t);
+ // Auto scale the x- and y-axis with a margin of 20%
+ double b = bottom - fabs(bottom) * 0.20;
+ double t = top + fabs(top) * 0.20;
+ set_axis(b, t, b, t);
}
-void
-ConstellationDisplayPlot::setAutoScale(bool state)
-{
- d_autoscale_state = state;
-}
+void ConstellationDisplayPlot::setAutoScale(bool state) { d_autoscale_state = state; }
#endif /* CONSTELLATION_DISPLAY_PLOT_C */
diff --git a/gr-qtgui/lib/DisplayPlot.cc b/gr-qtgui/lib/DisplayPlot.cc
index b79b912270..b14021e315 100644
--- a/gr-qtgui/lib/DisplayPlot.cc
+++ b/gr-qtgui/lib/DisplayPlot.cc
@@ -31,161 +31,168 @@
#include <QDebug>
DisplayPlot::DisplayPlot(int nplots, QWidget* parent)
- : QwtPlot(parent), d_nplots(nplots), d_stop(false)
+ : QwtPlot(parent), d_nplots(nplots), d_stop(false)
{
- qRegisterMetaType<QColorList>("QColorList");
- resize(parent->width(), parent->height());
+ qRegisterMetaType<QColorList>("QColorList");
+ resize(parent->width(), parent->height());
- d_autoscale_state = false;
+ d_autoscale_state = false;
- // Disable polygon clipping
+ // Disable polygon clipping
#if QWT_VERSION < 0x060000
- QwtPainter::setDeviceClipping(false);
+ QwtPainter::setDeviceClipping(false);
#else
- QwtPainter::setPolylineSplitting(false);
+ QwtPainter::setPolylineSplitting(false);
#endif
#if QWT_VERSION < 0x060000
- // We don't need the cache here
- canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false);
- canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, false);
+ // We don't need the cache here
+ canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false);
+ canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, false);
#endif
- QColor default_palette_color = QColor("white");
- setPaletteColor(default_palette_color);
+ QColor default_palette_color = QColor("white");
+ setPaletteColor(default_palette_color);
- d_panner = new QwtPlotPanner(canvas());
- d_panner->setAxisEnabled(QwtPlot::yRight, false);
- d_panner->setMouseButton(Qt::MidButton, Qt::ControlModifier);
+ d_panner = new QwtPlotPanner(canvas());
+ d_panner->setAxisEnabled(QwtPlot::yRight, false);
+ d_panner->setMouseButton(Qt::MidButton, Qt::ControlModifier);
- // emit the position of clicks on widget
- d_picker = new QwtDblClickPlotPicker(canvas());
+ // emit the position of clicks on widget
+ d_picker = new QwtDblClickPlotPicker(canvas());
#if QWT_VERSION < 0x060000
- connect(d_picker, SIGNAL(selected(const QwtDoublePoint &)),
- this, SLOT(onPickerPointSelected(const QwtDoublePoint &)));
+ connect(d_picker,
+ SIGNAL(selected(const QwtDoublePoint&)),
+ this,
+ SLOT(onPickerPointSelected(const QwtDoublePoint&)));
#else
- d_picker->setStateMachine(new QwtPickerDblClickPointMachine());
- connect(d_picker, SIGNAL(selected(const QPointF &)),
- this, SLOT(onPickerPointSelected6(const QPointF &)));
+ d_picker->setStateMachine(new QwtPickerDblClickPointMachine());
+ connect(d_picker,
+ SIGNAL(selected(const QPointF&)),
+ this,
+ SLOT(onPickerPointSelected6(const QPointF&)));
#endif
- // Configure magnify on mouse wheel
- d_magnifier = new QwtPlotMagnifier(canvas());
- d_magnifier->setAxisEnabled(QwtPlot::xBottom, false);
+ // Configure magnify on mouse wheel
+ d_magnifier = new QwtPlotMagnifier(canvas());
+ d_magnifier->setAxisEnabled(QwtPlot::xBottom, false);
- // Avoid jumping when labels with more/less digits
- // appear/disappear when scrolling vertically
+ // Avoid jumping when labels with more/less digits
+ // appear/disappear when scrolling vertically
- const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font());
- QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft);
- sd->setMinimumExtent( fm.width("100.00") );
+ const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font());
+ QwtScaleDraw* sd = axisScaleDraw(QwtPlot::yLeft);
+ sd->setMinimumExtent(fm.width("100.00"));
- QwtLegend* legendDisplay = new QwtLegend(this);
+ QwtLegend* legendDisplay = new QwtLegend(this);
#if QWT_VERSION < 0x060100
- legendDisplay->setItemMode(QwtLegend::CheckableItem);
- insertLegend(legendDisplay);
- connect(this, SIGNAL(legendChecked(QwtPlotItem *, bool)),
- this, SLOT(legendEntryChecked(QwtPlotItem *, bool)));
-#else /* QWT_VERSION < 0x060100 */
- legendDisplay->setDefaultItemMode(QwtLegendData::Checkable);
- insertLegend(legendDisplay);
- connect(legendDisplay, SIGNAL(checked(const QVariant&, bool, int)),
- this, SLOT(legendEntryChecked(const QVariant&, bool, int)));
+ legendDisplay->setItemMode(QwtLegend::CheckableItem);
+ insertLegend(legendDisplay);
+ connect(this,
+ SIGNAL(legendChecked(QwtPlotItem*, bool)),
+ this,
+ SLOT(legendEntryChecked(QwtPlotItem*, bool)));
+#else /* QWT_VERSION < 0x060100 */
+ legendDisplay->setDefaultItemMode(QwtLegendData::Checkable);
+ insertLegend(legendDisplay);
+ connect(legendDisplay,
+ SIGNAL(checked(const QVariant&, bool, int)),
+ this,
+ SLOT(legendEntryChecked(const QVariant&, bool, int)));
#endif /* QWT_VERSION < 0x060100 */
-
}
DisplayPlot::~DisplayPlot()
{
- // d_zoomer and d_panner deleted when parent deleted
+ // d_zoomer and d_panner deleted when parent deleted
}
-void
-DisplayPlot::disableLegend()
+void DisplayPlot::disableLegend()
{
- // Haven't found a good way to toggle it on/off
- insertLegend(NULL);
+ // Haven't found a good way to toggle it on/off
+ insertLegend(NULL);
}
-void
-DisplayPlot::setYaxis(double min, double max)
+void DisplayPlot::setYaxis(double min, double max)
{
- setAxisScale(QwtPlot::yLeft, min, max);
- if(!d_autoscale_state)
- d_zoomer->setZoomBase();
+ setAxisScale(QwtPlot::yLeft, min, max);
+ if (!d_autoscale_state)
+ d_zoomer->setZoomBase();
}
-void
-DisplayPlot::setXaxis(double min, double max)
+void DisplayPlot::setXaxis(double min, double max)
{
- setAxisScale(QwtPlot::xBottom, min, max);
- d_zoomer->setZoomBase();
+ setAxisScale(QwtPlot::xBottom, min, max);
+ d_zoomer->setZoomBase();
}
-void
-DisplayPlot::setLineLabel(unsigned int which, QString label)
+void DisplayPlot::setLineLabel(unsigned int which, QString label)
{
- if(which >= d_plot_curve.size())
- throw std::runtime_error("DisplayPlot::setLineLabel: index out of bounds");
- d_plot_curve[which]->setTitle(label);
+ if (which >= d_plot_curve.size())
+ throw std::runtime_error("DisplayPlot::setLineLabel: index out of bounds");
+ d_plot_curve[which]->setTitle(label);
}
-QString
-DisplayPlot::getLineLabel(unsigned int which)
+QString DisplayPlot::getLineLabel(unsigned int which)
{
- if(which >= d_plot_curve.size())
- throw std::runtime_error("DisplayPlot::getLineLabel: index out of bounds");
- return d_plot_curve[which]->title().text();
+ if (which >= d_plot_curve.size())
+ throw std::runtime_error("DisplayPlot::getLineLabel: index out of bounds");
+ return d_plot_curve[which]->title().text();
}
-void
-DisplayPlot::setLineColor(unsigned int which, QColor color)
+void DisplayPlot::setLineColor(unsigned int which, QColor color)
{
- if (which < d_nplots) {
- // Set the color of the pen
- QPen pen(d_plot_curve[which]->pen());
- pen.setColor(color);
- d_plot_curve[which]->setPen(pen);
- // And set the color of the markers
+ if (which < d_nplots) {
+ // Set the color of the pen
+ QPen pen(d_plot_curve[which]->pen());
+ pen.setColor(color);
+ d_plot_curve[which]->setPen(pen);
+ // And set the color of the markers
#if QWT_VERSION < 0x060000
- //d_plot_curve[which]->setBrush(QBrush(QColor(color)));
- d_plot_curve[which]->setPen(pen);
- QwtSymbol sym = (QwtSymbol)d_plot_curve[which]->symbol();
- setLineMarker(which, sym.style());
+ // d_plot_curve[which]->setBrush(QBrush(QColor(color)));
+ d_plot_curve[which]->setPen(pen);
+ QwtSymbol sym = (QwtSymbol)d_plot_curve[which]->symbol();
+ setLineMarker(which, sym.style());
#else
- QwtSymbol *sym = (QwtSymbol*)d_plot_curve[which]->symbol();
- if(sym) {
- sym->setColor(color);
- sym->setPen(pen);
- d_plot_curve[which]->setSymbol(sym);
- }
+ QwtSymbol* sym = (QwtSymbol*)d_plot_curve[which]->symbol();
+ if (sym) {
+ sym->setColor(color);
+ sym->setPen(pen);
+ d_plot_curve[which]->setSymbol(sym);
+ }
#endif
- }
-}
-
-QColor
-DisplayPlot::getLineColor(unsigned int which) const
-{
- // If that plot doesn't exist then return black.
- if (which < d_nplots)
- return d_plot_curve[which]->pen().color();
- return QColor("black");
-}
-
-// Use a preprocessor macro to create a bunch of hooks for Q_PROPERTY and hence the stylesheet.
-#define SETUPLINE(i, im1) \
- void DisplayPlot::setLineColor ## i (QColor c) {setLineColor(im1, c);} \
- const QColor DisplayPlot::getLineColor ## i () const {return getLineColor(im1);} \
- void DisplayPlot::setLineWidth ## i (int width) {setLineWidth(im1, width);} \
- int DisplayPlot::getLineWidth ## i () const {return getLineWidth(im1);} \
- void DisplayPlot::setLineStyle ## i (Qt::PenStyle ps) {setLineStyle(im1, ps);} \
- const Qt::PenStyle DisplayPlot::getLineStyle ## i () const {return getLineStyle(im1);} \
- void DisplayPlot::setLineMarker ## i (QwtSymbol::Style ms) {setLineMarker(im1, ms);} \
- const QwtSymbol::Style DisplayPlot::getLineMarker ## i () const {return getLineMarker(im1);} \
- void DisplayPlot::setMarkerAlpha ## i (int alpha) {setMarkerAlpha(im1, alpha);} \
- int DisplayPlot::getMarkerAlpha ## i () const {return getMarkerAlpha(im1);}
+ }
+}
+
+QColor DisplayPlot::getLineColor(unsigned int which) const
+{
+ // If that plot doesn't exist then return black.
+ if (which < d_nplots)
+ return d_plot_curve[which]->pen().color();
+ return QColor("black");
+}
+
+// Use a preprocessor macro to create a bunch of hooks for Q_PROPERTY and hence the
+// stylesheet.
+#define SETUPLINE(i, im1) \
+ void DisplayPlot::setLineColor##i(QColor c) { setLineColor(im1, c); } \
+ const QColor DisplayPlot::getLineColor##i() const { return getLineColor(im1); } \
+ void DisplayPlot::setLineWidth##i(int width) { setLineWidth(im1, width); } \
+ int DisplayPlot::getLineWidth##i() const { return getLineWidth(im1); } \
+ void DisplayPlot::setLineStyle##i(Qt::PenStyle ps) { setLineStyle(im1, ps); } \
+ const Qt::PenStyle DisplayPlot::getLineStyle##i() const \
+ { \
+ return getLineStyle(im1); \
+ } \
+ void DisplayPlot::setLineMarker##i(QwtSymbol::Style ms) { setLineMarker(im1, ms); } \
+ const QwtSymbol::Style DisplayPlot::getLineMarker##i() const \
+ { \
+ return getLineMarker(im1); \
+ } \
+ void DisplayPlot::setMarkerAlpha##i(int alpha) { setMarkerAlpha(im1, alpha); } \
+ int DisplayPlot::getMarkerAlpha##i() const { return getMarkerAlpha(im1); }
SETUPLINE(1, 0)
SETUPLINE(2, 1)
SETUPLINE(3, 2)
@@ -196,263 +203,240 @@ SETUPLINE(7, 6)
SETUPLINE(8, 7)
SETUPLINE(9, 8)
-void
-DisplayPlot::setZoomerColor(QColor c) {
- d_zoomer->setRubberBandPen(c);
- d_zoomer->setTrackerPen(c);
+void DisplayPlot::setZoomerColor(QColor c)
+{
+ d_zoomer->setRubberBandPen(c);
+ d_zoomer->setTrackerPen(c);
}
-QColor
-DisplayPlot::getZoomerColor() const {
- return d_zoomer->rubberBandPen().color();
-}
+QColor DisplayPlot::getZoomerColor() const { return d_zoomer->rubberBandPen().color(); }
-void
-DisplayPlot::setPaletteColor(QColor c) {
- QPalette palette;
- palette.setColor(canvas()->backgroundRole(), c);
- canvas()->setPalette(palette);
+void DisplayPlot::setPaletteColor(QColor c)
+{
+ QPalette palette;
+ palette.setColor(canvas()->backgroundRole(), c);
+ canvas()->setPalette(palette);
}
-QColor
-DisplayPlot::getPaletteColor() const {
- return canvas()->palette().color(canvas()->backgroundRole());
+QColor DisplayPlot::getPaletteColor() const
+{
+ return canvas()->palette().color(canvas()->backgroundRole());
}
-void
-DisplayPlot::setAxisLabelFontSize(int axisId, int fs) {
- QwtText axis_title = QwtText(axisWidget(axisId)->title());
- QFont font = QFont(axis_title.font());
- font.setPointSize(fs);
- axis_title.setFont(font);
- axisWidget(axisId)->setTitle(axis_title);
+void DisplayPlot::setAxisLabelFontSize(int axisId, int fs)
+{
+ QwtText axis_title = QwtText(axisWidget(axisId)->title());
+ QFont font = QFont(axis_title.font());
+ font.setPointSize(fs);
+ axis_title.setFont(font);
+ axisWidget(axisId)->setTitle(axis_title);
}
-int
-DisplayPlot::getAxisLabelFontSize(int axisId) const {
- return axisWidget(axisId)->title().font().pointSize();
+int DisplayPlot::getAxisLabelFontSize(int axisId) const
+{
+ return axisWidget(axisId)->title().font().pointSize();
}
-void
-DisplayPlot::setYaxisLabelFontSize(int fs) {
- setAxisLabelFontSize(QwtPlot::yLeft, fs);
+void DisplayPlot::setYaxisLabelFontSize(int fs)
+{
+ setAxisLabelFontSize(QwtPlot::yLeft, fs);
}
-int
-DisplayPlot::getYaxisLabelFontSize() const {
- int fs = getAxisLabelFontSize(QwtPlot::yLeft);
- return fs;
+int DisplayPlot::getYaxisLabelFontSize() const
+{
+ int fs = getAxisLabelFontSize(QwtPlot::yLeft);
+ return fs;
}
-void
-DisplayPlot::setXaxisLabelFontSize(int fs) {
- setAxisLabelFontSize(QwtPlot::xBottom, fs);
+void DisplayPlot::setXaxisLabelFontSize(int fs)
+{
+ setAxisLabelFontSize(QwtPlot::xBottom, fs);
}
-int
-DisplayPlot::getXaxisLabelFontSize() const {
- int fs = getAxisLabelFontSize(QwtPlot::xBottom);
- return fs;
+int DisplayPlot::getXaxisLabelFontSize() const
+{
+ int fs = getAxisLabelFontSize(QwtPlot::xBottom);
+ return fs;
}
-void
-DisplayPlot::setAxesLabelFontSize(int fs) {
- setAxisLabelFontSize(QwtPlot::yLeft, fs);
- setAxisLabelFontSize(QwtPlot::xBottom, fs);
+void DisplayPlot::setAxesLabelFontSize(int fs)
+{
+ setAxisLabelFontSize(QwtPlot::yLeft, fs);
+ setAxisLabelFontSize(QwtPlot::xBottom, fs);
}
-int
-DisplayPlot::getAxesLabelFontSize() const {
- // Returns 0 if all axes do not have the same font size.
- int fs = getAxisLabelFontSize(QwtPlot::yLeft);
- if (getAxisLabelFontSize(QwtPlot::xBottom) != fs)
- return 0;
- return fs;
+int DisplayPlot::getAxesLabelFontSize() const
+{
+ // Returns 0 if all axes do not have the same font size.
+ int fs = getAxisLabelFontSize(QwtPlot::yLeft);
+ if (getAxisLabelFontSize(QwtPlot::xBottom) != fs)
+ return 0;
+ return fs;
}
-void
-DisplayPlot::setLineWidth(unsigned int which, int width)
+void DisplayPlot::setLineWidth(unsigned int which, int width)
{
- if(which < d_nplots) {
- // Set the new line width
- QPen pen(d_plot_curve[which]->pen());
- pen.setWidth(width);
- d_plot_curve[which]->setPen(pen);
+ if (which < d_nplots) {
+ // Set the new line width
+ QPen pen(d_plot_curve[which]->pen());
+ pen.setWidth(width);
+ d_plot_curve[which]->setPen(pen);
- // Scale the marker size proportionally
+ // Scale the marker size proportionally
#if QWT_VERSION < 0x060000
- QwtSymbol sym = (QwtSymbol)d_plot_curve[which]->symbol();
- sym.setSize(7+10*log10(1.0*width), 7+10*log10(1.0*width));
- d_plot_curve[which]->setSymbol(sym);
+ QwtSymbol sym = (QwtSymbol)d_plot_curve[which]->symbol();
+ sym.setSize(7 + 10 * log10(1.0 * width), 7 + 10 * log10(1.0 * width));
+ d_plot_curve[which]->setSymbol(sym);
#else
- QwtSymbol *sym = (QwtSymbol*)d_plot_curve[which]->symbol();
- if(sym) {
- sym->setSize(7+10*log10(1.0*width), 7+10*log10(1.0*width));
- d_plot_curve[which]->setSymbol(sym);
- }
+ QwtSymbol* sym = (QwtSymbol*)d_plot_curve[which]->symbol();
+ if (sym) {
+ sym->setSize(7 + 10 * log10(1.0 * width), 7 + 10 * log10(1.0 * width));
+ d_plot_curve[which]->setSymbol(sym);
+ }
#endif
- }
+ }
}
-int
-DisplayPlot::getLineWidth(unsigned int which) const {
- if (which < d_nplots) {
- return d_plot_curve[which]->pen().width();
- }
- else {
- return 0;
- }
+int DisplayPlot::getLineWidth(unsigned int which) const
+{
+ if (which < d_nplots) {
+ return d_plot_curve[which]->pen().width();
+ } else {
+ return 0;
+ }
}
-void
-DisplayPlot::setLineStyle(unsigned int which, Qt::PenStyle style)
+void DisplayPlot::setLineStyle(unsigned int which, Qt::PenStyle style)
{
- if(which < d_nplots) {
- QPen pen(d_plot_curve[which]->pen());
- pen.setStyle(style);
- d_plot_curve[which]->setPen(pen);
- }
+ if (which < d_nplots) {
+ QPen pen(d_plot_curve[which]->pen());
+ pen.setStyle(style);
+ d_plot_curve[which]->setPen(pen);
+ }
}
-const Qt::PenStyle
-DisplayPlot::getLineStyle(unsigned int which) const
+const Qt::PenStyle DisplayPlot::getLineStyle(unsigned int which) const
{
- if(which < d_nplots) {
- return d_plot_curve[which]->pen().style();
- }
- else {
- return Qt::SolidLine;
- }
+ if (which < d_nplots) {
+ return d_plot_curve[which]->pen().style();
+ } else {
+ return Qt::SolidLine;
+ }
}
-void
-DisplayPlot::setLineMarker(unsigned int which, QwtSymbol::Style marker)
+void DisplayPlot::setLineMarker(unsigned int which, QwtSymbol::Style marker)
{
- if(which < d_nplots) {
+ if (which < d_nplots) {
#if QWT_VERSION < 0x060000
- QwtSymbol sym = (QwtSymbol)d_plot_curve[which]->symbol();
- QPen pen(d_plot_curve[which]->pen());
- QBrush brush(pen.color());
- sym.setStyle(marker);
- sym.setPen(pen);
- sym.setBrush(brush);
- d_plot_curve[which]->setSymbol(sym);
+ QwtSymbol sym = (QwtSymbol)d_plot_curve[which]->symbol();
+ QPen pen(d_plot_curve[which]->pen());
+ QBrush brush(pen.color());
+ sym.setStyle(marker);
+ sym.setPen(pen);
+ sym.setBrush(brush);
+ d_plot_curve[which]->setSymbol(sym);
#else
- QwtSymbol *sym = (QwtSymbol*)d_plot_curve[which]->symbol();
- if(sym) {
- sym->setStyle(marker);
- d_plot_curve[which]->setSymbol(sym);
- }
+ QwtSymbol* sym = (QwtSymbol*)d_plot_curve[which]->symbol();
+ if (sym) {
+ sym->setStyle(marker);
+ d_plot_curve[which]->setSymbol(sym);
+ }
#endif
- }
+ }
}
-const QwtSymbol::Style
-DisplayPlot::getLineMarker(unsigned int which) const
+const QwtSymbol::Style DisplayPlot::getLineMarker(unsigned int which) const
{
- if(which < d_nplots) {
+ if (which < d_nplots) {
#if QWT_VERSION < 0x060000
- QwtSymbol sym = (QwtSymbol)d_plot_curve[which]->symbol();
- return sym.style();
+ QwtSymbol sym = (QwtSymbol)d_plot_curve[which]->symbol();
+ return sym.style();
#else
- QwtSymbol *sym = (QwtSymbol*)d_plot_curve[which]->symbol();
- return sym->style();
+ QwtSymbol* sym = (QwtSymbol*)d_plot_curve[which]->symbol();
+ return sym->style();
#endif
- }
- else {
- return QwtSymbol::NoSymbol;
- }
+ } else {
+ return QwtSymbol::NoSymbol;
+ }
}
-void
-DisplayPlot::setMarkerAlpha(unsigned int which, int alpha)
+void DisplayPlot::setMarkerAlpha(unsigned int which, int alpha)
{
- if (which < d_nplots) {
- // Get the pen color
- QPen pen(d_plot_curve[which]->pen());
- QColor color = pen.color();
+ if (which < d_nplots) {
+ // Get the pen color
+ QPen pen(d_plot_curve[which]->pen());
+ QColor color = pen.color();
- // Set new alpha and update pen
- color.setAlpha(alpha);
- pen.setColor(color);
- d_plot_curve[which]->setPen(pen);
+ // Set new alpha and update pen
+ color.setAlpha(alpha);
+ pen.setColor(color);
+ d_plot_curve[which]->setPen(pen);
- // And set the new color for the markers
+ // And set the new color for the markers
#if QWT_VERSION < 0x060000
- QwtSymbol sym = (QwtSymbol)d_plot_curve[which]->symbol();
- setLineMarker(which, sym.style());
+ QwtSymbol sym = (QwtSymbol)d_plot_curve[which]->symbol();
+ setLineMarker(which, sym.style());
#else
- QwtSymbol *sym = (QwtSymbol*)d_plot_curve[which]->symbol();
- if(sym) {
- sym->setColor(color);
- sym->setPen(pen);
- d_plot_curve[which]->setSymbol(sym);
- }
+ QwtSymbol* sym = (QwtSymbol*)d_plot_curve[which]->symbol();
+ if (sym) {
+ sym->setColor(color);
+ sym->setPen(pen);
+ d_plot_curve[which]->setSymbol(sym);
+ }
#endif
- }
+ }
}
-int
-DisplayPlot::getMarkerAlpha(unsigned int which) const
+int DisplayPlot::getMarkerAlpha(unsigned int which) const
{
- if(which < d_nplots) {
- return d_plot_curve[which]->pen().color().alpha();
- }
- else {
- return 0;
- }
+ if (which < d_nplots) {
+ return d_plot_curve[which]->pen().color().alpha();
+ } else {
+ return 0;
+ }
}
-void
-DisplayPlot::setStop(bool on)
-{
- d_stop = on;
-}
+void DisplayPlot::setStop(bool on) { d_stop = on; }
-void
-DisplayPlot::resizeSlot( QSize *s )
+void DisplayPlot::resizeSlot(QSize* s)
{
- // -10 is to spare some room for the legend and x-axis label
- resize(s->width()-10, s->height()-10);
+ // -10 is to spare some room for the legend and x-axis label
+ resize(s->width() - 10, s->height() - 10);
}
void DisplayPlot::legendEntryChecked(QwtPlotItem* plotItem, bool on)
{
- plotItem->setVisible(!on);
- replot();
+ plotItem->setVisible(!on);
+ replot();
}
-void DisplayPlot::legendEntryChecked(const QVariant &plotItem, bool on, int index)
+void DisplayPlot::legendEntryChecked(const QVariant& plotItem, bool on, int index)
{
#if QWT_VERSION < 0x060100
- std::runtime_error("DisplayPlot::legendEntryChecked with QVariant not enabled in this version of QWT.\n");
+ std::runtime_error("DisplayPlot::legendEntryChecked with QVariant not enabled in "
+ "this version of QWT.\n");
#else
- QwtPlotItem *p = infoToItem(plotItem);
- legendEntryChecked(p, on);
+ QwtPlotItem* p = infoToItem(plotItem);
+ legendEntryChecked(p, on);
#endif /* QWT_VERSION < 0x060100 */
}
-void
-DisplayPlot::onPickerPointSelected(const QwtDoublePoint & p)
+void DisplayPlot::onPickerPointSelected(const QwtDoublePoint& p)
{
- QPointF point = p;
- //fprintf(stderr,"onPickerPointSelected %f %f\n", point.x(), point.y());
- emit plotPointSelected(point);
+ QPointF point = p;
+ // fprintf(stderr,"onPickerPointSelected %f %f\n", point.x(), point.y());
+ emit plotPointSelected(point);
}
-void
-DisplayPlot::onPickerPointSelected6(const QPointF & p)
+void DisplayPlot::onPickerPointSelected6(const QPointF& p)
{
- QPointF point = p;
- //fprintf(stderr,"onPickerPointSelected %f %f\n", point.x(), point.y());
- emit plotPointSelected(point);
+ QPointF point = p;
+ // fprintf(stderr,"onPickerPointSelected %f %f\n", point.x(), point.y());
+ emit plotPointSelected(point);
}
-void
-DisplayPlot::setAxisLabels(bool en)
+void DisplayPlot::setAxisLabels(bool en)
{
- enableAxis(0,en);
- enableAxis(2,en);
+ enableAxis(0, en);
+ enableAxis(2, en);
}
-
-
diff --git a/gr-qtgui/lib/FrequencyDisplayPlot.cc b/gr-qtgui/lib/FrequencyDisplayPlot.cc
index db0056c9bc..856c456c11 100644
--- a/gr-qtgui/lib/FrequencyDisplayPlot.cc
+++ b/gr-qtgui/lib/FrequencyDisplayPlot.cc
@@ -34,43 +34,37 @@
/***********************************************************************
* Widget to provide mouse pointer coordinate text
**********************************************************************/
-class FreqDisplayZoomer: public QwtPlotZoomer, public FreqOffsetAndPrecisionClass
+class FreqDisplayZoomer : public QwtPlotZoomer, public FreqOffsetAndPrecisionClass
{
public:
#if QWT_VERSION < 0x060100
- FreqDisplayZoomer(QwtPlotCanvas* canvas, const unsigned int freqPrecision)
-#else /* QWT_VERSION < 0x060100 */
- FreqDisplayZoomer(QWidget* canvas, const unsigned int freqPrecision)
+ FreqDisplayZoomer(QwtPlotCanvas* canvas, const unsigned int freqPrecision)
+#else /* QWT_VERSION < 0x060100 */
+ FreqDisplayZoomer(QWidget* canvas, const unsigned int freqPrecision)
#endif /* QWT_VERSION < 0x060100 */
- : QwtPlotZoomer(canvas),
- FreqOffsetAndPrecisionClass(freqPrecision)
- {
- setTrackerMode(QwtPicker::AlwaysOn);
- }
-
- virtual void updateTrackerText()
- {
- updateDisplay();
- }
-
- void setUnitType(const std::string &type)
- {
- d_unitType = type;
- }
+ : QwtPlotZoomer(canvas), FreqOffsetAndPrecisionClass(freqPrecision)
+ {
+ setTrackerMode(QwtPicker::AlwaysOn);
+ }
+
+ virtual void updateTrackerText() { updateDisplay(); }
+
+ void setUnitType(const std::string& type) { d_unitType = type; }
protected:
- using QwtPlotZoomer::trackerText;
- virtual QwtText trackerText(QPoint const &p) const
- {
- QwtDoublePoint dp = QwtPlotZoomer::invTransform(p);
- QwtText t(QString("%1 %2, %3 dB")
- .arg(dp.x(), 0, 'f', getFrequencyPrecision())
- .arg(d_unitType.c_str()).arg(dp.y(), 0, 'f', 2));
- return t;
- }
+ using QwtPlotZoomer::trackerText;
+ virtual QwtText trackerText(QPoint const& p) const
+ {
+ QwtDoublePoint dp = QwtPlotZoomer::invTransform(p);
+ QwtText t(QString("%1 %2, %3 dB")
+ .arg(dp.x(), 0, 'f', getFrequencyPrecision())
+ .arg(d_unitType.c_str())
+ .arg(dp.y(), 0, 'f', 2));
+ return t;
+ }
private:
- std::string d_unitType;
+ std::string d_unitType;
};
@@ -78,697 +72,629 @@ private:
* Main frequency display plotter widget
**********************************************************************/
FrequencyDisplayPlot::FrequencyDisplayPlot(int nplots, QWidget* parent)
- : DisplayPlot(nplots, parent)
-{
- d_start_frequency = -1;
- d_stop_frequency = 1;
-
- d_numPoints = 0;
- d_min_fft_data = new double[d_numPoints];
- d_max_fft_data = new double[d_numPoints];
- d_xdata = new double[d_numPoints];
- d_half_freq = false;
- d_autoscale_shot = false;
-
- setAxisTitle(QwtPlot::xBottom, "Frequency (Hz)");
- setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(0));
-
- d_ymin = -120;
- d_ymax = 10;
- setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine);
- setAxisScale(QwtPlot::yLeft, d_ymin, d_ymax);
- setAxisTitle(QwtPlot::yLeft, "Relative Gain (dB)");
-
- QList<QColor> default_colors;
- default_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);
-
- // Create a curve for each input
- // Automatically deleted when parent is deleted
- for(unsigned int i = 0; i < d_nplots; ++i) {
- d_ydata.push_back(new double[d_numPoints]);
- memset(d_ydata[i], 0x0, d_numPoints*sizeof(double));
-
- d_plot_curve.push_back(new QwtPlotCurve(QString("Data %1").arg(i)));
- d_plot_curve[i]->attach(this);
-
- QwtSymbol *symbol = new QwtSymbol(QwtSymbol::NoSymbol, QBrush(default_colors[i]),
- QPen(default_colors[i]), QSize(7,7));
+ : DisplayPlot(nplots, parent)
+{
+ d_start_frequency = -1;
+ d_stop_frequency = 1;
+
+ d_numPoints = 0;
+ d_min_fft_data = new double[d_numPoints];
+ d_max_fft_data = new double[d_numPoints];
+ d_xdata = new double[d_numPoints];
+ d_half_freq = false;
+ d_autoscale_shot = false;
+
+ setAxisTitle(QwtPlot::xBottom, "Frequency (Hz)");
+ setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(0));
+
+ d_ymin = -120;
+ d_ymax = 10;
+ setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine);
+ setAxisScale(QwtPlot::yLeft, d_ymin, d_ymax);
+ setAxisTitle(QwtPlot::yLeft, "Relative Gain (dB)");
+
+ QList<QColor> default_colors;
+ default_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);
+
+ // Create a curve for each input
+ // Automatically deleted when parent is deleted
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ d_ydata.push_back(new double[d_numPoints]);
+ memset(d_ydata[i], 0x0, d_numPoints * sizeof(double));
+
+ d_plot_curve.push_back(new QwtPlotCurve(QString("Data %1").arg(i)));
+ d_plot_curve[i]->attach(this);
+
+ QwtSymbol* symbol = new QwtSymbol(QwtSymbol::NoSymbol,
+ QBrush(default_colors[i]),
+ QPen(default_colors[i]),
+ QSize(7, 7));
#if QWT_VERSION < 0x060000
- d_plot_curve[i]->setRawData(d_xdata, d_ydata[i], d_numPoints);
- d_plot_curve[i]->setSymbol(*symbol);
+ d_plot_curve[i]->setRawData(d_xdata, d_ydata[i], d_numPoints);
+ d_plot_curve[i]->setSymbol(*symbol);
#else
- d_plot_curve[i]->setRawSamples(d_xdata, d_ydata[i], d_numPoints);
- d_plot_curve[i]->setSymbol(symbol);
+ d_plot_curve[i]->setRawSamples(d_xdata, d_ydata[i], d_numPoints);
+ d_plot_curve[i]->setSymbol(symbol);
#endif
- setLineColor(i, default_colors[i]);
- }
-
- // Create min/max plotter curves
- d_min_fft_plot_curve = new QwtPlotCurve("Min Hold");
- d_min_fft_plot_curve->attach(this);
- const QColor default_min_fft_color = Qt::magenta;
- setMinFFTColor(default_min_fft_color);
+ setLineColor(i, default_colors[i]);
+ }
+
+ // Create min/max plotter curves
+ d_min_fft_plot_curve = new QwtPlotCurve("Min Hold");
+ d_min_fft_plot_curve->attach(this);
+ const QColor default_min_fft_color = Qt::magenta;
+ setMinFFTColor(default_min_fft_color);
#if QWT_VERSION < 0x060000
- d_min_fft_plot_curve->setRawData(d_xdata, d_min_fft_data, d_numPoints);
+ d_min_fft_plot_curve->setRawData(d_xdata, d_min_fft_data, d_numPoints);
#else
- d_min_fft_plot_curve->setRawSamples(d_xdata, d_min_fft_data, d_numPoints);
+ d_min_fft_plot_curve->setRawSamples(d_xdata, d_min_fft_data, d_numPoints);
#endif
- d_min_fft_plot_curve->setVisible(false);
- d_min_fft_plot_curve->setZ(0);
+ d_min_fft_plot_curve->setVisible(false);
+ d_min_fft_plot_curve->setZ(0);
- d_max_fft_plot_curve = new QwtPlotCurve("Max Hold");
- d_max_fft_plot_curve->attach(this);
- QColor default_max_fft_color = Qt::darkYellow;
- setMaxFFTColor(default_max_fft_color);
+ d_max_fft_plot_curve = new QwtPlotCurve("Max Hold");
+ d_max_fft_plot_curve->attach(this);
+ QColor default_max_fft_color = Qt::darkYellow;
+ setMaxFFTColor(default_max_fft_color);
#if QWT_VERSION < 0x060000
- d_max_fft_plot_curve->setRawData(d_xdata, d_max_fft_data, d_numPoints);
+ d_max_fft_plot_curve->setRawData(d_xdata, d_max_fft_data, d_numPoints);
#else
- d_max_fft_plot_curve->setRawSamples(d_xdata, d_max_fft_data, d_numPoints);
+ d_max_fft_plot_curve->setRawSamples(d_xdata, d_max_fft_data, d_numPoints);
#endif
- d_max_fft_plot_curve->setVisible(false);
- d_max_fft_plot_curve->setZ(0);
-
- d_lower_intensity_marker= new QwtPlotMarker();
- d_lower_intensity_marker->setLineStyle(QwtPlotMarker::HLine);
- QColor default_marker_lower_intensity_color = Qt::cyan;
- setMarkerLowerIntensityColor(default_marker_lower_intensity_color);
- d_lower_intensity_marker->attach(this);
-
- d_upper_intensity_marker = new QwtPlotMarker();
- d_upper_intensity_marker->setLineStyle(QwtPlotMarker::HLine);
- QColor default_marker_upper_intensity_color = Qt::green;
- setMarkerUpperIntensityColor(default_marker_upper_intensity_color);
- d_upper_intensity_marker->attach(this);
-
- memset(d_xdata, 0x0, d_numPoints*sizeof(double));
-
- for(int64_t number = 0; number < d_numPoints; number++){
- d_min_fft_data[number] = 200.0;
- d_max_fft_data[number] = -280.0;
- }
-
- d_marker_peak_amplitude = new QwtPlotMarker();
- QColor default_marker_peak_amplitude_color = Qt::yellow;
- setMarkerPeakAmplitudeColor(default_marker_peak_amplitude_color);
- /// THIS CAUSES A PROBLEM!
- //d_marker_peak_amplitude->attach(this);
-
- d_marker_noise_floor_amplitude = new QwtPlotMarker();
- d_marker_noise_floor_amplitude->setLineStyle(QwtPlotMarker::HLine);
- QColor default_marker_noise_floor_amplitude_color = Qt::darkRed;
- setMarkerNoiseFloorAmplitudeColor(default_marker_noise_floor_amplitude_color);
- d_marker_noise_floor_amplitude->attach(this);
-
- d_marker_cf= new QwtPlotMarker();
- d_marker_cf->setLineStyle(QwtPlotMarker::VLine);
- QColor default_marker_cf_color = Qt::lightGray;
- setMarkerCFColor(default_marker_cf_color);
- d_marker_cf->attach(this);
- d_marker_cf->hide();
-
- d_peak_frequency = 0;
- d_peak_amplitude = -HUGE_VAL;
-
- d_noise_floor_amplitude = -HUGE_VAL;
-
- d_zoomer = new FreqDisplayZoomer(canvas(), 0);
+ d_max_fft_plot_curve->setVisible(false);
+ d_max_fft_plot_curve->setZ(0);
+
+ d_lower_intensity_marker = new QwtPlotMarker();
+ d_lower_intensity_marker->setLineStyle(QwtPlotMarker::HLine);
+ QColor default_marker_lower_intensity_color = Qt::cyan;
+ setMarkerLowerIntensityColor(default_marker_lower_intensity_color);
+ d_lower_intensity_marker->attach(this);
+
+ d_upper_intensity_marker = new QwtPlotMarker();
+ d_upper_intensity_marker->setLineStyle(QwtPlotMarker::HLine);
+ QColor default_marker_upper_intensity_color = Qt::green;
+ setMarkerUpperIntensityColor(default_marker_upper_intensity_color);
+ d_upper_intensity_marker->attach(this);
+
+ memset(d_xdata, 0x0, d_numPoints * sizeof(double));
+
+ for (int64_t number = 0; number < d_numPoints; number++) {
+ d_min_fft_data[number] = 200.0;
+ d_max_fft_data[number] = -280.0;
+ }
+
+ d_marker_peak_amplitude = new QwtPlotMarker();
+ QColor default_marker_peak_amplitude_color = Qt::yellow;
+ setMarkerPeakAmplitudeColor(default_marker_peak_amplitude_color);
+ /// THIS CAUSES A PROBLEM!
+ // d_marker_peak_amplitude->attach(this);
+
+ d_marker_noise_floor_amplitude = new QwtPlotMarker();
+ d_marker_noise_floor_amplitude->setLineStyle(QwtPlotMarker::HLine);
+ QColor default_marker_noise_floor_amplitude_color = Qt::darkRed;
+ setMarkerNoiseFloorAmplitudeColor(default_marker_noise_floor_amplitude_color);
+ d_marker_noise_floor_amplitude->attach(this);
+
+ d_marker_cf = new QwtPlotMarker();
+ d_marker_cf->setLineStyle(QwtPlotMarker::VLine);
+ QColor default_marker_cf_color = Qt::lightGray;
+ setMarkerCFColor(default_marker_cf_color);
+ d_marker_cf->attach(this);
+ d_marker_cf->hide();
+
+ d_peak_frequency = 0;
+ d_peak_amplitude = -HUGE_VAL;
+
+ d_noise_floor_amplitude = -HUGE_VAL;
+
+ d_zoomer = new FreqDisplayZoomer(canvas(), 0);
#if QWT_VERSION < 0x060000
- d_zoomer->setSelectionFlags(QwtPicker::RectSelection | QwtPicker::DragSelection);
+ d_zoomer->setSelectionFlags(QwtPicker::RectSelection | QwtPicker::DragSelection);
#endif
- d_zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
- Qt::RightButton, Qt::ControlModifier);
- d_zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
- Qt::RightButton);
+ d_zoomer->setMousePattern(
+ QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier);
+ d_zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
- const QColor default_zoomer_color(Qt::darkRed);
- setZoomerColor(default_zoomer_color);
+ const QColor default_zoomer_color(Qt::darkRed);
+ setZoomerColor(default_zoomer_color);
- // Do this after the zoomer has been built
- _resetXAxisPoints();
+ // Do this after the zoomer has been built
+ _resetXAxisPoints();
- // Turn off min/max hold plots in legend
+ // Turn off min/max hold plots in legend
#if QWT_VERSION < 0x060100
- QWidget *w;
- w = legend()->find(d_min_fft_plot_curve);
- ((QwtLegendItem*)w)->setChecked(true);
- ((QwtLegendItem*)w)->setVisible(false);
- w = legend()->find(d_max_fft_plot_curve);
- ((QwtLegendItem*)w)->setChecked(true);
- ((QwtLegendItem*)w)->setVisible(false);
- legend()->setVisible(false);
+ QWidget* w;
+ w = legend()->find(d_min_fft_plot_curve);
+ ((QwtLegendItem*)w)->setChecked(true);
+ ((QwtLegendItem*)w)->setVisible(false);
+ w = legend()->find(d_max_fft_plot_curve);
+ ((QwtLegendItem*)w)->setChecked(true);
+ ((QwtLegendItem*)w)->setVisible(false);
+ legend()->setVisible(false);
#else /* QWT_VERSION < 0x060100 */
- QWidget *w;
- w = ((QwtLegend*)legend())->legendWidget(itemToInfo(d_min_fft_plot_curve));
- ((QwtLegendLabel*)w)->setChecked(true);
- ((QwtLegendLabel*)w)->setVisible(false);
+ QWidget* w;
+ w = ((QwtLegend*)legend())->legendWidget(itemToInfo(d_min_fft_plot_curve));
+ ((QwtLegendLabel*)w)->setChecked(true);
+ ((QwtLegendLabel*)w)->setVisible(false);
- w = ((QwtLegend*)legend())->legendWidget(itemToInfo(d_max_fft_plot_curve));
- ((QwtLegendLabel*)w)->setChecked(true);
- ((QwtLegendLabel*)w)->setVisible(false);
+ w = ((QwtLegend*)legend())->legendWidget(itemToInfo(d_max_fft_plot_curve));
+ ((QwtLegendLabel*)w)->setChecked(true);
+ ((QwtLegendLabel*)w)->setVisible(false);
#endif /* QWT_VERSION < 0x060100 */
- d_trigger_line = new QwtPlotMarker();
- d_trigger_line->setLineStyle(QwtPlotMarker::HLine);
- d_trigger_line->setLinePen(QPen(Qt::red, 0.6, Qt::DashLine));
- d_trigger_line->setRenderHint(QwtPlotItem::RenderAntialiased);
- d_trigger_line->setXValue(0.0);
- d_trigger_line->setYValue(0.0);
+ d_trigger_line = new QwtPlotMarker();
+ d_trigger_line->setLineStyle(QwtPlotMarker::HLine);
+ d_trigger_line->setLinePen(QPen(Qt::red, 0.6, Qt::DashLine));
+ d_trigger_line->setRenderHint(QwtPlotItem::RenderAntialiased);
+ d_trigger_line->setXValue(0.0);
+ d_trigger_line->setYValue(0.0);
- replot();
+ replot();
}
FrequencyDisplayPlot::~FrequencyDisplayPlot()
{
- for(unsigned int i = 0; i < d_nplots; ++i)
- delete [] d_ydata[i];
- delete[] d_max_fft_data;
- delete[] d_min_fft_data;
- delete[] d_xdata;
+ for (unsigned int i = 0; i < d_nplots; ++i)
+ delete[] d_ydata[i];
+ delete[] d_max_fft_data;
+ delete[] d_min_fft_data;
+ delete[] d_xdata;
}
-void
-FrequencyDisplayPlot::setYaxis(double min, double max)
+void FrequencyDisplayPlot::setYaxis(double min, double max)
{
- // Get the new max/min values for the plot
- d_ymin = min;
- d_ymax = max;
+ // Get the new max/min values for the plot
+ d_ymin = min;
+ d_ymax = max;
- // Set the axis max/min to the new values
- setAxisScale(QwtPlot::yLeft, d_ymin, d_ymax);
+ // Set the axis max/min to the new values
+ setAxisScale(QwtPlot::yLeft, d_ymin, d_ymax);
- // Reset the base zoom level to the new axis scale set here.
- // But don't do it if we set the axis due to auto scaling.
- if(!d_autoscale_state)
- d_zoomer->setZoomBase();
+ // Reset the base zoom level to the new axis scale set here.
+ // But don't do it if we set the axis due to auto scaling.
+ if (!d_autoscale_state)
+ d_zoomer->setZoomBase();
}
-double
-FrequencyDisplayPlot::getYMin() const
-{
- return d_ymin;
-}
+double FrequencyDisplayPlot::getYMin() const { return d_ymin; }
-double
-FrequencyDisplayPlot::getYMax() const
-{
- return d_ymax;
-}
+double FrequencyDisplayPlot::getYMax() const { return d_ymax; }
-void
-FrequencyDisplayPlot::setFrequencyRange(const double centerfreq,
- const double bandwidth,
- const double units, const std::string &strunits)
+void FrequencyDisplayPlot::setFrequencyRange(const double centerfreq,
+ const double bandwidth,
+ const double units,
+ const std::string& strunits)
{
- double startFreq;
- double stopFreq = (centerfreq + bandwidth/2.0f) / units;
- if(d_half_freq)
- startFreq = centerfreq / units;
- else
- startFreq = (centerfreq - bandwidth/2.0f) / units;
+ double startFreq;
+ double stopFreq = (centerfreq + bandwidth / 2.0f) / units;
+ if (d_half_freq)
+ startFreq = centerfreq / units;
+ else
+ startFreq = (centerfreq - bandwidth / 2.0f) / units;
- d_xdata_multiplier = units;
+ d_xdata_multiplier = units;
- bool reset = false;
- if((startFreq != d_start_frequency) || (stopFreq != d_stop_frequency))
- reset = true;
+ bool reset = false;
+ if ((startFreq != d_start_frequency) || (stopFreq != d_stop_frequency))
+ reset = true;
- if(stopFreq > startFreq) {
- d_start_frequency = startFreq;
- d_stop_frequency = stopFreq;
- d_center_frequency = centerfreq / units;
+ if (stopFreq > startFreq) {
+ d_start_frequency = startFreq;
+ d_stop_frequency = stopFreq;
+ d_center_frequency = centerfreq / units;
- if((axisScaleDraw(QwtPlot::xBottom) != NULL) && (d_zoomer != NULL)) {
- double display_units = ceil(log10(units)/2.0);
- setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(display_units));
- setAxisTitle(QwtPlot::xBottom, QString("Frequency (%1)").arg(strunits.c_str()));
+ if ((axisScaleDraw(QwtPlot::xBottom) != NULL) && (d_zoomer != NULL)) {
+ double display_units = ceil(log10(units) / 2.0);
+ setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(display_units));
+ setAxisTitle(QwtPlot::xBottom,
+ QString("Frequency (%1)").arg(strunits.c_str()));
- if(reset) {
- _resetXAxisPoints();
- clearMaxData();
- clearMinData();
- }
+ if (reset) {
+ _resetXAxisPoints();
+ clearMaxData();
+ clearMinData();
+ }
- ((FreqDisplayZoomer*)d_zoomer)->setFrequencyPrecision(display_units);
- ((FreqDisplayZoomer*)d_zoomer)->setUnitType(strunits);
+ ((FreqDisplayZoomer*)d_zoomer)->setFrequencyPrecision(display_units);
+ ((FreqDisplayZoomer*)d_zoomer)->setUnitType(strunits);
+ }
}
- }
}
-double
-FrequencyDisplayPlot::getStartFrequency() const
-{
- return d_start_frequency;
-}
+double FrequencyDisplayPlot::getStartFrequency() const { return d_start_frequency; }
-double
-FrequencyDisplayPlot::getStopFrequency() const
-{
- return d_stop_frequency;
-}
+double FrequencyDisplayPlot::getStopFrequency() const { return d_stop_frequency; }
-void
-FrequencyDisplayPlot::replot()
+void FrequencyDisplayPlot::replot()
{
- d_marker_noise_floor_amplitude->setYValue(d_noise_floor_amplitude);
- d_marker_peak_amplitude->setXValue(d_peak_frequency + d_start_frequency);
+ d_marker_noise_floor_amplitude->setYValue(d_noise_floor_amplitude);
+ d_marker_peak_amplitude->setXValue(d_peak_frequency + d_start_frequency);
- // Make sure to take into account the start frequency
-// if(d_useCenterFrequencyFlag){
-// d_marker_peak_amplitude->setXValue((d_peak_frequency/1000.0) + d_start_frequency);
-// }
-// else{
-// _markerPeakAmplitude->setXValue(d_peak_frequency + d_start_frequency);
-// }
- d_marker_peak_amplitude->setYValue(d_peak_amplitude);
+ // Make sure to take into account the start frequency
+ // if(d_useCenterFrequencyFlag){
+ // d_marker_peak_amplitude->setXValue((d_peak_frequency/1000.0) +
+ // d_start_frequency);
+ // }
+ // else{
+ // _markerPeakAmplitude->setXValue(d_peak_frequency + d_start_frequency);
+ // }
+ d_marker_peak_amplitude->setYValue(d_peak_amplitude);
- QwtPlot::replot();
+ QwtPlot::replot();
}
-void
-FrequencyDisplayPlot::plotNewData(const std::vector<double*> dataPoints,
- const int64_t numDataPoints,
- const double noiseFloorAmplitude, const double peakFrequency,
- const double peakAmplitude, const double timeInterval)
+void FrequencyDisplayPlot::plotNewData(const std::vector<double*> dataPoints,
+ const int64_t numDataPoints,
+ const double noiseFloorAmplitude,
+ const double peakFrequency,
+ const double peakAmplitude,
+ const double timeInterval)
{
- int64_t _npoints_in = d_half_freq ? numDataPoints/2 : numDataPoints;
- int64_t _in_index = d_half_freq ? _npoints_in : 0;
+ int64_t _npoints_in = d_half_freq ? numDataPoints / 2 : numDataPoints;
+ int64_t _in_index = d_half_freq ? _npoints_in : 0;
- if(!d_stop) {
- if(numDataPoints > 0) {
- if(_npoints_in != d_numPoints) {
- d_numPoints = _npoints_in;
+ if (!d_stop) {
+ if (numDataPoints > 0) {
+ if (_npoints_in != d_numPoints) {
+ d_numPoints = _npoints_in;
- delete[] d_min_fft_data;
- delete[] d_max_fft_data;
- delete[] d_xdata;
- d_xdata = new double[d_numPoints];
- d_min_fft_data = new double[d_numPoints];
- d_max_fft_data = new double[d_numPoints];
+ delete[] d_min_fft_data;
+ delete[] d_max_fft_data;
+ delete[] d_xdata;
+ d_xdata = new double[d_numPoints];
+ d_min_fft_data = new double[d_numPoints];
+ d_max_fft_data = new double[d_numPoints];
- for(unsigned int i = 0; i < d_nplots; ++i) {
- delete[] d_ydata[i];
- d_ydata[i] = new double[d_numPoints];
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ delete[] d_ydata[i];
+ d_ydata[i] = new double[d_numPoints];
#if QWT_VERSION < 0x060000
- d_plot_curve[i]->setRawData(d_xdata, d_ydata[i], d_numPoints);
+ d_plot_curve[i]->setRawData(d_xdata, d_ydata[i], d_numPoints);
#else
- d_plot_curve[i]->setRawSamples(d_xdata, d_ydata[i], d_numPoints);
+ d_plot_curve[i]->setRawSamples(d_xdata, d_ydata[i], d_numPoints);
#endif
- }
+ }
#if QWT_VERSION < 0x060000
- d_min_fft_plot_curve->setRawData(d_xdata, d_min_fft_data, d_numPoints);
- d_max_fft_plot_curve->setRawData(d_xdata, d_max_fft_data, d_numPoints);
+ d_min_fft_plot_curve->setRawData(d_xdata, d_min_fft_data, d_numPoints);
+ d_max_fft_plot_curve->setRawData(d_xdata, d_max_fft_data, d_numPoints);
#else
- d_min_fft_plot_curve->setRawSamples(d_xdata, d_min_fft_data, d_numPoints);
- d_max_fft_plot_curve->setRawSamples(d_xdata, d_max_fft_data, d_numPoints);
+ d_min_fft_plot_curve->setRawSamples(d_xdata, d_min_fft_data, d_numPoints);
+ d_max_fft_plot_curve->setRawSamples(d_xdata, d_max_fft_data, d_numPoints);
#endif
- _resetXAxisPoints();
- clearMaxData();
- clearMinData();
- }
-
- double bottom=1e20, top=-1e20;
- for(unsigned int n = 0; n < d_nplots; ++n) {
-
- memcpy(d_ydata[n], &(dataPoints[n][_in_index]), _npoints_in*sizeof(double));
-
- for(int64_t point = 0; point < _npoints_in; point++) {
- if(dataPoints[n][point] < d_min_fft_data[point]) {
- d_min_fft_data[point] = dataPoints[n][point+_in_index];
- }
- if(dataPoints[n][point] > d_max_fft_data[point]) {
- d_max_fft_data[point] = dataPoints[n][point+_in_index];
- }
-
- // Find overall top and bottom values in plot.
- // Used for autoscaling y-axis.
- if(dataPoints[n][point] < bottom) {
- bottom = dataPoints[n][point];
- }
- if(dataPoints[n][point] > top) {
- top = dataPoints[n][point];
- }
- }
- }
-
- if(d_autoscale_state) {
- _autoScale(bottom, top);
- if(d_autoscale_shot) {
- d_autoscale_state = false;
- d_autoscale_shot = false;
+ _resetXAxisPoints();
+ clearMaxData();
+ clearMinData();
+ }
+
+ double bottom = 1e20, top = -1e20;
+ for (unsigned int n = 0; n < d_nplots; ++n) {
+
+ memcpy(d_ydata[n],
+ &(dataPoints[n][_in_index]),
+ _npoints_in * sizeof(double));
+
+ for (int64_t point = 0; point < _npoints_in; point++) {
+ if (dataPoints[n][point] < d_min_fft_data[point]) {
+ d_min_fft_data[point] = dataPoints[n][point + _in_index];
+ }
+ if (dataPoints[n][point] > d_max_fft_data[point]) {
+ d_max_fft_data[point] = dataPoints[n][point + _in_index];
+ }
+
+ // Find overall top and bottom values in plot.
+ // Used for autoscaling y-axis.
+ if (dataPoints[n][point] < bottom) {
+ bottom = dataPoints[n][point];
+ }
+ if (dataPoints[n][point] > top) {
+ top = dataPoints[n][point];
+ }
+ }
+ }
+
+ if (d_autoscale_state) {
+ _autoScale(bottom, top);
+ if (d_autoscale_shot) {
+ d_autoscale_state = false;
+ d_autoscale_shot = false;
+ }
+ }
+
+ d_noise_floor_amplitude = noiseFloorAmplitude;
+ d_peak_frequency = peakFrequency;
+ d_peak_amplitude = peakAmplitude;
+
+ setUpperIntensityLevel(d_peak_amplitude);
+
+ replot();
}
- }
-
- d_noise_floor_amplitude = noiseFloorAmplitude;
- d_peak_frequency = peakFrequency;
- d_peak_amplitude = peakAmplitude;
-
- setUpperIntensityLevel(d_peak_amplitude);
-
- replot();
}
- }
}
-void
-FrequencyDisplayPlot::plotNewData(const double* dataPoints,
- const int64_t numDataPoints,
- const double noiseFloorAmplitude, const double peakFrequency,
- const double peakAmplitude, const double timeInterval)
+void FrequencyDisplayPlot::plotNewData(const double* dataPoints,
+ const int64_t numDataPoints,
+ const double noiseFloorAmplitude,
+ const double peakFrequency,
+ const double peakAmplitude,
+ const double timeInterval)
{
- std::vector<double*> vecDataPoints;
- vecDataPoints.push_back((double*)dataPoints);
- plotNewData(vecDataPoints, numDataPoints, noiseFloorAmplitude,
- peakFrequency, peakAmplitude, timeInterval);
+ std::vector<double*> vecDataPoints;
+ vecDataPoints.push_back((double*)dataPoints);
+ plotNewData(vecDataPoints,
+ numDataPoints,
+ noiseFloorAmplitude,
+ peakFrequency,
+ peakAmplitude,
+ timeInterval);
}
-void
-FrequencyDisplayPlot::clearMaxData()
+void FrequencyDisplayPlot::clearMaxData()
{
- for(int64_t number = 0; number < d_numPoints; number++) {
- d_max_fft_data[number] = d_ymin;
- }
+ for (int64_t number = 0; number < d_numPoints; number++) {
+ d_max_fft_data[number] = d_ymin;
+ }
}
-void
-FrequencyDisplayPlot::clearMinData()
+void FrequencyDisplayPlot::clearMinData()
{
- for(int64_t number = 0; number < d_numPoints; number++) {
- d_min_fft_data[number] = d_ymax;
- }
+ for (int64_t number = 0; number < d_numPoints; number++) {
+ d_min_fft_data[number] = d_ymax;
+ }
}
-void
-FrequencyDisplayPlot::_autoScale(double bottom, double top)
+void FrequencyDisplayPlot::_autoScale(double bottom, double top)
{
- // Auto scale the y-axis with a margin of 10 dB on either side.
- d_ymin = bottom-10;
- d_ymax = top+10;
- setYaxis(d_ymin, d_ymax);
+ // Auto scale the y-axis with a margin of 10 dB on either side.
+ d_ymin = bottom - 10;
+ d_ymax = top + 10;
+ setYaxis(d_ymin, d_ymax);
}
-void
-FrequencyDisplayPlot::setAutoScale(bool state)
-{
- d_autoscale_state = state;
-}
+void FrequencyDisplayPlot::setAutoScale(bool state) { d_autoscale_state = state; }
-void
-FrequencyDisplayPlot::setAutoScaleShot()
+void FrequencyDisplayPlot::setAutoScaleShot()
{
- d_autoscale_state = true;
- d_autoscale_shot = true;
+ d_autoscale_state = true;
+ d_autoscale_shot = true;
}
-void
-FrequencyDisplayPlot::setPlotPosHalf(bool half)
+void FrequencyDisplayPlot::setPlotPosHalf(bool half)
{
- d_half_freq = half;
- if(half)
- d_start_frequency = d_center_frequency;
+ d_half_freq = half;
+ if (half)
+ d_start_frequency = d_center_frequency;
}
-void
-FrequencyDisplayPlot::setMaxFFTVisible(const bool visibleFlag)
+void FrequencyDisplayPlot::setMaxFFTVisible(const bool visibleFlag)
{
- d_max_fft_visible = visibleFlag;
- d_max_fft_plot_curve->setVisible(visibleFlag);
+ d_max_fft_visible = visibleFlag;
+ d_max_fft_plot_curve->setVisible(visibleFlag);
}
-const bool
-FrequencyDisplayPlot::getMaxFFTVisible() const
-{
- return d_max_fft_visible;
-}
+const bool FrequencyDisplayPlot::getMaxFFTVisible() const { return d_max_fft_visible; }
-void
-FrequencyDisplayPlot::setMinFFTVisible(const bool visibleFlag)
+void FrequencyDisplayPlot::setMinFFTVisible(const bool visibleFlag)
{
- d_min_fft_visible = visibleFlag;
- d_min_fft_plot_curve->setVisible(visibleFlag);
+ d_min_fft_visible = visibleFlag;
+ d_min_fft_plot_curve->setVisible(visibleFlag);
}
-const bool
-FrequencyDisplayPlot::getMinFFTVisible() const
-{
- return d_min_fft_visible;
-}
+const bool FrequencyDisplayPlot::getMinFFTVisible() const { return d_min_fft_visible; }
-void
-FrequencyDisplayPlot::_resetXAxisPoints()
+void FrequencyDisplayPlot::_resetXAxisPoints()
{
- double fft_bin_size = (d_stop_frequency - d_start_frequency)
- / static_cast<double>(d_numPoints);
- double freqValue = d_start_frequency;
- for(int64_t loc = 0; loc < d_numPoints; loc++) {
- d_xdata[loc] = freqValue;
- freqValue += fft_bin_size;
- }
+ double fft_bin_size =
+ (d_stop_frequency - d_start_frequency) / static_cast<double>(d_numPoints);
+ double freqValue = d_start_frequency;
+ for (int64_t loc = 0; loc < d_numPoints; loc++) {
+ d_xdata[loc] = freqValue;
+ freqValue += fft_bin_size;
+ }
- setAxisScale(QwtPlot::xBottom, d_start_frequency, d_stop_frequency);
+ setAxisScale(QwtPlot::xBottom, d_start_frequency, d_stop_frequency);
- // Set up zoomer base for maximum unzoom x-axis
- // and reset to maximum unzoom level
- QwtDoubleRect zbase = d_zoomer->zoomBase();
- d_zoomer->zoom(zbase);
- d_zoomer->setZoomBase(zbase);
- d_zoomer->setZoomBase(true);
- d_zoomer->zoom(0);
+ // Set up zoomer base for maximum unzoom x-axis
+ // and reset to maximum unzoom level
+ QwtDoubleRect zbase = d_zoomer->zoomBase();
+ d_zoomer->zoom(zbase);
+ d_zoomer->setZoomBase(zbase);
+ d_zoomer->setZoomBase(true);
+ d_zoomer->zoom(0);
}
-void
-FrequencyDisplayPlot::setLowerIntensityLevel(const double lowerIntensityLevel)
+void FrequencyDisplayPlot::setLowerIntensityLevel(const double lowerIntensityLevel)
{
- d_lower_intensity_marker->setYValue(lowerIntensityLevel);
+ d_lower_intensity_marker->setYValue(lowerIntensityLevel);
}
-void
-FrequencyDisplayPlot::setUpperIntensityLevel(const double upperIntensityLevel)
+void FrequencyDisplayPlot::setUpperIntensityLevel(const double upperIntensityLevel)
{
- d_upper_intensity_marker->setYValue(upperIntensityLevel);
+ d_upper_intensity_marker->setYValue(upperIntensityLevel);
}
-void
-FrequencyDisplayPlot::setTraceColour(QColor c)
-{
- d_plot_curve[0]->setPen(QPen(c));
-}
+void FrequencyDisplayPlot::setTraceColour(QColor c) { d_plot_curve[0]->setPen(QPen(c)); }
-void
-FrequencyDisplayPlot::setBGColour(QColor c)
+void FrequencyDisplayPlot::setBGColour(QColor c)
{
- QPalette palette;
- palette.setColor(canvas()->backgroundRole(), c);
- canvas()->setPalette(palette);
+ QPalette palette;
+ palette.setColor(canvas()->backgroundRole(), c);
+ canvas()->setPalette(palette);
}
-void
-FrequencyDisplayPlot::showCFMarker(const bool show)
+void FrequencyDisplayPlot::showCFMarker(const bool show)
{
- if(show)
- d_marker_cf->show();
- else
- d_marker_cf->hide();
+ if (show)
+ d_marker_cf->show();
+ else
+ d_marker_cf->hide();
}
-void
-FrequencyDisplayPlot::onPickerPointSelected(const QwtDoublePoint & p)
+void FrequencyDisplayPlot::onPickerPointSelected(const QwtDoublePoint& p)
{
- QPointF point = p;
- //fprintf(stderr,"onPickerPointSelected %f %f %d\n", point.x(), point.y(), d_xdata_multiplier);
- point.setX(point.x() * d_xdata_multiplier);
- emit plotPointSelected(point);
+ QPointF point = p;
+ // fprintf(stderr,"onPickerPointSelected %f %f %d\n", point.x(), point.y(),
+ // d_xdata_multiplier);
+ point.setX(point.x() * d_xdata_multiplier);
+ emit plotPointSelected(point);
}
-void
-FrequencyDisplayPlot::onPickerPointSelected6(const QPointF & p)
+void FrequencyDisplayPlot::onPickerPointSelected6(const QPointF& p)
{
- QPointF point = p;
- //fprintf(stderr,"onPickerPointSelected %f %f %d\n", point.x(), point.y(), d_xdata_multiplier);
- point.setX(point.x() * d_xdata_multiplier);
- emit plotPointSelected(point);
+ QPointF point = p;
+ // fprintf(stderr,"onPickerPointSelected %f %f %d\n", point.x(), point.y(),
+ // d_xdata_multiplier);
+ point.setX(point.x() * d_xdata_multiplier);
+ emit plotPointSelected(point);
}
-void
-FrequencyDisplayPlot::setYLabel(const std::string &label,
- const std::string &unit)
+void FrequencyDisplayPlot::setYLabel(const std::string& label, const std::string& unit)
{
- std::string l = label;
- if(unit.length() > 0)
- l += " (" + unit + ")";
- setAxisTitle(QwtPlot::yLeft, QString(l.c_str()));
+ std::string l = label;
+ if (unit.length() > 0)
+ l += " (" + unit + ")";
+ setAxisTitle(QwtPlot::yLeft, QString(l.c_str()));
}
-void
-FrequencyDisplayPlot::setMinFFTColor (QColor c)
-{
- d_min_fft_color = c;
- d_min_fft_plot_curve->setPen(QPen(c));
-}
-const QColor
-FrequencyDisplayPlot::getMinFFTColor() const
+void FrequencyDisplayPlot::setMinFFTColor(QColor c)
{
- return d_min_fft_color;
+ d_min_fft_color = c;
+ d_min_fft_plot_curve->setPen(QPen(c));
}
+const QColor FrequencyDisplayPlot::getMinFFTColor() const { return d_min_fft_color; }
-void
-FrequencyDisplayPlot::setMaxFFTColor (QColor c)
+void FrequencyDisplayPlot::setMaxFFTColor(QColor c)
{
- d_max_fft_color = c;
- d_max_fft_plot_curve->setPen(QPen(c));
+ d_max_fft_color = c;
+ d_max_fft_plot_curve->setPen(QPen(c));
}
-const QColor
-FrequencyDisplayPlot::getMaxFFTColor() const
-{
- return d_max_fft_color;
-}
+const QColor FrequencyDisplayPlot::getMaxFFTColor() const { return d_max_fft_color; }
-void
-FrequencyDisplayPlot::setMarkerLowerIntensityColor (QColor c)
+void FrequencyDisplayPlot::setMarkerLowerIntensityColor(QColor c)
{
- d_marker_lower_intensity_color = c;
- d_lower_intensity_marker->setLinePen(QPen(c));
+ d_marker_lower_intensity_color = c;
+ d_lower_intensity_marker->setLinePen(QPen(c));
}
-const QColor
-FrequencyDisplayPlot::getMarkerLowerIntensityColor () const
+const QColor FrequencyDisplayPlot::getMarkerLowerIntensityColor() const
{
- return d_marker_lower_intensity_color;
+ return d_marker_lower_intensity_color;
}
-void
-FrequencyDisplayPlot::setMarkerLowerIntensityVisible (bool visible)
+void FrequencyDisplayPlot::setMarkerLowerIntensityVisible(bool visible)
{
- d_marker_lower_intensity_visible = visible;
- if(visible)
- d_lower_intensity_marker->setLineStyle(QwtPlotMarker::HLine);
- else
- d_lower_intensity_marker->setLineStyle(QwtPlotMarker::NoLine);
+ d_marker_lower_intensity_visible = visible;
+ if (visible)
+ d_lower_intensity_marker->setLineStyle(QwtPlotMarker::HLine);
+ else
+ d_lower_intensity_marker->setLineStyle(QwtPlotMarker::NoLine);
}
-const bool
-FrequencyDisplayPlot::getMarkerLowerIntensityVisible() const
+const bool FrequencyDisplayPlot::getMarkerLowerIntensityVisible() const
{
- return d_marker_lower_intensity_visible;
+ return d_marker_lower_intensity_visible;
}
-void
-FrequencyDisplayPlot::setMarkerUpperIntensityColor(QColor c)
+void FrequencyDisplayPlot::setMarkerUpperIntensityColor(QColor c)
{
- d_marker_upper_intensity_color = c;
- d_upper_intensity_marker->setLinePen(QPen(c, 0, Qt::DotLine));
+ d_marker_upper_intensity_color = c;
+ d_upper_intensity_marker->setLinePen(QPen(c, 0, Qt::DotLine));
}
-const QColor
-FrequencyDisplayPlot::getMarkerUpperIntensityColor() const
+const QColor FrequencyDisplayPlot::getMarkerUpperIntensityColor() const
{
- return d_marker_upper_intensity_color;
+ return d_marker_upper_intensity_color;
}
-void
-FrequencyDisplayPlot::setMarkerUpperIntensityVisible(bool visible)
+void FrequencyDisplayPlot::setMarkerUpperIntensityVisible(bool visible)
{
- d_marker_upper_intensity_visible = visible;
- if(visible)
- d_upper_intensity_marker->setLineStyle(QwtPlotMarker::HLine);
- else
- d_upper_intensity_marker->setLineStyle(QwtPlotMarker::NoLine);
+ d_marker_upper_intensity_visible = visible;
+ if (visible)
+ d_upper_intensity_marker->setLineStyle(QwtPlotMarker::HLine);
+ else
+ d_upper_intensity_marker->setLineStyle(QwtPlotMarker::NoLine);
}
-const bool
-FrequencyDisplayPlot::getMarkerUpperIntensityVisible() const
+const bool FrequencyDisplayPlot::getMarkerUpperIntensityVisible() const
{
- return d_marker_upper_intensity_visible;
+ return d_marker_upper_intensity_visible;
}
-void
-FrequencyDisplayPlot::setMarkerPeakAmplitudeColor(QColor c)
+void FrequencyDisplayPlot::setMarkerPeakAmplitudeColor(QColor c)
{
- d_marker_peak_amplitude_color = c;
- d_marker_peak_amplitude->setLinePen(QPen(c));
- QwtSymbol symbol;
- symbol.setStyle(QwtSymbol::Diamond);
- symbol.setSize(8);
- symbol.setPen(QPen(c));
- symbol.setBrush(QBrush(c));
+ d_marker_peak_amplitude_color = c;
+ d_marker_peak_amplitude->setLinePen(QPen(c));
+ QwtSymbol symbol;
+ symbol.setStyle(QwtSymbol::Diamond);
+ symbol.setSize(8);
+ symbol.setPen(QPen(c));
+ symbol.setBrush(QBrush(c));
#if QWT_VERSION < 0x060000
- d_marker_peak_amplitude->setSymbol(symbol);
+ d_marker_peak_amplitude->setSymbol(symbol);
#else
- d_marker_peak_amplitude->setSymbol(&symbol);
+ d_marker_peak_amplitude->setSymbol(&symbol);
#endif
}
-const QColor
-FrequencyDisplayPlot::getMarkerPeakAmplitudeColor() const
+const QColor FrequencyDisplayPlot::getMarkerPeakAmplitudeColor() const
{
- return d_marker_peak_amplitude_color;
+ return d_marker_peak_amplitude_color;
}
-void
-FrequencyDisplayPlot::setMarkerNoiseFloorAmplitudeColor(QColor c)
+void FrequencyDisplayPlot::setMarkerNoiseFloorAmplitudeColor(QColor c)
{
- d_marker_noise_floor_amplitude_color = c;
- d_marker_noise_floor_amplitude->setLinePen(QPen(c, 0, Qt::DotLine));
+ d_marker_noise_floor_amplitude_color = c;
+ d_marker_noise_floor_amplitude->setLinePen(QPen(c, 0, Qt::DotLine));
}
-const QColor
-FrequencyDisplayPlot::getMarkerNoiseFloorAmplitudeColor() const
+const QColor FrequencyDisplayPlot::getMarkerNoiseFloorAmplitudeColor() const
{
- return d_marker_noise_floor_amplitude_color;
+ return d_marker_noise_floor_amplitude_color;
}
-void
-FrequencyDisplayPlot::setMarkerNoiseFloorAmplitudeVisible(bool visible)
+void FrequencyDisplayPlot::setMarkerNoiseFloorAmplitudeVisible(bool visible)
{
- d_marker_noise_floor_amplitude_visible = visible;
- if(visible)
- d_marker_noise_floor_amplitude->setLineStyle(QwtPlotMarker::HLine);
- else
- d_marker_noise_floor_amplitude->setLineStyle(QwtPlotMarker::NoLine);
+ d_marker_noise_floor_amplitude_visible = visible;
+ if (visible)
+ d_marker_noise_floor_amplitude->setLineStyle(QwtPlotMarker::HLine);
+ else
+ d_marker_noise_floor_amplitude->setLineStyle(QwtPlotMarker::NoLine);
}
-const bool
-FrequencyDisplayPlot::getMarkerNoiseFloorAmplitudeVisible() const
+const bool FrequencyDisplayPlot::getMarkerNoiseFloorAmplitudeVisible() const
{
- return d_marker_noise_floor_amplitude_visible;
+ return d_marker_noise_floor_amplitude_visible;
}
-void
-FrequencyDisplayPlot::setMarkerCFColor(QColor c)
+void FrequencyDisplayPlot::setMarkerCFColor(QColor c)
{
- d_marker_cf_color = c;
- d_marker_cf->setLinePen(QPen(c, 0, Qt::DotLine));
+ d_marker_cf_color = c;
+ d_marker_cf->setLinePen(QPen(c, 0, Qt::DotLine));
}
-const QColor
-FrequencyDisplayPlot::getMarkerCFColor() const
-{
- return d_marker_cf_color;
-}
+const QColor FrequencyDisplayPlot::getMarkerCFColor() const { return d_marker_cf_color; }
-void
-FrequencyDisplayPlot::attachTriggerLine(bool en)
+void FrequencyDisplayPlot::attachTriggerLine(bool en)
{
- if(en) {
- d_trigger_line->attach(this);
- }
- else {
- d_trigger_line->detach();
- }
+ if (en) {
+ d_trigger_line->attach(this);
+ } else {
+ d_trigger_line->detach();
+ }
}
-void
-FrequencyDisplayPlot::setTriggerLine(double level)
+void FrequencyDisplayPlot::setTriggerLine(double level)
{
- d_trigger_line->setYValue(level);
+ d_trigger_line->setYValue(level);
}
#endif /* FREQUENCY_DISPLAY_PLOT_C */
diff --git a/gr-qtgui/lib/HistogramDisplayPlot.cc b/gr-qtgui/lib/HistogramDisplayPlot.cc
index 0b7f824cff..e57557f954 100644
--- a/gr-qtgui/lib/HistogramDisplayPlot.cc
+++ b/gr-qtgui/lib/HistogramDisplayPlot.cc
@@ -41,78 +41,58 @@
class TimePrecisionClass
{
public:
- TimePrecisionClass(const int timeprecision)
- {
- d_time_precision = timeprecision;
- }
-
- virtual ~TimePrecisionClass()
- {
- }
-
- virtual unsigned int getTimePrecision() const
- {
- return d_time_precision;
- }
-
- virtual void setTimePrecision(const unsigned int newprecision)
- {
- d_time_precision = newprecision;
- }
+ TimePrecisionClass(const int timeprecision) { d_time_precision = timeprecision; }
+
+ virtual ~TimePrecisionClass() {}
+
+ virtual unsigned int getTimePrecision() const { return d_time_precision; }
+
+ virtual void setTimePrecision(const unsigned int newprecision)
+ {
+ d_time_precision = newprecision;
+ }
+
protected:
- unsigned int d_time_precision;
+ unsigned int d_time_precision;
};
-class HistogramDisplayZoomer: public QwtPlotZoomer, public TimePrecisionClass
+class HistogramDisplayZoomer : public QwtPlotZoomer, public TimePrecisionClass
{
public:
#if QWT_VERSION < 0x060100
- HistogramDisplayZoomer(QwtPlotCanvas* canvas, const unsigned int timeprecision)
-#else /* QWT_VERSION < 0x060100 */
- HistogramDisplayZoomer(QWidget* canvas, const unsigned int timeprecision)
+ HistogramDisplayZoomer(QwtPlotCanvas* canvas, const unsigned int timeprecision)
+#else /* QWT_VERSION < 0x060100 */
+ HistogramDisplayZoomer(QWidget* canvas, const unsigned int timeprecision)
#endif /* QWT_VERSION < 0x060100 */
- : QwtPlotZoomer(canvas),TimePrecisionClass(timeprecision)
- {
- setTrackerMode(QwtPicker::AlwaysOn);
- }
+ : QwtPlotZoomer(canvas), TimePrecisionClass(timeprecision)
+ {
+ setTrackerMode(QwtPicker::AlwaysOn);
+ }
- virtual ~HistogramDisplayZoomer()
- {
- }
+ virtual ~HistogramDisplayZoomer() {}
- virtual void updateTrackerText()
- {
- updateDisplay();
- }
+ virtual void updateTrackerText() { updateDisplay(); }
- void setUnitType(const std::string &type)
- {
- d_unit_type = type;
- }
+ void setUnitType(const std::string& type) { d_unit_type = type; }
protected:
- using QwtPlotZoomer::trackerText;
- virtual QwtText trackerText(const QPoint& p) const
- {
- QwtText t;
- QwtDoublePoint dp = QwtPlotZoomer::invTransform(p);
- if((dp.y() > 0.0001) && (dp.y() < 10000)) {
- t.setText(QString("%1, %2").
- arg(dp.x(), 0, 'f', 4).
- arg(dp.y(), 0, 'f', 0));
- }
- else {
- t.setText(QString("%1, %2").
- arg(dp.x(), 0, 'f', 4).
- arg(dp.y(), 0, 'e', 0));
- }
+ using QwtPlotZoomer::trackerText;
+ virtual QwtText trackerText(const QPoint& p) const
+ {
+ QwtText t;
+ QwtDoublePoint dp = QwtPlotZoomer::invTransform(p);
+ if ((dp.y() > 0.0001) && (dp.y() < 10000)) {
+ t.setText(QString("%1, %2").arg(dp.x(), 0, 'f', 4).arg(dp.y(), 0, 'f', 0));
+ } else {
+ t.setText(QString("%1, %2").arg(dp.x(), 0, 'f', 4).arg(dp.y(), 0, 'e', 0));
+ }
- return t;
- }
+ return t;
+ }
private:
- std::string d_unit_type;
+ std::string d_unit_type;
};
@@ -120,383 +100,352 @@ private:
* Main Time domain plotter widget
**********************************************************************/
HistogramDisplayPlot::HistogramDisplayPlot(unsigned int nplots, QWidget* parent)
- : DisplayPlot(nplots, parent)
+ : DisplayPlot(nplots, parent)
{
- d_bins = 100;
- d_accum = false;
+ d_bins = 100;
+ d_accum = false;
- // Initialize x-axis data array
- d_xdata = new double[d_bins];
- memset(d_xdata, 0x0, d_bins*sizeof(double));
+ // Initialize x-axis data array
+ d_xdata = new double[d_bins];
+ memset(d_xdata, 0x0, d_bins * sizeof(double));
- d_zoomer = new HistogramDisplayZoomer(canvas(), 0);
+ d_zoomer = new HistogramDisplayZoomer(canvas(), 0);
#if QWT_VERSION < 0x060000
- d_zoomer->setSelectionFlags(QwtPicker::RectSelection | QwtPicker::DragSelection);
+ d_zoomer->setSelectionFlags(QwtPicker::RectSelection | QwtPicker::DragSelection);
#endif
- d_zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
- Qt::RightButton, Qt::ControlModifier);
- d_zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
- Qt::RightButton);
-
- const QColor c(Qt::darkRed);
- d_zoomer->setRubberBandPen(c);
- d_zoomer->setTrackerPen(c);
-
- d_semilogx = false;
- d_semilogy = false;
- d_autoscale_state = true;
- d_autoscalex_state = false;
-
- setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine);
- setXaxis(-1, 1);
- setAxisTitle(QwtPlot::xBottom, "Value");
-
- setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine);
- setYaxis(-2.0, d_bins);
- setAxisTitle(QwtPlot::yLeft, "Count");
-
- QList<QColor> 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);
-
- // Setup dataPoints and plot vectors
- // Automatically deleted when parent is deleted
- for(unsigned int i = 0; i < d_nplots; ++i) {
- d_ydata.push_back(new double[d_bins]);
- memset(d_ydata[i], 0, d_bins*sizeof(double));
-
- d_plot_curve.push_back(new QwtPlotCurve(QString("Data %1").arg(i)));
- d_plot_curve[i]->attach(this);
- d_plot_curve[i]->setPen(QPen(colors[i]));
- d_plot_curve[i]->setRenderHint(QwtPlotItem::RenderAntialiased);
-
- // Adjust color's transparency for the brush
- colors[i].setAlpha(127 / d_nplots);
- d_plot_curve[i]->setBrush(QBrush(colors[i]));
-
- colors[i].setAlpha(255 / d_nplots);
- QwtSymbol *symbol = new QwtSymbol(QwtSymbol::NoSymbol, QBrush(colors[i]),
- QPen(colors[i]), QSize(7,7));
+ d_zoomer->setMousePattern(
+ QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier);
+ d_zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
+
+ const QColor c(Qt::darkRed);
+ d_zoomer->setRubberBandPen(c);
+ d_zoomer->setTrackerPen(c);
+
+ d_semilogx = false;
+ d_semilogy = false;
+ d_autoscale_state = true;
+ d_autoscalex_state = false;
+
+ setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine);
+ setXaxis(-1, 1);
+ setAxisTitle(QwtPlot::xBottom, "Value");
+
+ setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine);
+ setYaxis(-2.0, d_bins);
+ setAxisTitle(QwtPlot::yLeft, "Count");
+
+ QList<QColor> 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);
+
+ // Setup dataPoints and plot vectors
+ // Automatically deleted when parent is deleted
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ d_ydata.push_back(new double[d_bins]);
+ memset(d_ydata[i], 0, d_bins * sizeof(double));
+
+ d_plot_curve.push_back(new QwtPlotCurve(QString("Data %1").arg(i)));
+ d_plot_curve[i]->attach(this);
+ d_plot_curve[i]->setPen(QPen(colors[i]));
+ d_plot_curve[i]->setRenderHint(QwtPlotItem::RenderAntialiased);
+
+ // Adjust color's transparency for the brush
+ colors[i].setAlpha(127 / d_nplots);
+ d_plot_curve[i]->setBrush(QBrush(colors[i]));
+
+ colors[i].setAlpha(255 / d_nplots);
+ QwtSymbol* symbol = new QwtSymbol(
+ QwtSymbol::NoSymbol, QBrush(colors[i]), QPen(colors[i]), QSize(7, 7));
#if QWT_VERSION < 0x060000
- d_plot_curve[i]->setRawData(d_xdata, d_ydata[i], d_bins);
- d_plot_curve[i]->setSymbol(*symbol);
+ d_plot_curve[i]->setRawData(d_xdata, d_ydata[i], d_bins);
+ d_plot_curve[i]->setSymbol(*symbol);
#else
- d_plot_curve[i]->setRawSamples(d_xdata, d_ydata[i], d_bins);
- d_plot_curve[i]->setSymbol(symbol);
+ d_plot_curve[i]->setRawSamples(d_xdata, d_ydata[i], d_bins);
+ d_plot_curve[i]->setSymbol(symbol);
#endif
- }
+ }
- _resetXAxisPoints(-1, 1);
+ _resetXAxisPoints(-1, 1);
}
HistogramDisplayPlot::~HistogramDisplayPlot()
{
- for(unsigned int i = 0; i < d_nplots; ++i)
- delete[] d_ydata[i];
- delete[] d_xdata;
+ for (unsigned int i = 0; i < d_nplots; ++i)
+ delete[] d_ydata[i];
+ delete[] d_xdata;
- // d_zoomer and _panner deleted when parent deleted
+ // d_zoomer and _panner deleted when parent deleted
}
-void
-HistogramDisplayPlot::replot()
-{
- QwtPlot::replot();
-}
+void HistogramDisplayPlot::replot() { QwtPlot::replot(); }
-void
-HistogramDisplayPlot::plotNewData(const std::vector<double*> dataPoints,
- const uint64_t numDataPoints,
- const double timeInterval)
+void HistogramDisplayPlot::plotNewData(const std::vector<double*> dataPoints,
+ const uint64_t numDataPoints,
+ const double timeInterval)
{
- if(!d_stop) {
- if((numDataPoints > 0)) {
-
- // keep track of the min/max values for when autoscaleX is called.
- d_xmin = 1e20;
- d_xmax = -1e20;
- for(unsigned int n = 0; n < d_nplots; ++n) {
- d_xmin = std::min(d_xmin, *std::min_element(dataPoints[n], dataPoints[n]+numDataPoints));
- d_xmax = std::max(d_xmax, *std::max_element(dataPoints[n], dataPoints[n]+numDataPoints));
- }
-
- // If autoscalex has been clicked, clear the data for the new
- // bin widths and reset the x-axis.
- if(d_autoscalex_state) {
- clear();
- _resetXAxisPoints(d_xmin, d_xmax);
- d_autoscalex_state = false;
- }
-
- if(!d_accum) {
- clear();
- }
-
- unsigned int index;
- for(unsigned int n = 0; n < d_nplots; ++n) {
- for(uint64_t point = 0; point < numDataPoints; point++) {
- index = boost::math::iround(1e-20 + (dataPoints[n][point] - d_left)/d_width);
- if((index >= 0) && (index < d_bins))
- d_ydata[n][static_cast<unsigned int>(index)] += 1;
+ if (!d_stop) {
+ if ((numDataPoints > 0)) {
+
+ // keep track of the min/max values for when autoscaleX is called.
+ d_xmin = 1e20;
+ d_xmax = -1e20;
+ for (unsigned int n = 0; n < d_nplots; ++n) {
+ d_xmin = std::min(
+ d_xmin,
+ *std::min_element(dataPoints[n], dataPoints[n] + numDataPoints));
+ d_xmax = std::max(
+ d_xmax,
+ *std::max_element(dataPoints[n], dataPoints[n] + numDataPoints));
+ }
+
+ // If autoscalex has been clicked, clear the data for the new
+ // bin widths and reset the x-axis.
+ if (d_autoscalex_state) {
+ clear();
+ _resetXAxisPoints(d_xmin, d_xmax);
+ d_autoscalex_state = false;
+ }
+
+ if (!d_accum) {
+ clear();
+ }
+
+ unsigned int index;
+ for (unsigned int n = 0; n < d_nplots; ++n) {
+ for (uint64_t point = 0; point < numDataPoints; point++) {
+ index = boost::math::iround(1e-20 + (dataPoints[n][point] - d_left) /
+ d_width);
+ if ((index >= 0) && (index < d_bins))
+ d_ydata[n][static_cast<unsigned int>(index)] += 1;
+ }
+ }
+
+ double height = *std::max_element(d_ydata[0], d_ydata[0] + d_bins);
+ for (unsigned int n = 1; n < d_nplots; ++n) {
+ height =
+ std::max(height, *std::max_element(d_ydata[n], d_ydata[n] + d_bins));
+ }
+
+ if (d_autoscale_state)
+ _autoScaleY(0, height);
+
+ replot();
}
- }
-
- double height = *std::max_element(d_ydata[0], d_ydata[0]+d_bins);
- for(unsigned int n = 1; n < d_nplots; ++n) {
- height = std::max(height, *std::max_element(d_ydata[n], d_ydata[n]+d_bins));
- }
-
- if(d_autoscale_state)
- _autoScaleY(0, height);
-
- replot();
}
- }
}
-void
-HistogramDisplayPlot::setXaxis(double min, double max)
+void HistogramDisplayPlot::setXaxis(double min, double max)
{
- _resetXAxisPoints(min, max);
+ _resetXAxisPoints(min, max);
}
-void
-HistogramDisplayPlot::_resetXAxisPoints(double left, double right)
+void HistogramDisplayPlot::_resetXAxisPoints(double left, double right)
{
- // Something's wrong with the data (NaN, Inf, or something else)
- if((left == right) || (left > right))
- throw std::runtime_error("HistogramDisplayPlot::_resetXAxisPoints left and/or right values are invalid");
-
- d_left = left *(1 - copysign(0.1, left));
- d_right = right*(1 + copysign(0.1, right));
- d_width = (d_right - d_left)/(d_bins);
- for(unsigned int loc = 0; loc < d_bins; loc++){
- d_xdata[loc] = d_left + loc*d_width;
- }
+ // Something's wrong with the data (NaN, Inf, or something else)
+ if ((left == right) || (left > right))
+ throw std::runtime_error("HistogramDisplayPlot::_resetXAxisPoints left and/or "
+ "right values are invalid");
+
+ d_left = left * (1 - copysign(0.1, left));
+ d_right = right * (1 + copysign(0.1, right));
+ d_width = (d_right - d_left) / (d_bins);
+ for (unsigned int loc = 0; loc < d_bins; loc++) {
+ d_xdata[loc] = d_left + loc * d_width;
+ }
#if QWT_VERSION < 0x060100
- axisScaleDiv(QwtPlot::xBottom)->setInterval(d_left, d_right);
-#else /* QWT_VERSION < 0x060100 */
- QwtScaleDiv scalediv(d_left, d_right);
- setAxisScaleDiv(QwtPlot::xBottom, scalediv);
+ axisScaleDiv(QwtPlot::xBottom)->setInterval(d_left, d_right);
+#else /* QWT_VERSION < 0x060100 */
+ QwtScaleDiv scalediv(d_left, d_right);
+ setAxisScaleDiv(QwtPlot::xBottom, scalediv);
#endif /* QWT_VERSION < 0x060100 */
- // Set up zoomer base for maximum unzoom x-axis
- // and reset to maximum unzoom level
- QwtDoubleRect zbase = d_zoomer->zoomBase();
-
- if(d_semilogx) {
- setAxisScale(QwtPlot::xBottom, 1e-1, d_right);
- zbase.setLeft(1e-1);
- }
- else {
- setAxisScale(QwtPlot::xBottom, d_left, d_right);
- zbase.setLeft(d_left);
- }
-
- zbase.setRight(d_right);
- d_zoomer->zoom(zbase);
- d_zoomer->setZoomBase(zbase);
- d_zoomer->zoom(0);
-}
+ // Set up zoomer base for maximum unzoom x-axis
+ // and reset to maximum unzoom level
+ QwtDoubleRect zbase = d_zoomer->zoomBase();
-void
-HistogramDisplayPlot::_autoScaleY(double bottom, double top)
-{
- // Auto scale the y-axis with a margin of 20% (10 dB for log scale)
- double b = bottom - fabs(bottom)*0.20;
- double t = top + fabs(top)*0.20;
- if(d_semilogy) {
- if(bottom > 0) {
- setYaxis(b-10, t+10);
- }
- else {
- setYaxis(1e-3, t+10);
+ if (d_semilogx) {
+ setAxisScale(QwtPlot::xBottom, 1e-1, d_right);
+ zbase.setLeft(1e-1);
+ } else {
+ setAxisScale(QwtPlot::xBottom, d_left, d_right);
+ zbase.setLeft(d_left);
}
- }
- else {
- setYaxis(b, t);
- }
-}
-void
-HistogramDisplayPlot::setAutoScaleX()
-{
- d_autoscalex_state = true;
+ zbase.setRight(d_right);
+ d_zoomer->zoom(zbase);
+ d_zoomer->setZoomBase(zbase);
+ d_zoomer->zoom(0);
}
-void
-HistogramDisplayPlot::setAutoScale(bool state)
+void HistogramDisplayPlot::_autoScaleY(double bottom, double top)
{
- d_autoscale_state = state;
+ // Auto scale the y-axis with a margin of 20% (10 dB for log scale)
+ double b = bottom - fabs(bottom) * 0.20;
+ double t = top + fabs(top) * 0.20;
+ if (d_semilogy) {
+ if (bottom > 0) {
+ setYaxis(b - 10, t + 10);
+ } else {
+ setYaxis(1e-3, t + 10);
+ }
+ } else {
+ setYaxis(b, t);
+ }
}
-void
-HistogramDisplayPlot::setSemilogx(bool en)
+void HistogramDisplayPlot::setAutoScaleX() { d_autoscalex_state = true; }
+
+void HistogramDisplayPlot::setAutoScale(bool state) { d_autoscale_state = state; }
+
+void HistogramDisplayPlot::setSemilogx(bool en)
{
- d_semilogx = en;
- if(!d_semilogx) {
- setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine);
- }
- else {
+ d_semilogx = en;
+ if (!d_semilogx) {
+ setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine);
+ } else {
#if QWT_VERSION < 0x060100
- setAxisScaleEngine(QwtPlot::xBottom, new QwtLog10ScaleEngine);
-#else /* QWT_VERSION < 0x060100 */
- setAxisScaleEngine(QwtPlot::xBottom, new QwtLogScaleEngine);
+ setAxisScaleEngine(QwtPlot::xBottom, new QwtLog10ScaleEngine);
+#else /* QWT_VERSION < 0x060100 */
+ setAxisScaleEngine(QwtPlot::xBottom, new QwtLogScaleEngine);
#endif /* QWT_VERSION < 0x060100 */
- }
+ }
}
-void
-HistogramDisplayPlot::setSemilogy(bool en)
+void HistogramDisplayPlot::setSemilogy(bool en)
{
- if(d_semilogy != en) {
- d_semilogy = en;
+ if (d_semilogy != en) {
+ d_semilogy = en;
#if QWT_VERSION < 0x060100
- double max = axisScaleDiv(QwtPlot::yLeft)->upperBound();
-#else /* QWT_VERSION < 0x060100 */
- double max = axisScaleDiv(QwtPlot::yLeft).upperBound();
+ double max = axisScaleDiv(QwtPlot::yLeft)->upperBound();
+#else /* QWT_VERSION < 0x060100 */
+ double max = axisScaleDiv(QwtPlot::yLeft).upperBound();
#endif /* QWT_VERSION < 0x060100 */
- if(!d_semilogy) {
- setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine);
- setYaxis(-pow(10.0, max/10.0), pow(10.0, max/10.0));
- }
- else {
+ if (!d_semilogy) {
+ setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine);
+ setYaxis(-pow(10.0, max / 10.0), pow(10.0, max / 10.0));
+ } else {
#if QWT_VERSION < 0x060100
- setAxisScaleEngine(QwtPlot::yLeft, new QwtLog10ScaleEngine);
-#else /* QWT_VERSION < 0x060100 */
- setAxisScaleEngine(QwtPlot::yLeft, new QwtLogScaleEngine);
+ setAxisScaleEngine(QwtPlot::yLeft, new QwtLog10ScaleEngine);
+#else /* QWT_VERSION < 0x060100 */
+ setAxisScaleEngine(QwtPlot::yLeft, new QwtLogScaleEngine);
#endif /* QWT_VERSION < 0x060100 */
- setYaxis(1e-10, 10.0*log10(100*max));
+ setYaxis(1e-10, 10.0 * log10(100 * max));
+ }
}
- }
}
-void
-HistogramDisplayPlot::setAccumulate(bool state)
-{
- d_accum = state;
-}
+void HistogramDisplayPlot::setAccumulate(bool state) { d_accum = state; }
-bool
-HistogramDisplayPlot::getAccumulate() const
-{
- return d_accum;
-}
+bool HistogramDisplayPlot::getAccumulate() const { return d_accum; }
-void
-HistogramDisplayPlot::setMarkerAlpha(unsigned int which, int alpha)
+void HistogramDisplayPlot::setMarkerAlpha(unsigned int which, int alpha)
{
- if(which < d_nplots) {
- // Get the pen color
- QPen pen(d_plot_curve[which]->pen());
- QBrush brush(d_plot_curve[which]->brush());
- QColor color = brush.color();
-
- // Set new alpha and update pen
- color.setAlpha(alpha);
- brush.setColor(color);
- color.setAlpha(std::min(255, static_cast<int>(alpha*1.5)));
- pen.setColor(color);
- d_plot_curve[which]->setBrush(brush);
- d_plot_curve[which]->setPen(pen);
-
- // And set the new color for the markers
+ if (which < d_nplots) {
+ // Get the pen color
+ QPen pen(d_plot_curve[which]->pen());
+ QBrush brush(d_plot_curve[which]->brush());
+ QColor color = brush.color();
+
+ // Set new alpha and update pen
+ color.setAlpha(alpha);
+ brush.setColor(color);
+ color.setAlpha(std::min(255, static_cast<int>(alpha * 1.5)));
+ pen.setColor(color);
+ d_plot_curve[which]->setBrush(brush);
+ d_plot_curve[which]->setPen(pen);
+
+ // And set the new color for the markers
#if QWT_VERSION < 0x060000
- QwtSymbol sym = (QwtSymbol)d_plot_curve[which]->symbol();
- setLineMarker(which, sym.style());
+ QwtSymbol sym = (QwtSymbol)d_plot_curve[which]->symbol();
+ setLineMarker(which, sym.style());
#else
- QwtSymbol *sym = (QwtSymbol*)d_plot_curve[which]->symbol();
- if(sym) {
- sym->setColor(color);
- sym->setPen(pen);
- d_plot_curve[which]->setSymbol(sym);
- }
+ QwtSymbol* sym = (QwtSymbol*)d_plot_curve[which]->symbol();
+ if (sym) {
+ sym->setColor(color);
+ sym->setPen(pen);
+ d_plot_curve[which]->setSymbol(sym);
+ }
#endif
- }
+ }
}
-int
-HistogramDisplayPlot::getMarkerAlpha(unsigned int which) const
+int HistogramDisplayPlot::getMarkerAlpha(unsigned int which) const
{
- if(which < d_nplots) {
- return d_plot_curve[which]->brush().color().alpha();
- }
- else {
- return 0;
- }
+ if (which < d_nplots) {
+ return d_plot_curve[which]->brush().color().alpha();
+ } else {
+ return 0;
+ }
}
-void
-HistogramDisplayPlot::setLineColor(unsigned int which, QColor color)
+void HistogramDisplayPlot::setLineColor(unsigned int which, QColor color)
{
- if(which < d_nplots) {
- // Adjust color's transparency for the brush
- color.setAlpha(127 / d_nplots);
+ if (which < d_nplots) {
+ // Adjust color's transparency for the brush
+ color.setAlpha(127 / d_nplots);
- QBrush brush(d_plot_curve[which]->brush());
- brush.setColor(color);
- d_plot_curve[which]->setBrush(brush);
+ QBrush brush(d_plot_curve[which]->brush());
+ brush.setColor(color);
+ d_plot_curve[which]->setBrush(brush);
- // Adjust color's transparency darker for the pen and markers
- color.setAlpha(255 / d_nplots);
+ // Adjust color's transparency darker for the pen and markers
+ color.setAlpha(255 / d_nplots);
- QPen pen(d_plot_curve[which]->pen());
- pen.setColor(color);
- d_plot_curve[which]->setPen(pen);
+ QPen pen(d_plot_curve[which]->pen());
+ pen.setColor(color);
+ d_plot_curve[which]->setPen(pen);
#if QWT_VERSION < 0x060000
- d_plot_curve[which]->setPen(pen);
- QwtSymbol sym = (QwtSymbol)d_plot_curve[which]->symbol();
- setLineMarker(which, sym.style());
+ d_plot_curve[which]->setPen(pen);
+ QwtSymbol sym = (QwtSymbol)d_plot_curve[which]->symbol();
+ setLineMarker(which, sym.style());
#else
- QwtSymbol *sym = (QwtSymbol*)d_plot_curve[which]->symbol();
- if(sym) {
- sym->setColor(color);
- sym->setPen(pen);
- d_plot_curve[which]->setSymbol(sym);
- }
+ QwtSymbol* sym = (QwtSymbol*)d_plot_curve[which]->symbol();
+ if (sym) {
+ sym->setColor(color);
+ sym->setPen(pen);
+ d_plot_curve[which]->setSymbol(sym);
+ }
#endif
- }
+ }
}
-void
-HistogramDisplayPlot::setNumBins(unsigned int bins)
+void HistogramDisplayPlot::setNumBins(unsigned int bins)
{
- d_bins = bins;
+ d_bins = bins;
- delete [] d_xdata;
- d_xdata = new double[d_bins];
- _resetXAxisPoints(d_left, d_right);
+ delete[] d_xdata;
+ d_xdata = new double[d_bins];
+ _resetXAxisPoints(d_left, d_right);
- for(unsigned int i = 0; i < d_nplots; ++i) {
- delete [] d_ydata[i];
- d_ydata[i] = new double[d_bins];
- memset(d_ydata[i], 0, d_bins*sizeof(double));
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ delete[] d_ydata[i];
+ d_ydata[i] = new double[d_bins];
+ memset(d_ydata[i], 0, d_bins * sizeof(double));
#if QWT_VERSION < 0x060000
- d_plot_curve[i]->setRawData(d_xdata, d_ydata[i], d_bins);
+ d_plot_curve[i]->setRawData(d_xdata, d_ydata[i], d_bins);
#else
- d_plot_curve[i]->setRawSamples(d_xdata, d_ydata[i], d_bins);
+ d_plot_curve[i]->setRawSamples(d_xdata, d_ydata[i], d_bins);
#endif
- }
+ }
}
-void
-HistogramDisplayPlot::clear()
+void HistogramDisplayPlot::clear()
{
- if(!d_stop) {
- for(unsigned int n = 0; n < d_nplots; ++n) {
- memset(d_ydata[n], 0, d_bins*sizeof(double));
+ if (!d_stop) {
+ for (unsigned int n = 0; n < d_nplots; ++n) {
+ memset(d_ydata[n], 0, d_bins * sizeof(double));
+ }
}
- }
}
#endif /* HISTOGRAM_DISPLAY_PLOT_C */
diff --git a/gr-qtgui/lib/SpectrumGUIClass.cc b/gr-qtgui/lib/SpectrumGUIClass.cc
index 8f207b403e..442ff6a4f9 100644
--- a/gr-qtgui/lib/SpectrumGUIClass.cc
+++ b/gr-qtgui/lib/SpectrumGUIClass.cc
@@ -25,7 +25,7 @@
#include <gnuradio/qtgui/SpectrumGUIClass.h>
-//Added by qt3to4:
+// Added by qt3to4:
#include <QEvent>
#include <volk/volk.h>
@@ -33,465 +33,449 @@ const long SpectrumGUIClass::MAX_FFT_SIZE = 32768;
const long SpectrumGUIClass::MIN_FFT_SIZE = 256;
SpectrumGUIClass::SpectrumGUIClass(const uint64_t maxDataSize,
- const uint64_t fftSize,
- const double newCenterFrequency,
- const double newStartFrequency,
- const double newStopFrequency)
-{
- _dataPoints = maxDataSize;
- if(_dataPoints < 2){
- _dataPoints = 2;
- }
- _lastDataPointCount = _dataPoints;
+ const uint64_t fftSize,
+ const double newCenterFrequency,
+ const double newStartFrequency,
+ const double newStopFrequency)
+{
+ _dataPoints = maxDataSize;
+ if (_dataPoints < 2) {
+ _dataPoints = 2;
+ }
+ _lastDataPointCount = _dataPoints;
- _fftSize = fftSize;
+ _fftSize = fftSize;
- _pendingGUIUpdateEventsCount = 0;
- _droppedEntriesCount = 0;
+ _pendingGUIUpdateEventsCount = 0;
+ _droppedEntriesCount = 0;
- _centerFrequency = newCenterFrequency;
- _startFrequency = newStartFrequency;
- _stopFrequency = newStopFrequency;
+ _centerFrequency = newCenterFrequency;
+ _startFrequency = newStartFrequency;
+ _stopFrequency = newStopFrequency;
- _windowType = 5;
+ _windowType = 5;
- _lastGUIUpdateTime = 0;
+ _lastGUIUpdateTime = 0;
- _windowOpennedFlag = false;
- _fftBuffersCreatedFlag = false;
+ _windowOpennedFlag = false;
+ _fftBuffersCreatedFlag = false;
- _powerValue = 1;
+ _powerValue = 1;
}
SpectrumGUIClass::~SpectrumGUIClass()
{
- // We don't need to delete this since as a QWidget, it is supposed to be destroyed
- // with it's parent. Deleting it causes a segmentation fault, and not deleting it
- // does not leave any extra memory.
- //if(getWindowOpenFlag()){
- //delete _spectrumDisplayForm;
- //}
-
- if(_fftBuffersCreatedFlag){
- delete[] _fftPoints;
- delete[] _realTimeDomainPoints;
- delete[] _imagTimeDomainPoints;
- }
+ // We don't need to delete this since as a QWidget, it is supposed to be destroyed
+ // with it's parent. Deleting it causes a segmentation fault, and not deleting it
+ // does not leave any extra memory.
+ // if(getWindowOpenFlag()){
+ // delete _spectrumDisplayForm;
+ //}
+
+ if (_fftBuffersCreatedFlag) {
+ delete[] _fftPoints;
+ delete[] _realTimeDomainPoints;
+ delete[] _imagTimeDomainPoints;
+ }
}
-void
-SpectrumGUIClass::openSpectrumWindow(QWidget* parent,
- const bool frequency, const bool waterfall,
- const bool time, const bool constellation)
+void SpectrumGUIClass::openSpectrumWindow(QWidget* parent,
+ const bool frequency,
+ const bool waterfall,
+ const bool time,
+ const bool constellation)
{
- d_mutex.lock();
+ d_mutex.lock();
- if(!_windowOpennedFlag) {
+ if (!_windowOpennedFlag) {
- if(!_fftBuffersCreatedFlag) {
- _fftPoints = new float[_dataPoints];
- _realTimeDomainPoints = new double[_dataPoints];
- _imagTimeDomainPoints = new double[_dataPoints];
- _fftBuffersCreatedFlag = true;
+ if (!_fftBuffersCreatedFlag) {
+ _fftPoints = new float[_dataPoints];
+ _realTimeDomainPoints = new double[_dataPoints];
+ _imagTimeDomainPoints = new double[_dataPoints];
+ _fftBuffersCreatedFlag = true;
- memset(_fftPoints, 0x0, _dataPoints*sizeof(float));
- memset(_realTimeDomainPoints, 0x0, _dataPoints*sizeof(double));
- memset(_imagTimeDomainPoints, 0x0, _dataPoints*sizeof(double));
- }
+ memset(_fftPoints, 0x0, _dataPoints * sizeof(float));
+ memset(_realTimeDomainPoints, 0x0, _dataPoints * sizeof(double));
+ memset(_imagTimeDomainPoints, 0x0, _dataPoints * sizeof(double));
+ }
- // Called from the Event Thread
- _spectrumDisplayForm = new SpectrumDisplayForm(parent);
+ // Called from the Event Thread
+ _spectrumDisplayForm = new SpectrumDisplayForm(parent);
- // Toggle Windows on/off
- _spectrumDisplayForm->toggleTabFrequency(frequency);
- _spectrumDisplayForm->toggleTabWaterfall(waterfall);
- _spectrumDisplayForm->toggleTabTime(time);
- _spectrumDisplayForm->toggleTabConstellation(constellation);
+ // Toggle Windows on/off
+ _spectrumDisplayForm->toggleTabFrequency(frequency);
+ _spectrumDisplayForm->toggleTabWaterfall(waterfall);
+ _spectrumDisplayForm->toggleTabTime(time);
+ _spectrumDisplayForm->toggleTabConstellation(constellation);
- _windowOpennedFlag = true;
+ _windowOpennedFlag = true;
- _spectrumDisplayForm->setSystem(this, _dataPoints, _fftSize);
+ _spectrumDisplayForm->setSystem(this, _dataPoints, _fftSize);
- qApp->processEvents();
- }
- d_mutex.unlock();
+ qApp->processEvents();
+ }
+ d_mutex.unlock();
- setDisplayTitle(_title);
- reset();
+ setDisplayTitle(_title);
+ reset();
- qApp->postEvent(_spectrumDisplayForm,
- new QEvent(QEvent::Type(QEvent::User+3)));
+ qApp->postEvent(_spectrumDisplayForm, new QEvent(QEvent::Type(QEvent::User + 3)));
- _lastGUIUpdateTime = 0;
+ _lastGUIUpdateTime = 0;
- // Draw Blank Display
- updateWindow(false, NULL, 0, NULL, 0, NULL, 0, gr::high_res_timer_now(), true);
+ // Draw Blank Display
+ updateWindow(false, NULL, 0, NULL, 0, NULL, 0, gr::high_res_timer_now(), true);
- // Set up the initial frequency axis settings
- setFrequencyRange(_centerFrequency, _startFrequency, _stopFrequency);
+ // Set up the initial frequency axis settings
+ setFrequencyRange(_centerFrequency, _startFrequency, _stopFrequency);
- // GUI Thread only
- qApp->processEvents();
+ // GUI Thread only
+ qApp->processEvents();
- // Set the FFT Size combo box to display the right number
- int idx = _spectrumDisplayForm->FFTSizeComboBox->findText(QString("%1").arg(_fftSize));
- _spectrumDisplayForm->FFTSizeComboBox->setCurrentIndex(idx);
+ // Set the FFT Size combo box to display the right number
+ int idx =
+ _spectrumDisplayForm->FFTSizeComboBox->findText(QString("%1").arg(_fftSize));
+ _spectrumDisplayForm->FFTSizeComboBox->setCurrentIndex(idx);
}
-void
-SpectrumGUIClass::reset()
+void SpectrumGUIClass::reset()
{
- if(getWindowOpenFlag()) {
- qApp->postEvent(_spectrumDisplayForm,
- new SpectrumFrequencyRangeEvent(_centerFrequency,
- _startFrequency,
- _stopFrequency));
- qApp->postEvent(_spectrumDisplayForm, new SpectrumWindowResetEvent());
- }
- _droppedEntriesCount = 0;
- // Call the following function from the Spectrum Window Reset Event window
- // ResetPendingGUIUpdateEvents();
+ if (getWindowOpenFlag()) {
+ qApp->postEvent(_spectrumDisplayForm,
+ new SpectrumFrequencyRangeEvent(
+ _centerFrequency, _startFrequency, _stopFrequency));
+ qApp->postEvent(_spectrumDisplayForm, new SpectrumWindowResetEvent());
+ }
+ _droppedEntriesCount = 0;
+ // Call the following function from the Spectrum Window Reset Event window
+ // ResetPendingGUIUpdateEvents();
}
-void
-SpectrumGUIClass::setDisplayTitle(const std::string newString)
+void SpectrumGUIClass::setDisplayTitle(const std::string newString)
{
- _title.assign(newString);
+ _title.assign(newString);
- if(getWindowOpenFlag()){
- qApp->postEvent(_spectrumDisplayForm,
- new SpectrumWindowCaptionEvent(_title.c_str()));
- }
+ if (getWindowOpenFlag()) {
+ qApp->postEvent(_spectrumDisplayForm,
+ new SpectrumWindowCaptionEvent(_title.c_str()));
+ }
}
-bool
-SpectrumGUIClass::getWindowOpenFlag()
+bool SpectrumGUIClass::getWindowOpenFlag()
{
- gr::thread::scoped_lock lock(d_mutex);
- bool returnFlag = false;
- returnFlag = _windowOpennedFlag;
- return returnFlag;
+ gr::thread::scoped_lock lock(d_mutex);
+ bool returnFlag = false;
+ returnFlag = _windowOpennedFlag;
+ return returnFlag;
}
-void
-SpectrumGUIClass::setWindowOpenFlag(const bool newFlag)
+void SpectrumGUIClass::setWindowOpenFlag(const bool newFlag)
{
- gr::thread::scoped_lock lock(d_mutex);
- _windowOpennedFlag = newFlag;
+ gr::thread::scoped_lock lock(d_mutex);
+ _windowOpennedFlag = newFlag;
}
-void
-SpectrumGUIClass::setFrequencyRange(const double centerFreq,
- const double startFreq,
- const double stopFreq)
+void SpectrumGUIClass::setFrequencyRange(const double centerFreq,
+ const double startFreq,
+ const double stopFreq)
{
- gr::thread::scoped_lock lock(d_mutex);
- _centerFrequency = centerFreq;
- _startFrequency = startFreq;
- _stopFrequency = stopFreq;
+ gr::thread::scoped_lock lock(d_mutex);
+ _centerFrequency = centerFreq;
+ _startFrequency = startFreq;
+ _stopFrequency = stopFreq;
- qApp->postEvent(_spectrumDisplayForm,
- new SpectrumFrequencyRangeEvent(_centerFrequency,
- _startFrequency,
- _stopFrequency));
+ qApp->postEvent(_spectrumDisplayForm,
+ new SpectrumFrequencyRangeEvent(
+ _centerFrequency, _startFrequency, _stopFrequency));
}
-double
-SpectrumGUIClass::getStartFrequency()
+double SpectrumGUIClass::getStartFrequency()
{
- gr::thread::scoped_lock lock(d_mutex);
- double returnValue = 0.0;
- returnValue = _startFrequency;
- return returnValue;
+ gr::thread::scoped_lock lock(d_mutex);
+ double returnValue = 0.0;
+ returnValue = _startFrequency;
+ return returnValue;
}
-double
-SpectrumGUIClass::getStopFrequency()
+double SpectrumGUIClass::getStopFrequency()
{
- gr::thread::scoped_lock lock(d_mutex);
- double returnValue = 0.0;
- returnValue = _stopFrequency;
- return returnValue;
+ gr::thread::scoped_lock lock(d_mutex);
+ double returnValue = 0.0;
+ returnValue = _stopFrequency;
+ return returnValue;
}
-double
-SpectrumGUIClass::getCenterFrequency()
+double SpectrumGUIClass::getCenterFrequency()
{
- gr::thread::scoped_lock lock(d_mutex);
- double returnValue = 0.0;
- returnValue = _centerFrequency;
- return returnValue;
+ gr::thread::scoped_lock lock(d_mutex);
+ double returnValue = 0.0;
+ returnValue = _centerFrequency;
+ return returnValue;
}
-void
-SpectrumGUIClass::updateWindow(const bool updateDisplayFlag,
- const float* fftBuffer,
- const uint64_t inputBufferSize,
- const float* realTimeDomainData,
- const uint64_t realTimeDomainDataSize,
- const float* complexTimeDomainData,
- const uint64_t complexTimeDomainDataSize,
- const gr::high_res_timer_type timestamp,
- const bool lastOfMultipleFFTUpdateFlag)
+void SpectrumGUIClass::updateWindow(const bool updateDisplayFlag,
+ const float* fftBuffer,
+ const uint64_t inputBufferSize,
+ const float* realTimeDomainData,
+ const uint64_t realTimeDomainDataSize,
+ const float* complexTimeDomainData,
+ const uint64_t complexTimeDomainDataSize,
+ const gr::high_res_timer_type timestamp,
+ const bool lastOfMultipleFFTUpdateFlag)
{
- //gr::thread::scoped_lock lock(d_mutex);
- int64_t bufferSize = inputBufferSize;
- bool repeatDataFlag = false;
- if(bufferSize > _dataPoints){
- bufferSize = _dataPoints;
- }
- int64_t timeDomainBufferSize = 0;
-
- if(updateDisplayFlag) {
- if((fftBuffer != NULL) && (bufferSize > 0)) {
- memcpy(_fftPoints, fftBuffer, bufferSize * sizeof(float));
+ // gr::thread::scoped_lock lock(d_mutex);
+ int64_t bufferSize = inputBufferSize;
+ bool repeatDataFlag = false;
+ if (bufferSize > _dataPoints) {
+ bufferSize = _dataPoints;
}
-
- //ALL OF THIS SHIT SHOULD BE COMBINED WITH THE FFTSHIFT
- //USE VOLK_32FC_DEINTERLEAVE_64F_X2_A TO GET REAL/IMAG FROM COMPLEX32
- // Can't do a memcpy since this is going from float to double data type
- if((realTimeDomainData != NULL) && (realTimeDomainDataSize > 0)){
- const float* realTimeDomainDataPtr = realTimeDomainData;
-
- double* realTimeDomainPointsPtr = _realTimeDomainPoints;
- timeDomainBufferSize = realTimeDomainDataSize;
-
- memset(_imagTimeDomainPoints, 0x0, realTimeDomainDataSize*sizeof(double));
- for(uint64_t number = 0; number < realTimeDomainDataSize; number++){
- *realTimeDomainPointsPtr++ = *realTimeDomainDataPtr++;
- }
+ int64_t timeDomainBufferSize = 0;
+
+ if (updateDisplayFlag) {
+ if ((fftBuffer != NULL) && (bufferSize > 0)) {
+ memcpy(_fftPoints, fftBuffer, bufferSize * sizeof(float));
+ }
+
+ // ALL OF THIS SHIT SHOULD BE COMBINED WITH THE FFTSHIFT
+ // USE VOLK_32FC_DEINTERLEAVE_64F_X2_A TO GET REAL/IMAG FROM COMPLEX32
+ // Can't do a memcpy since this is going from float to double data type
+ if ((realTimeDomainData != NULL) && (realTimeDomainDataSize > 0)) {
+ const float* realTimeDomainDataPtr = realTimeDomainData;
+
+ double* realTimeDomainPointsPtr = _realTimeDomainPoints;
+ timeDomainBufferSize = realTimeDomainDataSize;
+
+ memset(_imagTimeDomainPoints, 0x0, realTimeDomainDataSize * sizeof(double));
+ for (uint64_t number = 0; number < realTimeDomainDataSize; number++) {
+ *realTimeDomainPointsPtr++ = *realTimeDomainDataPtr++;
+ }
+ }
+
+ if ((complexTimeDomainData != NULL) && (complexTimeDomainDataSize > 0)) {
+ volk_32fc_deinterleave_64f_x2(_realTimeDomainPoints,
+ _imagTimeDomainPoints,
+ (const lv_32fc_t*)complexTimeDomainData,
+ complexTimeDomainDataSize);
+ timeDomainBufferSize = complexTimeDomainDataSize;
+ }
}
- if((complexTimeDomainData != NULL) && (complexTimeDomainDataSize > 0)) {
- volk_32fc_deinterleave_64f_x2(_realTimeDomainPoints,
- _imagTimeDomainPoints,
- (const lv_32fc_t *)complexTimeDomainData,
- complexTimeDomainDataSize);
- timeDomainBufferSize = complexTimeDomainDataSize;
+ // If bufferSize is zero, then just update the display by sending over the old data
+ if (bufferSize < 1) {
+ bufferSize = _lastDataPointCount;
+ repeatDataFlag = true;
+ } else {
+ // Since there is data this time, update the count
+ _lastDataPointCount = bufferSize;
}
- }
-
- // If bufferSize is zero, then just update the display by sending over the old data
- if(bufferSize < 1) {
- bufferSize = _lastDataPointCount;
- repeatDataFlag = true;
- }
- else {
- // Since there is data this time, update the count
- _lastDataPointCount = bufferSize;
- }
-
- const gr::high_res_timer_type currentTime = gr::high_res_timer_now();
- const gr::high_res_timer_type lastUpdateGUITime = getLastGUIUpdateTime();
-
- if((currentTime - lastUpdateGUITime > (4*_updateTime)*gr::high_res_timer_tps()) &&
- (getPendingGUIUpdateEvents() > 0) && lastUpdateGUITime != 0) {
- // Do not update the display if too much data is pending to be displayed
- _droppedEntriesCount++;
- }
- else {
- // Draw the Data
- incrementPendingGUIUpdateEvents();
- qApp->postEvent(_spectrumDisplayForm,
- new SpectrumUpdateEvent(_fftPoints, bufferSize,
- _realTimeDomainPoints,
- _imagTimeDomainPoints,
- timeDomainBufferSize,
- timestamp,
- repeatDataFlag,
- lastOfMultipleFFTUpdateFlag,
- currentTime,
- _droppedEntriesCount));
-
- // Only reset the dropped entries counter if this is not
- // repeat data since repeat data is dropped by the display systems
- if(!repeatDataFlag) {
- _droppedEntriesCount = 0;
+
+ const gr::high_res_timer_type currentTime = gr::high_res_timer_now();
+ const gr::high_res_timer_type lastUpdateGUITime = getLastGUIUpdateTime();
+
+ if ((currentTime - lastUpdateGUITime >
+ (4 * _updateTime) * gr::high_res_timer_tps()) &&
+ (getPendingGUIUpdateEvents() > 0) && lastUpdateGUITime != 0) {
+ // Do not update the display if too much data is pending to be displayed
+ _droppedEntriesCount++;
+ } else {
+ // Draw the Data
+ incrementPendingGUIUpdateEvents();
+ qApp->postEvent(_spectrumDisplayForm,
+ new SpectrumUpdateEvent(_fftPoints,
+ bufferSize,
+ _realTimeDomainPoints,
+ _imagTimeDomainPoints,
+ timeDomainBufferSize,
+ timestamp,
+ repeatDataFlag,
+ lastOfMultipleFFTUpdateFlag,
+ currentTime,
+ _droppedEntriesCount));
+
+ // Only reset the dropped entries counter if this is not
+ // repeat data since repeat data is dropped by the display systems
+ if (!repeatDataFlag) {
+ _droppedEntriesCount = 0;
+ }
}
- }
}
-float
-SpectrumGUIClass::getPowerValue()
+float SpectrumGUIClass::getPowerValue()
{
- gr::thread::scoped_lock lock(d_mutex);
- float returnValue = 0;
- returnValue = _powerValue;
- return returnValue;
+ gr::thread::scoped_lock lock(d_mutex);
+ float returnValue = 0;
+ returnValue = _powerValue;
+ return returnValue;
}
-void
-SpectrumGUIClass::setPowerValue(const float value)
+void SpectrumGUIClass::setPowerValue(const float value)
{
- gr::thread::scoped_lock lock(d_mutex);
- _powerValue = value;
+ gr::thread::scoped_lock lock(d_mutex);
+ _powerValue = value;
}
-int
-SpectrumGUIClass::getWindowType()
+int SpectrumGUIClass::getWindowType()
{
- gr::thread::scoped_lock lock(d_mutex);
- int returnValue = 0;
- returnValue = _windowType;
- return returnValue;
+ gr::thread::scoped_lock lock(d_mutex);
+ int returnValue = 0;
+ returnValue = _windowType;
+ return returnValue;
}
-void
-SpectrumGUIClass::setWindowType(const int newType)
+void SpectrumGUIClass::setWindowType(const int newType)
{
- gr::thread::scoped_lock lock(d_mutex);
- _windowType = newType;
+ gr::thread::scoped_lock lock(d_mutex);
+ _windowType = newType;
}
-int
-SpectrumGUIClass::getFFTSize()
+int SpectrumGUIClass::getFFTSize()
{
- int returnValue = 0;
- returnValue = _fftSize;
- return returnValue;
+ int returnValue = 0;
+ returnValue = _fftSize;
+ return returnValue;
}
-int
-SpectrumGUIClass::getFFTSizeIndex()
+int SpectrumGUIClass::getFFTSizeIndex()
{
- gr::thread::scoped_lock lock(d_mutex);
- int fftsize = getFFTSize();
- int rv = 0;
- switch(fftsize) {
- case(1024): rv = 0; break;
- case(2048): rv = 1; break;
- case(4096): rv = 2; break;
- case(8192): rv = 3; break;
- case(16384): rv = 3; break;
- case(32768): rv = 3; break;
- default: rv = 0; break;
- }
- return rv;
+ gr::thread::scoped_lock lock(d_mutex);
+ int fftsize = getFFTSize();
+ int rv = 0;
+ switch (fftsize) {
+ case (1024):
+ rv = 0;
+ break;
+ case (2048):
+ rv = 1;
+ break;
+ case (4096):
+ rv = 2;
+ break;
+ case (8192):
+ rv = 3;
+ break;
+ case (16384):
+ rv = 3;
+ break;
+ case (32768):
+ rv = 3;
+ break;
+ default:
+ rv = 0;
+ break;
+ }
+ return rv;
}
-void
-SpectrumGUIClass::setFFTSize(const int newSize)
+void SpectrumGUIClass::setFFTSize(const int newSize)
{
- gr::thread::scoped_lock lock(d_mutex);
- _fftSize = newSize;
+ gr::thread::scoped_lock lock(d_mutex);
+ _fftSize = newSize;
}
-gr::high_res_timer_type
-SpectrumGUIClass::getLastGUIUpdateTime()
+gr::high_res_timer_type SpectrumGUIClass::getLastGUIUpdateTime()
{
- gr::thread::scoped_lock lock(d_mutex);
- gr::high_res_timer_type returnValue;
- returnValue = _lastGUIUpdateTime;
- return returnValue;
+ gr::thread::scoped_lock lock(d_mutex);
+ gr::high_res_timer_type returnValue;
+ returnValue = _lastGUIUpdateTime;
+ return returnValue;
}
-void
-SpectrumGUIClass::setLastGUIUpdateTime(const gr::high_res_timer_type newTime)
+void SpectrumGUIClass::setLastGUIUpdateTime(const gr::high_res_timer_type newTime)
{
- gr::thread::scoped_lock lock(d_mutex);
- _lastGUIUpdateTime = newTime;
+ gr::thread::scoped_lock lock(d_mutex);
+ _lastGUIUpdateTime = newTime;
}
-unsigned int
-SpectrumGUIClass::getPendingGUIUpdateEvents()
+unsigned int SpectrumGUIClass::getPendingGUIUpdateEvents()
{
- gr::thread::scoped_lock lock(d_mutex);
- unsigned int returnValue = 0;
- returnValue = _pendingGUIUpdateEventsCount;
- return returnValue;
+ gr::thread::scoped_lock lock(d_mutex);
+ unsigned int returnValue = 0;
+ returnValue = _pendingGUIUpdateEventsCount;
+ return returnValue;
}
-void
-SpectrumGUIClass::incrementPendingGUIUpdateEvents()
+void SpectrumGUIClass::incrementPendingGUIUpdateEvents()
{
- gr::thread::scoped_lock lock(d_mutex);
- _pendingGUIUpdateEventsCount++;
+ gr::thread::scoped_lock lock(d_mutex);
+ _pendingGUIUpdateEventsCount++;
}
-void
-SpectrumGUIClass::decrementPendingGUIUpdateEvents()
+void SpectrumGUIClass::decrementPendingGUIUpdateEvents()
{
- gr::thread::scoped_lock lock(d_mutex);
- if(_pendingGUIUpdateEventsCount > 0){
- _pendingGUIUpdateEventsCount--;
- }
+ gr::thread::scoped_lock lock(d_mutex);
+ if (_pendingGUIUpdateEventsCount > 0) {
+ _pendingGUIUpdateEventsCount--;
+ }
}
-void
-SpectrumGUIClass::resetPendingGUIUpdateEvents()
+void SpectrumGUIClass::resetPendingGUIUpdateEvents()
{
- gr::thread::scoped_lock lock(d_mutex);
- _pendingGUIUpdateEventsCount = 0;
+ gr::thread::scoped_lock lock(d_mutex);
+ _pendingGUIUpdateEventsCount = 0;
}
-QWidget*
-SpectrumGUIClass::qwidget()
+QWidget* SpectrumGUIClass::qwidget()
{
- gr::thread::scoped_lock lock(d_mutex);
- return (QWidget*)_spectrumDisplayForm;
+ gr::thread::scoped_lock lock(d_mutex);
+ return (QWidget*)_spectrumDisplayForm;
}
-void
-SpectrumGUIClass::setTimeDomainAxis(double min, double max)
+void SpectrumGUIClass::setTimeDomainAxis(double min, double max)
{
- gr::thread::scoped_lock lock(d_mutex);
- _spectrumDisplayForm->setTimeDomainAxis(min, max);
+ gr::thread::scoped_lock lock(d_mutex);
+ _spectrumDisplayForm->setTimeDomainAxis(min, max);
}
-void
-SpectrumGUIClass::setConstellationAxis(double xmin, double xmax,
- double ymin, double ymax)
+void SpectrumGUIClass::setConstellationAxis(double xmin,
+ double xmax,
+ double ymin,
+ double ymax)
{
- gr::thread::scoped_lock lock(d_mutex);
- _spectrumDisplayForm->setConstellationAxis(xmin, xmax, ymin, ymax);
+ gr::thread::scoped_lock lock(d_mutex);
+ _spectrumDisplayForm->setConstellationAxis(xmin, xmax, ymin, ymax);
}
-void
-SpectrumGUIClass::setConstellationPenSize(int size)
+void SpectrumGUIClass::setConstellationPenSize(int size)
{
- gr::thread::scoped_lock lock(d_mutex);
- _spectrumDisplayForm->setConstellationPenSize(size);
+ gr::thread::scoped_lock lock(d_mutex);
+ _spectrumDisplayForm->setConstellationPenSize(size);
}
-void
-SpectrumGUIClass::setFrequencyAxis(double min, double max)
+void SpectrumGUIClass::setFrequencyAxis(double min, double max)
{
- gr::thread::scoped_lock lock(d_mutex);
- _spectrumDisplayForm->setFrequencyAxis(min, max);
+ gr::thread::scoped_lock lock(d_mutex);
+ _spectrumDisplayForm->setFrequencyAxis(min, max);
}
-void
-SpectrumGUIClass::setUpdateTime(double t)
+void SpectrumGUIClass::setUpdateTime(double t)
{
- gr::thread::scoped_lock lock(d_mutex);
- _updateTime = t;
- _spectrumDisplayForm->setUpdateTime(_updateTime);
+ gr::thread::scoped_lock lock(d_mutex);
+ _updateTime = t;
+ _spectrumDisplayForm->setUpdateTime(_updateTime);
}
-void
-SpectrumGUIClass::enableRFFreq(bool en)
+void SpectrumGUIClass::enableRFFreq(bool en)
{
- gr::thread::scoped_lock lock(d_mutex);
- _spectrumDisplayForm->toggleRFFrequencies(en);
+ gr::thread::scoped_lock lock(d_mutex);
+ _spectrumDisplayForm->toggleRFFrequencies(en);
}
-bool
-SpectrumGUIClass::checkClicked()
+bool SpectrumGUIClass::checkClicked()
{
- gr::thread::scoped_lock lock(d_mutex);
- return _spectrumDisplayForm->checkClicked();
+ gr::thread::scoped_lock lock(d_mutex);
+ return _spectrumDisplayForm->checkClicked();
}
-float
-SpectrumGUIClass::getClickedFreq()
+float SpectrumGUIClass::getClickedFreq()
{
- gr::thread::scoped_lock lock(d_mutex);
- return _spectrumDisplayForm->getClickedFreq();
+ gr::thread::scoped_lock lock(d_mutex);
+ return _spectrumDisplayForm->getClickedFreq();
}
#endif /* SPECTRUM_GUI_CLASS_CPP */
diff --git a/gr-qtgui/lib/TimeDomainDisplayPlot.cc b/gr-qtgui/lib/TimeDomainDisplayPlot.cc
index c979642b59..ad8a300abf 100644
--- a/gr-qtgui/lib/TimeDomainDisplayPlot.cc
+++ b/gr-qtgui/lib/TimeDomainDisplayPlot.cc
@@ -35,93 +35,71 @@
class TimePrecisionClass
{
public:
- TimePrecisionClass(const int timePrecision)
- {
- d_timePrecision = timePrecision;
- }
-
- virtual ~TimePrecisionClass()
- {
- }
-
- virtual unsigned int getTimePrecision() const
- {
- return d_timePrecision;
- }
-
- virtual void setTimePrecision(const unsigned int newPrecision)
- {
- d_timePrecision = newPrecision;
- }
+ TimePrecisionClass(const int timePrecision) { d_timePrecision = timePrecision; }
+
+ virtual ~TimePrecisionClass() {}
+
+ virtual unsigned int getTimePrecision() const { return d_timePrecision; }
+
+ virtual void setTimePrecision(const unsigned int newPrecision)
+ {
+ d_timePrecision = newPrecision;
+ }
+
protected:
- unsigned int d_timePrecision;
+ unsigned int d_timePrecision;
};
-class TimeDomainDisplayZoomer: public QwtPlotZoomer, public TimePrecisionClass
+class TimeDomainDisplayZoomer : public QwtPlotZoomer, public TimePrecisionClass
{
public:
#if QWT_VERSION < 0x060100
- TimeDomainDisplayZoomer(QwtPlotCanvas* canvas, const unsigned int timePrecision)
-#else /* QWT_VERSION < 0x060100 */
- TimeDomainDisplayZoomer(QWidget* canvas, const unsigned int timePrecision)
+ TimeDomainDisplayZoomer(QwtPlotCanvas* canvas, const unsigned int timePrecision)
+#else /* QWT_VERSION < 0x060100 */
+ TimeDomainDisplayZoomer(QWidget* canvas, const unsigned int timePrecision)
#endif /* QWT_VERSION < 0x060100 */
- : QwtPlotZoomer(canvas),TimePrecisionClass(timePrecision),d_yUnitType("V")
- {
- setTrackerMode(QwtPicker::AlwaysOn);
- }
-
- virtual ~TimeDomainDisplayZoomer()
- {
- }
-
- virtual void updateTrackerText()
- {
- updateDisplay();
- }
-
- void setUnitType(const std::string &type)
- {
- d_unitType = type;
- }
-
- std::string unitType()
- {
- return d_unitType;
- }
-
- void setYUnitType(const std::string &type)
- {
- d_yUnitType = type;
- }
+ : QwtPlotZoomer(canvas), TimePrecisionClass(timePrecision), d_yUnitType("V")
+ {
+ setTrackerMode(QwtPicker::AlwaysOn);
+ }
+
+ virtual ~TimeDomainDisplayZoomer() {}
+
+ virtual void updateTrackerText() { updateDisplay(); }
+
+ void setUnitType(const std::string& type) { d_unitType = type; }
+
+ std::string unitType() { return d_unitType; }
+
+ void setYUnitType(const std::string& type) { d_yUnitType = type; }
protected:
- using QwtPlotZoomer::trackerText;
- virtual QwtText trackerText( const QPoint& p ) const
- {
- QwtText t;
- QwtDoublePoint dp = QwtPlotZoomer::invTransform(p);
- if((fabs(dp.y()) > 0.0001) && (fabs(dp.y()) < 10000)) {
- t.setText(QString("%1 %2, %3 %4").
- arg(dp.x(), 0, 'f', getTimePrecision()).
- arg(d_unitType.c_str()).
- arg(dp.y(), 0, 'f', 4).
- arg(d_yUnitType.c_str()));
- }
- else {
- t.setText(QString("%1 %2, %3 %4").
- arg(dp.x(), 0, 'f', getTimePrecision()).
- arg(d_unitType.c_str()).
- arg(dp.y(), 0, 'e', 4).
- arg(d_yUnitType.c_str()));
- }
+ using QwtPlotZoomer::trackerText;
+ virtual QwtText trackerText(const QPoint& p) const
+ {
+ QwtText t;
+ QwtDoublePoint dp = QwtPlotZoomer::invTransform(p);
+ if ((fabs(dp.y()) > 0.0001) && (fabs(dp.y()) < 10000)) {
+ t.setText(QString("%1 %2, %3 %4")
+ .arg(dp.x(), 0, 'f', getTimePrecision())
+ .arg(d_unitType.c_str())
+ .arg(dp.y(), 0, 'f', 4)
+ .arg(d_yUnitType.c_str()));
+ } else {
+ t.setText(QString("%1 %2, %3 %4")
+ .arg(dp.x(), 0, 'f', getTimePrecision())
+ .arg(d_unitType.c_str())
+ .arg(dp.y(), 0, 'e', 4)
+ .arg(d_yUnitType.c_str()));
+ }
- return t;
- }
+ return t;
+ }
private:
- std::string d_unitType;
- std::string d_yUnitType;
+ std::string d_unitType;
+ std::string d_yUnitType;
};
@@ -129,560 +107,520 @@ private:
* Main Time domain plotter widget
**********************************************************************/
TimeDomainDisplayPlot::TimeDomainDisplayPlot(int nplots, QWidget* parent)
- : DisplayPlot(nplots, parent)
+ : DisplayPlot(nplots, parent)
{
- d_numPoints = 1024;
- d_xdata = new double[d_numPoints];
- memset(d_xdata, 0x0, d_numPoints*sizeof(double));
+ d_numPoints = 1024;
+ d_xdata = new double[d_numPoints];
+ memset(d_xdata, 0x0, d_numPoints * sizeof(double));
- d_tag_text_color = Qt::black;
- d_tag_background_color = Qt::white;
- d_tag_background_style = Qt::NoBrush;
+ d_tag_text_color = Qt::black;
+ d_tag_background_color = Qt::white;
+ d_tag_background_style = Qt::NoBrush;
- d_zoomer = new TimeDomainDisplayZoomer(canvas(), 0);
+ d_zoomer = new TimeDomainDisplayZoomer(canvas(), 0);
#if QWT_VERSION < 0x060000
- d_zoomer->setSelectionFlags(QwtPicker::RectSelection | QwtPicker::DragSelection);
+ d_zoomer->setSelectionFlags(QwtPicker::RectSelection | QwtPicker::DragSelection);
#endif
- d_zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
- Qt::RightButton, Qt::ControlModifier);
- d_zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
- Qt::RightButton);
-
- const QColor c(Qt::darkRed);
- d_zoomer->setRubberBandPen(c);
- d_zoomer->setTrackerPen(c);
-
- d_semilogx = false;
- d_semilogy = false;
- d_autoscale_shot = false;
-
- setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine);
- setXaxis(0, d_numPoints);
- setAxisTitle(QwtPlot::xBottom, "Time (sec)");
-
- setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine);
- setYaxis(-2.0, 2.0);
- setAxisTitle(QwtPlot::yLeft, "Amplitude");
-
- QList<QColor> 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)
- // cycle through all colors again to increase time_sink_f input limit
- // from 12 to 24, otherwise you get a segfault
- << 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);
-
- // Setup dataPoints and plot vectors
- // Automatically deleted when parent is deleted
- for(unsigned int i = 0; i < d_nplots; ++i) {
- d_ydata.push_back(new double[d_numPoints]);
- memset(d_ydata[i], 0x0, d_numPoints*sizeof(double));
-
- d_plot_curve.push_back(new QwtPlotCurve(QString("Data %1").arg(i)));
- d_plot_curve[i]->attach(this);
- d_plot_curve[i]->setPen(QPen(colors[i]));
- d_plot_curve[i]->setRenderHint(QwtPlotItem::RenderAntialiased);
-
- QwtSymbol *symbol = new QwtSymbol(QwtSymbol::NoSymbol, QBrush(colors[i]),
- QPen(colors[i]), QSize(7,7));
+ d_zoomer->setMousePattern(
+ QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier);
+ d_zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
+
+ const QColor c(Qt::darkRed);
+ d_zoomer->setRubberBandPen(c);
+ d_zoomer->setTrackerPen(c);
+
+ d_semilogx = false;
+ d_semilogy = false;
+ d_autoscale_shot = false;
+
+ setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine);
+ setXaxis(0, d_numPoints);
+ setAxisTitle(QwtPlot::xBottom, "Time (sec)");
+
+ setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine);
+ setYaxis(-2.0, 2.0);
+ setAxisTitle(QwtPlot::yLeft, "Amplitude");
+
+ QList<QColor> 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)
+ // cycle through all colors again to increase time_sink_f input limit
+ // from 12 to 24, otherwise you get a segfault
+ << 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);
+
+ // Setup dataPoints and plot vectors
+ // Automatically deleted when parent is deleted
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ d_ydata.push_back(new double[d_numPoints]);
+ memset(d_ydata[i], 0x0, d_numPoints * sizeof(double));
+
+ d_plot_curve.push_back(new QwtPlotCurve(QString("Data %1").arg(i)));
+ d_plot_curve[i]->attach(this);
+ d_plot_curve[i]->setPen(QPen(colors[i]));
+ d_plot_curve[i]->setRenderHint(QwtPlotItem::RenderAntialiased);
+
+ QwtSymbol* symbol = new QwtSymbol(
+ QwtSymbol::NoSymbol, QBrush(colors[i]), QPen(colors[i]), QSize(7, 7));
#if QWT_VERSION < 0x060000
- d_plot_curve[i]->setRawData(d_xdata, d_ydata[i], d_numPoints);
- d_plot_curve[i]->setSymbol(*symbol);
+ d_plot_curve[i]->setRawData(d_xdata, d_ydata[i], d_numPoints);
+ d_plot_curve[i]->setSymbol(*symbol);
#else
- d_plot_curve[i]->setRawSamples(d_xdata, d_ydata[i], d_numPoints);
- d_plot_curve[i]->setSymbol(symbol);
+ d_plot_curve[i]->setRawSamples(d_xdata, d_ydata[i], d_numPoints);
+ d_plot_curve[i]->setSymbol(symbol);
#endif
- }
-
- d_sample_rate = 1;
- _resetXAxisPoints();
-
- d_tag_markers.resize(d_nplots);
- d_tag_markers_en = std::vector<bool>(d_nplots, true);
-
- d_trigger_lines[0] = new QwtPlotMarker();
- d_trigger_lines[0]->setLineStyle(QwtPlotMarker::HLine);
- d_trigger_lines[0]->setLinePen(QPen(Qt::red, 0.6, Qt::DashLine));
- d_trigger_lines[0]->setRenderHint(QwtPlotItem::RenderAntialiased);
- d_trigger_lines[0]->setXValue(0.0);
- d_trigger_lines[0]->setYValue(0.0);
-
- d_trigger_lines[1] = new QwtPlotMarker();
- d_trigger_lines[1]->setLineStyle(QwtPlotMarker::VLine);
- d_trigger_lines[1]->setLinePen(QPen(Qt::red, 0.6, Qt::DashLine));
- d_trigger_lines[1]->setRenderHint(QwtPlotItem::RenderAntialiased);
- d_trigger_lines[1]->setXValue(0.0);
- d_trigger_lines[1]->setYValue(0.0);
+ }
+
+ d_sample_rate = 1;
+ _resetXAxisPoints();
+
+ d_tag_markers.resize(d_nplots);
+ d_tag_markers_en = std::vector<bool>(d_nplots, true);
+
+ d_trigger_lines[0] = new QwtPlotMarker();
+ d_trigger_lines[0]->setLineStyle(QwtPlotMarker::HLine);
+ d_trigger_lines[0]->setLinePen(QPen(Qt::red, 0.6, Qt::DashLine));
+ d_trigger_lines[0]->setRenderHint(QwtPlotItem::RenderAntialiased);
+ d_trigger_lines[0]->setXValue(0.0);
+ d_trigger_lines[0]->setYValue(0.0);
+
+ d_trigger_lines[1] = new QwtPlotMarker();
+ d_trigger_lines[1]->setLineStyle(QwtPlotMarker::VLine);
+ d_trigger_lines[1]->setLinePen(QPen(Qt::red, 0.6, Qt::DashLine));
+ d_trigger_lines[1]->setRenderHint(QwtPlotItem::RenderAntialiased);
+ d_trigger_lines[1]->setXValue(0.0);
+ d_trigger_lines[1]->setYValue(0.0);
}
TimeDomainDisplayPlot::~TimeDomainDisplayPlot()
{
- for(unsigned int i = 0; i < d_nplots; ++i)
- delete [] d_ydata[i];
- delete[] d_xdata;
+ for (unsigned int i = 0; i < d_nplots; ++i)
+ delete[] d_ydata[i];
+ delete[] d_xdata;
- // d_zoomer and _panner deleted when parent deleted
+ // d_zoomer and _panner deleted when parent deleted
}
-void
-TimeDomainDisplayPlot::replot()
-{
- QwtPlot::replot();
-}
+void TimeDomainDisplayPlot::replot() { QwtPlot::replot(); }
-void
-TimeDomainDisplayPlot::plotNewData(const std::vector<double*> dataPoints,
- const int64_t numDataPoints,
- const double timeInterval,
- const std::vector< std::vector<gr::tag_t> > &tags)
+void TimeDomainDisplayPlot::plotNewData(const std::vector<double*> dataPoints,
+ const int64_t numDataPoints,
+ const double timeInterval,
+ const std::vector<std::vector<gr::tag_t>>& tags)
{
- if(!d_stop) {
- if((numDataPoints > 0)) {
- if(numDataPoints != d_numPoints){
- d_numPoints = numDataPoints;
+ if (!d_stop) {
+ if ((numDataPoints > 0)) {
+ if (numDataPoints != d_numPoints) {
+ d_numPoints = numDataPoints;
- delete[] d_xdata;
- d_xdata = new double[d_numPoints];
+ delete[] d_xdata;
+ d_xdata = new double[d_numPoints];
- for(unsigned int i = 0; i < d_nplots; ++i) {
- delete[] d_ydata[i];
- d_ydata[i] = new double[d_numPoints];
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ delete[] d_ydata[i];
+ d_ydata[i] = new double[d_numPoints];
#if QWT_VERSION < 0x060000
- d_plot_curve[i]->setRawData(d_xdata, d_ydata[i], d_numPoints);
+ d_plot_curve[i]->setRawData(d_xdata, d_ydata[i], d_numPoints);
#else
- d_plot_curve[i]->setRawSamples(d_xdata, d_ydata[i], d_numPoints);
+ d_plot_curve[i]->setRawSamples(d_xdata, d_ydata[i], d_numPoints);
#endif
- }
-
- _resetXAxisPoints();
- }
-
- for(unsigned int i = 0; i < d_nplots; ++i) {
- if(d_semilogy) {
- for(int n = 0; n < numDataPoints; n++)
- d_ydata[i][n] = fabs(dataPoints[i][n]);
- }
- else {
- memcpy(d_ydata[i], dataPoints[i], numDataPoints*sizeof(double));
- }
- }
-
- // Detach and delete any tags that were plotted last time
- for(unsigned int n = 0; n < d_nplots; ++n) {
- for(size_t i = 0; i < d_tag_markers[n].size(); i++) {
- d_tag_markers[n][i]->detach();
- delete d_tag_markers[n][i];
- }
- d_tag_markers[n].clear();
- }
-
- // Plot and attach any new tags found.
- // First test if this was a complex input where real/imag get
- // split here into two stream.
- if(tags.size() > 0) {
- bool cmplx = false;
- unsigned int mult = d_nplots / tags.size();
- if(mult == 2)
- cmplx = true;
-
- std::vector< std::vector<gr::tag_t> >::const_iterator tag = tags.begin();
- for(unsigned int i = 0; i < d_nplots; i += mult) {
- std::vector<gr::tag_t>::const_iterator t;
- for(t = tag->begin(); t != tag->end(); t++) {
- uint64_t offset = (*t).offset;
-
- // Ignore tag if its offset is outside our plottable vector.
- if(offset >= (uint64_t)d_numPoints) {
- continue;
- }
+ }
- double sample_offset = double(offset)/d_sample_rate;
-
- std::stringstream s;
- s << (*t).key << ": " << (*t).value;
-
- // Select the right input stream to put the tag on. If real,
- // just use i; if it's a complex stream, find the max of the
- // real and imaginary parts and put the tag on that one.
- int which = i;
- if(cmplx) {
- bool show0 = d_plot_curve[i]->isVisible();
- bool show1 = d_plot_curve[i+1]->isVisible();
-
- // If we are showing both streams, select the inptu stream
- // with the larger value
- if(show0 && show1) {
- if(fabs(d_ydata[i][offset]) < fabs(d_ydata[i+1][offset]))
- which = i+1;
- }
- else {
- // If show0, we keep which = i; otherwise, use i+1.
- if(show1)
- which = i+1;
- }
+ _resetXAxisPoints();
}
- double yval = d_ydata[which][offset];
-
- // Find if we already have a marker at this location
- std::vector<QwtPlotMarker*>::iterator mitr;
- for(mitr = d_tag_markers[which].begin(); mitr != d_tag_markers[which].end(); mitr++) {
- if((*mitr)->xValue() == sample_offset) {
- break;
- }
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ if (d_semilogy) {
+ for (int n = 0; n < numDataPoints; n++)
+ d_ydata[i][n] = fabs(dataPoints[i][n]);
+ } else {
+ memcpy(d_ydata[i], dataPoints[i], numDataPoints * sizeof(double));
+ }
}
- // If no matching marker, create a new one
- if(mitr == d_tag_markers[which].end()) {
- bool show = d_plot_curve[which]->isVisible();
-
- QwtPlotMarker *m = new QwtPlotMarker();
- m->setXValue(sample_offset);
- m->setYValue(yval);
-
- QBrush brush(getTagBackgroundColor(), getTagBackgroundStyle());
-
- QPen pen;
- pen.setColor(Qt::black);
- pen.setWidth(1);
-
- QwtSymbol *sym = new QwtSymbol(QwtSymbol::NoSymbol, brush, pen, QSize(12,12));
+ // Detach and delete any tags that were plotted last time
+ for (unsigned int n = 0; n < d_nplots; ++n) {
+ for (size_t i = 0; i < d_tag_markers[n].size(); i++) {
+ d_tag_markers[n][i]->detach();
+ delete d_tag_markers[n][i];
+ }
+ d_tag_markers[n].clear();
+ }
- if(yval >= 0) {
- sym->setStyle(QwtSymbol::DTriangle);
- m->setLabelAlignment(Qt::AlignTop);
- }
- else {
- sym->setStyle(QwtSymbol::UTriangle);
- m->setLabelAlignment(Qt::AlignBottom);
- }
+ // Plot and attach any new tags found.
+ // First test if this was a complex input where real/imag get
+ // split here into two stream.
+ if (tags.size() > 0) {
+ bool cmplx = false;
+ unsigned int mult = d_nplots / tags.size();
+ if (mult == 2)
+ cmplx = true;
+
+ std::vector<std::vector<gr::tag_t>>::const_iterator tag = tags.begin();
+ for (unsigned int i = 0; i < d_nplots; i += mult) {
+ std::vector<gr::tag_t>::const_iterator t;
+ for (t = tag->begin(); t != tag->end(); t++) {
+ uint64_t offset = (*t).offset;
+
+ // Ignore tag if its offset is outside our plottable vector.
+ if (offset >= (uint64_t)d_numPoints) {
+ continue;
+ }
+
+ double sample_offset = double(offset) / d_sample_rate;
+
+ std::stringstream s;
+ s << (*t).key << ": " << (*t).value;
+
+ // Select the right input stream to put the tag on. If real,
+ // just use i; if it's a complex stream, find the max of the
+ // real and imaginary parts and put the tag on that one.
+ int which = i;
+ if (cmplx) {
+ bool show0 = d_plot_curve[i]->isVisible();
+ bool show1 = d_plot_curve[i + 1]->isVisible();
+
+ // If we are showing both streams, select the inptu stream
+ // with the larger value
+ if (show0 && show1) {
+ if (fabs(d_ydata[i][offset]) <
+ fabs(d_ydata[i + 1][offset]))
+ which = i + 1;
+ } else {
+ // If show0, we keep which = i; otherwise, use i+1.
+ if (show1)
+ which = i + 1;
+ }
+ }
+
+ double yval = d_ydata[which][offset];
+
+ // Find if we already have a marker at this location
+ std::vector<QwtPlotMarker*>::iterator mitr;
+ for (mitr = d_tag_markers[which].begin();
+ mitr != d_tag_markers[which].end();
+ mitr++) {
+ if ((*mitr)->xValue() == sample_offset) {
+ break;
+ }
+ }
+
+ // If no matching marker, create a new one
+ if (mitr == d_tag_markers[which].end()) {
+ bool show = d_plot_curve[which]->isVisible();
+
+ QwtPlotMarker* m = new QwtPlotMarker();
+ m->setXValue(sample_offset);
+ m->setYValue(yval);
+
+ QBrush brush(getTagBackgroundColor(),
+ getTagBackgroundStyle());
+
+ QPen pen;
+ pen.setColor(Qt::black);
+ pen.setWidth(1);
+
+ QwtSymbol* sym = new QwtSymbol(
+ QwtSymbol::NoSymbol, brush, pen, QSize(12, 12));
+
+ if (yval >= 0) {
+ sym->setStyle(QwtSymbol::DTriangle);
+ m->setLabelAlignment(Qt::AlignTop);
+ } else {
+ sym->setStyle(QwtSymbol::UTriangle);
+ m->setLabelAlignment(Qt::AlignBottom);
+ }
#if QWT_VERSION < 0x060000
- m->setSymbol(*sym);
+ m->setSymbol(*sym);
#else
- m->setSymbol(sym);
+ m->setSymbol(sym);
#endif
- QwtText tag_label(s.str().c_str());
- tag_label.setColor(getTagTextColor());
- m->setLabel(tag_label);
-
- m->attach(this);
-
- if(!(show && d_tag_markers_en[which])) {
- m->hide();
- }
-
- d_tag_markers[which].push_back(m);
+ QwtText tag_label(s.str().c_str());
+ tag_label.setColor(getTagTextColor());
+ m->setLabel(tag_label);
+
+ m->attach(this);
+
+ if (!(show && d_tag_markers_en[which])) {
+ m->hide();
+ }
+
+ d_tag_markers[which].push_back(m);
+ } else {
+ // Prepend the new tag to the existing marker
+ // And set it at the max value
+ if (fabs(yval) < fabs((*mitr)->yValue()))
+ (*mitr)->setYValue(yval);
+ QString orig = (*mitr)->label().text();
+ s << std::endl;
+ orig.prepend(s.str().c_str());
+
+ QwtText newtext(orig);
+ newtext.setColor(getTagTextColor());
+
+ QBrush brush(getTagBackgroundColor(),
+ getTagBackgroundStyle());
+ newtext.setBackgroundBrush(brush);
+
+ (*mitr)->setLabel(newtext);
+ }
+ }
+
+ tag++;
+ }
}
- else {
- // Prepend the new tag to the existing marker
- // And set it at the max value
- if(fabs(yval) < fabs((*mitr)->yValue()))
- (*mitr)->setYValue(yval);
- QString orig = (*mitr)->label().text();
- s << std::endl;
- orig.prepend(s.str().c_str());
-
- QwtText newtext(orig);
- newtext.setColor(getTagTextColor());
-
- QBrush brush(getTagBackgroundColor(), getTagBackgroundStyle());
- newtext.setBackgroundBrush(brush);
-
- (*mitr)->setLabel(newtext);
+
+ if (d_autoscale_state) {
+ double bottom = 1e20, top = -1e20;
+ for (unsigned int n = 0; n < d_nplots; ++n) {
+ for (int64_t point = 0; point < numDataPoints; point++) {
+ if (d_ydata[n][point] < bottom) {
+ bottom = d_ydata[n][point];
+ }
+ if (d_ydata[n][point] > top) {
+ top = d_ydata[n][point];
+ }
+ }
+ }
+ _autoScale(bottom, top);
+ if (d_autoscale_shot) {
+ d_autoscale_state = false;
+ d_autoscale_shot = false;
+ }
}
- }
- tag++;
+ replot();
}
- }
-
- if(d_autoscale_state) {
- double bottom=1e20, top=-1e20;
- for(unsigned int n = 0; n < d_nplots; ++n) {
- for(int64_t point = 0; point < numDataPoints; point++) {
- if(d_ydata[n][point] < bottom) {
- bottom = d_ydata[n][point];
- }
- if(d_ydata[n][point] > top) {
- top = d_ydata[n][point];
- }
- }
- }
- _autoScale(bottom, top);
- if(d_autoscale_shot) {
- d_autoscale_state = false;
- d_autoscale_shot = false;
- }
- }
-
- replot();
}
- }
}
-void
-TimeDomainDisplayPlot::legendEntryChecked(QwtPlotItem* plotItem, bool on)
+void TimeDomainDisplayPlot::legendEntryChecked(QwtPlotItem* plotItem, bool on)
{
- // When line is turned on/off, immediately show/hide tag markers
- for(unsigned int n = 0; n < d_nplots; ++n) {
- if(plotItem == d_plot_curve[n]) {
- for(size_t i = 0; i < d_tag_markers[n].size(); i++) {
- if(!(!on && d_tag_markers_en[n]))
- d_tag_markers[n][i]->hide();
- else
- d_tag_markers[n][i]->show();
- }
+ // When line is turned on/off, immediately show/hide tag markers
+ for (unsigned int n = 0; n < d_nplots; ++n) {
+ if (plotItem == d_plot_curve[n]) {
+ for (size_t i = 0; i < d_tag_markers[n].size(); i++) {
+ if (!(!on && d_tag_markers_en[n]))
+ d_tag_markers[n][i]->hide();
+ else
+ d_tag_markers[n][i]->show();
+ }
+ }
}
- }
- DisplayPlot::legendEntryChecked(plotItem, on);
+ DisplayPlot::legendEntryChecked(plotItem, on);
}
-void
-TimeDomainDisplayPlot::legendEntryChecked(const QVariant &plotItem, bool on, int index)
+void TimeDomainDisplayPlot::legendEntryChecked(const QVariant& plotItem,
+ bool on,
+ int index)
{
#if QWT_VERSION < 0x060100
- std::runtime_error("TimeDomainDisplayPlot::legendEntryChecked with QVariant not enabled in this version of QWT.\n");
+ std::runtime_error("TimeDomainDisplayPlot::legendEntryChecked with QVariant not "
+ "enabled in this version of QWT.\n");
#else
- QwtPlotItem *p = infoToItem(plotItem);
- legendEntryChecked(p, on);
+ QwtPlotItem* p = infoToItem(plotItem);
+ legendEntryChecked(p, on);
#endif /* QWT_VERSION < 0x060100 */
}
-void
-TimeDomainDisplayPlot::_resetXAxisPoints()
+void TimeDomainDisplayPlot::_resetXAxisPoints()
{
- double delt = 1.0/d_sample_rate;
- for(long loc = 0; loc < d_numPoints; loc++){
- d_xdata[loc] = loc*delt;
- }
-
- // Set up zoomer base for maximum unzoom x-axis
- // and reset to maximum unzoom level
- QwtDoubleRect zbase = d_zoomer->zoomBase();
-
- if(d_semilogx) {
- setAxisScale(QwtPlot::xBottom, 1e-1, d_numPoints*delt);
- zbase.setLeft(1e-1);
- }
- else {
- setAxisScale(QwtPlot::xBottom, 0, d_numPoints*delt);
- zbase.setLeft(0);
- }
-
- zbase.setRight(d_numPoints*delt);
- d_zoomer->zoom(zbase);
- d_zoomer->setZoomBase(zbase);
- d_zoomer->zoom(0);
+ double delt = 1.0 / d_sample_rate;
+ for (long loc = 0; loc < d_numPoints; loc++) {
+ d_xdata[loc] = loc * delt;
+ }
-}
+ // Set up zoomer base for maximum unzoom x-axis
+ // and reset to maximum unzoom level
+ QwtDoubleRect zbase = d_zoomer->zoomBase();
-void
-TimeDomainDisplayPlot::_autoScale(double bottom, double top)
-{
- // Auto scale the y-axis with a margin of 20% (10 dB for log scale)
- double _bot = bottom - fabs(bottom)*0.20;
- double _top = top + fabs(top)*0.20;
- if(d_semilogy) {
- if(bottom > 0) {
- setYaxis(_bot-10, _top+10);
- }
- else {
- setYaxis(1e-3, _top+10);
+ if (d_semilogx) {
+ setAxisScale(QwtPlot::xBottom, 1e-1, d_numPoints * delt);
+ zbase.setLeft(1e-1);
+ } else {
+ setAxisScale(QwtPlot::xBottom, 0, d_numPoints * delt);
+ zbase.setLeft(0);
}
- }
- else {
- setYaxis(_bot, _top);
- }
-}
-void
-TimeDomainDisplayPlot::setAutoScale(bool state)
-{
- d_autoscale_state = state;
+ zbase.setRight(d_numPoints * delt);
+ d_zoomer->zoom(zbase);
+ d_zoomer->setZoomBase(zbase);
+ d_zoomer->zoom(0);
}
-void
-TimeDomainDisplayPlot::setAutoScaleShot()
+void TimeDomainDisplayPlot::_autoScale(double bottom, double top)
{
- d_autoscale_state = true;
- d_autoscale_shot = true;
+ // Auto scale the y-axis with a margin of 20% (10 dB for log scale)
+ double _bot = bottom - fabs(bottom) * 0.20;
+ double _top = top + fabs(top) * 0.20;
+ if (d_semilogy) {
+ if (bottom > 0) {
+ setYaxis(_bot - 10, _top + 10);
+ } else {
+ setYaxis(1e-3, _top + 10);
+ }
+ } else {
+ setYaxis(_bot, _top);
+ }
}
+void TimeDomainDisplayPlot::setAutoScale(bool state) { d_autoscale_state = state; }
-void
-TimeDomainDisplayPlot::setSampleRate(double sr, double units,
- const std::string &strunits)
+void TimeDomainDisplayPlot::setAutoScaleShot()
{
- double newsr = sr/units;
- if((newsr != d_sample_rate) ||
- (((TimeDomainDisplayZoomer*)d_zoomer)->unitType() != strunits)) {
- d_sample_rate = sr/units;
- _resetXAxisPoints();
-
- // While we could change the displayed sigfigs based on the unit being
- // displayed, I think it looks better by just setting it to 4 regardless.
- //double display_units = ceil(log10(units)/2.0);
- double display_units = 4;
- setAxisTitle(QwtPlot::xBottom, QString("Time (%1)").arg(strunits.c_str()));
- ((TimeDomainDisplayZoomer*)d_zoomer)->setTimePrecision(display_units);
- ((TimeDomainDisplayZoomer*)d_zoomer)->setUnitType(strunits);
- }
+ d_autoscale_state = true;
+ d_autoscale_shot = true;
}
-double
-TimeDomainDisplayPlot::sampleRate() const
+
+void TimeDomainDisplayPlot::setSampleRate(double sr,
+ double units,
+ const std::string& strunits)
{
- return d_sample_rate;
+ double newsr = sr / units;
+ if ((newsr != d_sample_rate) ||
+ (((TimeDomainDisplayZoomer*)d_zoomer)->unitType() != strunits)) {
+ d_sample_rate = sr / units;
+ _resetXAxisPoints();
+
+ // While we could change the displayed sigfigs based on the unit being
+ // displayed, I think it looks better by just setting it to 4 regardless.
+ // double display_units = ceil(log10(units)/2.0);
+ double display_units = 4;
+ setAxisTitle(QwtPlot::xBottom, QString("Time (%1)").arg(strunits.c_str()));
+ ((TimeDomainDisplayZoomer*)d_zoomer)->setTimePrecision(display_units);
+ ((TimeDomainDisplayZoomer*)d_zoomer)->setUnitType(strunits);
+ }
}
-void
-TimeDomainDisplayPlot::stemPlot(bool en)
+double TimeDomainDisplayPlot::sampleRate() const { return d_sample_rate; }
+
+void TimeDomainDisplayPlot::stemPlot(bool en)
{
- if(en) {
- for(unsigned int i = 0; i < d_nplots; ++i) {
- d_plot_curve[i]->setStyle(QwtPlotCurve::Sticks);
- setLineMarker(i, QwtSymbol::Ellipse);
- }
- }
- else {
- for(unsigned int i = 0; i < d_nplots; ++i) {
- d_plot_curve[i]->setStyle(QwtPlotCurve::Lines);
- setLineMarker(i, QwtSymbol::NoSymbol);
+ if (en) {
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ d_plot_curve[i]->setStyle(QwtPlotCurve::Sticks);
+ setLineMarker(i, QwtSymbol::Ellipse);
+ }
+ } else {
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ d_plot_curve[i]->setStyle(QwtPlotCurve::Lines);
+ setLineMarker(i, QwtSymbol::NoSymbol);
+ }
}
- }
}
-void
-TimeDomainDisplayPlot::setSemilogx(bool en)
+void TimeDomainDisplayPlot::setSemilogx(bool en)
{
- d_semilogx = en;
- if(!d_semilogx) {
- setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine);
- }
- else {
+ d_semilogx = en;
+ if (!d_semilogx) {
+ setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine);
+ } else {
#if QWT_VERSION < 0x060100
- setAxisScaleEngine(QwtPlot::xBottom, new QwtLog10ScaleEngine);
-#else /* QWT_VERSION < 0x060100 */
- setAxisScaleEngine(QwtPlot::xBottom, new QwtLogScaleEngine);
+ setAxisScaleEngine(QwtPlot::xBottom, new QwtLog10ScaleEngine);
+#else /* QWT_VERSION < 0x060100 */
+ setAxisScaleEngine(QwtPlot::xBottom, new QwtLogScaleEngine);
#endif /*QWT_VERSION < 0x060100 */
- }
- _resetXAxisPoints();
+ }
+ _resetXAxisPoints();
}
-void
-TimeDomainDisplayPlot::setSemilogy(bool en)
+void TimeDomainDisplayPlot::setSemilogy(bool en)
{
- if(d_semilogy != en) {
- d_semilogy = en;
+ if (d_semilogy != en) {
+ d_semilogy = en;
#if QWT_VERSION < 0x060100
- double max = axisScaleDiv(QwtPlot::yLeft)->upperBound();
-#else /* QWT_VERSION < 0x060100 */
- double max = axisScaleDiv(QwtPlot::yLeft).upperBound();
+ double max = axisScaleDiv(QwtPlot::yLeft)->upperBound();
+#else /* QWT_VERSION < 0x060100 */
+ double max = axisScaleDiv(QwtPlot::yLeft).upperBound();
#endif /* QWT_VERSION < 0x060100 */
- if(!d_semilogy) {
- setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine);
- setYaxis(-pow(10.0, max/10.0), pow(10.0, max/10.0));
- }
- else {
+ if (!d_semilogy) {
+ setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine);
+ setYaxis(-pow(10.0, max / 10.0), pow(10.0, max / 10.0));
+ } else {
#if QWT_VERSION < 0x060100
- setAxisScaleEngine(QwtPlot::yLeft, new QwtLog10ScaleEngine);
-#else /* QWT_VERSION < 0x060100 */
- setAxisScaleEngine(QwtPlot::yLeft, new QwtLogScaleEngine);
+ setAxisScaleEngine(QwtPlot::yLeft, new QwtLog10ScaleEngine);
+#else /* QWT_VERSION < 0x060100 */
+ setAxisScaleEngine(QwtPlot::yLeft, new QwtLogScaleEngine);
#endif /*QWT_VERSION < 0x060100 */
- setYaxis(1e-10, 10.0*log10(max));
+ setYaxis(1e-10, 10.0 * log10(max));
+ }
}
- }
}
-void
-TimeDomainDisplayPlot::enableTagMarker(unsigned int which, bool en)
+void TimeDomainDisplayPlot::enableTagMarker(unsigned int which, bool en)
{
- if((size_t)which < d_tag_markers_en.size())
- d_tag_markers_en[which] = en;
- else
- throw std::runtime_error("TimeDomainDisplayPlot: enabled tag marker does not exist.\n");
+ if ((size_t)which < d_tag_markers_en.size())
+ d_tag_markers_en[which] = en;
+ else
+ throw std::runtime_error(
+ "TimeDomainDisplayPlot: enabled tag marker does not exist.\n");
}
-const QColor
-TimeDomainDisplayPlot::getTagTextColor()
-{
- return d_tag_text_color;
-}
+const QColor TimeDomainDisplayPlot::getTagTextColor() { return d_tag_text_color; }
-const QColor
-TimeDomainDisplayPlot::getTagBackgroundColor()
+const QColor TimeDomainDisplayPlot::getTagBackgroundColor()
{
- return d_tag_background_color;
+ return d_tag_background_color;
}
-const Qt::BrushStyle
-TimeDomainDisplayPlot::getTagBackgroundStyle()
+const Qt::BrushStyle TimeDomainDisplayPlot::getTagBackgroundStyle()
{
- return d_tag_background_style;
+ return d_tag_background_style;
}
-void
-TimeDomainDisplayPlot::setTagTextColor(QColor c)
-{
- d_tag_text_color = c;
-}
+void TimeDomainDisplayPlot::setTagTextColor(QColor c) { d_tag_text_color = c; }
-void
-TimeDomainDisplayPlot::setTagBackgroundColor(QColor c)
+void TimeDomainDisplayPlot::setTagBackgroundColor(QColor c)
{
- d_tag_background_color = c;
+ d_tag_background_color = c;
}
-void
-TimeDomainDisplayPlot::setTagBackgroundStyle(Qt::BrushStyle b)
+void TimeDomainDisplayPlot::setTagBackgroundStyle(Qt::BrushStyle b)
{
- d_tag_background_style = b;
+ d_tag_background_style = b;
}
-void
-TimeDomainDisplayPlot::setYLabel(const std::string &label,
- const std::string &unit)
+void TimeDomainDisplayPlot::setYLabel(const std::string& label, const std::string& unit)
{
- std::string l = label;
- if(unit.length() > 0)
- l += " (" + unit + ")";
- setAxisTitle(QwtPlot::yLeft, QString(l.c_str()));
- ((TimeDomainDisplayZoomer*)d_zoomer)->setYUnitType(unit);
+ std::string l = label;
+ if (unit.length() > 0)
+ l += " (" + unit + ")";
+ setAxisTitle(QwtPlot::yLeft, QString(l.c_str()));
+ ((TimeDomainDisplayZoomer*)d_zoomer)->setYUnitType(unit);
}
-void
-TimeDomainDisplayPlot::attachTriggerLines(bool en)
+void TimeDomainDisplayPlot::attachTriggerLines(bool en)
{
- if(en) {
- d_trigger_lines[0]->attach(this);
- d_trigger_lines[1]->attach(this);
- }
- else {
- d_trigger_lines[0]->detach();
- d_trigger_lines[1]->detach();
- }
+ if (en) {
+ d_trigger_lines[0]->attach(this);
+ d_trigger_lines[1]->attach(this);
+ } else {
+ d_trigger_lines[0]->detach();
+ d_trigger_lines[1]->detach();
+ }
}
-void
-TimeDomainDisplayPlot::setTriggerLines(double x, double y)
+void TimeDomainDisplayPlot::setTriggerLines(double x, double y)
{
- d_trigger_lines[0]->setXValue(x);
- d_trigger_lines[0]->setYValue(y);
- d_trigger_lines[1]->setXValue(x);
- d_trigger_lines[1]->setYValue(y);
+ d_trigger_lines[0]->setXValue(x);
+ d_trigger_lines[0]->setYValue(y);
+ d_trigger_lines[1]->setXValue(x);
+ d_trigger_lines[1]->setYValue(y);
}
#endif /* TIME_DOMAIN_DISPLAY_PLOT_C */
diff --git a/gr-qtgui/lib/TimeRasterDisplayPlot.cc b/gr-qtgui/lib/TimeRasterDisplayPlot.cc
index 9f87abd435..5fc333c6b2 100644
--- a/gr-qtgui/lib/TimeRasterDisplayPlot.cc
+++ b/gr-qtgui/lib/TimeRasterDisplayPlot.cc
@@ -48,577 +48,539 @@ namespace pt = boost::posix_time;
/***********************************************************************
* Text scale widget to provide X (time) axis text
**********************************************************************/
-class QwtXScaleDraw: public QwtScaleDraw, public TimeScaleData
+class QwtXScaleDraw : public QwtScaleDraw, public TimeScaleData
{
public:
- QwtXScaleDraw():QwtScaleDraw(),TimeScaleData() { }
-
- virtual ~QwtXScaleDraw() { }
-
- virtual QwtText label(double value) const
- {
- double secs = double(value * getSecondsPerLine());
- return QwtText(QString("").sprintf("%.2f", secs));
- }
-
- virtual void initiateUpdate()
- {
- // Do this in one call rather than when zeroTime and secondsPerLine
- // updates is to prevent the display from being updated too often...
- invalidateCache();
- }
+ QwtXScaleDraw() : QwtScaleDraw(), TimeScaleData() {}
+
+ virtual ~QwtXScaleDraw() {}
+
+ virtual QwtText label(double value) const
+ {
+ double secs = double(value * getSecondsPerLine());
+ return QwtText(QString("").sprintf("%.2f", secs));
+ }
+
+ virtual void initiateUpdate()
+ {
+ // Do this in one call rather than when zeroTime and secondsPerLine
+ // updates is to prevent the display from being updated too often...
+ invalidateCache();
+ }
};
/***********************************************************************
* Text scale widget to provide Y axis text
**********************************************************************/
-class QwtYScaleDraw: public QwtScaleDraw
+class QwtYScaleDraw : public QwtScaleDraw
{
public:
- QwtYScaleDraw(): QwtScaleDraw(), d_rows(0) { }
+ QwtYScaleDraw() : QwtScaleDraw(), d_rows(0) {}
- virtual ~QwtYScaleDraw() { }
+ virtual ~QwtYScaleDraw() {}
- virtual QwtText label(double value) const
- {
- if(d_rows > 0)
- value = d_rows - value;
- return QwtText(QString("").sprintf("%.0f", value));
- }
+ virtual QwtText label(double value) const
+ {
+ if (d_rows > 0)
+ value = d_rows - value;
+ return QwtText(QString("").sprintf("%.0f", value));
+ }
- virtual void initiateUpdate()
- {
- // Do this in one call rather than when zeroTime and secondsPerLine
- // updates is to prevent the display from being updated too often...
- invalidateCache();
- }
+ virtual void initiateUpdate()
+ {
+ // Do this in one call rather than when zeroTime and secondsPerLine
+ // updates is to prevent the display from being updated too often...
+ invalidateCache();
+ }
- void setRows(double rows) { rows>0 ? d_rows = rows : d_rows = 0; }
+ void setRows(double rows) { rows > 0 ? d_rows = rows : d_rows = 0; }
private:
- double d_rows;
+ double d_rows;
};
class TimePrecisionClass
{
public:
- TimePrecisionClass(const int timePrecision)
- {
- d_timePrecision = timePrecision;
- }
-
- virtual ~TimePrecisionClass()
- {
- }
-
- virtual unsigned int getTimePrecision() const
- {
- return d_timePrecision;
- }
-
- virtual void setTimePrecision(const unsigned int newPrecision)
- {
- d_timePrecision = newPrecision;
- }
+ TimePrecisionClass(const int timePrecision) { d_timePrecision = timePrecision; }
+
+ virtual ~TimePrecisionClass() {}
+
+ virtual unsigned int getTimePrecision() const { return d_timePrecision; }
+
+ virtual void setTimePrecision(const unsigned int newPrecision)
+ {
+ d_timePrecision = newPrecision;
+ }
+
protected:
- unsigned int d_timePrecision;
+ unsigned int d_timePrecision;
};
/***********************************************************************
* Widget to provide mouse pointer coordinate text
**********************************************************************/
-class TimeRasterZoomer: public QwtPlotZoomer, public TimePrecisionClass,
- public TimeScaleData
+class TimeRasterZoomer : public QwtPlotZoomer,
+ public TimePrecisionClass,
+ public TimeScaleData
{
public:
#if QWT_VERSION < 0x060100
- TimeRasterZoomer(QwtPlotCanvas* canvas, double rows, double cols,
- const unsigned int timePrecision)
-#else /* QWT_VERSION < 0x060100 */
- TimeRasterZoomer(QWidget* canvas, double rows, double cols,
- const unsigned int timePrecision)
+ TimeRasterZoomer(QwtPlotCanvas* canvas,
+ double rows,
+ double cols,
+ const unsigned int timePrecision)
+#else /* QWT_VERSION < 0x060100 */
+ TimeRasterZoomer(QWidget* canvas,
+ double rows,
+ double cols,
+ const unsigned int timePrecision)
#endif /* QWT_VERSION < 0x060100 */
- : QwtPlotZoomer(canvas), TimePrecisionClass(timePrecision), TimeScaleData(),
- d_rows(static_cast<double>(rows)), d_cols(static_cast<double>(cols))
- {
- setTrackerMode(QwtPicker::AlwaysOn);
- }
-
- virtual ~TimeRasterZoomer()
- {
- }
-
- virtual void updateTrackerText()
- {
- updateDisplay();
- }
-
- void setUnitType(const std::string &type)
- {
- d_unitType = type;
- }
-
- void setColumns(const double cols)
- {
- d_cols = cols;
- }
+ : QwtPlotZoomer(canvas),
+ TimePrecisionClass(timePrecision),
+ TimeScaleData(),
+ d_rows(static_cast<double>(rows)),
+ d_cols(static_cast<double>(cols))
+ {
+ setTrackerMode(QwtPicker::AlwaysOn);
+ }
- void setRows(const double rows)
- {
- d_rows = rows;
- }
+ virtual ~TimeRasterZoomer() {}
+
+ virtual void updateTrackerText() { updateDisplay(); }
+
+ void setUnitType(const std::string& type) { d_unitType = type; }
+
+ void setColumns(const double cols) { d_cols = cols; }
+
+ void setRows(const double rows) { d_rows = rows; }
protected:
- using QwtPlotZoomer::trackerText;
- virtual QwtText trackerText( QPoint const &p ) const
- {
- QwtDoublePoint dp = QwtPlotZoomer::invTransform(p);
- double x = dp.x() * getSecondsPerLine();
- //double y = dp.y() * getSecondsPerLine() * d_cols;
- double y = floor(d_rows - dp.y());
- QwtText t(QString("%1 %2, %3")
- .arg(x, 0, 'f', getTimePrecision())
- .arg(d_unitType.c_str())
- .arg(y, 0, 'f', 0));
- return t;
- }
+ using QwtPlotZoomer::trackerText;
+ virtual QwtText trackerText(QPoint const& p) const
+ {
+ QwtDoublePoint dp = QwtPlotZoomer::invTransform(p);
+ double x = dp.x() * getSecondsPerLine();
+ // double y = dp.y() * getSecondsPerLine() * d_cols;
+ double y = floor(d_rows - dp.y());
+ QwtText t(QString("%1 %2, %3")
+ .arg(x, 0, 'f', getTimePrecision())
+ .arg(d_unitType.c_str())
+ .arg(y, 0, 'f', 0));
+ return t;
+ }
private:
- std::string d_unitType;
- double d_rows, d_cols;
+ std::string d_unitType;
+ double d_rows, d_cols;
};
/*********************************************************************
-* Main time raster plot widget
-*********************************************************************/
-TimeRasterDisplayPlot::TimeRasterDisplayPlot(int nplots,
- double samp_rate,
- double rows, double cols,
- QWidget* parent)
- : DisplayPlot(nplots, parent)
+ * Main time raster plot widget
+ *********************************************************************/
+TimeRasterDisplayPlot::TimeRasterDisplayPlot(
+ int nplots, double samp_rate, double rows, double cols, QWidget* parent)
+ : DisplayPlot(nplots, parent)
{
- d_zoomer = NULL; // need this for proper init
+ d_zoomer = NULL; // need this for proper init
- resize(parent->width(), parent->height());
+ resize(parent->width(), parent->height());
- d_samp_rate = samp_rate;
- d_cols = cols;
- d_rows = rows;
- d_numPoints = d_cols;
- d_color_bar_title_font_size = 18;
+ d_samp_rate = samp_rate;
+ d_cols = cols;
+ d_rows = rows;
+ d_numPoints = d_cols;
+ d_color_bar_title_font_size = 18;
- setAxisScaleDraw(QwtPlot::xBottom, new QwtXScaleDraw());
- setAxisScaleDraw(QwtPlot::yLeft, new QwtYScaleDraw());
+ setAxisScaleDraw(QwtPlot::xBottom, new QwtXScaleDraw());
+ setAxisScaleDraw(QwtPlot::yLeft, new QwtYScaleDraw());
- for(unsigned int i = 0; i < d_nplots; ++i) {
- d_data.push_back(new TimeRasterData(d_rows, d_cols));
- d_raster.push_back(new PlotTimeRaster("Raster"));
- d_raster[i]->setData(d_data[i]);
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ d_data.push_back(new TimeRasterData(d_rows, d_cols));
+ d_raster.push_back(new PlotTimeRaster("Raster"));
+ d_raster[i]->setData(d_data[i]);
- // a hack around the fact that we aren't using plot curves for the
- // raster plots.
- d_plot_curve.push_back(new QwtPlotCurve(QString("Data")));
+ // a hack around the fact that we aren't using plot curves for the
+ // raster plots.
+ d_plot_curve.push_back(new QwtPlotCurve(QString("Data")));
- d_raster[i]->attach(this);
+ d_raster[i]->attach(this);
- d_color_map_type.push_back(INTENSITY_COLOR_MAP_TYPE_BLACK_HOT);
- setAlpha(i, 255/d_nplots);
- }
+ d_color_map_type.push_back(INTENSITY_COLOR_MAP_TYPE_BLACK_HOT);
+ setAlpha(i, 255 / d_nplots);
+ }
- // Set bottom plot with no transparency as a base
- setAlpha(0, 255);
+ // Set bottom plot with no transparency as a base
+ setAlpha(0, 255);
- // LeftButton for the zooming
- // MidButton for the panning
- // RightButton: zoom out by 1
- // Ctrl+RighButton: zoom out to full size
- d_zoomer = new TimeRasterZoomer(canvas(), d_rows, d_cols, 0);
+ // LeftButton for the zooming
+ // MidButton for the panning
+ // RightButton: zoom out by 1
+ // Ctrl+RighButton: zoom out to full size
+ d_zoomer = new TimeRasterZoomer(canvas(), d_rows, d_cols, 0);
#if QWT_VERSION < 0x060000
- d_zoomer->setSelectionFlags(QwtPicker::RectSelection | QwtPicker::DragSelection);
+ d_zoomer->setSelectionFlags(QwtPicker::RectSelection | QwtPicker::DragSelection);
#endif
- d_zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
- Qt::RightButton, Qt::ControlModifier);
- d_zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
- Qt::RightButton);
-
- const QColor c(Qt::red);
- d_zoomer->setRubberBandPen(c);
- d_zoomer->setTrackerPen(c);
-
- // Set intensity color now (needed d_zoomer before we could do this).
- // We've made sure the old type is different than here so we'll
- // force and update.
- for(unsigned int i = 0; i < d_nplots; ++i) {
- setIntensityColorMapType(i, INTENSITY_COLOR_MAP_TYPE_WHITE_HOT,
- QColor("white"), QColor("white"));
- }
-
- _updateIntensityRangeDisplay();
-
- reset();
-}
+ d_zoomer->setMousePattern(
+ QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier);
+ d_zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
+
+ const QColor c(Qt::red);
+ d_zoomer->setRubberBandPen(c);
+ d_zoomer->setTrackerPen(c);
+
+ // Set intensity color now (needed d_zoomer before we could do this).
+ // We've made sure the old type is different than here so we'll
+ // force and update.
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ setIntensityColorMapType(
+ i, INTENSITY_COLOR_MAP_TYPE_WHITE_HOT, QColor("white"), QColor("white"));
+ }
-TimeRasterDisplayPlot::~TimeRasterDisplayPlot()
-{
-}
+ _updateIntensityRangeDisplay();
-void
-TimeRasterDisplayPlot::reset()
-{
- for(unsigned int i = 0; i < d_nplots; ++i) {
- d_data[i]->resizeData(d_rows, d_cols);
- d_data[i]->reset();
- }
-
- // Update zoomer/picker text units
- std::string strunits[4] = {"sec", "ms", "us", "ns"};
- double units10 = floor(log10(d_samp_rate));
- double units3 = std::max(floor(units10/3), 0.0);
- double units = pow(10, (units10-fmod(units10, 3.0)));
- int iunit = static_cast<int>(units3);
-
- double sec_per_samp = units/d_samp_rate;
-
- QwtYScaleDraw* yScale = (QwtYScaleDraw*)axisScaleDraw(QwtPlot::yLeft);
- yScale->setRows(d_rows);
-
- QwtXScaleDraw* xScale = (QwtXScaleDraw*)axisScaleDraw(QwtPlot::xBottom);
- xScale->setSecondsPerLine(sec_per_samp);
- setAxisTitle(QwtPlot::xBottom, QString("Time (%1)")
- .arg(strunits[iunit].c_str()));
- xScale->initiateUpdate();
-
- // Load up the new base zoom settings
- if(d_zoomer) {
- double display_units = 4;
- ((TimeRasterZoomer*)d_zoomer)->setColumns(d_cols);
- ((TimeRasterZoomer*)d_zoomer)->setRows(d_rows);
- ((TimeRasterZoomer*)d_zoomer)->setSecondsPerLine(sec_per_samp);
- ((TimeRasterZoomer*)d_zoomer)->setTimePrecision(display_units);
- ((TimeRasterZoomer*)d_zoomer)->setUnitType(strunits[iunit]);
-
- QwtDoubleRect newSize = d_zoomer->zoomBase();
- newSize.setLeft(0);
- newSize.setWidth(d_cols);
- newSize.setBottom(0);
- newSize.setHeight(d_rows);
-
- d_zoomer->zoom(newSize);
- d_zoomer->setZoomBase(newSize);
- d_zoomer->zoom(0);
- }
+ reset();
}
-void
-TimeRasterDisplayPlot::setNumRows(double rows)
-{
- d_rows = rows;
- reset();
-}
+TimeRasterDisplayPlot::~TimeRasterDisplayPlot() {}
-void
-TimeRasterDisplayPlot::setNumCols(double cols)
+void TimeRasterDisplayPlot::reset()
{
- d_cols = cols;
- reset();
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ d_data[i]->resizeData(d_rows, d_cols);
+ d_data[i]->reset();
+ }
+
+ // Update zoomer/picker text units
+ std::string strunits[4] = { "sec", "ms", "us", "ns" };
+ double units10 = floor(log10(d_samp_rate));
+ double units3 = std::max(floor(units10 / 3), 0.0);
+ double units = pow(10, (units10 - fmod(units10, 3.0)));
+ int iunit = static_cast<int>(units3);
+
+ double sec_per_samp = units / d_samp_rate;
+
+ QwtYScaleDraw* yScale = (QwtYScaleDraw*)axisScaleDraw(QwtPlot::yLeft);
+ yScale->setRows(d_rows);
+
+ QwtXScaleDraw* xScale = (QwtXScaleDraw*)axisScaleDraw(QwtPlot::xBottom);
+ xScale->setSecondsPerLine(sec_per_samp);
+ setAxisTitle(QwtPlot::xBottom, QString("Time (%1)").arg(strunits[iunit].c_str()));
+ xScale->initiateUpdate();
+
+ // Load up the new base zoom settings
+ if (d_zoomer) {
+ double display_units = 4;
+ ((TimeRasterZoomer*)d_zoomer)->setColumns(d_cols);
+ ((TimeRasterZoomer*)d_zoomer)->setRows(d_rows);
+ ((TimeRasterZoomer*)d_zoomer)->setSecondsPerLine(sec_per_samp);
+ ((TimeRasterZoomer*)d_zoomer)->setTimePrecision(display_units);
+ ((TimeRasterZoomer*)d_zoomer)->setUnitType(strunits[iunit]);
+
+ QwtDoubleRect newSize = d_zoomer->zoomBase();
+ newSize.setLeft(0);
+ newSize.setWidth(d_cols);
+ newSize.setBottom(0);
+ newSize.setHeight(d_rows);
+
+ d_zoomer->zoom(newSize);
+ d_zoomer->setZoomBase(newSize);
+ d_zoomer->zoom(0);
+ }
}
-void
-TimeRasterDisplayPlot::setAlpha(unsigned int which, int alpha)
+void TimeRasterDisplayPlot::setNumRows(double rows)
{
- d_raster[which]->setAlpha(alpha);
+ d_rows = rows;
+ reset();
}
-void
-TimeRasterDisplayPlot::setSampleRate(double samprate)
+void TimeRasterDisplayPlot::setNumCols(double cols)
{
- d_samp_rate = samprate;
- reset();
+ d_cols = cols;
+ reset();
}
-double
-TimeRasterDisplayPlot::numRows() const
+void TimeRasterDisplayPlot::setAlpha(unsigned int which, int alpha)
{
- return d_rows;
+ d_raster[which]->setAlpha(alpha);
}
-double
-TimeRasterDisplayPlot::numCols() const
+void TimeRasterDisplayPlot::setSampleRate(double samprate)
{
- return d_cols;
+ d_samp_rate = samprate;
+ reset();
}
-int
-TimeRasterDisplayPlot::getAlpha(unsigned int which)
+double TimeRasterDisplayPlot::numRows() const { return d_rows; }
+
+double TimeRasterDisplayPlot::numCols() const { return d_cols; }
+
+int TimeRasterDisplayPlot::getAlpha(unsigned int which)
{
- return d_raster[which]->alpha();
+ return d_raster[which]->alpha();
}
-void
-TimeRasterDisplayPlot::setPlotDimensions(const double rows, const double cols,
- const double units, const std::string &strunits)
+void TimeRasterDisplayPlot::setPlotDimensions(const double rows,
+ const double cols,
+ const double units,
+ const std::string& strunits)
{
- bool rst = false;
- if((rows != d_rows) || (cols != d_cols))
- rst = true;
+ bool rst = false;
+ if ((rows != d_rows) || (cols != d_cols))
+ rst = true;
- d_rows = rows;
- d_cols = cols;
+ d_rows = rows;
+ d_cols = cols;
- if((axisScaleDraw(QwtPlot::xBottom) != NULL) && (d_zoomer != NULL)) {
- if(rst) {
- reset();
+ if ((axisScaleDraw(QwtPlot::xBottom) != NULL) && (d_zoomer != NULL)) {
+ if (rst) {
+ reset();
+ }
}
- }
}
-void
-TimeRasterDisplayPlot::plotNewData(const std::vector<double*> dataPoints,
- const uint64_t numDataPoints)
+void TimeRasterDisplayPlot::plotNewData(const std::vector<double*> dataPoints,
+ const uint64_t numDataPoints)
{
- if(!d_stop) {
- if(numDataPoints > 0) {
- for(unsigned int i = 0; i < d_nplots; ++i) {
- d_data[i]->addData(dataPoints[i], numDataPoints);
- d_raster[i]->invalidateCache();
- d_raster[i]->itemChanged();
- }
-
- replot();
+ if (!d_stop) {
+ if (numDataPoints > 0) {
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ d_data[i]->addData(dataPoints[i], numDataPoints);
+ d_raster[i]->invalidateCache();
+ d_raster[i]->itemChanged();
+ }
+
+ replot();
+ }
}
- }
}
-void
-TimeRasterDisplayPlot::plotNewData(const double* dataPoints,
- const uint64_t numDataPoints)
+void TimeRasterDisplayPlot::plotNewData(const double* dataPoints,
+ const uint64_t numDataPoints)
{
- std::vector<double*> vecDataPoints;
- vecDataPoints.push_back((double*)dataPoints);
- plotNewData(vecDataPoints, numDataPoints);
+ std::vector<double*> vecDataPoints;
+ vecDataPoints.push_back((double*)dataPoints);
+ plotNewData(vecDataPoints, numDataPoints);
}
-void
-TimeRasterDisplayPlot::setIntensityRange(const double minIntensity,
- const double maxIntensity)
+void TimeRasterDisplayPlot::setIntensityRange(const double minIntensity,
+ const double maxIntensity)
{
- for(unsigned int i = 0; i < d_nplots; ++i) {
+ for (unsigned int i = 0; i < d_nplots; ++i) {
#if QWT_VERSION < 0x060000
- d_data[i]->setRange(QwtDoubleInterval(minIntensity, maxIntensity));
+ d_data[i]->setRange(QwtDoubleInterval(minIntensity, maxIntensity));
#else
- d_data[i]->setInterval(Qt::ZAxis, QwtInterval(minIntensity, maxIntensity));
+ d_data[i]->setInterval(Qt::ZAxis, QwtInterval(minIntensity, maxIntensity));
#endif
- emit updatedLowerIntensityLevel(minIntensity);
- emit updatedUpperIntensityLevel(maxIntensity);
+ emit updatedLowerIntensityLevel(minIntensity);
+ emit updatedUpperIntensityLevel(maxIntensity);
- _updateIntensityRangeDisplay();
- }
+ _updateIntensityRangeDisplay();
+ }
}
-double
-TimeRasterDisplayPlot::getMinIntensity(unsigned int which) const
+double TimeRasterDisplayPlot::getMinIntensity(unsigned int which) const
{
#if QWT_VERSION < 0x060000
- QwtDoubleInterval r = d_data[which]->range();
+ QwtDoubleInterval r = d_data[which]->range();
#else
- QwtInterval r = d_data[which]->interval(Qt::ZAxis);
+ QwtInterval r = d_data[which]->interval(Qt::ZAxis);
#endif
- return r.minValue();
+ return r.minValue();
}
-double
-TimeRasterDisplayPlot::getMaxIntensity(unsigned int which) const
+double TimeRasterDisplayPlot::getMaxIntensity(unsigned int which) const
{
#if QWT_VERSION < 0x060000
- QwtDoubleInterval r = d_data[which]->range();
+ QwtDoubleInterval r = d_data[which]->range();
#else
- QwtInterval r = d_data[which]->interval(Qt::ZAxis);
+ QwtInterval r = d_data[which]->interval(Qt::ZAxis);
#endif
- return r.maxValue();
+ return r.maxValue();
}
-void
-TimeRasterDisplayPlot::replot()
+void TimeRasterDisplayPlot::replot()
{
- // Update the x-axis display
- if(axisWidget(QwtPlot::yLeft) != NULL) {
- axisWidget(QwtPlot::yLeft)->update();
- }
-
- // Update the y-axis display
- if(axisWidget(QwtPlot::xBottom) != NULL) {
- axisWidget(QwtPlot::xBottom)->update();
- }
-
- if(d_zoomer != NULL) {
- ((TimeRasterZoomer*)d_zoomer)->updateTrackerText();
- }
-
- if(!d_stop) {
- QwtPlot::replot();
- }
+ // Update the x-axis display
+ if (axisWidget(QwtPlot::yLeft) != NULL) {
+ axisWidget(QwtPlot::yLeft)->update();
+ }
+
+ // Update the y-axis display
+ if (axisWidget(QwtPlot::xBottom) != NULL) {
+ axisWidget(QwtPlot::xBottom)->update();
+ }
+
+ if (d_zoomer != NULL) {
+ ((TimeRasterZoomer*)d_zoomer)->updateTrackerText();
+ }
+
+ if (!d_stop) {
+ QwtPlot::replot();
+ }
}
-int
-TimeRasterDisplayPlot::getIntensityColorMapType(unsigned int which) const
+int TimeRasterDisplayPlot::getIntensityColorMapType(unsigned int which) const
{
- if(which >= d_color_map_type.size())
- throw std::runtime_error("TimerasterDisplayPlot::GetIntesityColorMap: invalid which.\n");
+ if (which >= d_color_map_type.size())
+ throw std::runtime_error(
+ "TimerasterDisplayPlot::GetIntesityColorMap: invalid which.\n");
- return d_color_map_type[which];
+ return d_color_map_type[which];
}
-int
-TimeRasterDisplayPlot::getIntensityColorMapType1() const
+int TimeRasterDisplayPlot::getIntensityColorMapType1() const
{
- return getIntensityColorMapType(0);
+ return getIntensityColorMapType(0);
}
-int
-TimeRasterDisplayPlot::getColorMapTitleFontSize() const
+int TimeRasterDisplayPlot::getColorMapTitleFontSize() const
{
- return d_color_bar_title_font_size;
+ return d_color_bar_title_font_size;
}
-void
-TimeRasterDisplayPlot::setColorMapTitleFontSize(int tfs)
+void TimeRasterDisplayPlot::setColorMapTitleFontSize(int tfs)
{
- d_color_bar_title_font_size = tfs;
+ d_color_bar_title_font_size = tfs;
}
-void
-TimeRasterDisplayPlot::setIntensityColorMapType(const unsigned int which,
- const int newType,
- const QColor lowColor,
- const QColor highColor)
+void TimeRasterDisplayPlot::setIntensityColorMapType(const unsigned int which,
+ const int newType,
+ const QColor lowColor,
+ const QColor highColor)
{
- if(which >= d_color_map_type.size())
- throw std::runtime_error("TimerasterDisplayPlot::setIntesityColorMap: invalid which.\n");
-
- if((d_color_map_type[which] != newType) ||
- ((newType == INTENSITY_COLOR_MAP_TYPE_USER_DEFINED) &&
- (lowColor.isValid() && highColor.isValid()))) {
- switch(newType) {
- case INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR: {
- d_color_map_type[which] = newType;
-
- d_raster[which]->setColorMap(new ColorMap_MultiColor());
- if(d_zoomer)
- d_zoomer->setTrackerPen(QColor(Qt::black));
- break;
- }
- case INTENSITY_COLOR_MAP_TYPE_WHITE_HOT: {
- d_color_map_type[which] = newType;
- d_raster[which]->setColorMap(new ColorMap_WhiteHot());
- break;
- }
- case INTENSITY_COLOR_MAP_TYPE_BLACK_HOT: {
- d_color_map_type[which] = newType;
- d_raster[which]->setColorMap(new ColorMap_BlackHot());
- break;
- }
- case INTENSITY_COLOR_MAP_TYPE_INCANDESCENT: {
- d_color_map_type[which] = newType;
- d_raster[which]->setColorMap(new ColorMap_Incandescent());
- break;
- }
- case INTENSITY_COLOR_MAP_TYPE_SUNSET: {
- d_color_map_type[which] = newType;
- d_raster[which]->setColorMap(new ColorMap_Sunset());
- break;
+ if (which >= d_color_map_type.size())
+ throw std::runtime_error(
+ "TimerasterDisplayPlot::setIntesityColorMap: invalid which.\n");
+
+ if ((d_color_map_type[which] != newType) ||
+ ((newType == INTENSITY_COLOR_MAP_TYPE_USER_DEFINED) &&
+ (lowColor.isValid() && highColor.isValid()))) {
+ switch (newType) {
+ case INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR: {
+ d_color_map_type[which] = newType;
+
+ d_raster[which]->setColorMap(new ColorMap_MultiColor());
+ if (d_zoomer)
+ d_zoomer->setTrackerPen(QColor(Qt::black));
+ break;
+ }
+ case INTENSITY_COLOR_MAP_TYPE_WHITE_HOT: {
+ d_color_map_type[which] = newType;
+ d_raster[which]->setColorMap(new ColorMap_WhiteHot());
+ break;
+ }
+ case INTENSITY_COLOR_MAP_TYPE_BLACK_HOT: {
+ d_color_map_type[which] = newType;
+ d_raster[which]->setColorMap(new ColorMap_BlackHot());
+ break;
+ }
+ case INTENSITY_COLOR_MAP_TYPE_INCANDESCENT: {
+ d_color_map_type[which] = newType;
+ d_raster[which]->setColorMap(new ColorMap_Incandescent());
+ break;
+ }
+ case INTENSITY_COLOR_MAP_TYPE_SUNSET: {
+ d_color_map_type[which] = newType;
+ d_raster[which]->setColorMap(new ColorMap_Sunset());
+ break;
+ }
+ case INTENSITY_COLOR_MAP_TYPE_COOL: {
+ d_color_map_type[which] = newType;
+ d_raster[which]->setColorMap(new ColorMap_Cool());
+ break;
+ }
+ case INTENSITY_COLOR_MAP_TYPE_USER_DEFINED: {
+ d_low_intensity = lowColor;
+ d_high_intensity = highColor;
+ d_color_map_type[which] = newType;
+ d_raster[which]->setColorMap(new ColorMap_UserDefined(lowColor, highColor));
+ break;
+ }
+ default:
+ break;
+ }
+
+ _updateIntensityRangeDisplay();
}
- case INTENSITY_COLOR_MAP_TYPE_COOL: {
- d_color_map_type[which] = newType;
- d_raster[which]->setColorMap(new ColorMap_Cool());
- break;
- }
- case INTENSITY_COLOR_MAP_TYPE_USER_DEFINED: {
- d_low_intensity = lowColor;
- d_high_intensity = highColor;
- d_color_map_type[which] = newType;
- d_raster[which]->setColorMap(new ColorMap_UserDefined(lowColor, highColor));
- break;
- }
- default: break;
- }
-
- _updateIntensityRangeDisplay();
- }
}
-void
-TimeRasterDisplayPlot::setIntensityColorMapType1(int newType)
+void TimeRasterDisplayPlot::setIntensityColorMapType1(int newType)
{
- setIntensityColorMapType(0, newType, d_low_intensity, d_high_intensity);
+ setIntensityColorMapType(0, newType, d_low_intensity, d_high_intensity);
}
-const QColor
-TimeRasterDisplayPlot::getUserDefinedLowIntensityColor() const
+const QColor TimeRasterDisplayPlot::getUserDefinedLowIntensityColor() const
{
- return d_low_intensity;
+ return d_low_intensity;
}
-const QColor
-TimeRasterDisplayPlot::getUserDefinedHighIntensityColor() const
+const QColor TimeRasterDisplayPlot::getUserDefinedHighIntensityColor() const
{
- return d_high_intensity;
+ return d_high_intensity;
}
-void
-TimeRasterDisplayPlot::_updateIntensityRangeDisplay()
+void TimeRasterDisplayPlot::_updateIntensityRangeDisplay()
{
- QwtScaleWidget *rightAxis = axisWidget(QwtPlot::yRight);
- QwtText colorBarTitle("Intensity");
- colorBarTitle.setFont(QFont("Arial",d_color_bar_title_font_size));
- rightAxis->setTitle(colorBarTitle);
- rightAxis->setColorBarEnabled(true);
+ QwtScaleWidget* rightAxis = axisWidget(QwtPlot::yRight);
+ QwtText colorBarTitle("Intensity");
+ colorBarTitle.setFont(QFont("Arial", d_color_bar_title_font_size));
+ rightAxis->setTitle(colorBarTitle);
+ rightAxis->setColorBarEnabled(true);
- for(unsigned int i = 0; i < d_nplots; ++i) {
+ for (unsigned int i = 0; i < d_nplots; ++i) {
#if QWT_VERSION < 0x060000
- rightAxis->setColorMap(d_raster[i]->data()->range(),
- d_raster[i]->colorMap());
- setAxisScale(QwtPlot::yRight,
- d_raster[i]->data()->range().minValue(),
- d_raster[i]->data()->range().maxValue());
+ rightAxis->setColorMap(d_raster[i]->data()->range(), d_raster[i]->colorMap());
+ setAxisScale(QwtPlot::yRight,
+ d_raster[i]->data()->range().minValue(),
+ d_raster[i]->data()->range().maxValue());
#else
- QwtInterval intv = d_raster[i]->interval(Qt::ZAxis);
- switch(d_color_map_type[i]) {
- case INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR:
- rightAxis->setColorMap(intv, new ColorMap_MultiColor()); break;
- case INTENSITY_COLOR_MAP_TYPE_WHITE_HOT:
- rightAxis->setColorMap(intv, new ColorMap_WhiteHot()); break;
- case INTENSITY_COLOR_MAP_TYPE_BLACK_HOT:
- rightAxis->setColorMap(intv, new ColorMap_BlackHot()); break;
- case INTENSITY_COLOR_MAP_TYPE_INCANDESCENT:
- rightAxis->setColorMap(intv, new ColorMap_Incandescent()); break;
- case INTENSITY_COLOR_MAP_TYPE_SUNSET:
- rightAxis->setColorMap(intv, new ColorMap_Sunset()); break;
- case INTENSITY_COLOR_MAP_TYPE_COOL:
- rightAxis->setColorMap(intv, new ColorMap_Cool()); break;
- case INTENSITY_COLOR_MAP_TYPE_USER_DEFINED:
- rightAxis->setColorMap(intv, new ColorMap_UserDefined(d_low_intensity,
- d_high_intensity));
- break;
- default:
- rightAxis->setColorMap(intv, new ColorMap_MultiColor()); break;
- }
- setAxisScale(QwtPlot::yRight, intv.minValue(), intv.maxValue());
+ QwtInterval intv = d_raster[i]->interval(Qt::ZAxis);
+ switch (d_color_map_type[i]) {
+ case INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR:
+ rightAxis->setColorMap(intv, new ColorMap_MultiColor());
+ break;
+ case INTENSITY_COLOR_MAP_TYPE_WHITE_HOT:
+ rightAxis->setColorMap(intv, new ColorMap_WhiteHot());
+ break;
+ case INTENSITY_COLOR_MAP_TYPE_BLACK_HOT:
+ rightAxis->setColorMap(intv, new ColorMap_BlackHot());
+ break;
+ case INTENSITY_COLOR_MAP_TYPE_INCANDESCENT:
+ rightAxis->setColorMap(intv, new ColorMap_Incandescent());
+ break;
+ case INTENSITY_COLOR_MAP_TYPE_SUNSET:
+ rightAxis->setColorMap(intv, new ColorMap_Sunset());
+ break;
+ case INTENSITY_COLOR_MAP_TYPE_COOL:
+ rightAxis->setColorMap(intv, new ColorMap_Cool());
+ break;
+ case INTENSITY_COLOR_MAP_TYPE_USER_DEFINED:
+ rightAxis->setColorMap(
+ intv, new ColorMap_UserDefined(d_low_intensity, d_high_intensity));
+ break;
+ default:
+ rightAxis->setColorMap(intv, new ColorMap_MultiColor());
+ break;
+ }
+ setAxisScale(QwtPlot::yRight, intv.minValue(), intv.maxValue());
#endif
- enableAxis(QwtPlot::yRight);
+ enableAxis(QwtPlot::yRight);
- plotLayout()->setAlignCanvasToScales(true);
+ plotLayout()->setAlignCanvasToScales(true);
- // Tell the display to redraw everything
- d_raster[i]->invalidateCache();
- d_raster[i]->itemChanged();
- }
+ // Tell the display to redraw everything
+ d_raster[i]->invalidateCache();
+ d_raster[i]->itemChanged();
+ }
- // Draw again
- replot();
+ // Draw again
+ replot();
}
#endif /* TIMERASTER_DISPLAY_PLOT_C */
diff --git a/gr-qtgui/lib/VectorDisplayPlot.cc b/gr-qtgui/lib/VectorDisplayPlot.cc
index 009233b3e6..dbc1209b50 100644
--- a/gr-qtgui/lib/VectorDisplayPlot.cc
+++ b/gr-qtgui/lib/VectorDisplayPlot.cc
@@ -41,53 +41,41 @@
/***********************************************************************
* Widget to provide mouse pointer coordinate text
**********************************************************************/
-class VectorDisplayZoomer: public QwtPlotZoomer
+class VectorDisplayZoomer : public QwtPlotZoomer
{
public:
#if QWT_VERSION < 0x060100
- VectorDisplayZoomer(QwtPlotCanvas* canvas)
-#else /* QWT_VERSION < 0x060100 */
- VectorDisplayZoomer(QWidget* canvas)
+ VectorDisplayZoomer(QwtPlotCanvas* canvas)
+#else /* QWT_VERSION < 0x060100 */
+ VectorDisplayZoomer(QWidget* canvas)
#endif /* QWT_VERSION < 0x060100 */
- : QwtPlotZoomer(canvas),
- d_x_units(" "),
- d_y_units(" ")
- {
- setTrackerMode(QwtPicker::AlwaysOn);
- }
-
- virtual void updateTrackerText()
- {
- updateDisplay();
- }
-
- void setXUnits(const QString &units)
- {
- d_x_units = units;
- }
-
- void setYUnits(const QString &units)
- {
- d_y_units = units;
- }
+ : QwtPlotZoomer(canvas), d_x_units(" "), d_y_units(" ")
+ {
+ setTrackerMode(QwtPicker::AlwaysOn);
+ }
+
+ virtual void updateTrackerText() { updateDisplay(); }
+
+ void setXUnits(const QString& units) { d_x_units = units; }
+
+ void setYUnits(const QString& units) { d_y_units = units; }
protected:
- using QwtPlotZoomer::trackerText;
- virtual QwtText trackerText(QPoint const &p) const
- {
- QwtDoublePoint dp = QwtPlotZoomer::invTransform(p);
- QwtText t(QString("%1 %2, %3 %4")
- .arg(dp.x(), 0, 'f', 2)
- .arg(d_x_units)
- .arg(dp.y(), 0, 'f', 2)
- .arg(d_y_units)
- );
- return t;
- }
+ using QwtPlotZoomer::trackerText;
+ virtual QwtText trackerText(QPoint const& p) const
+ {
+ QwtDoublePoint dp = QwtPlotZoomer::invTransform(p);
+ QwtText t(QString("%1 %2, %3 %4")
+ .arg(dp.x(), 0, 'f', 2)
+ .arg(d_x_units)
+ .arg(dp.y(), 0, 'f', 2)
+ .arg(d_y_units));
+ return t;
+ }
private:
- QString d_x_units; //!< Units on x-Axis (e.g. Hz)
- QString d_y_units; //!< Units on y-Axis (e.g. V)
+ QString d_x_units; //!< Units on x-Axis (e.g. Hz)
+ QString d_y_units; //!< Units on y-Axis (e.g. V)
};
@@ -95,535 +83,471 @@ private:
* Main frequency display plotter widget
**********************************************************************/
VectorDisplayPlot::VectorDisplayPlot(int nplots, QWidget* parent)
- : DisplayPlot(nplots, parent),
- d_x_axis_label("x"),
- d_y_axis_label("y")
+ : DisplayPlot(nplots, parent), d_x_axis_label("x"), d_y_axis_label("y")
{
- d_numPoints = 1024;
- d_x_axis_start = 0;
- d_x_axis_step = 1.0;
- d_ymin = -10;
- d_ymax = 10;
+ d_numPoints = 1024;
+ d_x_axis_start = 0;
+ d_x_axis_step = 1.0;
+ d_ymin = -10;
+ d_ymax = 10;
- d_min_vec_data = new double[d_numPoints];
- d_max_vec_data = new double[d_numPoints];
- d_xdata = new double[d_numPoints];
+ d_min_vec_data = new double[d_numPoints];
+ d_max_vec_data = new double[d_numPoints];
+ d_xdata = new double[d_numPoints];
- setAxisTitle(QwtPlot::xBottom, d_x_axis_label);
- setAxisScale(QwtPlot::xBottom, d_x_axis_start, d_numPoints-1);
+ setAxisTitle(QwtPlot::xBottom, d_x_axis_label);
+ setAxisScale(QwtPlot::xBottom, d_x_axis_start, d_numPoints - 1);
- setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine);
- setAxisScale(QwtPlot::yLeft, d_ymin, d_ymax);
- setAxisTitle(QwtPlot::yLeft, d_y_axis_label);
+ setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine);
+ setAxisScale(QwtPlot::yLeft, d_ymin, d_ymax);
+ setAxisTitle(QwtPlot::yLeft, d_y_axis_label);
- QList<QColor> default_colors;
- default_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);
+ QList<QColor> default_colors;
+ default_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);
- // Create a curve for each input
- // Automatically deleted when parent is deleted
- for(unsigned int i = 0; i < d_nplots; ++i) {
- d_ydata.push_back(new double[d_numPoints]);
- memset(d_ydata[i], 0x0, d_numPoints*sizeof(double));
+ // Create a curve for each input
+ // Automatically deleted when parent is deleted
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ d_ydata.push_back(new double[d_numPoints]);
+ memset(d_ydata[i], 0x0, d_numPoints * sizeof(double));
- d_plot_curve.push_back(new QwtPlotCurve(QString("Data %1").arg(i)));
- d_plot_curve[i]->attach(this);
+ d_plot_curve.push_back(new QwtPlotCurve(QString("Data %1").arg(i)));
+ d_plot_curve[i]->attach(this);
- QwtSymbol *symbol = new QwtSymbol(QwtSymbol::NoSymbol, QBrush(default_colors[i]),
- QPen(default_colors[i]), QSize(7,7));
+ QwtSymbol* symbol = new QwtSymbol(QwtSymbol::NoSymbol,
+ QBrush(default_colors[i]),
+ QPen(default_colors[i]),
+ QSize(7, 7));
#if QWT_VERSION < 0x060000
- d_plot_curve[i]->setRawData(d_xdata, d_ydata[i], d_numPoints);
- d_plot_curve[i]->setSymbol(*symbol);
+ d_plot_curve[i]->setRawData(d_xdata, d_ydata[i], d_numPoints);
+ d_plot_curve[i]->setSymbol(*symbol);
#else
- d_plot_curve[i]->setRawSamples(d_xdata, d_ydata[i], d_numPoints);
- d_plot_curve[i]->setSymbol(symbol);
+ d_plot_curve[i]->setRawSamples(d_xdata, d_ydata[i], d_numPoints);
+ d_plot_curve[i]->setSymbol(symbol);
#endif
- setLineColor(i, default_colors[i]);
- }
-
- // Create min/max plotter curves
- d_min_vec_plot_curve = new QwtPlotCurve("Min Hold");
- d_min_vec_plot_curve->attach(this);
- const QColor default_min_fft_color = Qt::magenta;
- setMinVecColor(default_min_fft_color);
+ setLineColor(i, default_colors[i]);
+ }
+
+ // Create min/max plotter curves
+ d_min_vec_plot_curve = new QwtPlotCurve("Min Hold");
+ d_min_vec_plot_curve->attach(this);
+ const QColor default_min_fft_color = Qt::magenta;
+ setMinVecColor(default_min_fft_color);
#if QWT_VERSION < 0x060000
- d_min_vec_plot_curve->setRawData(d_xdata, d_min_vec_data, d_numPoints);
+ d_min_vec_plot_curve->setRawData(d_xdata, d_min_vec_data, d_numPoints);
#else
- d_min_vec_plot_curve->setRawSamples(d_xdata, d_min_vec_data, d_numPoints);
+ d_min_vec_plot_curve->setRawSamples(d_xdata, d_min_vec_data, d_numPoints);
#endif
- d_min_vec_plot_curve->setVisible(false);
- d_min_vec_plot_curve->setZ(0);
+ d_min_vec_plot_curve->setVisible(false);
+ d_min_vec_plot_curve->setZ(0);
- d_max_vec_plot_curve = new QwtPlotCurve("Max Hold");
- d_max_vec_plot_curve->attach(this);
- QColor default_max_fft_color = Qt::darkYellow;
- setMaxVecColor(default_max_fft_color);
+ d_max_vec_plot_curve = new QwtPlotCurve("Max Hold");
+ d_max_vec_plot_curve->attach(this);
+ QColor default_max_fft_color = Qt::darkYellow;
+ setMaxVecColor(default_max_fft_color);
#if QWT_VERSION < 0x060000
- d_max_vec_plot_curve->setRawData(d_xdata, d_max_vec_data, d_numPoints);
+ d_max_vec_plot_curve->setRawData(d_xdata, d_max_vec_data, d_numPoints);
#else
- d_max_vec_plot_curve->setRawSamples(d_xdata, d_max_vec_data, d_numPoints);
+ d_max_vec_plot_curve->setRawSamples(d_xdata, d_max_vec_data, d_numPoints);
#endif
- d_max_vec_plot_curve->setVisible(false);
- d_max_vec_plot_curve->setZ(0);
+ d_max_vec_plot_curve->setVisible(false);
+ d_max_vec_plot_curve->setZ(0);
- d_lower_intensity_marker= new QwtPlotMarker();
- d_lower_intensity_marker->setLineStyle(QwtPlotMarker::HLine);
- QColor default_marker_lower_intensity_color = Qt::cyan;
- setMarkerLowerIntensityColor(default_marker_lower_intensity_color);
- d_lower_intensity_marker->attach(this);
+ d_lower_intensity_marker = new QwtPlotMarker();
+ d_lower_intensity_marker->setLineStyle(QwtPlotMarker::HLine);
+ QColor default_marker_lower_intensity_color = Qt::cyan;
+ setMarkerLowerIntensityColor(default_marker_lower_intensity_color);
+ d_lower_intensity_marker->attach(this);
- d_upper_intensity_marker = new QwtPlotMarker();
- d_upper_intensity_marker->setLineStyle(QwtPlotMarker::HLine);
- QColor default_marker_upper_intensity_color = Qt::green;
- setMarkerUpperIntensityColor(default_marker_upper_intensity_color);
- d_upper_intensity_marker->attach(this);
+ d_upper_intensity_marker = new QwtPlotMarker();
+ d_upper_intensity_marker->setLineStyle(QwtPlotMarker::HLine);
+ QColor default_marker_upper_intensity_color = Qt::green;
+ setMarkerUpperIntensityColor(default_marker_upper_intensity_color);
+ d_upper_intensity_marker->attach(this);
- memset(d_xdata, 0x0, d_numPoints*sizeof(double));
+ memset(d_xdata, 0x0, d_numPoints * sizeof(double));
- for(int64_t number = 0; number < d_numPoints; number++){
- d_min_vec_data[number] = 1e6;
- d_max_vec_data[number] = -1e6;
- }
+ for (int64_t number = 0; number < d_numPoints; number++) {
+ d_min_vec_data[number] = 1e6;
+ d_max_vec_data[number] = -1e6;
+ }
- d_marker_ref_level = new QwtPlotMarker();
- d_marker_ref_level->setLineStyle(QwtPlotMarker::HLine);
- QColor d_default_marker_ref_level_color = Qt::darkRed;
- setMarkerRefLevelAmplitudeColor(d_default_marker_ref_level_color);
- d_marker_ref_level->attach(this);
+ d_marker_ref_level = new QwtPlotMarker();
+ d_marker_ref_level->setLineStyle(QwtPlotMarker::HLine);
+ QColor d_default_marker_ref_level_color = Qt::darkRed;
+ setMarkerRefLevelAmplitudeColor(d_default_marker_ref_level_color);
+ d_marker_ref_level->attach(this);
- d_ref_level = -HUGE_VAL;
+ d_ref_level = -HUGE_VAL;
- d_zoomer = new VectorDisplayZoomer(canvas());
+ d_zoomer = new VectorDisplayZoomer(canvas());
#if QWT_VERSION < 0x060000
- d_zoomer->setSelectionFlags(QwtPicker::RectSelection | QwtPicker::DragSelection);
+ d_zoomer->setSelectionFlags(QwtPicker::RectSelection | QwtPicker::DragSelection);
#endif
- d_zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
- Qt::RightButton, Qt::ControlModifier);
- d_zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
- Qt::RightButton);
+ d_zoomer->setMousePattern(
+ QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier);
+ d_zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
- const QColor default_zoomer_color(Qt::darkRed);
- setZoomerColor(default_zoomer_color);
+ const QColor default_zoomer_color(Qt::darkRed);
+ setZoomerColor(default_zoomer_color);
- // Do this after the zoomer has been built
- _resetXAxisPoints();
+ // Do this after the zoomer has been built
+ _resetXAxisPoints();
- // Turn off min/max hold plots in legend
+ // Turn off min/max hold plots in legend
#if QWT_VERSION < 0x060100
- QWidget *w;
- QwtLegend* legendDisplay = legend();
- w = legendDisplay->find(d_min_vec_plot_curve);
- ((QwtLegendItem*)w)->setChecked(true);
- w = legendDisplay->find(d_max_vec_plot_curve);
- ((QwtLegendItem*)w)->setChecked(true);
-#else /* QWT_VERSION < 0x060100 */
- QWidget *w;
- w = ((QwtLegend*)legend())->legendWidget(itemToInfo(d_min_vec_plot_curve));
- ((QwtLegendLabel*)w)->setChecked(true);
- w = ((QwtLegend*)legend())->legendWidget(itemToInfo(d_max_vec_plot_curve));
- ((QwtLegendLabel*)w)->setChecked(true);
+ QWidget* w;
+ QwtLegend* legendDisplay = legend();
+ w = legendDisplay->find(d_min_vec_plot_curve);
+ ((QwtLegendItem*)w)->setChecked(true);
+ w = legendDisplay->find(d_max_vec_plot_curve);
+ ((QwtLegendItem*)w)->setChecked(true);
+#else /* QWT_VERSION < 0x060100 */
+ QWidget* w;
+ w = ((QwtLegend*)legend())->legendWidget(itemToInfo(d_min_vec_plot_curve));
+ ((QwtLegendLabel*)w)->setChecked(true);
+ w = ((QwtLegend*)legend())->legendWidget(itemToInfo(d_max_vec_plot_curve));
+ ((QwtLegendLabel*)w)->setChecked(true);
#endif /* QWT_VERSION < 0x060100 */
- replot();
+ replot();
}
VectorDisplayPlot::~VectorDisplayPlot()
{
- for(unsigned int i = 0; i < d_nplots; ++i)
- delete [] d_ydata[i];
- delete[] d_max_vec_data;
- delete[] d_min_vec_data;
- delete[] d_xdata;
+ for (unsigned int i = 0; i < d_nplots; ++i)
+ delete[] d_ydata[i];
+ delete[] d_max_vec_data;
+ delete[] d_min_vec_data;
+ delete[] d_xdata;
}
-void
-VectorDisplayPlot::setYaxis(double min, double max)
+void VectorDisplayPlot::setYaxis(double min, double max)
{
- // Get the new max/min values for the plot
- d_ymin = min;
- d_ymax = max;
+ // Get the new max/min values for the plot
+ d_ymin = min;
+ d_ymax = max;
- // Set the axis max/min to the new values
- setAxisScale(QwtPlot::yLeft, d_ymin, d_ymax);
+ // Set the axis max/min to the new values
+ setAxisScale(QwtPlot::yLeft, d_ymin, d_ymax);
- // Reset the base zoom level to the new axis scale set here.
- // But don't do it if we set the axis due to auto scaling.
- if(!d_autoscale_state)
- d_zoomer->setZoomBase();
+ // Reset the base zoom level to the new axis scale set here.
+ // But don't do it if we set the axis due to auto scaling.
+ if (!d_autoscale_state)
+ d_zoomer->setZoomBase();
}
-double
-VectorDisplayPlot::getYMin() const
-{
- return d_ymin;
-}
+double VectorDisplayPlot::getYMin() const { return d_ymin; }
-double
-VectorDisplayPlot::getYMax() const
-{
- return d_ymax;
-}
+double VectorDisplayPlot::getYMax() const { return d_ymax; }
-void VectorDisplayPlot::setXAxisLabel(const QString &label)
+void VectorDisplayPlot::setXAxisLabel(const QString& label)
{
- d_x_axis_label = label;
- setAxisTitle(QwtPlot::xBottom, label);
+ d_x_axis_label = label;
+ setAxisTitle(QwtPlot::xBottom, label);
}
-void VectorDisplayPlot::setYAxisLabel(const QString &label)
+void VectorDisplayPlot::setYAxisLabel(const QString& label)
{
- d_y_axis_label = label;
- setAxisTitle(QwtPlot::yLeft, label);
+ d_y_axis_label = label;
+ setAxisTitle(QwtPlot::yLeft, label);
}
-void VectorDisplayPlot::setXAxisUnit(const QString &unit)
+void VectorDisplayPlot::setXAxisUnit(const QString& unit)
{
- ((VectorDisplayZoomer*)d_zoomer)->setXUnits(unit);
+ ((VectorDisplayZoomer*)d_zoomer)->setXUnits(unit);
}
-void VectorDisplayPlot::setYAxisUnit(const QString &unit)
+void VectorDisplayPlot::setYAxisUnit(const QString& unit)
{
- ((VectorDisplayZoomer*)d_zoomer)->setYUnits(unit);
+ ((VectorDisplayZoomer*)d_zoomer)->setYUnits(unit);
}
-void
-VectorDisplayPlot::setXAxisValues(
- const double start,
- const double step
-) {
- bool reset = false;
- if((start != d_x_axis_start) || (step != d_x_axis_step))
- reset = true;
+void VectorDisplayPlot::setXAxisValues(const double start, const double step)
+{
+ bool reset = false;
+ if ((start != d_x_axis_start) || (step != d_x_axis_step))
+ reset = true;
- d_x_axis_start = start;
- d_x_axis_step = step;
+ d_x_axis_start = start;
+ d_x_axis_step = step;
- if((axisScaleDraw(QwtPlot::xBottom) != NULL) && (d_zoomer != NULL)) {
- setAxisTitle(QwtPlot::xBottom, d_x_axis_label);
- if(reset) {
- _resetXAxisPoints();
- clearMaxData();
- clearMinData();
+ if ((axisScaleDraw(QwtPlot::xBottom) != NULL) && (d_zoomer != NULL)) {
+ setAxisTitle(QwtPlot::xBottom, d_x_axis_label);
+ if (reset) {
+ _resetXAxisPoints();
+ clearMaxData();
+ clearMinData();
+ }
}
- }
}
-void
-VectorDisplayPlot::replot()
+void VectorDisplayPlot::replot()
{
- d_marker_ref_level->setYValue(d_ref_level);
- QwtPlot::replot();
+ d_marker_ref_level->setYValue(d_ref_level);
+ QwtPlot::replot();
}
-void
-VectorDisplayPlot::plotNewData(
- const std::vector<double*> dataPoints,
- const int64_t numDataPoints,
- const double refLevel,
- const double timeInterval
-) {
- if(!d_stop) {
- if(numDataPoints > 0) {
- if(numDataPoints != d_numPoints) {
- d_numPoints = numDataPoints;
+void VectorDisplayPlot::plotNewData(const std::vector<double*> dataPoints,
+ const int64_t numDataPoints,
+ const double refLevel,
+ const double timeInterval)
+{
+ if (!d_stop) {
+ if (numDataPoints > 0) {
+ if (numDataPoints != d_numPoints) {
+ d_numPoints = numDataPoints;
- delete[] d_min_vec_data;
- delete[] d_max_vec_data;
- delete[] d_xdata;
- d_xdata = new double[d_numPoints];
- d_min_vec_data = new double[d_numPoints];
- d_max_vec_data = new double[d_numPoints];
+ delete[] d_min_vec_data;
+ delete[] d_max_vec_data;
+ delete[] d_xdata;
+ d_xdata = new double[d_numPoints];
+ d_min_vec_data = new double[d_numPoints];
+ d_max_vec_data = new double[d_numPoints];
- for(unsigned int i = 0; i < d_nplots; ++i) {
- delete[] d_ydata[i];
- d_ydata[i] = new double[d_numPoints];
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ delete[] d_ydata[i];
+ d_ydata[i] = new double[d_numPoints];
#if QWT_VERSION < 0x060000
- d_plot_curve[i]->setRawData(d_xdata, d_ydata[i], d_numPoints);
+ d_plot_curve[i]->setRawData(d_xdata, d_ydata[i], d_numPoints);
#else
- d_plot_curve[i]->setRawSamples(d_xdata, d_ydata[i], d_numPoints);
+ d_plot_curve[i]->setRawSamples(d_xdata, d_ydata[i], d_numPoints);
#endif
- }
+ }
#if QWT_VERSION < 0x060000
- d_min_vec_plot_curve->setRawData(d_xdata, d_min_vec_data, d_numPoints);
- d_max_vec_plot_curve->setRawData(d_xdata, d_max_vec_data, d_numPoints);
+ d_min_vec_plot_curve->setRawData(d_xdata, d_min_vec_data, d_numPoints);
+ d_max_vec_plot_curve->setRawData(d_xdata, d_max_vec_data, d_numPoints);
#else
- d_min_vec_plot_curve->setRawSamples(d_xdata, d_min_vec_data, d_numPoints);
- d_max_vec_plot_curve->setRawSamples(d_xdata, d_max_vec_data, d_numPoints);
+ d_min_vec_plot_curve->setRawSamples(d_xdata, d_min_vec_data, d_numPoints);
+ d_max_vec_plot_curve->setRawSamples(d_xdata, d_max_vec_data, d_numPoints);
#endif
- _resetXAxisPoints();
- clearMaxData();
- clearMinData();
- }
-
- double bottom=1e20, top=-1e20;
- for(unsigned int n = 0; n < d_nplots; ++n) {
-
- memcpy(d_ydata[n], dataPoints[n], numDataPoints*sizeof(double));
-
- for(int64_t point = 0; point < numDataPoints; point++) {
- if(dataPoints[n][point] < d_min_vec_data[point]) {
- d_min_vec_data[point] = dataPoints[n][point];
- }
- if(dataPoints[n][point] > d_max_vec_data[point]) {
- d_max_vec_data[point] = dataPoints[n][point];
- }
-
- // Find overall top and bottom values in plot.
- // Used for autoscaling y-axis.
- if(dataPoints[n][point] < bottom) {
- bottom = dataPoints[n][point];
- }
- if(dataPoints[n][point] > top) {
- top = dataPoints[n][point];
- }
+ _resetXAxisPoints();
+ clearMaxData();
+ clearMinData();
+ }
+
+ double bottom = 1e20, top = -1e20;
+ for (unsigned int n = 0; n < d_nplots; ++n) {
+
+ memcpy(d_ydata[n], dataPoints[n], numDataPoints * sizeof(double));
+
+ for (int64_t point = 0; point < numDataPoints; point++) {
+ if (dataPoints[n][point] < d_min_vec_data[point]) {
+ d_min_vec_data[point] = dataPoints[n][point];
+ }
+ if (dataPoints[n][point] > d_max_vec_data[point]) {
+ d_max_vec_data[point] = dataPoints[n][point];
+ }
+
+ // Find overall top and bottom values in plot.
+ // Used for autoscaling y-axis.
+ if (dataPoints[n][point] < bottom) {
+ bottom = dataPoints[n][point];
+ }
+ if (dataPoints[n][point] > top) {
+ top = dataPoints[n][point];
+ }
+ }
+ }
+
+ if (d_autoscale_state)
+ _autoScale(bottom, top);
+
+ d_ref_level = refLevel;
+
+ replot();
}
- }
-
- if(d_autoscale_state)
- _autoScale(bottom, top);
-
- d_ref_level = refLevel;
-
- replot();
}
- }
}
-void
-VectorDisplayPlot::clearMaxData()
+void VectorDisplayPlot::clearMaxData()
{
- for(int64_t number = 0; number < d_numPoints; number++) {
- d_max_vec_data[number] = d_ymin;
- }
+ for (int64_t number = 0; number < d_numPoints; number++) {
+ d_max_vec_data[number] = d_ymin;
+ }
}
-void
-VectorDisplayPlot::clearMinData()
+void VectorDisplayPlot::clearMinData()
{
- for(int64_t number = 0; number < d_numPoints; number++) {
- d_min_vec_data[number] = d_ymax;
- }
+ for (int64_t number = 0; number < d_numPoints; number++) {
+ d_min_vec_data[number] = d_ymax;
+ }
}
-void
-VectorDisplayPlot::_autoScale(double bottom, double top)
+void VectorDisplayPlot::_autoScale(double bottom, double top)
{
- // Auto scale the y-axis with a margin of 10 dB on either side.
- d_ymin = bottom-10;
- d_ymax = top+10;
- setYaxis(d_ymin, d_ymax);
+ // Auto scale the y-axis with a margin of 10 dB on either side.
+ d_ymin = bottom - 10;
+ d_ymax = top + 10;
+ setYaxis(d_ymin, d_ymax);
}
-void
-VectorDisplayPlot::setAutoScale(bool state)
-{
- d_autoscale_state = state;
-}
+void VectorDisplayPlot::setAutoScale(bool state) { d_autoscale_state = state; }
-void
-VectorDisplayPlot::setMaxVecVisible(const bool visibleFlag)
+void VectorDisplayPlot::setMaxVecVisible(const bool visibleFlag)
{
- d_max_vec_visible = visibleFlag;
- d_max_vec_plot_curve->setVisible(visibleFlag);
+ d_max_vec_visible = visibleFlag;
+ d_max_vec_plot_curve->setVisible(visibleFlag);
}
-const bool
-VectorDisplayPlot::getMaxVecVisible() const
-{
- return d_max_vec_visible;
-}
+const bool VectorDisplayPlot::getMaxVecVisible() const { return d_max_vec_visible; }
-void
-VectorDisplayPlot::setMinVecVisible(const bool visibleFlag)
+void VectorDisplayPlot::setMinVecVisible(const bool visibleFlag)
{
- d_min_vec_visible = visibleFlag;
- d_min_vec_plot_curve->setVisible(visibleFlag);
+ d_min_vec_visible = visibleFlag;
+ d_min_vec_plot_curve->setVisible(visibleFlag);
}
-const bool
-VectorDisplayPlot::getMinVecVisible() const
-{
- return d_min_vec_visible;
-}
+const bool VectorDisplayPlot::getMinVecVisible() const { return d_min_vec_visible; }
-void
-VectorDisplayPlot::_resetXAxisPoints()
+void VectorDisplayPlot::_resetXAxisPoints()
{
- double xValue = d_x_axis_start;
- for(int64_t loc = 0; loc < d_numPoints; loc++) {
- d_xdata[loc] = xValue;
- xValue += d_x_axis_step;
- }
+ double xValue = d_x_axis_start;
+ for (int64_t loc = 0; loc < d_numPoints; loc++) {
+ d_xdata[loc] = xValue;
+ xValue += d_x_axis_step;
+ }
- setAxisScale(QwtPlot::xBottom, d_xdata[0], d_xdata[d_numPoints-1]);
+ setAxisScale(QwtPlot::xBottom, d_xdata[0], d_xdata[d_numPoints - 1]);
- // Set up zoomer base for maximum unzoom x-axis
- // and reset to maximum unzoom level
- QwtDoubleRect zbase = d_zoomer->zoomBase();
- d_zoomer->zoom(zbase);
- d_zoomer->setZoomBase(zbase);
- d_zoomer->setZoomBase(true);
- d_zoomer->zoom(0);
+ // Set up zoomer base for maximum unzoom x-axis
+ // and reset to maximum unzoom level
+ QwtDoubleRect zbase = d_zoomer->zoomBase();
+ d_zoomer->zoom(zbase);
+ d_zoomer->setZoomBase(zbase);
+ d_zoomer->setZoomBase(true);
+ d_zoomer->zoom(0);
}
-void
-VectorDisplayPlot::setLowerIntensityLevel(const double lowerIntensityLevel)
+void VectorDisplayPlot::setLowerIntensityLevel(const double lowerIntensityLevel)
{
- d_lower_intensity_marker->setYValue(lowerIntensityLevel);
+ d_lower_intensity_marker->setYValue(lowerIntensityLevel);
}
-void
-VectorDisplayPlot::setUpperIntensityLevel(const double upperIntensityLevel)
+void VectorDisplayPlot::setUpperIntensityLevel(const double upperIntensityLevel)
{
- d_upper_intensity_marker->setYValue(upperIntensityLevel);
+ d_upper_intensity_marker->setYValue(upperIntensityLevel);
}
-void
-VectorDisplayPlot::setTraceColour(QColor c)
-{
- d_plot_curve[0]->setPen(QPen(c));
-}
+void VectorDisplayPlot::setTraceColour(QColor c) { d_plot_curve[0]->setPen(QPen(c)); }
-void
-VectorDisplayPlot::setBGColour(QColor c)
+void VectorDisplayPlot::setBGColour(QColor c)
{
- QPalette palette;
- palette.setColor(canvas()->backgroundRole(), c);
- canvas()->setPalette(palette);
+ QPalette palette;
+ palette.setColor(canvas()->backgroundRole(), c);
+ canvas()->setPalette(palette);
}
-void
-VectorDisplayPlot::onPickerPointSelected(const QwtDoublePoint & p)
+void VectorDisplayPlot::onPickerPointSelected(const QwtDoublePoint& p)
{
- QPointF point = p;
- point.setX(point.x());
- emit plotPointSelected(point);
+ QPointF point = p;
+ point.setX(point.x());
+ emit plotPointSelected(point);
}
-void
-VectorDisplayPlot::onPickerPointSelected6(const QPointF & p)
+void VectorDisplayPlot::onPickerPointSelected6(const QPointF& p)
{
- QPointF point = p;
- point.setX(point.x());
- emit plotPointSelected(point);
+ QPointF point = p;
+ point.setX(point.x());
+ emit plotPointSelected(point);
}
-void
-VectorDisplayPlot::setMinVecColor (QColor c)
+void VectorDisplayPlot::setMinVecColor(QColor c)
{
- d_min_vec_color = c;
- d_min_vec_plot_curve->setPen(QPen(c));
+ d_min_vec_color = c;
+ d_min_vec_plot_curve->setPen(QPen(c));
}
-const QColor
-VectorDisplayPlot::getMinVecColor() const
-{
- return d_min_vec_color;
-}
+const QColor VectorDisplayPlot::getMinVecColor() const { return d_min_vec_color; }
-void
-VectorDisplayPlot::setMaxVecColor (QColor c)
+void VectorDisplayPlot::setMaxVecColor(QColor c)
{
- d_max_vec_color = c;
- d_max_vec_plot_curve->setPen(QPen(c));
+ d_max_vec_color = c;
+ d_max_vec_plot_curve->setPen(QPen(c));
}
-const QColor
-VectorDisplayPlot::getMaxVecColor() const
-{
- return d_max_vec_color;
-}
+const QColor VectorDisplayPlot::getMaxVecColor() const { return d_max_vec_color; }
-void
-VectorDisplayPlot::setMarkerLowerIntensityColor (QColor c)
+void VectorDisplayPlot::setMarkerLowerIntensityColor(QColor c)
{
- d_marker_lower_intensity_color = c;
- d_lower_intensity_marker->setLinePen(QPen(c));
+ d_marker_lower_intensity_color = c;
+ d_lower_intensity_marker->setLinePen(QPen(c));
}
-const QColor
-VectorDisplayPlot::getMarkerLowerIntensityColor () const
+const QColor VectorDisplayPlot::getMarkerLowerIntensityColor() const
{
- return d_marker_lower_intensity_color;
+ return d_marker_lower_intensity_color;
}
-void
-VectorDisplayPlot::setMarkerLowerIntensityVisible (bool visible)
+void VectorDisplayPlot::setMarkerLowerIntensityVisible(bool visible)
{
- d_marker_lower_intensity_visible = visible;
- if(visible)
- d_lower_intensity_marker->setLineStyle(QwtPlotMarker::HLine);
- else
- d_lower_intensity_marker->setLineStyle(QwtPlotMarker::NoLine);
+ d_marker_lower_intensity_visible = visible;
+ if (visible)
+ d_lower_intensity_marker->setLineStyle(QwtPlotMarker::HLine);
+ else
+ d_lower_intensity_marker->setLineStyle(QwtPlotMarker::NoLine);
}
-const bool
-VectorDisplayPlot::getMarkerLowerIntensityVisible() const
+const bool VectorDisplayPlot::getMarkerLowerIntensityVisible() const
{
- return d_marker_lower_intensity_visible;
+ return d_marker_lower_intensity_visible;
}
-void
-VectorDisplayPlot::setMarkerUpperIntensityColor(QColor c)
+void VectorDisplayPlot::setMarkerUpperIntensityColor(QColor c)
{
- d_marker_upper_intensity_color = c;
- d_upper_intensity_marker->setLinePen(QPen(c, 0, Qt::DotLine));
+ d_marker_upper_intensity_color = c;
+ d_upper_intensity_marker->setLinePen(QPen(c, 0, Qt::DotLine));
}
-const QColor
-VectorDisplayPlot::getMarkerUpperIntensityColor() const
+const QColor VectorDisplayPlot::getMarkerUpperIntensityColor() const
{
- return d_marker_upper_intensity_color;
+ return d_marker_upper_intensity_color;
}
-void
-VectorDisplayPlot::setMarkerUpperIntensityVisible(bool visible)
+void VectorDisplayPlot::setMarkerUpperIntensityVisible(bool visible)
{
- d_marker_upper_intensity_visible = visible;
- if(visible)
- d_upper_intensity_marker->setLineStyle(QwtPlotMarker::HLine);
- else
- d_upper_intensity_marker->setLineStyle(QwtPlotMarker::NoLine);
+ d_marker_upper_intensity_visible = visible;
+ if (visible)
+ d_upper_intensity_marker->setLineStyle(QwtPlotMarker::HLine);
+ else
+ d_upper_intensity_marker->setLineStyle(QwtPlotMarker::NoLine);
}
-const bool
-VectorDisplayPlot::getMarkerUpperIntensityVisible() const
+const bool VectorDisplayPlot::getMarkerUpperIntensityVisible() const
{
- return d_marker_upper_intensity_visible;
+ return d_marker_upper_intensity_visible;
}
-void
-VectorDisplayPlot::setMarkerRefLevelAmplitudeColor(QColor c)
+void VectorDisplayPlot::setMarkerRefLevelAmplitudeColor(QColor c)
{
- d_marker_ref_level_color = c;
- d_marker_ref_level->setLinePen(QPen(c, 0, Qt::DotLine));
+ d_marker_ref_level_color = c;
+ d_marker_ref_level->setLinePen(QPen(c, 0, Qt::DotLine));
}
-const QColor
-VectorDisplayPlot::getMarkerRefLevelAmplitudeColor() const
+const QColor VectorDisplayPlot::getMarkerRefLevelAmplitudeColor() const
{
- return d_marker_ref_level_color;
+ return d_marker_ref_level_color;
}
-void
-VectorDisplayPlot::setMarkerRefLevelAmplitudeVisible(bool visible)
+void VectorDisplayPlot::setMarkerRefLevelAmplitudeVisible(bool visible)
{
- d_marker_ref_level_visible = visible;
- if(visible)
- d_marker_ref_level->setLineStyle(QwtPlotMarker::HLine);
- else
- d_marker_ref_level->setLineStyle(QwtPlotMarker::NoLine);
+ d_marker_ref_level_visible = visible;
+ if (visible)
+ d_marker_ref_level->setLineStyle(QwtPlotMarker::HLine);
+ else
+ d_marker_ref_level->setLineStyle(QwtPlotMarker::NoLine);
}
-const bool
-VectorDisplayPlot::getMarkerRefLevelAmplitudeVisible() const
+const bool VectorDisplayPlot::getMarkerRefLevelAmplitudeVisible() const
{
- return d_marker_ref_level_visible;
+ return d_marker_ref_level_visible;
}
#endif /* VECTOR_DISPLAY_PLOT */
diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc b/gr-qtgui/lib/WaterfallDisplayPlot.cc
index 66299f1fa8..cd87fc965d 100644
--- a/gr-qtgui/lib/WaterfallDisplayPlot.cc
+++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc
@@ -48,659 +48,619 @@ namespace pt = boost::posix_time;
/***********************************************************************
* Text scale widget to provide Y (time) axis text
**********************************************************************/
-class QwtTimeScaleDraw: public QwtScaleDraw, public TimeScaleData
+class QwtTimeScaleDraw : public QwtScaleDraw, public TimeScaleData
{
public:
- QwtTimeScaleDraw():QwtScaleDraw(),TimeScaleData()
- {
- }
-
- virtual ~QwtTimeScaleDraw()
- {
- }
-
- virtual QwtText label(double value) const
- {
- double secs = double(value * getSecondsPerLine());
- return QwtText(QString("").sprintf("%.2e", secs));
- }
-
- virtual void initiateUpdate()
- {
- // Do this in one call rather than when zeroTime and secondsPerLine
- // updates is to prevent the display from being updated too often...
- invalidateCache();
- }
+ QwtTimeScaleDraw() : QwtScaleDraw(), TimeScaleData() {}
-protected:
+ virtual ~QwtTimeScaleDraw() {}
-private:
+ virtual QwtText label(double value) const
+ {
+ double secs = double(value * getSecondsPerLine());
+ return QwtText(QString("").sprintf("%.2e", secs));
+ }
+
+ virtual void initiateUpdate()
+ {
+ // Do this in one call rather than when zeroTime and secondsPerLine
+ // updates is to prevent the display from being updated too often...
+ invalidateCache();
+ }
+protected:
+private:
};
/***********************************************************************
* Widget to provide mouse pointer coordinate text
**********************************************************************/
-class WaterfallZoomer: public QwtPlotZoomer, public TimeScaleData,
- public FreqOffsetAndPrecisionClass
+class WaterfallZoomer : public QwtPlotZoomer,
+ public TimeScaleData,
+ public FreqOffsetAndPrecisionClass
{
public:
#if QWT_VERSION < 0x060100
- WaterfallZoomer(QwtPlotCanvas* canvas, const unsigned int freqPrecision)
-#else /* QWT_VERSION < 0x060100 */
- WaterfallZoomer(QWidget* canvas, const unsigned int freqPrecision)
+ WaterfallZoomer(QwtPlotCanvas* canvas, const unsigned int freqPrecision)
+#else /* QWT_VERSION < 0x060100 */
+ WaterfallZoomer(QWidget* canvas, const unsigned int freqPrecision)
#endif /* QWT_VERSION < 0x060100 */
- : QwtPlotZoomer(canvas), TimeScaleData(),
- FreqOffsetAndPrecisionClass(freqPrecision)
- {
- setTrackerMode(QwtPicker::AlwaysOn);
- }
-
- virtual ~WaterfallZoomer()
- {
- }
-
- virtual void updateTrackerText()
- {
- updateDisplay();
- }
-
- void setUnitType(const std::string &type)
- {
- d_unitType = type;
- }
+ : QwtPlotZoomer(canvas),
+ TimeScaleData(),
+ FreqOffsetAndPrecisionClass(freqPrecision)
+ {
+ setTrackerMode(QwtPicker::AlwaysOn);
+ }
+
+ virtual ~WaterfallZoomer() {}
+
+ virtual void updateTrackerText() { updateDisplay(); }
+
+ void setUnitType(const std::string& type) { d_unitType = type; }
protected:
- using QwtPlotZoomer::trackerText;
- virtual QwtText trackerText( QPoint const &p ) const
- {
- QwtDoublePoint dp = QwtPlotZoomer::invTransform(p);
- double secs = double(dp.y() * getSecondsPerLine());
- QwtText t(QString("%1 %2, %3 s")
- .arg(dp.x(), 0, 'f', getFrequencyPrecision())
- .arg(d_unitType.c_str())
- .arg(secs, 0, 'e', 2));
- return t;
- }
+ using QwtPlotZoomer::trackerText;
+ virtual QwtText trackerText(QPoint const& p) const
+ {
+ QwtDoublePoint dp = QwtPlotZoomer::invTransform(p);
+ double secs = double(dp.y() * getSecondsPerLine());
+ QwtText t(QString("%1 %2, %3 s")
+ .arg(dp.x(), 0, 'f', getFrequencyPrecision())
+ .arg(d_unitType.c_str())
+ .arg(secs, 0, 'e', 2));
+ return t;
+ }
private:
- std::string d_unitType;
+ std::string d_unitType;
};
/*********************************************************************
-* Main waterfall plot widget
-*********************************************************************/
+ * Main waterfall plot widget
+ *********************************************************************/
WaterfallDisplayPlot::WaterfallDisplayPlot(int nplots, QWidget* parent)
- : DisplayPlot(nplots, parent)
+ : DisplayPlot(nplots, parent)
{
- d_zoomer = NULL; // need this for proper init
- d_start_frequency = -1;
- d_stop_frequency = 1;
+ d_zoomer = NULL; // need this for proper init
+ d_start_frequency = -1;
+ d_stop_frequency = 1;
- resize(parent->width(), parent->height());
- d_numPoints = 0;
- d_half_freq = false;
- d_legend_enabled = true;
- d_nrows = 200;
- d_color_bar_title_font_size = 18;
+ resize(parent->width(), parent->height());
+ d_numPoints = 0;
+ d_half_freq = false;
+ d_legend_enabled = true;
+ d_nrows = 200;
+ d_color_bar_title_font_size = 18;
- setAxisTitle(QwtPlot::xBottom, "Frequency (Hz)");
- setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(0));
+ setAxisTitle(QwtPlot::xBottom, "Frequency (Hz)");
+ setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(0));
- setAxisTitle(QwtPlot::yLeft, "Time (s)");
- setAxisScaleDraw(QwtPlot::yLeft, new QwtTimeScaleDraw());
+ setAxisTitle(QwtPlot::yLeft, "Time (s)");
+ setAxisScaleDraw(QwtPlot::yLeft, new QwtTimeScaleDraw());
- for(unsigned int i = 0; i < d_nplots; ++i) {
- d_data.push_back(new WaterfallData(d_start_frequency, d_stop_frequency,
- d_numPoints, d_nrows));
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ d_data.push_back(
+ new WaterfallData(d_start_frequency, d_stop_frequency, d_numPoints, d_nrows));
#if QWT_VERSION < 0x060000
- d_spectrogram.push_back(new PlotWaterfall(d_data[i], "Spectrogram"));
+ d_spectrogram.push_back(new PlotWaterfall(d_data[i], "Spectrogram"));
#else
- d_spectrogram.push_back(new QwtPlotSpectrogram("Spectrogram"));
- d_spectrogram[i]->setData(d_data[i]);
- d_spectrogram[i]->setDisplayMode(QwtPlotSpectrogram::ImageMode, true);
- d_spectrogram[i]->setColorMap(new ColorMap_MultiColor());
+ d_spectrogram.push_back(new QwtPlotSpectrogram("Spectrogram"));
+ d_spectrogram[i]->setData(d_data[i]);
+ d_spectrogram[i]->setDisplayMode(QwtPlotSpectrogram::ImageMode, true);
+ d_spectrogram[i]->setColorMap(new ColorMap_MultiColor());
#endif
- // a hack around the fact that we aren't using plot curves for the
- // spectrogram plots.
- d_plot_curve.push_back(new QwtPlotCurve(QString("Data %1").arg(i)));
+ // a hack around the fact that we aren't using plot curves for the
+ // spectrogram plots.
+ d_plot_curve.push_back(new QwtPlotCurve(QString("Data %1").arg(i)));
- d_spectrogram[i]->attach(this);
+ d_spectrogram[i]->attach(this);
- d_intensity_color_map_type.push_back(INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR);
- setIntensityColorMapType(i, d_intensity_color_map_type[i],
- QColor("white"), QColor("white"));
+ d_intensity_color_map_type.push_back(INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR);
+ setIntensityColorMapType(
+ i, d_intensity_color_map_type[i], QColor("white"), QColor("white"));
- setAlpha(i, 255/d_nplots);
- }
+ setAlpha(i, 255 / d_nplots);
+ }
- // Set bottom plot with no transparency as a base
- setAlpha(0, 255);
+ // Set bottom plot with no transparency as a base
+ setAlpha(0, 255);
- // LeftButton for the zooming
- // MidButton for the panning
- // RightButton: zoom out by 1
- // Ctrl+RighButton: zoom out to full size
- d_zoomer = new WaterfallZoomer(canvas(), 0);
+ // LeftButton for the zooming
+ // MidButton for the panning
+ // RightButton: zoom out by 1
+ // Ctrl+RighButton: zoom out to full size
+ d_zoomer = new WaterfallZoomer(canvas(), 0);
#if QWT_VERSION < 0x060000
- d_zoomer->setSelectionFlags(QwtPicker::RectSelection | QwtPicker::DragSelection);
+ d_zoomer->setSelectionFlags(QwtPicker::RectSelection | QwtPicker::DragSelection);
#endif
- d_zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
- Qt::RightButton, Qt::ControlModifier);
- d_zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
- Qt::RightButton);
+ d_zoomer->setMousePattern(
+ QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier);
+ d_zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
- const QColor c(Qt::black);
- d_zoomer->setRubberBandPen(c);
- d_zoomer->setTrackerPen(c);
+ const QColor c(Qt::black);
+ d_zoomer->setRubberBandPen(c);
+ d_zoomer->setTrackerPen(c);
- _updateIntensityRangeDisplay();
+ _updateIntensityRangeDisplay();
- d_xaxis_multiplier = 1;
+ d_xaxis_multiplier = 1;
}
-WaterfallDisplayPlot::~WaterfallDisplayPlot()
-{
-}
+WaterfallDisplayPlot::~WaterfallDisplayPlot() {}
-void
-WaterfallDisplayPlot::resetAxis()
+void WaterfallDisplayPlot::resetAxis()
{
- for(unsigned int i = 0; i < d_nplots; ++i) {
- d_data[i]->resizeData(d_start_frequency, d_stop_frequency,
- d_numPoints, d_nrows);
- d_data[i]->reset();
- }
-
- setAxisScale(QwtPlot::xBottom, d_start_frequency, d_stop_frequency);
-
- // Load up the new base zoom settings
- QwtDoubleRect zbase = d_zoomer->zoomBase();
- d_zoomer->zoom(zbase);
- d_zoomer->setZoomBase(zbase);
- d_zoomer->setZoomBase(true);
- d_zoomer->zoom(0);
-}
-
-void
-WaterfallDisplayPlot::setFrequencyRange(const double centerfreq,
- const double bandwidth,
- const double units, const std::string &strunits)
-{
- double startFreq;
- double stopFreq = (centerfreq + bandwidth/2.0f) / units;
- if(d_half_freq)
- startFreq = centerfreq / units;
- else
- startFreq = (centerfreq - bandwidth/2.0f) / units;
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ d_data[i]->resizeData(d_start_frequency, d_stop_frequency, d_numPoints, d_nrows);
+ d_data[i]->reset();
+ }
+ setAxisScale(QwtPlot::xBottom, d_start_frequency, d_stop_frequency);
- d_xaxis_multiplier = units;
+ // Load up the new base zoom settings
+ QwtDoubleRect zbase = d_zoomer->zoomBase();
+ d_zoomer->zoom(zbase);
+ d_zoomer->setZoomBase(zbase);
+ d_zoomer->setZoomBase(true);
+ d_zoomer->zoom(0);
+}
- bool reset = false;
- if((startFreq != d_start_frequency) || (stopFreq != d_stop_frequency))
- reset = true;
+void WaterfallDisplayPlot::setFrequencyRange(const double centerfreq,
+ const double bandwidth,
+ const double units,
+ const std::string& strunits)
+{
+ double startFreq;
+ double stopFreq = (centerfreq + bandwidth / 2.0f) / units;
+ if (d_half_freq)
+ startFreq = centerfreq / units;
+ else
+ startFreq = (centerfreq - bandwidth / 2.0f) / units;
- if(stopFreq > startFreq) {
- d_start_frequency = startFreq;
- d_stop_frequency = stopFreq;
- d_center_frequency = centerfreq / units;
- if((axisScaleDraw(QwtPlot::xBottom) != NULL) && (d_zoomer != NULL)) {
- double display_units = ceil(log10(units)/2.0);
- setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(display_units));
- setAxisTitle(QwtPlot::xBottom, QString("Frequency (%1)").arg(strunits.c_str()));
+ d_xaxis_multiplier = units;
- if(reset) {
- resetAxis();
- }
-
- ((WaterfallZoomer*)d_zoomer)->setFrequencyPrecision(display_units);
- ((WaterfallZoomer*)d_zoomer)->setUnitType(strunits);
- }
- }
-}
+ bool reset = false;
+ if ((startFreq != d_start_frequency) || (stopFreq != d_stop_frequency))
+ reset = true;
+ if (stopFreq > startFreq) {
+ d_start_frequency = startFreq;
+ d_stop_frequency = stopFreq;
+ d_center_frequency = centerfreq / units;
-double
-WaterfallDisplayPlot::getStartFrequency() const
-{
- return d_start_frequency;
-}
+ if ((axisScaleDraw(QwtPlot::xBottom) != NULL) && (d_zoomer != NULL)) {
+ double display_units = ceil(log10(units) / 2.0);
+ setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(display_units));
+ setAxisTitle(QwtPlot::xBottom,
+ QString("Frequency (%1)").arg(strunits.c_str()));
-double
-WaterfallDisplayPlot::getStopFrequency() const
-{
- return d_stop_frequency;
-}
+ if (reset) {
+ resetAxis();
+ }
-void
-WaterfallDisplayPlot::plotNewData(const std::vector<double*> dataPoints,
- const int64_t numDataPoints,
- const double timePerFFT,
- const gr::high_res_timer_type timestamp,
- const int droppedFrames)
-{
- int64_t _npoints_in = d_half_freq ? numDataPoints/2 : numDataPoints;
- int64_t _in_index = d_half_freq ? _npoints_in : 0;
-
- if(!d_stop) {
- if(_npoints_in > 0 && timestamp == 0){
- d_numPoints = _npoints_in/d_nrows;
- resetAxis();
-
- // If not displaying just the positive half of the spectrum,
- // plot the full thing now.
- if(!d_half_freq) {
- for(unsigned int i = 0; i < d_nplots; ++i) {
- d_data[i]->setSpectrumDataBuffer(dataPoints[i]);
- d_data[i]->setNumLinesToUpdate(0);
- d_spectrogram[i]->invalidateCache();
- d_spectrogram[i]->itemChanged();
+ ((WaterfallZoomer*)d_zoomer)->setFrequencyPrecision(display_units);
+ ((WaterfallZoomer*)d_zoomer)->setUnitType(strunits);
}
- }
-
- // Otherwise, loop through our input data vector and only plot
- // the second half of each row.
- else {
- for(unsigned int i = 0; i < d_nplots; ++i) {
- d_data[i]->setSpectrumDataBuffer(&(dataPoints[i][d_numPoints]));
- for(int n = 1; n < d_nrows; n++) {
- d_data[i]->addFFTData(&(dataPoints[i][d_numPoints + 2*n*d_numPoints]),
- d_numPoints, 0);
- d_data[i]->incrementNumLinesToUpdate();
- }
- d_spectrogram[i]->invalidateCache();
- d_spectrogram[i]->itemChanged();
- }
- }
-
- QwtTimeScaleDraw* timeScale = (QwtTimeScaleDraw*)axisScaleDraw(QwtPlot::yLeft);
- timeScale->setSecondsPerLine(timePerFFT);
- timeScale->setZeroTime(timestamp);
- timeScale->initiateUpdate();
-
- ((WaterfallZoomer*)d_zoomer)->setSecondsPerLine(timePerFFT);
- ((WaterfallZoomer*)d_zoomer)->setZeroTime(timestamp);
- replot();
}
+}
- else if(_npoints_in > 0) {
- if(_npoints_in != d_numPoints) {
- d_numPoints = _npoints_in;
- resetAxis();
- for(unsigned int i = 0; i < d_nplots; ++i) {
- d_spectrogram[i]->invalidateCache();
- d_spectrogram[i]->itemChanged();
+double WaterfallDisplayPlot::getStartFrequency() const { return d_start_frequency; }
+
+double WaterfallDisplayPlot::getStopFrequency() const { return d_stop_frequency; }
+
+void WaterfallDisplayPlot::plotNewData(const std::vector<double*> dataPoints,
+ const int64_t numDataPoints,
+ const double timePerFFT,
+ const gr::high_res_timer_type timestamp,
+ const int droppedFrames)
+{
+ int64_t _npoints_in = d_half_freq ? numDataPoints / 2 : numDataPoints;
+ int64_t _in_index = d_half_freq ? _npoints_in : 0;
+
+ if (!d_stop) {
+ if (_npoints_in > 0 && timestamp == 0) {
+ d_numPoints = _npoints_in / d_nrows;
+ resetAxis();
+
+ // If not displaying just the positive half of the spectrum,
+ // plot the full thing now.
+ if (!d_half_freq) {
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ d_data[i]->setSpectrumDataBuffer(dataPoints[i]);
+ d_data[i]->setNumLinesToUpdate(0);
+ d_spectrogram[i]->invalidateCache();
+ d_spectrogram[i]->itemChanged();
+ }
+ }
+
+ // Otherwise, loop through our input data vector and only plot
+ // the second half of each row.
+ else {
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ d_data[i]->setSpectrumDataBuffer(&(dataPoints[i][d_numPoints]));
+ for (int n = 1; n < d_nrows; n++) {
+ d_data[i]->addFFTData(
+ &(dataPoints[i][d_numPoints + 2 * n * d_numPoints]),
+ d_numPoints,
+ 0);
+ d_data[i]->incrementNumLinesToUpdate();
+ }
+ d_spectrogram[i]->invalidateCache();
+ d_spectrogram[i]->itemChanged();
+ }
+ }
+
+ QwtTimeScaleDraw* timeScale =
+ (QwtTimeScaleDraw*)axisScaleDraw(QwtPlot::yLeft);
+ timeScale->setSecondsPerLine(timePerFFT);
+ timeScale->setZeroTime(timestamp);
+ timeScale->initiateUpdate();
+
+ ((WaterfallZoomer*)d_zoomer)->setSecondsPerLine(timePerFFT);
+ ((WaterfallZoomer*)d_zoomer)->setZeroTime(timestamp);
+ replot();
}
- if(isVisible()) {
- replot();
+ else if (_npoints_in > 0) {
+ if (_npoints_in != d_numPoints) {
+ d_numPoints = _npoints_in;
+ resetAxis();
+
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ d_spectrogram[i]->invalidateCache();
+ d_spectrogram[i]->itemChanged();
+ }
+
+ if (isVisible()) {
+ replot();
+ }
+ }
+
+ QwtTimeScaleDraw* timeScale =
+ (QwtTimeScaleDraw*)axisScaleDraw(QwtPlot::yLeft);
+ timeScale->setSecondsPerLine(timePerFFT);
+ timeScale->setZeroTime(timestamp);
+
+ ((WaterfallZoomer*)d_zoomer)->setSecondsPerLine(timePerFFT);
+ ((WaterfallZoomer*)d_zoomer)->setZeroTime(timestamp);
+
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ d_data[i]->addFFTData(
+ &(dataPoints[i][_in_index]), _npoints_in, droppedFrames);
+ d_data[i]->incrementNumLinesToUpdate();
+ d_spectrogram[i]->invalidateCache();
+ d_spectrogram[i]->itemChanged();
+ }
+
+ replot();
}
- }
-
- QwtTimeScaleDraw* timeScale = (QwtTimeScaleDraw*)axisScaleDraw(QwtPlot::yLeft);
- timeScale->setSecondsPerLine(timePerFFT);
- timeScale->setZeroTime(timestamp);
-
- ((WaterfallZoomer*)d_zoomer)->setSecondsPerLine(timePerFFT);
- ((WaterfallZoomer*)d_zoomer)->setZeroTime(timestamp);
-
- for(unsigned int i = 0; i < d_nplots; ++i) {
- d_data[i]->addFFTData(&(dataPoints[i][_in_index]),
- _npoints_in, droppedFrames);
- d_data[i]->incrementNumLinesToUpdate();
- d_spectrogram[i]->invalidateCache();
- d_spectrogram[i]->itemChanged();
- }
-
- replot();
}
- }
}
-void
-WaterfallDisplayPlot::plotNewData(const double* dataPoints,
- const int64_t numDataPoints,
- const double timePerFFT,
- const gr::high_res_timer_type timestamp,
- const int droppedFrames)
+void WaterfallDisplayPlot::plotNewData(const double* dataPoints,
+ const int64_t numDataPoints,
+ const double timePerFFT,
+ const gr::high_res_timer_type timestamp,
+ const int droppedFrames)
{
- std::vector<double*> vecDataPoints;
- vecDataPoints.push_back((double*)dataPoints);
- plotNewData(vecDataPoints, numDataPoints, timePerFFT,
- timestamp, droppedFrames);
+ std::vector<double*> vecDataPoints;
+ vecDataPoints.push_back((double*)dataPoints);
+ plotNewData(vecDataPoints, numDataPoints, timePerFFT, timestamp, droppedFrames);
}
-void
-WaterfallDisplayPlot::setIntensityRange(const double minIntensity,
- const double maxIntensity)
+void WaterfallDisplayPlot::setIntensityRange(const double minIntensity,
+ const double maxIntensity)
{
- for(unsigned int i = 0; i < d_nplots; ++i) {
+ for (unsigned int i = 0; i < d_nplots; ++i) {
#if QWT_VERSION < 0x060000
- d_data[i]->setRange(QwtDoubleInterval(minIntensity, maxIntensity));
+ d_data[i]->setRange(QwtDoubleInterval(minIntensity, maxIntensity));
#else
- d_data[i]->setInterval(Qt::ZAxis, QwtInterval(minIntensity, maxIntensity));
+ d_data[i]->setInterval(Qt::ZAxis, QwtInterval(minIntensity, maxIntensity));
#endif
- emit updatedLowerIntensityLevel(minIntensity);
- emit updatedUpperIntensityLevel(maxIntensity);
+ emit updatedLowerIntensityLevel(minIntensity);
+ emit updatedUpperIntensityLevel(maxIntensity);
- _updateIntensityRangeDisplay();
- }
+ _updateIntensityRangeDisplay();
+ }
}
-double
-WaterfallDisplayPlot::getMinIntensity(unsigned int which) const
+double WaterfallDisplayPlot::getMinIntensity(unsigned int which) const
{
#if QWT_VERSION < 0x060000
- QwtDoubleInterval r = d_data[which]->range();
+ QwtDoubleInterval r = d_data[which]->range();
#else
- QwtInterval r = d_data[which]->interval(Qt::ZAxis);
+ QwtInterval r = d_data[which]->interval(Qt::ZAxis);
#endif
- return r.minValue();
+ return r.minValue();
}
-double
-WaterfallDisplayPlot::getMaxIntensity(unsigned int which) const
+double WaterfallDisplayPlot::getMaxIntensity(unsigned int which) const
{
#if QWT_VERSION < 0x060000
- QwtDoubleInterval r = d_data[which]->range();
+ QwtDoubleInterval r = d_data[which]->range();
#else
- QwtInterval r = d_data[which]->interval(Qt::ZAxis);
+ QwtInterval r = d_data[which]->interval(Qt::ZAxis);
#endif
- return r.maxValue();
+ return r.maxValue();
}
-int
-WaterfallDisplayPlot::getColorMapTitleFontSize() const
+int WaterfallDisplayPlot::getColorMapTitleFontSize() const
{
- return d_color_bar_title_font_size;
+ return d_color_bar_title_font_size;
}
-void
-WaterfallDisplayPlot::setColorMapTitleFontSize(int tfs)
+void WaterfallDisplayPlot::setColorMapTitleFontSize(int tfs)
{
- d_color_bar_title_font_size = tfs;
+ d_color_bar_title_font_size = tfs;
}
-void
-WaterfallDisplayPlot::replot()
+void WaterfallDisplayPlot::replot()
{
- QwtTimeScaleDraw* timeScale = (QwtTimeScaleDraw*)axisScaleDraw(QwtPlot::yLeft);
- timeScale->initiateUpdate();
+ QwtTimeScaleDraw* timeScale = (QwtTimeScaleDraw*)axisScaleDraw(QwtPlot::yLeft);
+ timeScale->initiateUpdate();
- FreqDisplayScaleDraw* freqScale = \
- (FreqDisplayScaleDraw*)axisScaleDraw(QwtPlot::xBottom);
- freqScale->initiateUpdate();
+ FreqDisplayScaleDraw* freqScale =
+ (FreqDisplayScaleDraw*)axisScaleDraw(QwtPlot::xBottom);
+ freqScale->initiateUpdate();
- // Update the time axis display
- if(axisWidget(QwtPlot::yLeft) != NULL){
- axisWidget(QwtPlot::yLeft)->update();
- }
+ // Update the time axis display
+ if (axisWidget(QwtPlot::yLeft) != NULL) {
+ axisWidget(QwtPlot::yLeft)->update();
+ }
- // Update the Frequency Offset Display
- if(axisWidget(QwtPlot::xBottom) != NULL){
- axisWidget(QwtPlot::xBottom)->update();
- }
+ // Update the Frequency Offset Display
+ if (axisWidget(QwtPlot::xBottom) != NULL) {
+ axisWidget(QwtPlot::xBottom)->update();
+ }
- if(d_zoomer != NULL){
- ((WaterfallZoomer*)d_zoomer)->updateTrackerText();
- }
+ if (d_zoomer != NULL) {
+ ((WaterfallZoomer*)d_zoomer)->updateTrackerText();
+ }
- QwtPlot::replot();
+ QwtPlot::replot();
}
-void
-WaterfallDisplayPlot::clearData()
+void WaterfallDisplayPlot::clearData()
{
- for(unsigned int i = 0; i < d_nplots; ++i) {
- d_data[i]->reset();
- }
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ d_data[i]->reset();
+ }
}
-int
-WaterfallDisplayPlot::getIntensityColorMapType(unsigned int which) const
+int WaterfallDisplayPlot::getIntensityColorMapType(unsigned int which) const
{
- return d_intensity_color_map_type[which];
+ return d_intensity_color_map_type[which];
}
-void
-WaterfallDisplayPlot::setIntensityColorMapType(const unsigned int which,
- const int newType,
- const QColor lowColor,
- const QColor highColor)
+void WaterfallDisplayPlot::setIntensityColorMapType(const unsigned int which,
+ const int newType,
+ const QColor lowColor,
+ const QColor highColor)
{
- if((d_intensity_color_map_type[which] != newType) ||
- ((newType == INTENSITY_COLOR_MAP_TYPE_USER_DEFINED) &&
- (lowColor.isValid() && highColor.isValid()))){
- switch(newType){
- case INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR:{
- d_intensity_color_map_type[which] = newType;
+ if ((d_intensity_color_map_type[which] != newType) ||
+ ((newType == INTENSITY_COLOR_MAP_TYPE_USER_DEFINED) &&
+ (lowColor.isValid() && highColor.isValid()))) {
+ switch (newType) {
+ case INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR: {
+ d_intensity_color_map_type[which] = newType;
#if QWT_VERSION < 0x060000
- ColorMap_MultiColor colorMap;
- d_spectrogram[which]->setColorMap(colorMap);
+ ColorMap_MultiColor colorMap;
+ d_spectrogram[which]->setColorMap(colorMap);
#else
- d_spectrogram[which]->setColorMap(new ColorMap_MultiColor());
+ d_spectrogram[which]->setColorMap(new ColorMap_MultiColor());
#endif
- break;
- }
- case INTENSITY_COLOR_MAP_TYPE_WHITE_HOT:{
- d_intensity_color_map_type[which] = newType;
+ break;
+ }
+ case INTENSITY_COLOR_MAP_TYPE_WHITE_HOT: {
+ d_intensity_color_map_type[which] = newType;
#if QWT_VERSION < 0x060000
- ColorMap_WhiteHot colorMap;
- d_spectrogram[which]->setColorMap(colorMap);
+ ColorMap_WhiteHot colorMap;
+ d_spectrogram[which]->setColorMap(colorMap);
#else
- d_spectrogram[which]->setColorMap(new ColorMap_WhiteHot());
+ d_spectrogram[which]->setColorMap(new ColorMap_WhiteHot());
#endif
- break;
- }
- case INTENSITY_COLOR_MAP_TYPE_BLACK_HOT:{
- d_intensity_color_map_type[which] = newType;
+ break;
+ }
+ case INTENSITY_COLOR_MAP_TYPE_BLACK_HOT: {
+ d_intensity_color_map_type[which] = newType;
#if QWT_VERSION < 0x060000
- ColorMap_BlackHot colorMap;
- d_spectrogram[which]->setColorMap(colorMap);
+ ColorMap_BlackHot colorMap;
+ d_spectrogram[which]->setColorMap(colorMap);
#else
- d_spectrogram[which]->setColorMap(new ColorMap_BlackHot());
+ d_spectrogram[which]->setColorMap(new ColorMap_BlackHot());
#endif
- break;
- }
- case INTENSITY_COLOR_MAP_TYPE_INCANDESCENT:{
- d_intensity_color_map_type[which] = newType;
+ break;
+ }
+ case INTENSITY_COLOR_MAP_TYPE_INCANDESCENT: {
+ d_intensity_color_map_type[which] = newType;
#if QWT_VERSION < 0x060000
- ColorMap_Incandescent colorMap;
- d_spectrogram[which]->setColorMap(colorMap);
+ ColorMap_Incandescent colorMap;
+ d_spectrogram[which]->setColorMap(colorMap);
#else
- d_spectrogram[which]->setColorMap(new ColorMap_Incandescent());
+ d_spectrogram[which]->setColorMap(new ColorMap_Incandescent());
#endif
- break;
- }
- case INTENSITY_COLOR_MAP_TYPE_SUNSET: {
- d_intensity_color_map_type[which] = newType;
+ break;
+ }
+ case INTENSITY_COLOR_MAP_TYPE_SUNSET: {
+ d_intensity_color_map_type[which] = newType;
#if QWT_VERSION < 0x060000
- ColorMap_Sunset colorMap;
- d_spectrogram[which]->setColorMap(colorMap);
+ ColorMap_Sunset colorMap;
+ d_spectrogram[which]->setColorMap(colorMap);
#else
- d_spectrogram[which]->setColorMap(new ColorMap_Sunset());
+ d_spectrogram[which]->setColorMap(new ColorMap_Sunset());
#endif
- break;
- }
- case INTENSITY_COLOR_MAP_TYPE_COOL: {
- d_intensity_color_map_type[which] = newType;
+ break;
+ }
+ case INTENSITY_COLOR_MAP_TYPE_COOL: {
+ d_intensity_color_map_type[which] = newType;
#if QWT_VERSION < 0x060000
- ColorMap_Cool colorMap;
- d_spectrogram[which]->setColorMap(colorMap);
+ ColorMap_Cool colorMap;
+ d_spectrogram[which]->setColorMap(colorMap);
#else
- d_spectrogram[which]->setColorMap(new ColorMap_Cool());
+ d_spectrogram[which]->setColorMap(new ColorMap_Cool());
#endif
- break;
- }
- case INTENSITY_COLOR_MAP_TYPE_USER_DEFINED:{
- d_user_defined_low_intensity_color = lowColor;
- d_user_defined_high_intensity_color = highColor;
- d_intensity_color_map_type[which] = newType;
+ break;
+ }
+ case INTENSITY_COLOR_MAP_TYPE_USER_DEFINED: {
+ d_user_defined_low_intensity_color = lowColor;
+ d_user_defined_high_intensity_color = highColor;
+ d_intensity_color_map_type[which] = newType;
#if QWT_VERSION < 0x060000
- ColorMap_UserDefined colorMap(lowColor, highColor);
- d_spectrogram[which]->setColorMap(colorMap);
+ ColorMap_UserDefined colorMap(lowColor, highColor);
+ d_spectrogram[which]->setColorMap(colorMap);
#else
- d_spectrogram[which]->setColorMap(new ColorMap_UserDefined(lowColor, highColor));
+ d_spectrogram[which]->setColorMap(
+ new ColorMap_UserDefined(lowColor, highColor));
#endif
- break;
- }
- default: break;
- }
+ break;
+ }
+ default:
+ break;
+ }
- _updateIntensityRangeDisplay();
- }
+ _updateIntensityRangeDisplay();
+ }
}
-void
-WaterfallDisplayPlot::setIntensityColorMapType1(int newType)
+void WaterfallDisplayPlot::setIntensityColorMapType1(int newType)
{
- setIntensityColorMapType(0, newType, d_user_defined_low_intensity_color,
- d_user_defined_high_intensity_color);
+ setIntensityColorMapType(0,
+ newType,
+ d_user_defined_low_intensity_color,
+ d_user_defined_high_intensity_color);
}
-int
-WaterfallDisplayPlot::getIntensityColorMapType1() const
+int WaterfallDisplayPlot::getIntensityColorMapType1() const
{
- return getIntensityColorMapType(0);
+ return getIntensityColorMapType(0);
}
-void
-WaterfallDisplayPlot::setUserDefinedLowIntensityColor(QColor c)
+void WaterfallDisplayPlot::setUserDefinedLowIntensityColor(QColor c)
{
- d_user_defined_low_intensity_color = c;
+ d_user_defined_low_intensity_color = c;
}
-const QColor
-WaterfallDisplayPlot::getUserDefinedLowIntensityColor() const
+const QColor WaterfallDisplayPlot::getUserDefinedLowIntensityColor() const
{
- return d_user_defined_low_intensity_color;
+ return d_user_defined_low_intensity_color;
}
-void
-WaterfallDisplayPlot::setUserDefinedHighIntensityColor(QColor c)
+void WaterfallDisplayPlot::setUserDefinedHighIntensityColor(QColor c)
{
- d_user_defined_high_intensity_color = c;
+ d_user_defined_high_intensity_color = c;
}
-const QColor
-WaterfallDisplayPlot::getUserDefinedHighIntensityColor() const
+const QColor WaterfallDisplayPlot::getUserDefinedHighIntensityColor() const
{
- return d_user_defined_high_intensity_color;
+ return d_user_defined_high_intensity_color;
}
-int
-WaterfallDisplayPlot::getAlpha(unsigned int which)
+int WaterfallDisplayPlot::getAlpha(unsigned int which)
{
- return d_spectrogram[which]->alpha();
+ return d_spectrogram[which]->alpha();
}
-void
-WaterfallDisplayPlot::setAlpha(unsigned int which, int alpha)
+void WaterfallDisplayPlot::setAlpha(unsigned int which, int alpha)
{
- d_spectrogram[which]->setAlpha(alpha);
+ d_spectrogram[which]->setAlpha(alpha);
}
-int
-WaterfallDisplayPlot::getNumRows() const
-{
- return d_nrows;
-}
+int WaterfallDisplayPlot::getNumRows() const { return d_nrows; }
-void
-WaterfallDisplayPlot::_updateIntensityRangeDisplay()
+void WaterfallDisplayPlot::_updateIntensityRangeDisplay()
{
- QwtScaleWidget *rightAxis = axisWidget(QwtPlot::yRight);
- QwtText colorBarTitle("Intensity (dB)");
- colorBarTitle.setFont(QFont("Arial",d_color_bar_title_font_size));
- rightAxis->setTitle(colorBarTitle);
- rightAxis->setColorBarEnabled(true);
+ QwtScaleWidget* rightAxis = axisWidget(QwtPlot::yRight);
+ QwtText colorBarTitle("Intensity (dB)");
+ colorBarTitle.setFont(QFont("Arial", d_color_bar_title_font_size));
+ rightAxis->setTitle(colorBarTitle);
+ rightAxis->setColorBarEnabled(true);
- for(unsigned int i = 0; i < d_nplots; ++i) {
+ for (unsigned int i = 0; i < d_nplots; ++i) {
#if QWT_VERSION < 0x060000
- rightAxis->setColorMap(d_spectrogram[i]->data()->range(),
- d_spectrogram[i]->colorMap());
- setAxisScale(QwtPlot::yRight,
- d_spectrogram[i]->data()->range().minValue(),
- d_spectrogram[i]->data()->range().maxValue());
+ rightAxis->setColorMap(d_spectrogram[i]->data()->range(),
+ d_spectrogram[i]->colorMap());
+ setAxisScale(QwtPlot::yRight,
+ d_spectrogram[i]->data()->range().minValue(),
+ d_spectrogram[i]->data()->range().maxValue());
#else
- QwtInterval intv = d_spectrogram[i]->interval(Qt::ZAxis);
- switch(d_intensity_color_map_type[i]) {
- case INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR:
- rightAxis->setColorMap(intv, new ColorMap_MultiColor()); break;
- case INTENSITY_COLOR_MAP_TYPE_WHITE_HOT:
- rightAxis->setColorMap(intv, new ColorMap_WhiteHot()); break;
- case INTENSITY_COLOR_MAP_TYPE_BLACK_HOT:
- rightAxis->setColorMap(intv, new ColorMap_BlackHot()); break;
- case INTENSITY_COLOR_MAP_TYPE_INCANDESCENT:
- rightAxis->setColorMap(intv, new ColorMap_Incandescent()); break;
- case INTENSITY_COLOR_MAP_TYPE_SUNSET:
- rightAxis->setColorMap(intv, new ColorMap_Sunset()); break;
- case INTENSITY_COLOR_MAP_TYPE_COOL:
- rightAxis->setColorMap(intv, new ColorMap_Cool()); break;
- case INTENSITY_COLOR_MAP_TYPE_USER_DEFINED:
- rightAxis->setColorMap(intv, new ColorMap_UserDefined(d_user_defined_low_intensity_color,
- d_user_defined_high_intensity_color));
- break;
- default:
- rightAxis->setColorMap(intv, new ColorMap_MultiColor()); break;
- }
- setAxisScale(QwtPlot::yRight, intv.minValue(), intv.maxValue());
+ QwtInterval intv = d_spectrogram[i]->interval(Qt::ZAxis);
+ switch (d_intensity_color_map_type[i]) {
+ case INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR:
+ rightAxis->setColorMap(intv, new ColorMap_MultiColor());
+ break;
+ case INTENSITY_COLOR_MAP_TYPE_WHITE_HOT:
+ rightAxis->setColorMap(intv, new ColorMap_WhiteHot());
+ break;
+ case INTENSITY_COLOR_MAP_TYPE_BLACK_HOT:
+ rightAxis->setColorMap(intv, new ColorMap_BlackHot());
+ break;
+ case INTENSITY_COLOR_MAP_TYPE_INCANDESCENT:
+ rightAxis->setColorMap(intv, new ColorMap_Incandescent());
+ break;
+ case INTENSITY_COLOR_MAP_TYPE_SUNSET:
+ rightAxis->setColorMap(intv, new ColorMap_Sunset());
+ break;
+ case INTENSITY_COLOR_MAP_TYPE_COOL:
+ rightAxis->setColorMap(intv, new ColorMap_Cool());
+ break;
+ case INTENSITY_COLOR_MAP_TYPE_USER_DEFINED:
+ rightAxis->setColorMap(
+ intv,
+ new ColorMap_UserDefined(d_user_defined_low_intensity_color,
+ d_user_defined_high_intensity_color));
+ break;
+ default:
+ rightAxis->setColorMap(intv, new ColorMap_MultiColor());
+ break;
+ }
+ setAxisScale(QwtPlot::yRight, intv.minValue(), intv.maxValue());
#endif
- plotLayout()->setAlignCanvasToScales(true);
+ plotLayout()->setAlignCanvasToScales(true);
- // Tell the display to redraw everything
- d_spectrogram[i]->invalidateCache();
- d_spectrogram[i]->itemChanged();
- }
+ // Tell the display to redraw everything
+ d_spectrogram[i]->invalidateCache();
+ d_spectrogram[i]->itemChanged();
+ }
- // Draw again
- replot();
+ // Draw again
+ replot();
}
-void
-WaterfallDisplayPlot::disableLegend()
+void WaterfallDisplayPlot::disableLegend()
{
- d_legend_enabled = false;
- enableAxis(QwtPlot::yRight, false);
+ d_legend_enabled = false;
+ enableAxis(QwtPlot::yRight, false);
}
-void
-WaterfallDisplayPlot::enableLegend()
+void WaterfallDisplayPlot::enableLegend()
{
- d_legend_enabled = true;
- enableAxis(QwtPlot::yRight, true);
+ d_legend_enabled = true;
+ enableAxis(QwtPlot::yRight, true);
}
-void
-WaterfallDisplayPlot::enableLegend(bool en)
+void WaterfallDisplayPlot::enableLegend(bool en)
{
- d_legend_enabled = en;
- enableAxis(QwtPlot::yRight, en);
+ d_legend_enabled = en;
+ enableAxis(QwtPlot::yRight, en);
}
-void
-WaterfallDisplayPlot::setNumRows(int nrows)
-{
- d_nrows = nrows;
-}
+void WaterfallDisplayPlot::setNumRows(int nrows) { d_nrows = nrows; }
-void
-WaterfallDisplayPlot::setPlotPosHalf(bool half)
+void WaterfallDisplayPlot::setPlotPosHalf(bool half)
{
- d_half_freq = half;
- if(half)
- d_start_frequency = d_center_frequency;
+ d_half_freq = half;
+ if (half)
+ d_start_frequency = d_center_frequency;
}
diff --git a/gr-qtgui/lib/ber_sink_b_impl.cc b/gr-qtgui/lib/ber_sink_b_impl.cc
index 5c9c447cc9..b2f98981ce 100644
--- a/gr-qtgui/lib/ber_sink_b_impl.cc
+++ b/gr-qtgui/lib/ber_sink_b_impl.cc
@@ -33,370 +33,327 @@
#endif
namespace gr {
- namespace qtgui {
-
- ber_sink_b::sptr
- ber_sink_b::make(std::vector<float> esnos, int curves,
- int ber_min_errors, float ber_limit,
- std::vector<std::string> curvenames,
- QWidget *parent)
- {
- return gnuradio::get_initial_sptr
- (new ber_sink_b_impl(esnos, curves,
- ber_min_errors, ber_limit,
- curvenames, parent));
+namespace qtgui {
+
+ber_sink_b::sptr ber_sink_b::make(std::vector<float> esnos,
+ int curves,
+ int ber_min_errors,
+ float ber_limit,
+ std::vector<std::string> curvenames,
+ QWidget* parent)
+{
+ return gnuradio::get_initial_sptr(new ber_sink_b_impl(
+ esnos, curves, ber_min_errors, ber_limit, curvenames, parent));
+}
+
+ber_sink_b_impl::ber_sink_b_impl(std::vector<float> esnos,
+ int curves,
+ int ber_min_errors,
+ float ber_limit,
+ std::vector<std::string> curvenames,
+ QWidget* parent)
+ : block("ber_sink_b",
+ io_signature::make(curves * esnos.size() * 2,
+ curves * esnos.size() * 2,
+ sizeof(unsigned char)),
+ io_signature::make(0, 0, 0)),
+ d_ber_min_errors(ber_min_errors),
+ d_ber_limit(ber_limit),
+ d_parent(parent),
+ d_nconnections(esnos.size()),
+ d_last_time(0)
+{
+ d_main_gui = NULL;
+
+ // Enough curves for the input streams plus the BPSK AWGN curve.
+ d_curves = curves;
+ d_esno_buffers.reserve(curves + 1);
+ d_ber_buffers.reserve(curves + 1);
+ d_total.reserve(curves * esnos.size());
+ d_total_errors.reserve(curves * esnos.size());
+
+ for (int j = 0; j < curves; j++) {
+ d_esno_buffers.push_back(
+ (double*)volk_malloc(esnos.size() * sizeof(double), volk_get_alignment()));
+ d_ber_buffers.push_back(
+ (double*)volk_malloc(esnos.size() * sizeof(double), volk_get_alignment()));
+
+ for (int i = 0; i < d_nconnections; i++) {
+ d_esno_buffers[j][i] = esnos[i];
+ d_ber_buffers[j][i] = 0.0;
+ d_total.push_back(0);
+ d_total_errors.push_back(1);
+ }
}
- ber_sink_b_impl::ber_sink_b_impl(std::vector<float> esnos, int curves,
- int ber_min_errors, float ber_limit,
- std::vector<std::string> curvenames,
- QWidget *parent)
- : block("ber_sink_b",
- io_signature::make(curves*esnos.size()*2, curves*esnos.size()*2, sizeof(unsigned char)),
- io_signature::make(0, 0, 0)),
- d_ber_min_errors(ber_min_errors),
- d_ber_limit(ber_limit),
- d_parent(parent),
- d_nconnections(esnos.size()),
- d_last_time(0)
- {
- d_main_gui = NULL;
-
- // Enough curves for the input streams plus the BPSK AWGN curve.
- d_curves = curves;
- d_esno_buffers.reserve(curves + 1);
- d_ber_buffers.reserve(curves + 1);
- d_total.reserve(curves * esnos.size());
- d_total_errors.reserve(curves * esnos.size());
-
- for(int j = 0; j < curves; j++) {
- d_esno_buffers.push_back((double*)volk_malloc(esnos.size()*sizeof(double),
- volk_get_alignment()));
- d_ber_buffers.push_back((double*)volk_malloc(esnos.size()*sizeof(double),
- volk_get_alignment()));
-
- for(int i = 0; i < d_nconnections; i++) {
- d_esno_buffers[j][i] = esnos[i];
- d_ber_buffers[j][i] = 0.0;
- d_total.push_back(0);
- d_total_errors.push_back(1);
- }
- }
-
- // Now add the known curves
- d_esno_buffers.push_back((double*)volk_malloc(esnos.size()*sizeof(double),
- volk_get_alignment()));
- d_ber_buffers.push_back((double*)volk_malloc(esnos.size()*sizeof(double),
- volk_get_alignment()));
- for(size_t i = 0; i < esnos.size(); i++) {
- double e = pow(10.0, esnos[i]/10.0);
+ // Now add the known curves
+ d_esno_buffers.push_back(
+ (double*)volk_malloc(esnos.size() * sizeof(double), volk_get_alignment()));
+ d_ber_buffers.push_back(
+ (double*)volk_malloc(esnos.size() * sizeof(double), volk_get_alignment()));
+ for (size_t i = 0; i < esnos.size(); i++) {
+ double e = pow(10.0, esnos[i] / 10.0);
d_esno_buffers[curves][i] = esnos[i];
- d_ber_buffers[curves][i] = std::log10(0.5*std::erf(std::sqrt(e)));
- }
+ d_ber_buffers[curves][i] = std::log10(0.5 * std::erf(std::sqrt(e)));
+ }
- // Initialize and set up some of the curve visual properties
- initialize();
- for(int j= 0; j < curves; j++) {
+ // Initialize and set up some of the curve visual properties
+ initialize();
+ for (int j = 0; j < curves; j++) {
set_line_width(j, 1);
- //35 unique styles supported
- set_line_style(j, (j%5) + 1);
- set_line_marker(j, (j%7));
- }
-
- if(curvenames.size() == (unsigned int)curves) {
- for(int j = 0; j < curves; j++) {
- if(curvenames[j] != "") {
- set_line_label(j, curvenames[j]);
- }
- }
- }
+ // 35 unique styles supported
+ set_line_style(j, (j % 5) + 1);
+ set_line_marker(j, (j % 7));
+ }
- set_line_label(d_curves, "BPSK AWGN");
- set_line_style(d_curves, 5); // non-solid line
- set_line_marker(d_curves, -1); // no marker
- set_line_alpha(d_curves, 0.25); // high transparency
+ if (curvenames.size() == (unsigned int)curves) {
+ for (int j = 0; j < curves; j++) {
+ if (curvenames[j] != "") {
+ set_line_label(j, curvenames[j]);
+ }
+ }
}
- ber_sink_b_impl::~ber_sink_b_impl()
- {
- if(!d_main_gui->isClosed()) {
- d_main_gui->close();
- }
+ set_line_label(d_curves, "BPSK AWGN");
+ set_line_style(d_curves, 5); // non-solid line
+ set_line_marker(d_curves, -1); // no marker
+ set_line_alpha(d_curves, 0.25); // high transparency
+}
- for(unsigned int i = 0; i < d_esno_buffers.size(); i++) {
- volk_free(d_esno_buffers[i]);
- volk_free(d_ber_buffers[i]);
- }
+ber_sink_b_impl::~ber_sink_b_impl()
+{
+ if (!d_main_gui->isClosed()) {
+ d_main_gui->close();
}
- bool
- ber_sink_b_impl::check_topology(int ninputs, int noutputs)
- {
- return ninputs == (int)(d_curves * d_nconnections * 2);
+ for (unsigned int i = 0; i < d_esno_buffers.size(); i++) {
+ volk_free(d_esno_buffers[i]);
+ volk_free(d_ber_buffers[i]);
}
+}
- void
- ber_sink_b_impl::initialize()
- {
- if(qApp != NULL) {
+bool ber_sink_b_impl::check_topology(int ninputs, int noutputs)
+{
+ return ninputs == (int)(d_curves * d_nconnections * 2);
+}
+
+void ber_sink_b_impl::initialize()
+{
+ if (qApp != NULL) {
d_qApplication = qApp;
- }
- else {
- int argc=0;
- char **argv = NULL;
+ } else {
+ int argc = 0;
+ char** argv = NULL;
d_qApplication = new QApplication(argc, argv);
- }
+ }
- d_main_gui = new ConstellationDisplayForm(d_esno_buffers.size(), d_parent);
+ d_main_gui = new ConstellationDisplayForm(d_esno_buffers.size(), d_parent);
- d_main_gui->setNPoints(d_nconnections);
- d_main_gui->getPlot()->setAxisTitle(QwtPlot::yLeft, "LogScale BER");
- d_main_gui->getPlot()->setAxisTitle(QwtPlot::xBottom, "ESNO");
- // initialize update time to 10 times a second
- set_update_time(0.1);
- }
+ d_main_gui->setNPoints(d_nconnections);
+ d_main_gui->getPlot()->setAxisTitle(QwtPlot::yLeft, "LogScale BER");
+ d_main_gui->getPlot()->setAxisTitle(QwtPlot::xBottom, "ESNO");
+ // initialize update time to 10 times a second
+ set_update_time(0.1);
+}
- void
- ber_sink_b_impl::exec_()
- {
- d_qApplication->exec();
- }
+void ber_sink_b_impl::exec_() { d_qApplication->exec(); }
- QWidget*
- ber_sink_b_impl::qwidget()
- {
- return d_main_gui;
- }
+QWidget* ber_sink_b_impl::qwidget() { return d_main_gui; }
#ifdef ENABLE_PYTHON
- PyObject*
- ber_sink_b_impl::pyqwidget()
- {
- PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui);
- PyObject *retarg = Py_BuildValue("N", w);
- return retarg;
- }
+PyObject* ber_sink_b_impl::pyqwidget()
+{
+ PyObject* w = PyLong_FromVoidPtr((void*)d_main_gui);
+ PyObject* retarg = Py_BuildValue("N", w);
+ return retarg;
+}
#else
- void *
- ber_sink_b_impl::pyqwidget()
- {
- return NULL;
- }
+void* ber_sink_b_impl::pyqwidget() { return NULL; }
#endif
- void
- ber_sink_b_impl::set_y_axis(double min, double max)
- {
- d_main_gui->setYaxis(min, max);
- }
-
- void
- ber_sink_b_impl::set_x_axis(double min, double max)
- {
- d_main_gui->setXaxis(min, max);
- }
-
- void
- ber_sink_b_impl::set_update_time(double t)
- {
- //convert update time to ticks
- gr::high_res_timer_type tps = gr::high_res_timer_tps();
- d_update_time = t * tps;
- d_main_gui->setUpdateTime(t);
- d_last_time = 0;
- }
-
- void
- ber_sink_b_impl::set_title(const std::string &title)
- {
- d_main_gui->setTitle(title.c_str());
- }
-
- void
- ber_sink_b_impl::set_line_label(unsigned int which, const std::string &label)
- {
- d_main_gui->setLineLabel(which, label.c_str());
- }
-
- void
- ber_sink_b_impl::set_line_color(unsigned int which, const std::string &color)
- {
- d_main_gui->setLineColor(which, color.c_str());
- }
-
- void
- ber_sink_b_impl::set_line_width(unsigned int which, int width)
- {
- d_main_gui->setLineWidth(which, width);
- }
-
- void
- ber_sink_b_impl::set_line_style(unsigned int which, int style)
- {
- d_main_gui->setLineStyle(which, (Qt::PenStyle)style);
- }
-
- void
- ber_sink_b_impl::set_line_marker(unsigned int which, int marker)
- {
- d_main_gui->setLineMarker(which, (QwtSymbol::Style)marker);
- }
-
- void
- ber_sink_b_impl::set_line_alpha(unsigned int which, double alpha)
- {
- d_main_gui->setMarkerAlpha(which, (int)(255.0*alpha));
- }
-
- void
- ber_sink_b_impl::set_size(int width, int height)
- {
- d_main_gui->resize(QSize(width, height));
- }
-
- std::string
- ber_sink_b_impl::title()
- {
- return d_main_gui->title().toStdString();
- }
-
- std::string
- ber_sink_b_impl::line_label(unsigned int which)
- {
- return d_main_gui->lineLabel(which).toStdString();
- }
-
- std::string
- ber_sink_b_impl::line_color(unsigned int which)
- {
- return d_main_gui->lineColor(which).toStdString();
- }
-
- int
- ber_sink_b_impl::line_width(unsigned int which)
- {
- return d_main_gui->lineWidth(which);
- }
-
- int
- ber_sink_b_impl::line_style(unsigned int which)
- {
- return d_main_gui->lineStyle(which);
- }
-
- int
- ber_sink_b_impl::line_marker(unsigned int which)
- {
- return d_main_gui->lineMarker(which);
- }
-
- double
- ber_sink_b_impl::line_alpha(unsigned int which)
- {
- return (double)(d_main_gui->markerAlpha(which))/255.0;
- }
-
- int
- ber_sink_b_impl::nsamps() const
- {
- return d_nconnections;
+void ber_sink_b_impl::set_y_axis(double min, double max)
+{
+ d_main_gui->setYaxis(min, max);
+}
+
+void ber_sink_b_impl::set_x_axis(double min, double max)
+{
+ d_main_gui->setXaxis(min, max);
+}
+
+void ber_sink_b_impl::set_update_time(double t)
+{
+ // convert update time to ticks
+ gr::high_res_timer_type tps = gr::high_res_timer_tps();
+ d_update_time = t * tps;
+ d_main_gui->setUpdateTime(t);
+ d_last_time = 0;
+}
+
+void ber_sink_b_impl::set_title(const std::string& title)
+{
+ d_main_gui->setTitle(title.c_str());
+}
+
+void ber_sink_b_impl::set_line_label(unsigned int which, const std::string& label)
+{
+ d_main_gui->setLineLabel(which, label.c_str());
+}
+
+void ber_sink_b_impl::set_line_color(unsigned int which, const std::string& color)
+{
+ d_main_gui->setLineColor(which, color.c_str());
+}
+
+void ber_sink_b_impl::set_line_width(unsigned int which, int width)
+{
+ d_main_gui->setLineWidth(which, width);
+}
+
+void ber_sink_b_impl::set_line_style(unsigned int which, int style)
+{
+ d_main_gui->setLineStyle(which, (Qt::PenStyle)style);
+}
+
+void ber_sink_b_impl::set_line_marker(unsigned int which, int marker)
+{
+ d_main_gui->setLineMarker(which, (QwtSymbol::Style)marker);
+}
+
+void ber_sink_b_impl::set_line_alpha(unsigned int which, double alpha)
+{
+ d_main_gui->setMarkerAlpha(which, (int)(255.0 * alpha));
+}
+
+void ber_sink_b_impl::set_size(int width, int height)
+{
+ d_main_gui->resize(QSize(width, height));
+}
+
+std::string ber_sink_b_impl::title() { return d_main_gui->title().toStdString(); }
+
+std::string ber_sink_b_impl::line_label(unsigned int which)
+{
+ return d_main_gui->lineLabel(which).toStdString();
+}
+
+std::string ber_sink_b_impl::line_color(unsigned int which)
+{
+ return d_main_gui->lineColor(which).toStdString();
+}
+
+int ber_sink_b_impl::line_width(unsigned int which)
+{
+ return d_main_gui->lineWidth(which);
+}
+
+int ber_sink_b_impl::line_style(unsigned int which)
+{
+ return d_main_gui->lineStyle(which);
+}
+
+int ber_sink_b_impl::line_marker(unsigned int which)
+{
+ return d_main_gui->lineMarker(which);
+}
+
+double ber_sink_b_impl::line_alpha(unsigned int which)
+{
+ return (double)(d_main_gui->markerAlpha(which)) / 255.0;
+}
+
+int ber_sink_b_impl::nsamps() const { return d_nconnections; }
+
+void ber_sink_b_impl::enable_menu(bool en) { d_main_gui->enableMenu(en); }
+
+void ber_sink_b_impl::enable_autoscale(bool en) { d_main_gui->autoScale(en); }
+
+int ber_sink_b_impl::general_work(int noutput_items,
+ gr_vector_int& ninput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ if (gr::high_res_timer_now() - d_last_time > d_update_time) {
+ d_last_time = gr::high_res_timer_now();
+ d_qApplication->postEvent(
+ d_main_gui,
+ new ConstUpdateEvent(d_esno_buffers, d_ber_buffers, d_nconnections));
}
- void
- ber_sink_b_impl::enable_menu(bool en)
- {
- d_main_gui->enableMenu(en);
+ // check stopping condition
+ int done = 0, maxed = 0;
+ for (int j = 0; j < d_curves; ++j) {
+ for (int i = 0; i < d_nconnections; ++i) {
+
+ if (d_total_errors[j * d_nconnections + i] >= d_ber_min_errors) {
+ done++;
+ } else if (std::log10(((double)d_ber_min_errors) /
+ (d_total[j * d_nconnections + i] * 8.0)) <
+ d_ber_limit) {
+ maxed++;
+ }
+ }
}
- void
- ber_sink_b_impl::enable_autoscale(bool en)
- {
- d_main_gui->autoScale(en);
+ if (done + maxed == (int)(d_nconnections * d_curves)) {
+ d_qApplication->postEvent(
+ d_main_gui,
+ new ConstUpdateEvent(d_esno_buffers, d_ber_buffers, d_nconnections));
+ return -1;
}
- int
- ber_sink_b_impl::general_work(int noutput_items,
- gr_vector_int& ninput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- if(gr::high_res_timer_now() - d_last_time > d_update_time) {
- d_last_time = gr::high_res_timer_now();
- d_qApplication->postEvent(d_main_gui,
- new ConstUpdateEvent(d_esno_buffers,
- d_ber_buffers,
- d_nconnections));
- }
-
- //check stopping condition
- int done=0, maxed=0;
- for(int j = 0; j < d_curves; ++j) {
- for(int i = 0; i < d_nconnections; ++i) {
-
- if(d_total_errors[j * d_nconnections + i] >= d_ber_min_errors) {
- done++;
- }
- else if(std::log10(((double)d_ber_min_errors)/(d_total[j * d_nconnections + i] * 8.0)) < d_ber_limit) {
- maxed++;
- }
- }
- }
+ float ber;
+ for (unsigned int i = 0; i < ninput_items.size(); i += 2) {
- if(done+maxed == (int)(d_nconnections * d_curves)) {
- d_qApplication->postEvent(d_main_gui,
- new ConstUpdateEvent(d_esno_buffers,
- d_ber_buffers,
- d_nconnections));
- return -1;
- }
+ if ((d_total_errors[i >> 1] < d_ber_min_errors) &&
+ (std::log10(((double)d_ber_min_errors) / (d_total[i >> 1] * 8.0)) >=
+ d_ber_limit)) {
- float ber;
- for(unsigned int i = 0; i < ninput_items.size(); i += 2) {
+ int items = ninput_items[i] <= ninput_items[i + 1] ? ninput_items[i]
+ : ninput_items[i + 1];
- if((d_total_errors[i >> 1] < d_ber_min_errors) && \
- (std::log10(((double)d_ber_min_errors)/(d_total[i >> 1] * 8.0)) >= d_ber_limit)) {
+ unsigned char* inbuffer0 = (unsigned char*)input_items[i];
+ unsigned char* inbuffer1 = (unsigned char*)input_items[i + 1];
- int items = ninput_items[i] <= ninput_items[i+1] ? ninput_items[i] : ninput_items[i+1];
+ if (items > 0) {
+ uint32_t ret;
+ for (int j = 0; j < items; j++) {
+ volk_32u_popcnt(&ret,
+ static_cast<uint32_t>(inbuffer0[j] ^ inbuffer1[j]));
+ d_total_errors[i >> 1] += ret;
+ }
- unsigned char *inbuffer0 = (unsigned char *)input_items[i];
- unsigned char *inbuffer1 = (unsigned char *)input_items[i+1];
+ d_total[i >> 1] += items;
- if(items > 0) {
- uint32_t ret;
- for(int j = 0; j < items; j++) {
- volk_32u_popcnt(&ret, static_cast<uint32_t>(inbuffer0[j]^inbuffer1[j]));
- d_total_errors[i >> 1] += ret;
+ ber = std::log10(((double)d_total_errors[i >> 1]) /
+ (d_total[i >> 1] * 8.0));
+ d_ber_buffers[i / (d_nconnections * 2)][(i % (d_nconnections * 2)) >> 1] =
+ ber;
}
-
- d_total[i >> 1] += items;
-
- ber = std::log10(((double)d_total_errors[i >> 1])/(d_total[i >> 1] * 8.0));
- d_ber_buffers[i/(d_nconnections * 2)][(i%(d_nconnections * 2)) >> 1] = ber;
-
- }
- consume(i, items);
- consume(i + 1, items);
-
- if(d_total_errors[i >> 1] >= d_ber_min_errors) {
- GR_LOG_INFO(d_logger, boost::format(" %1% over %2% --> %3%") \
- % d_total_errors[i >> 1] % (d_total[i >> 1] * 8) % ber);
- }
- else if(std::log10(((double)d_ber_min_errors)/(d_total[i >> 1] * 8.0)) < d_ber_limit) {
- GR_LOG_INFO(d_logger, "BER Limit Reached");
- d_ber_buffers[i/(d_nconnections * 2)][(i%(d_nconnections * 2)) >> 1] = d_ber_limit;
- d_total_errors[i >> 1] = d_ber_min_errors + 1;
- }
- }
- else {
- consume(i, ninput_items[i]);
- consume(i+1, ninput_items[i+1]);
+ consume(i, items);
+ consume(i + 1, items);
+
+ if (d_total_errors[i >> 1] >= d_ber_min_errors) {
+ GR_LOG_INFO(d_logger,
+ boost::format(" %1% over %2% --> %3%") %
+ d_total_errors[i >> 1] % (d_total[i >> 1] * 8) % ber);
+ } else if (std::log10(((double)d_ber_min_errors) / (d_total[i >> 1] * 8.0)) <
+ d_ber_limit) {
+ GR_LOG_INFO(d_logger, "BER Limit Reached");
+ d_ber_buffers[i / (d_nconnections * 2)][(i % (d_nconnections * 2)) >> 1] =
+ d_ber_limit;
+ d_total_errors[i >> 1] = d_ber_min_errors + 1;
+ }
+ } else {
+ consume(i, ninput_items[i]);
+ consume(i + 1, ninput_items[i + 1]);
}
- }
-
- return 0;
}
+ return 0;
+}
+
- } /* namespace qtgui */
+} /* namespace qtgui */
} /* namespace gr */
diff --git a/gr-qtgui/lib/ber_sink_b_impl.h b/gr-qtgui/lib/ber_sink_b_impl.h
index b70d6e7b97..fbe3c4d6c7 100644
--- a/gr-qtgui/lib/ber_sink_b_impl.h
+++ b/gr-qtgui/lib/ber_sink_b_impl.h
@@ -29,81 +29,83 @@
#include <gnuradio/qtgui/constellationdisplayform.h>
namespace gr {
- namespace qtgui {
-
- class QTGUI_API ber_sink_b_impl : public ber_sink_b
- {
- private:
- void initialize();
-
- std::vector<double*> d_esno_buffers;
- std::vector<double*> d_ber_buffers;
-
- ConstellationDisplayForm *d_main_gui;
- gr::high_res_timer_type d_update_time;
- std::vector<int> d_total_errors;
- int d_ber_min_errors;
- float d_ber_limit;
- QWidget *d_parent;
- int d_nconnections;
- int d_curves;
- gr::high_res_timer_type d_last_time;
- std::vector<int> d_total;
-
- //int compBER(unsigned char *inBuffer1, unsigned char *inBuffer2,int buffSize);
-
- public:
- ber_sink_b_impl(std::vector<float> esnos, int curves = 1,
- int ber_min_errors = 100, float ber_limit = -7.0,
- std::vector<std::string> curvenames = std::vector<std::string>(),
- QWidget *parent=NULL);
- ~ber_sink_b_impl();
-
- bool check_topology(int ninputs, int noutputs);
-
- void exec_();
- QWidget* qwidget();
+namespace qtgui {
+
+class QTGUI_API ber_sink_b_impl : public ber_sink_b
+{
+private:
+ void initialize();
+
+ std::vector<double*> d_esno_buffers;
+ std::vector<double*> d_ber_buffers;
+
+ ConstellationDisplayForm* d_main_gui;
+ gr::high_res_timer_type d_update_time;
+ std::vector<int> d_total_errors;
+ int d_ber_min_errors;
+ float d_ber_limit;
+ QWidget* d_parent;
+ int d_nconnections;
+ int d_curves;
+ gr::high_res_timer_type d_last_time;
+ std::vector<int> d_total;
+
+ // int compBER(unsigned char *inBuffer1, unsigned char *inBuffer2,int buffSize);
+
+public:
+ ber_sink_b_impl(std::vector<float> esnos,
+ int curves = 1,
+ int ber_min_errors = 100,
+ float ber_limit = -7.0,
+ std::vector<std::string> curvenames = std::vector<std::string>(),
+ QWidget* parent = NULL);
+ ~ber_sink_b_impl();
+
+ bool check_topology(int ninputs, int noutputs);
+
+ void exec_();
+ QWidget* qwidget();
#ifdef ENABLE_PYTHON
- PyObject* pyqwidget();
+ PyObject* pyqwidget();
#else
- void* pyqwidget();
+ void* pyqwidget();
#endif
- void set_y_axis(double min, double max);
- void set_x_axis(double min, double max);
+ void set_y_axis(double min, double max);
+ void set_x_axis(double min, double max);
- void set_update_time(double t);
- void set_title(const std::string &title);
- void set_line_label(unsigned int which, const std::string &label);
- void set_line_color(unsigned int which, const std::string &color);
- void set_line_width(unsigned int which, int width);
- void set_line_style(unsigned int which, int style);
- void set_line_marker(unsigned int which, int marker);
+ void set_update_time(double t);
+ void set_title(const std::string& title);
+ void set_line_label(unsigned int which, const std::string& label);
+ void set_line_color(unsigned int which, const std::string& color);
+ void set_line_width(unsigned int which, int width);
+ void set_line_style(unsigned int which, int style);
+ void set_line_marker(unsigned int which, int marker);
- void set_line_alpha(unsigned int which, double alpha);
+ void set_line_alpha(unsigned int which, double alpha);
- std::string title();
- std::string line_label(unsigned int which);
- std::string line_color(unsigned int which);
- int line_width(unsigned int which);
- int line_style(unsigned int which);
- int line_marker(unsigned int which);
- double line_alpha(unsigned int which);
+ std::string title();
+ std::string line_label(unsigned int which);
+ std::string line_color(unsigned int which);
+ int line_width(unsigned int which);
+ int line_style(unsigned int which);
+ int line_marker(unsigned int which);
+ double line_alpha(unsigned int which);
- void set_size(int width, int height);
+ void set_size(int width, int height);
- int nsamps() const;
- void enable_menu(bool en);
- void enable_autoscale(bool en);
+ int nsamps() const;
+ void enable_menu(bool en);
+ void enable_autoscale(bool en);
- int general_work(int noutput_items,
- gr_vector_int& ninput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
+ int general_work(int noutput_items,
+ gr_vector_int& ninput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace qtgui */
+} /* namespace qtgui */
} /* namespace gr */
#endif /*INCLUDED_QTGUI_BER_SINK_B_IMPL_H*/
diff --git a/gr-qtgui/lib/const_sink_c_impl.cc b/gr-qtgui/lib/const_sink_c_impl.cc
index 1ed4f3b1d5..a6024bbed7 100644
--- a/gr-qtgui/lib/const_sink_c_impl.cc
+++ b/gr-qtgui/lib/const_sink_c_impl.cc
@@ -33,572 +33,494 @@
#include <qwt_symbol.h>
namespace gr {
- namespace qtgui {
-
- const_sink_c::sptr
- const_sink_c::make(int size,
- const std::string &name,
- int nconnections,
- QWidget *parent)
- {
- return gnuradio::get_initial_sptr
- (new const_sink_c_impl(size, name, nconnections, parent));
- }
-
- const_sink_c_impl::const_sink_c_impl(int size,
- const std::string &name,
- int nconnections,
- QWidget *parent)
- : sync_block("const_sink_c",
- io_signature::make(0, nconnections, sizeof(gr_complex)),
- io_signature::make(0, 0, 0)),
- d_size(size), d_buffer_size(2*size), d_name(name),
- d_nconnections(nconnections), d_parent(parent)
- {
- // Required now for Qt; argc must be greater than 0 and argv
- // must have at least one valid character. Must be valid through
- // life of the qApplication:
- // http://harmattan-dev.nokia.com/docs/library/html/qt4/qapplication.html
- d_argc = 1;
- d_argv = new char;
- d_argv[0] = '\0';
-
- d_main_gui = NULL;
-
- d_index = 0;
-
- // setup PDU handling input port
- message_port_register_in(pmt::mp("in"));
- set_msg_handler(pmt::mp("in"),
- boost::bind(&const_sink_c_impl::handle_pdus, this, _1));
-
- for(int i = 0; i < d_nconnections; i++) {
- d_residbufs_real.push_back((double*)volk_malloc(d_buffer_size*sizeof(double),
- volk_get_alignment()));
- d_residbufs_imag.push_back((double*)volk_malloc(d_buffer_size*sizeof(double),
- volk_get_alignment()));
- memset(d_residbufs_real[i], 0, d_buffer_size*sizeof(double));
- memset(d_residbufs_imag[i], 0, d_buffer_size*sizeof(double));
- }
-
- // Used for PDU message input
- d_residbufs_real.push_back((double*)volk_malloc(d_buffer_size*sizeof(double),
- volk_get_alignment()));
- d_residbufs_imag.push_back((double*)volk_malloc(d_buffer_size*sizeof(double),
- volk_get_alignment()));
- memset(d_residbufs_real[d_nconnections], 0, d_buffer_size*sizeof(double));
- memset(d_residbufs_imag[d_nconnections], 0, d_buffer_size*sizeof(double));
-
- // Set alignment properties for VOLK
- const int alignment_multiple =
- volk_get_alignment() / sizeof(gr_complex);
- set_alignment(std::max(1,alignment_multiple));
-
- initialize();
-
- set_trigger_mode(TRIG_MODE_FREE, TRIG_SLOPE_POS, 0, 0);
-
- set_history(2); // so we can look ahead for the trigger slope
- }
-
- const_sink_c_impl::~const_sink_c_impl()
- {
- if(!d_main_gui->isClosed())
+namespace qtgui {
+
+const_sink_c::sptr
+const_sink_c::make(int size, const std::string& name, int nconnections, QWidget* parent)
+{
+ return gnuradio::get_initial_sptr(
+ new const_sink_c_impl(size, name, nconnections, parent));
+}
+
+const_sink_c_impl::const_sink_c_impl(int size,
+ const std::string& name,
+ int nconnections,
+ QWidget* parent)
+ : sync_block("const_sink_c",
+ io_signature::make(0, nconnections, sizeof(gr_complex)),
+ io_signature::make(0, 0, 0)),
+ d_size(size),
+ d_buffer_size(2 * size),
+ d_name(name),
+ d_nconnections(nconnections),
+ d_parent(parent)
+{
+ // Required now for Qt; argc must be greater than 0 and argv
+ // must have at least one valid character. Must be valid through
+ // life of the qApplication:
+ // http://harmattan-dev.nokia.com/docs/library/html/qt4/qapplication.html
+ d_argc = 1;
+ d_argv = new char;
+ d_argv[0] = '\0';
+
+ d_main_gui = NULL;
+
+ d_index = 0;
+
+ // setup PDU handling input port
+ message_port_register_in(pmt::mp("in"));
+ set_msg_handler(pmt::mp("in"),
+ boost::bind(&const_sink_c_impl::handle_pdus, this, _1));
+
+ for (int i = 0; i < d_nconnections; i++) {
+ d_residbufs_real.push_back(
+ (double*)volk_malloc(d_buffer_size * sizeof(double), volk_get_alignment()));
+ d_residbufs_imag.push_back(
+ (double*)volk_malloc(d_buffer_size * sizeof(double), volk_get_alignment()));
+ memset(d_residbufs_real[i], 0, d_buffer_size * sizeof(double));
+ memset(d_residbufs_imag[i], 0, d_buffer_size * sizeof(double));
+ }
+
+ // Used for PDU message input
+ d_residbufs_real.push_back(
+ (double*)volk_malloc(d_buffer_size * sizeof(double), volk_get_alignment()));
+ d_residbufs_imag.push_back(
+ (double*)volk_malloc(d_buffer_size * sizeof(double), volk_get_alignment()));
+ memset(d_residbufs_real[d_nconnections], 0, d_buffer_size * sizeof(double));
+ memset(d_residbufs_imag[d_nconnections], 0, d_buffer_size * sizeof(double));
+
+ // Set alignment properties for VOLK
+ const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
+ set_alignment(std::max(1, alignment_multiple));
+
+ initialize();
+
+ set_trigger_mode(TRIG_MODE_FREE, TRIG_SLOPE_POS, 0, 0);
+
+ set_history(2); // so we can look ahead for the trigger slope
+}
+
+const_sink_c_impl::~const_sink_c_impl()
+{
+ if (!d_main_gui->isClosed())
d_main_gui->close();
- // d_main_gui is a qwidget destroyed with its parent
- for(int i = 0; i < d_nconnections+1; i++) {
- volk_free(d_residbufs_real[i]);
- volk_free(d_residbufs_imag[i]);
- }
-
- delete d_argv;
+ // d_main_gui is a qwidget destroyed with its parent
+ for (int i = 0; i < d_nconnections + 1; i++) {
+ volk_free(d_residbufs_real[i]);
+ volk_free(d_residbufs_imag[i]);
}
- bool
- const_sink_c_impl::check_topology(int ninputs, int noutputs)
- {
- return ninputs == d_nconnections;
- }
+ delete d_argv;
+}
+
+bool const_sink_c_impl::check_topology(int ninputs, int noutputs)
+{
+ return ninputs == d_nconnections;
+}
- void
- const_sink_c_impl::initialize()
- {
- if(qApp != NULL) {
- d_qApplication = qApp;
- }
- else {
+void const_sink_c_impl::initialize()
+{
+ if (qApp != NULL) {
+ d_qApplication = qApp;
+ } else {
#if QT_VERSION >= 0x040500 && QT_VERSION < 0x050000
std::string style = prefs::singleton()->get_string("qtgui", "style", "raster");
QApplication::setGraphicsSystem(QString(style.c_str()));
#endif
- d_qApplication = new QApplication(d_argc, &d_argv);
- }
+ d_qApplication = new QApplication(d_argc, &d_argv);
+ }
- // If a style sheet is set in the prefs file, enable it here.
- check_set_qss(d_qApplication);
+ // If a style sheet is set in the prefs file, enable it here.
+ check_set_qss(d_qApplication);
- int numplots = (d_nconnections > 0) ? d_nconnections : 1;
- d_main_gui = new ConstellationDisplayForm(numplots, d_parent);
- d_main_gui->setNPoints(d_size);
+ int numplots = (d_nconnections > 0) ? d_nconnections : 1;
+ d_main_gui = new ConstellationDisplayForm(numplots, d_parent);
+ d_main_gui->setNPoints(d_size);
- if(d_name.size() > 0)
+ if (d_name.size() > 0)
set_title(d_name);
- // initialize update time to 10 times a second
- set_update_time(0.1);
- }
+ // initialize update time to 10 times a second
+ set_update_time(0.1);
+}
- void
- const_sink_c_impl::exec_()
- {
- d_qApplication->exec();
- }
+void const_sink_c_impl::exec_() { d_qApplication->exec(); }
- QWidget*
- const_sink_c_impl::qwidget()
- {
- return d_main_gui;
- }
+QWidget* const_sink_c_impl::qwidget() { return d_main_gui; }
#ifdef ENABLE_PYTHON
- PyObject*
- const_sink_c_impl::pyqwidget()
- {
- PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui);
- PyObject *retarg = Py_BuildValue("N", w);
- return retarg;
- }
+PyObject* const_sink_c_impl::pyqwidget()
+{
+ PyObject* w = PyLong_FromVoidPtr((void*)d_main_gui);
+ PyObject* retarg = Py_BuildValue("N", w);
+ return retarg;
+}
#else
- void *
- const_sink_c_impl::pyqwidget()
- {
- return NULL;
- }
+void* const_sink_c_impl::pyqwidget() { return NULL; }
#endif
- void
- const_sink_c_impl::set_y_axis(double min, double max)
- {
- d_main_gui->setYaxis(min, max);
- }
-
- void
- const_sink_c_impl::set_x_axis(double min, double max)
- {
- d_main_gui->setXaxis(min, max);
- }
-
- void
- const_sink_c_impl::set_update_time(double t)
- {
- //convert update time to ticks
- gr::high_res_timer_type tps = gr::high_res_timer_tps();
- d_update_time = t * tps;
- d_main_gui->setUpdateTime(t);
- d_last_time = 0;
- }
-
- void
- const_sink_c_impl::set_title(const std::string &title)
- {
- d_main_gui->setTitle(title.c_str());
- }
-
- void
- const_sink_c_impl::set_line_label(unsigned int which, const std::string &label)
- {
- d_main_gui->setLineLabel(which, label.c_str());
- }
-
- void
- const_sink_c_impl::set_line_color(unsigned int which, const std::string &color)
- {
- d_main_gui->setLineColor(which, color.c_str());
- }
-
- void
- const_sink_c_impl::set_line_width(unsigned int which, int width)
- {
- d_main_gui->setLineWidth(which, width);
- }
-
- void
- const_sink_c_impl::set_line_style(unsigned int which, int style)
- {
- d_main_gui->setLineStyle(which, (Qt::PenStyle)style);
- }
-
- void
- const_sink_c_impl::set_line_marker(unsigned int which, int marker)
- {
- d_main_gui->setLineMarker(which, (QwtSymbol::Style)marker);
- }
-
- void
- const_sink_c_impl::set_line_alpha(unsigned int which, double alpha)
- {
- d_main_gui->setMarkerAlpha(which, (int)(255.0*alpha));
- }
-
- void
- const_sink_c_impl::set_trigger_mode(trigger_mode mode,
- trigger_slope slope,
- float level,
- int channel,
- const std::string &tag_key)
- {
- gr::thread::scoped_lock lock(d_setlock);
-
- d_trigger_mode = mode;
- d_trigger_slope = slope;
- d_trigger_level = level;
- d_trigger_channel = channel;
- d_trigger_tag_key = pmt::intern(tag_key);
- d_triggered = false;
- d_trigger_count = 0;
-
- d_main_gui->setTriggerMode(d_trigger_mode);
- d_main_gui->setTriggerSlope(d_trigger_slope);
- d_main_gui->setTriggerLevel(d_trigger_level);
- d_main_gui->setTriggerChannel(d_trigger_channel);
- d_main_gui->setTriggerTagKey(tag_key);
-
- _reset();
- }
-
- void
- const_sink_c_impl::set_size(int width, int height)
- {
- d_main_gui->resize(QSize(width, height));
- }
-
- std::string
- const_sink_c_impl::title()
- {
- return d_main_gui->title().toStdString();
- }
-
- std::string
- const_sink_c_impl::line_label(unsigned int which)
- {
- return d_main_gui->lineLabel(which).toStdString();
- }
-
- std::string
- const_sink_c_impl::line_color(unsigned int which)
- {
- return d_main_gui->lineColor(which).toStdString();
- }
-
- int
- const_sink_c_impl::line_width(unsigned int which)
- {
- return d_main_gui->lineWidth(which);
- }
-
- int
- const_sink_c_impl::line_style(unsigned int which)
- {
- return d_main_gui->lineStyle(which);
- }
-
- int
- const_sink_c_impl::line_marker(unsigned int which)
- {
- return d_main_gui->lineMarker(which);
- }
-
- double
- const_sink_c_impl::line_alpha(unsigned int which)
- {
- return (double)(d_main_gui->markerAlpha(which))/255.0;
- }
-
- void
- const_sink_c_impl::set_nsamps(const int newsize)
- {
- gr::thread::scoped_lock lock(d_setlock);
-
- if(newsize != d_size) {
- // Set new size and reset buffer index
- // (throws away any currently held data, but who cares?)
- d_size = newsize;
- d_buffer_size = 2*d_size;
- d_index = 0;
-
- // Resize residbuf and replace data
+void const_sink_c_impl::set_y_axis(double min, double max)
+{
+ d_main_gui->setYaxis(min, max);
+}
+
+void const_sink_c_impl::set_x_axis(double min, double max)
+{
+ d_main_gui->setXaxis(min, max);
+}
+
+void const_sink_c_impl::set_update_time(double t)
+{
+ // convert update time to ticks
+ gr::high_res_timer_type tps = gr::high_res_timer_tps();
+ d_update_time = t * tps;
+ d_main_gui->setUpdateTime(t);
+ d_last_time = 0;
+}
+
+void const_sink_c_impl::set_title(const std::string& title)
+{
+ d_main_gui->setTitle(title.c_str());
+}
+
+void const_sink_c_impl::set_line_label(unsigned int which, const std::string& label)
+{
+ d_main_gui->setLineLabel(which, label.c_str());
+}
+
+void const_sink_c_impl::set_line_color(unsigned int which, const std::string& color)
+{
+ d_main_gui->setLineColor(which, color.c_str());
+}
+
+void const_sink_c_impl::set_line_width(unsigned int which, int width)
+{
+ d_main_gui->setLineWidth(which, width);
+}
+
+void const_sink_c_impl::set_line_style(unsigned int which, int style)
+{
+ d_main_gui->setLineStyle(which, (Qt::PenStyle)style);
+}
+
+void const_sink_c_impl::set_line_marker(unsigned int which, int marker)
+{
+ d_main_gui->setLineMarker(which, (QwtSymbol::Style)marker);
+}
+
+void const_sink_c_impl::set_line_alpha(unsigned int which, double alpha)
+{
+ d_main_gui->setMarkerAlpha(which, (int)(255.0 * alpha));
+}
+
+void const_sink_c_impl::set_trigger_mode(trigger_mode mode,
+ trigger_slope slope,
+ float level,
+ int channel,
+ const std::string& tag_key)
+{
+ gr::thread::scoped_lock lock(d_setlock);
+
+ d_trigger_mode = mode;
+ d_trigger_slope = slope;
+ d_trigger_level = level;
+ d_trigger_channel = channel;
+ d_trigger_tag_key = pmt::intern(tag_key);
+ d_triggered = false;
+ d_trigger_count = 0;
+
+ d_main_gui->setTriggerMode(d_trigger_mode);
+ d_main_gui->setTriggerSlope(d_trigger_slope);
+ d_main_gui->setTriggerLevel(d_trigger_level);
+ d_main_gui->setTriggerChannel(d_trigger_channel);
+ d_main_gui->setTriggerTagKey(tag_key);
+
+ _reset();
+}
+
+void const_sink_c_impl::set_size(int width, int height)
+{
+ d_main_gui->resize(QSize(width, height));
+}
+
+std::string const_sink_c_impl::title() { return d_main_gui->title().toStdString(); }
+
+std::string const_sink_c_impl::line_label(unsigned int which)
+{
+ return d_main_gui->lineLabel(which).toStdString();
+}
+
+std::string const_sink_c_impl::line_color(unsigned int which)
+{
+ return d_main_gui->lineColor(which).toStdString();
+}
+
+int const_sink_c_impl::line_width(unsigned int which)
+{
+ return d_main_gui->lineWidth(which);
+}
+
+int const_sink_c_impl::line_style(unsigned int which)
+{
+ return d_main_gui->lineStyle(which);
+}
+
+int const_sink_c_impl::line_marker(unsigned int which)
+{
+ return d_main_gui->lineMarker(which);
+}
+
+double const_sink_c_impl::line_alpha(unsigned int which)
+{
+ return (double)(d_main_gui->markerAlpha(which)) / 255.0;
+}
+
+void const_sink_c_impl::set_nsamps(const int newsize)
+{
+ gr::thread::scoped_lock lock(d_setlock);
+
+ if (newsize != d_size) {
+ // Set new size and reset buffer index
+ // (throws away any currently held data, but who cares?)
+ d_size = newsize;
+ d_buffer_size = 2 * d_size;
+ d_index = 0;
+
+ // Resize residbuf and replace data
// +1 to handle PDU message input buffers
- for(int i = 0; i < d_nconnections+1; i++) {
- volk_free(d_residbufs_real[i]);
- volk_free(d_residbufs_imag[i]);
- d_residbufs_real[i] = (double*)volk_malloc(d_buffer_size*sizeof(double),
- volk_get_alignment());
- d_residbufs_imag[i] = (double*)volk_malloc(d_buffer_size*sizeof(double),
- volk_get_alignment());
-
- memset(d_residbufs_real[i], 0, d_buffer_size*sizeof(double));
- memset(d_residbufs_imag[i], 0, d_buffer_size*sizeof(double));
- }
-
- d_main_gui->setNPoints(d_size);
+ for (int i = 0; i < d_nconnections + 1; i++) {
+ volk_free(d_residbufs_real[i]);
+ volk_free(d_residbufs_imag[i]);
+ d_residbufs_real[i] = (double*)volk_malloc(d_buffer_size * sizeof(double),
+ volk_get_alignment());
+ d_residbufs_imag[i] = (double*)volk_malloc(d_buffer_size * sizeof(double),
+ volk_get_alignment());
+
+ memset(d_residbufs_real[i], 0, d_buffer_size * sizeof(double));
+ memset(d_residbufs_imag[i], 0, d_buffer_size * sizeof(double));
+ }
+
+ d_main_gui->setNPoints(d_size);
_reset();
- }
}
+}
- int
- const_sink_c_impl::nsamps() const
- {
- return d_size;
- }
+int const_sink_c_impl::nsamps() const { return d_size; }
- void
- const_sink_c_impl::enable_menu(bool en)
- {
- d_main_gui->enableMenu(en);
- }
+void const_sink_c_impl::enable_menu(bool en) { d_main_gui->enableMenu(en); }
- void
- const_sink_c_impl::enable_autoscale(bool en)
- {
- d_main_gui->autoScale(en);
- }
+void const_sink_c_impl::enable_autoscale(bool en) { d_main_gui->autoScale(en); }
- void
- const_sink_c_impl::enable_grid(bool en)
- {
- d_main_gui->setGrid(en);
- }
+void const_sink_c_impl::enable_grid(bool en) { d_main_gui->setGrid(en); }
- void
- const_sink_c_impl::enable_axis_labels(bool en)
- {
- d_main_gui->setAxisLabels(en);
- }
+void const_sink_c_impl::enable_axis_labels(bool en) { d_main_gui->setAxisLabels(en); }
- void
- const_sink_c_impl::disable_legend()
- {
- d_main_gui->disableLegend();
- }
+void const_sink_c_impl::disable_legend() { d_main_gui->disableLegend(); }
- void
- const_sink_c_impl::reset()
- {
- gr::thread::scoped_lock lock(d_setlock);
- _reset();
- }
+void const_sink_c_impl::reset()
+{
+ gr::thread::scoped_lock lock(d_setlock);
+ _reset();
+}
- void
- const_sink_c_impl::_reset()
- {
- // Reset the start and end indices.
- d_start = 0;
- d_end = d_size;
- d_index = 0;
+void const_sink_c_impl::_reset()
+{
+ // Reset the start and end indices.
+ d_start = 0;
+ d_end = d_size;
+ d_index = 0;
- // Reset the trigger.
- if(d_trigger_mode == TRIG_MODE_FREE) {
+ // Reset the trigger.
+ if (d_trigger_mode == TRIG_MODE_FREE) {
d_triggered = true;
- }
- else {
+ } else {
d_triggered = false;
- }
- }
-
- void
- const_sink_c_impl::_npoints_resize()
- {
- int newsize = d_main_gui->getNPoints();
- set_nsamps(newsize);
}
-
- void
- const_sink_c_impl::_gui_update_trigger()
- {
- d_trigger_mode = d_main_gui->getTriggerMode();
- d_trigger_slope = d_main_gui->getTriggerSlope();
- d_trigger_level = d_main_gui->getTriggerLevel();
- d_trigger_channel = d_main_gui->getTriggerChannel();
- d_trigger_count = 0;
-
- std::string tagkey = d_main_gui->getTriggerTagKey();
- d_trigger_tag_key = pmt::intern(tagkey);
- }
-
- void
- const_sink_c_impl::_test_trigger_tags(int nitems)
- {
- int trigger_index;
-
- uint64_t nr = nitems_read(d_trigger_channel);
- std::vector<gr::tag_t> tags;
- get_tags_in_range(tags, d_trigger_channel,
- nr, nr + nitems,
- d_trigger_tag_key);
- if(tags.size() > 0) {
+}
+
+void const_sink_c_impl::_npoints_resize()
+{
+ int newsize = d_main_gui->getNPoints();
+ set_nsamps(newsize);
+}
+
+void const_sink_c_impl::_gui_update_trigger()
+{
+ d_trigger_mode = d_main_gui->getTriggerMode();
+ d_trigger_slope = d_main_gui->getTriggerSlope();
+ d_trigger_level = d_main_gui->getTriggerLevel();
+ d_trigger_channel = d_main_gui->getTriggerChannel();
+ d_trigger_count = 0;
+
+ std::string tagkey = d_main_gui->getTriggerTagKey();
+ d_trigger_tag_key = pmt::intern(tagkey);
+}
+
+void const_sink_c_impl::_test_trigger_tags(int nitems)
+{
+ int trigger_index;
+
+ uint64_t nr = nitems_read(d_trigger_channel);
+ std::vector<gr::tag_t> tags;
+ get_tags_in_range(tags, d_trigger_channel, nr, nr + nitems, d_trigger_tag_key);
+ if (tags.size() > 0) {
d_triggered = true;
trigger_index = tags[0].offset - nr;
d_start = d_index + trigger_index;
d_end = d_start + d_size;
d_trigger_count = 0;
- }
}
+}
- void
- const_sink_c_impl::_test_trigger_norm(int nitems, gr_vector_const_void_star inputs)
- {
- int trigger_index;
- const gr_complex *in = (const gr_complex*)inputs[d_trigger_channel];
- for(trigger_index = 0; trigger_index < nitems - 1; trigger_index++) {
+void const_sink_c_impl::_test_trigger_norm(int nitems, gr_vector_const_void_star inputs)
+{
+ int trigger_index;
+ const gr_complex* in = (const gr_complex*)inputs[d_trigger_channel];
+ for (trigger_index = 0; trigger_index < nitems - 1; trigger_index++) {
d_trigger_count++;
// Test if trigger has occurred based on the input stream,
// channel number, and slope direction
- if(_test_trigger_slope(&in[trigger_index])) {
- d_triggered = true;
- d_start = d_index + trigger_index;
- d_end = d_start + d_size;
- d_trigger_count = 0;
- break;
+ if (_test_trigger_slope(&in[trigger_index])) {
+ d_triggered = true;
+ d_start = d_index + trigger_index;
+ d_end = d_start + d_size;
+ d_trigger_count = 0;
+ break;
}
- }
+ }
- // If using auto trigger mode, trigger periodically even
- // without a trigger event.
- if((d_trigger_mode == TRIG_MODE_AUTO) && (d_trigger_count > d_size)) {
+ // If using auto trigger mode, trigger periodically even
+ // without a trigger event.
+ if ((d_trigger_mode == TRIG_MODE_AUTO) && (d_trigger_count > d_size)) {
d_triggered = true;
d_trigger_count = 0;
- }
}
+}
- bool
- const_sink_c_impl::_test_trigger_slope(const gr_complex *in) const
- {
- float x0, x1;
- x0 = abs(in[0]);
- x1 = abs(in[1]);
+bool const_sink_c_impl::_test_trigger_slope(const gr_complex* in) const
+{
+ float x0, x1;
+ x0 = abs(in[0]);
+ x1 = abs(in[1]);
- if(d_trigger_slope == TRIG_SLOPE_POS)
+ if (d_trigger_slope == TRIG_SLOPE_POS)
return ((x0 <= d_trigger_level) && (x1 > d_trigger_level));
- else
+ else
return ((x0 >= d_trigger_level) && (x1 < d_trigger_level));
- }
+}
- int
- const_sink_c_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- int n=0;
- const gr_complex *in;
+int const_sink_c_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ int n = 0;
+ const gr_complex* in;
- _npoints_resize();
- _gui_update_trigger();
+ _npoints_resize();
+ _gui_update_trigger();
- int nfill = d_end - d_index; // how much room left in buffers
- int nitems = std::min(noutput_items, nfill); // num items we can put in buffers
+ int nfill = d_end - d_index; // how much room left in buffers
+ int nitems = std::min(noutput_items, nfill); // num items we can put in buffers
- // If auto, normal, or tag trigger, look for the trigger
- if((d_trigger_mode != TRIG_MODE_FREE) && !d_triggered) {
+ // If auto, normal, or tag trigger, look for the trigger
+ if ((d_trigger_mode != TRIG_MODE_FREE) && !d_triggered) {
// trigger off a tag key (first one found)
- if(d_trigger_mode == TRIG_MODE_TAG) {
- _test_trigger_tags(nitems);
+ if (d_trigger_mode == TRIG_MODE_TAG) {
+ _test_trigger_tags(nitems);
}
// Normal or Auto trigger
else {
- _test_trigger_norm(nitems, input_items);
+ _test_trigger_norm(nitems, input_items);
}
- }
+ }
- // Copy data into the buffers.
- for(n = 0; n < d_nconnections; n++) {
+ // Copy data into the buffers.
+ for (n = 0; n < d_nconnections; n++) {
in = (const gr_complex*)input_items[n];
volk_32fc_deinterleave_64f_x2(&d_residbufs_real[n][d_index],
&d_residbufs_imag[n][d_index],
- &in[history()-1], nitems);
- }
- d_index += nitems;
+ &in[history() - 1],
+ nitems);
+ }
+ d_index += nitems;
- // If we have a trigger and a full d_size of items in the buffers, plot.
- if((d_triggered) && (d_index == d_end)) {
+ // If we have a trigger and a full d_size of items in the buffers, plot.
+ if ((d_triggered) && (d_index == d_end)) {
// Copy data to be plotted to start of buffers.
- for(n = 0; n < d_nconnections; n++) {
- memmove(d_residbufs_real[n], &d_residbufs_real[n][d_start], d_size*sizeof(double));
- memmove(d_residbufs_imag[n], &d_residbufs_imag[n][d_start], d_size*sizeof(double));
+ for (n = 0; n < d_nconnections; n++) {
+ memmove(d_residbufs_real[n],
+ &d_residbufs_real[n][d_start],
+ d_size * sizeof(double));
+ memmove(d_residbufs_imag[n],
+ &d_residbufs_imag[n][d_start],
+ d_size * sizeof(double));
}
// Plot if we are able to update
- if(gr::high_res_timer_now() - d_last_time > d_update_time) {
- d_last_time = gr::high_res_timer_now();
- d_qApplication->postEvent(d_main_gui,
- new ConstUpdateEvent(d_residbufs_real,
- d_residbufs_imag,
- d_size));
+ if (gr::high_res_timer_now() - d_last_time > d_update_time) {
+ d_last_time = gr::high_res_timer_now();
+ d_qApplication->postEvent(
+ d_main_gui,
+ new ConstUpdateEvent(d_residbufs_real, d_residbufs_imag, d_size));
}
// We've plotting, so reset the state
_reset();
- }
+ }
- // If we've filled up the buffers but haven't triggered, reset.
- if(d_index == d_end) {
+ // If we've filled up the buffers but haven't triggered, reset.
+ if (d_index == d_end) {
_reset();
- }
-
- return nitems;
}
- void
- const_sink_c_impl::handle_pdus(pmt::pmt_t msg)
- {
- size_t len = 0;
- pmt::pmt_t dict, samples;
+ return nitems;
+}
- // Test to make sure this is either a PDU or a uniform vector of
- // samples. Get the samples PMT and the dictionary if it's a PDU.
- // If not, we throw an error and exit.
- if(pmt::is_pair(msg)) {
+void const_sink_c_impl::handle_pdus(pmt::pmt_t msg)
+{
+ size_t len = 0;
+ pmt::pmt_t dict, samples;
+
+ // Test to make sure this is either a PDU or a uniform vector of
+ // samples. Get the samples PMT and the dictionary if it's a PDU.
+ // If not, we throw an error and exit.
+ if (pmt::is_pair(msg)) {
dict = pmt::car(msg);
samples = pmt::cdr(msg);
- }
- else if(pmt::is_uniform_vector(msg)) {
+ } else if (pmt::is_uniform_vector(msg)) {
samples = msg;
- }
- else {
+ } else {
throw std::runtime_error("const_sink_c: message must be either "
"a PDU or a uniform vector of samples.");
- }
+ }
- len = pmt::length(samples);
+ len = pmt::length(samples);
- const gr_complex *in;
- if(pmt::is_c32vector(samples)) {
+ const gr_complex* in;
+ if (pmt::is_c32vector(samples)) {
in = (const gr_complex*)pmt::c32vector_elements(samples, len);
- }
- else {
+ } else {
throw std::runtime_error("const_sink_c: unknown data type "
"of samples; must be complex.");
- }
+ }
- set_nsamps(len);
+ set_nsamps(len);
- // Plot if we're past the last update time
- if(gr::high_res_timer_now() - d_last_time > d_update_time) {
+ // Plot if we're past the last update time
+ if (gr::high_res_timer_now() - d_last_time > d_update_time) {
d_last_time = gr::high_res_timer_now();
// Copy data into the buffers.
- volk_32fc_deinterleave_64f_x2(d_residbufs_real[d_nconnections],
- d_residbufs_imag[d_nconnections],
- in, len);
-
- d_qApplication->postEvent(d_main_gui,
- new ConstUpdateEvent(d_residbufs_real,
- d_residbufs_imag,
- len));
- }
+ volk_32fc_deinterleave_64f_x2(
+ d_residbufs_real[d_nconnections], d_residbufs_imag[d_nconnections], in, len);
+
+ d_qApplication->postEvent(
+ d_main_gui, new ConstUpdateEvent(d_residbufs_real, d_residbufs_imag, len));
}
+}
- } /* namespace qtgui */
+} /* namespace qtgui */
} /* namespace gr */
diff --git a/gr-qtgui/lib/const_sink_c_impl.h b/gr-qtgui/lib/const_sink_c_impl.h
index ddaa0116a8..ee832cacc5 100644
--- a/gr-qtgui/lib/const_sink_c_impl.h
+++ b/gr-qtgui/lib/const_sink_c_impl.h
@@ -29,106 +29,108 @@
#include <gnuradio/qtgui/constellationdisplayform.h>
namespace gr {
- namespace qtgui {
-
- class QTGUI_API const_sink_c_impl : public const_sink_c
- {
- private:
- void initialize();
-
- int d_size, d_buffer_size;
- std::string d_name;
- int d_nconnections;
-
- int d_index, d_start, d_end;
- std::vector<double*> d_residbufs_real;
- std::vector<double*> d_residbufs_imag;
-
- int d_argc;
- char *d_argv;
- QWidget *d_parent;
- ConstellationDisplayForm *d_main_gui;
-
- gr::high_res_timer_type d_update_time;
- gr::high_res_timer_type d_last_time;
-
- // Members used for triggering scope
- trigger_mode d_trigger_mode;
- trigger_slope d_trigger_slope;
- float d_trigger_level;
- int d_trigger_channel;
- pmt::pmt_t d_trigger_tag_key;
- bool d_triggered;
- int d_trigger_count;
-
- void _reset();
- void _npoints_resize();
- void _gui_update_trigger();
- void _test_trigger_tags(int nitems);
- void _test_trigger_norm(int nitems, gr_vector_const_void_star inputs);
- bool _test_trigger_slope(const gr_complex *in) const;
-
- // Handles message input port for displaying PDU samples.
- void handle_pdus(pmt::pmt_t msg);
-
- public:
- const_sink_c_impl(int size,
- const std::string &name,
- int nconnections,
- QWidget *parent=NULL);
- ~const_sink_c_impl();
-
- bool check_topology(int ninputs, int noutputs);
-
- void exec_();
- QWidget* qwidget();
+namespace qtgui {
+
+class QTGUI_API const_sink_c_impl : public const_sink_c
+{
+private:
+ void initialize();
+
+ int d_size, d_buffer_size;
+ std::string d_name;
+ int d_nconnections;
+
+ int d_index, d_start, d_end;
+ std::vector<double*> d_residbufs_real;
+ std::vector<double*> d_residbufs_imag;
+
+ int d_argc;
+ char* d_argv;
+ QWidget* d_parent;
+ ConstellationDisplayForm* d_main_gui;
+
+ gr::high_res_timer_type d_update_time;
+ gr::high_res_timer_type d_last_time;
+
+ // Members used for triggering scope
+ trigger_mode d_trigger_mode;
+ trigger_slope d_trigger_slope;
+ float d_trigger_level;
+ int d_trigger_channel;
+ pmt::pmt_t d_trigger_tag_key;
+ bool d_triggered;
+ int d_trigger_count;
+
+ void _reset();
+ void _npoints_resize();
+ void _gui_update_trigger();
+ void _test_trigger_tags(int nitems);
+ void _test_trigger_norm(int nitems, gr_vector_const_void_star inputs);
+ bool _test_trigger_slope(const gr_complex* in) const;
+
+ // Handles message input port for displaying PDU samples.
+ void handle_pdus(pmt::pmt_t msg);
+
+public:
+ const_sink_c_impl(int size,
+ const std::string& name,
+ int nconnections,
+ QWidget* parent = NULL);
+ ~const_sink_c_impl();
+
+ bool check_topology(int ninputs, int noutputs);
+
+ void exec_();
+ QWidget* qwidget();
#ifdef ENABLE_PYTHON
- PyObject* pyqwidget();
+ PyObject* pyqwidget();
#else
- void* pyqwidget();
+ void* pyqwidget();
#endif
- void set_y_axis(double min, double max);
- void set_x_axis(double min, double max);
-
- void set_update_time(double t);
- void set_title(const std::string &title);
- void set_line_label(unsigned int which, const std::string &label);
- void set_line_color(unsigned int which, const std::string &color);
- void set_line_width(unsigned int which, int width);
- void set_line_style(unsigned int which, int style);
- void set_line_marker(unsigned int which, int marker);
- void set_nsamps(const int size);
- void set_line_alpha(unsigned int which, double alpha);
- void set_trigger_mode(trigger_mode mode, trigger_slope slope,
- float level, int channel,
- const std::string &tag_key="");
-
- std::string title();
- std::string line_label(unsigned int which);
- std::string line_color(unsigned int which);
- int line_width(unsigned int which);
- int line_style(unsigned int which);
- int line_marker(unsigned int which);
- double line_alpha(unsigned int which);
-
- void set_size(int width, int height);
-
- int nsamps() const;
- void enable_menu(bool en);
- void enable_autoscale(bool en);
- void enable_grid(bool en);
- void enable_axis_labels(bool en);
- void disable_legend();
- void reset();
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace qtgui */
+ void set_y_axis(double min, double max);
+ void set_x_axis(double min, double max);
+
+ void set_update_time(double t);
+ void set_title(const std::string& title);
+ void set_line_label(unsigned int which, const std::string& label);
+ void set_line_color(unsigned int which, const std::string& color);
+ void set_line_width(unsigned int which, int width);
+ void set_line_style(unsigned int which, int style);
+ void set_line_marker(unsigned int which, int marker);
+ void set_nsamps(const int size);
+ void set_line_alpha(unsigned int which, double alpha);
+ void set_trigger_mode(trigger_mode mode,
+ trigger_slope slope,
+ float level,
+ int channel,
+ const std::string& tag_key = "");
+
+ std::string title();
+ std::string line_label(unsigned int which);
+ std::string line_color(unsigned int which);
+ int line_width(unsigned int which);
+ int line_style(unsigned int which);
+ int line_marker(unsigned int which);
+ double line_alpha(unsigned int which);
+
+ void set_size(int width, int height);
+
+ int nsamps() const;
+ void enable_menu(bool en);
+ void enable_autoscale(bool en);
+ void enable_grid(bool en);
+ void enable_axis_labels(bool en);
+ void disable_legend();
+ void reset();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
+
+} /* namespace qtgui */
} /* namespace gr */
#endif /* INCLUDED_QTGUI_CONST_SINK_C_IMPL_H */
diff --git a/gr-qtgui/lib/constellationdisplayform.cc b/gr-qtgui/lib/constellationdisplayform.cc
index bc70bb92d2..b14a8a8fbd 100644
--- a/gr-qtgui/lib/constellationdisplayform.cc
+++ b/gr-qtgui/lib/constellationdisplayform.cc
@@ -27,227 +27,195 @@
#include <iostream>
ConstellationDisplayForm::ConstellationDisplayForm(int nplots, QWidget* parent)
- : DisplayForm(nplots, parent)
-{
- d_int_validator = new QIntValidator(this);
- d_int_validator->setBottom(0);
-
- d_layout = new QGridLayout(this);
- d_display_plot = new ConstellationDisplayPlot(nplots, this);
- d_layout->addWidget(d_display_plot, 0, 0);
- setLayout(d_layout);
-
- d_nptsmenu = new NPointsMenu(this);
- d_menu->addAction(d_nptsmenu);
- connect(d_nptsmenu, SIGNAL(whichTrigger(int)),
- this, SLOT(setNPoints(const int)));
-
- // Set up the trigger menu
- d_triggermenu = new QMenu("Trigger", this);
- d_tr_mode_menu = new TriggerModeMenu(this);
- d_tr_slope_menu = new TriggerSlopeMenu(this);
- d_tr_level_act = new PopupMenu("Level", this);
- d_tr_channel_menu = new TriggerChannelMenu(nplots, this);
- d_tr_tag_key_act = new PopupMenu("Tag Key", this);
- d_triggermenu->addMenu(d_tr_mode_menu);
- d_triggermenu->addMenu(d_tr_slope_menu);
- d_triggermenu->addAction(d_tr_level_act);
- d_triggermenu->addMenu(d_tr_channel_menu);
- d_triggermenu->addAction(d_tr_tag_key_act);
- d_menu->addMenu(d_triggermenu);
-
- setTriggerMode(gr::qtgui::TRIG_MODE_FREE);
- connect(d_tr_mode_menu, SIGNAL(whichTrigger(gr::qtgui::trigger_mode)),
- this, SLOT(setTriggerMode(gr::qtgui::trigger_mode)));
- // updates trigger state by calling set level or set tag key.
- connect(d_tr_mode_menu, SIGNAL(whichTrigger(gr::qtgui::trigger_mode)),
- this, SLOT(updateTrigger(gr::qtgui::trigger_mode)));
-
- setTriggerSlope(gr::qtgui::TRIG_SLOPE_POS);
- connect(d_tr_slope_menu, SIGNAL(whichTrigger(gr::qtgui::trigger_slope)),
- this, SLOT(setTriggerSlope(gr::qtgui::trigger_slope)));
-
- setTriggerLevel(0);
- connect(d_tr_level_act, SIGNAL(whichTrigger(QString)),
- this, SLOT(setTriggerLevel(QString)));
-
- setTriggerChannel(0);
- connect(d_tr_channel_menu, SIGNAL(whichTrigger(int)),
- this, SLOT(setTriggerChannel(int)));
-
- setTriggerTagKey(std::string(""));
- connect(d_tr_tag_key_act, SIGNAL(whichTrigger(QString)),
- this, SLOT(setTriggerTagKey(QString)));
-
- Reset();
-
- connect(d_display_plot, SIGNAL(plotPointSelected(const QPointF)),
- this, SLOT(onPlotPointSelected(const QPointF)));
+ : DisplayForm(nplots, parent)
+{
+ d_int_validator = new QIntValidator(this);
+ d_int_validator->setBottom(0);
+
+ d_layout = new QGridLayout(this);
+ d_display_plot = new ConstellationDisplayPlot(nplots, this);
+ d_layout->addWidget(d_display_plot, 0, 0);
+ setLayout(d_layout);
+
+ d_nptsmenu = new NPointsMenu(this);
+ d_menu->addAction(d_nptsmenu);
+ connect(d_nptsmenu, SIGNAL(whichTrigger(int)), this, SLOT(setNPoints(const int)));
+
+ // Set up the trigger menu
+ d_triggermenu = new QMenu("Trigger", this);
+ d_tr_mode_menu = new TriggerModeMenu(this);
+ d_tr_slope_menu = new TriggerSlopeMenu(this);
+ d_tr_level_act = new PopupMenu("Level", this);
+ d_tr_channel_menu = new TriggerChannelMenu(nplots, this);
+ d_tr_tag_key_act = new PopupMenu("Tag Key", this);
+ d_triggermenu->addMenu(d_tr_mode_menu);
+ d_triggermenu->addMenu(d_tr_slope_menu);
+ d_triggermenu->addAction(d_tr_level_act);
+ d_triggermenu->addMenu(d_tr_channel_menu);
+ d_triggermenu->addAction(d_tr_tag_key_act);
+ d_menu->addMenu(d_triggermenu);
+
+ setTriggerMode(gr::qtgui::TRIG_MODE_FREE);
+ connect(d_tr_mode_menu,
+ SIGNAL(whichTrigger(gr::qtgui::trigger_mode)),
+ this,
+ SLOT(setTriggerMode(gr::qtgui::trigger_mode)));
+ // updates trigger state by calling set level or set tag key.
+ connect(d_tr_mode_menu,
+ SIGNAL(whichTrigger(gr::qtgui::trigger_mode)),
+ this,
+ SLOT(updateTrigger(gr::qtgui::trigger_mode)));
+
+ setTriggerSlope(gr::qtgui::TRIG_SLOPE_POS);
+ connect(d_tr_slope_menu,
+ SIGNAL(whichTrigger(gr::qtgui::trigger_slope)),
+ this,
+ SLOT(setTriggerSlope(gr::qtgui::trigger_slope)));
+
+ setTriggerLevel(0);
+ connect(d_tr_level_act,
+ SIGNAL(whichTrigger(QString)),
+ this,
+ SLOT(setTriggerLevel(QString)));
+
+ setTriggerChannel(0);
+ connect(
+ d_tr_channel_menu, SIGNAL(whichTrigger(int)), this, SLOT(setTriggerChannel(int)));
+
+ setTriggerTagKey(std::string(""));
+ connect(d_tr_tag_key_act,
+ SIGNAL(whichTrigger(QString)),
+ this,
+ SLOT(setTriggerTagKey(QString)));
+
+ Reset();
+
+ connect(d_display_plot,
+ SIGNAL(plotPointSelected(const QPointF)),
+ this,
+ SLOT(onPlotPointSelected(const QPointF)));
}
ConstellationDisplayForm::~ConstellationDisplayForm()
{
- // Qt deletes children when parent is deleted
+ // Qt deletes children when parent is deleted
- // Don't worry about deleting Display Plots - they are deleted when parents are deleted
- delete d_int_validator;
+ // Don't worry about deleting Display Plots - they are deleted when parents are
+ // deleted
+ delete d_int_validator;
}
-ConstellationDisplayPlot*
-ConstellationDisplayForm::getPlot()
+ConstellationDisplayPlot* ConstellationDisplayForm::getPlot()
{
- return ((ConstellationDisplayPlot*)d_display_plot);
+ return ((ConstellationDisplayPlot*)d_display_plot);
}
-void
-ConstellationDisplayForm::newData(const QEvent* updateEvent)
+void ConstellationDisplayForm::newData(const QEvent* updateEvent)
{
- ConstUpdateEvent *tevent = (ConstUpdateEvent*)updateEvent;
- const std::vector<double*> realDataPoints = tevent->getRealPoints();
- const std::vector<double*> imagDataPoints = tevent->getImagPoints();
- const uint64_t numDataPoints = tevent->getNumDataPoints();
+ ConstUpdateEvent* tevent = (ConstUpdateEvent*)updateEvent;
+ const std::vector<double*> realDataPoints = tevent->getRealPoints();
+ const std::vector<double*> imagDataPoints = tevent->getImagPoints();
+ const uint64_t numDataPoints = tevent->getNumDataPoints();
- getPlot()->plotNewData(realDataPoints,
- imagDataPoints,
- numDataPoints,
- d_update_time);
+ getPlot()->plotNewData(realDataPoints, imagDataPoints, numDataPoints, d_update_time);
}
-void
-ConstellationDisplayForm::customEvent(QEvent * e)
+void ConstellationDisplayForm::customEvent(QEvent* e)
{
- if(e->type() == ConstUpdateEvent::Type()) {
- newData(e);
- }
+ if (e->type() == ConstUpdateEvent::Type()) {
+ newData(e);
+ }
}
-int
-ConstellationDisplayForm::getNPoints() const
-{
- return d_npoints;
-}
+int ConstellationDisplayForm::getNPoints() const { return d_npoints; }
-void
-ConstellationDisplayForm::setNPoints(const int npoints)
-{
- d_npoints = npoints;
-}
+void ConstellationDisplayForm::setNPoints(const int npoints) { d_npoints = npoints; }
-void
-ConstellationDisplayForm::setYaxis(double min, double max)
+void ConstellationDisplayForm::setYaxis(double min, double max)
{
- getPlot()->set_yaxis(min, max);
+ getPlot()->set_yaxis(min, max);
}
-void
-ConstellationDisplayForm::setXaxis(double min, double max)
+void ConstellationDisplayForm::setXaxis(double min, double max)
{
- getPlot()->set_xaxis(min, max);
+ getPlot()->set_xaxis(min, max);
}
-void
-ConstellationDisplayForm::autoScale(bool en)
+void ConstellationDisplayForm::autoScale(bool en)
{
- d_autoscale_state = en;
- d_autoscale_act->setChecked(en);
- getPlot()->setAutoScale(d_autoscale_state);
- getPlot()->replot();
+ d_autoscale_state = en;
+ d_autoscale_act->setChecked(en);
+ getPlot()->setAutoScale(d_autoscale_state);
+ getPlot()->replot();
}
-void
-ConstellationDisplayForm::setSampleRate(const QString &samprate)
-{
-}
+void ConstellationDisplayForm::setSampleRate(const QString& samprate) {}
/********************************************************************
* TRIGGER METHODS
*******************************************************************/
-void
-ConstellationDisplayForm::setTriggerMode(gr::qtgui::trigger_mode mode)
+void ConstellationDisplayForm::setTriggerMode(gr::qtgui::trigger_mode mode)
{
- d_trig_mode = mode;
- d_tr_mode_menu->getAction(mode)->setChecked(true);
+ d_trig_mode = mode;
+ d_tr_mode_menu->getAction(mode)->setChecked(true);
}
-void
-ConstellationDisplayForm::updateTrigger(gr::qtgui::trigger_mode mode)
+void ConstellationDisplayForm::updateTrigger(gr::qtgui::trigger_mode mode)
{
- // If auto or normal mode, popup trigger level box to set
- if((d_trig_mode == gr::qtgui::TRIG_MODE_AUTO) || (d_trig_mode == gr::qtgui::TRIG_MODE_NORM))
- d_tr_level_act->activate(QAction::Trigger);
+ // If auto or normal mode, popup trigger level box to set
+ if ((d_trig_mode == gr::qtgui::TRIG_MODE_AUTO) ||
+ (d_trig_mode == gr::qtgui::TRIG_MODE_NORM))
+ d_tr_level_act->activate(QAction::Trigger);
- // if tag mode, popup tag key box to set
- if(d_trig_mode == gr::qtgui::TRIG_MODE_TAG)
- d_tr_tag_key_act->activate(QAction::Trigger);
+ // if tag mode, popup tag key box to set
+ if (d_trig_mode == gr::qtgui::TRIG_MODE_TAG)
+ d_tr_tag_key_act->activate(QAction::Trigger);
}
-gr::qtgui::trigger_mode
-ConstellationDisplayForm::getTriggerMode() const
+gr::qtgui::trigger_mode ConstellationDisplayForm::getTriggerMode() const
{
- return d_trig_mode;
+ return d_trig_mode;
}
-void
-ConstellationDisplayForm::setTriggerSlope(gr::qtgui::trigger_slope slope)
+void ConstellationDisplayForm::setTriggerSlope(gr::qtgui::trigger_slope slope)
{
- d_trig_slope = slope;
- d_tr_slope_menu->getAction(slope)->setChecked(true);
+ d_trig_slope = slope;
+ d_tr_slope_menu->getAction(slope)->setChecked(true);
}
-gr::qtgui::trigger_slope
-ConstellationDisplayForm::getTriggerSlope() const
+gr::qtgui::trigger_slope ConstellationDisplayForm::getTriggerSlope() const
{
- return d_trig_slope;
+ return d_trig_slope;
}
-void
-ConstellationDisplayForm::setTriggerLevel(QString s)
-{
- d_trig_level = s.toFloat();
-}
+void ConstellationDisplayForm::setTriggerLevel(QString s) { d_trig_level = s.toFloat(); }
-void
-ConstellationDisplayForm::setTriggerLevel(float level)
+void ConstellationDisplayForm::setTriggerLevel(float level)
{
- d_trig_level = level;
- d_tr_level_act->setText(QString().setNum(d_trig_level));
+ d_trig_level = level;
+ d_tr_level_act->setText(QString().setNum(d_trig_level));
}
-float
-ConstellationDisplayForm::getTriggerLevel() const
-{
- return d_trig_level;
-}
+float ConstellationDisplayForm::getTriggerLevel() const { return d_trig_level; }
-void
-ConstellationDisplayForm::setTriggerChannel(int channel)
+void ConstellationDisplayForm::setTriggerChannel(int channel)
{
- d_trig_channel = channel;
- d_tr_channel_menu->getAction(d_trig_channel)->setChecked(true);
+ d_trig_channel = channel;
+ d_tr_channel_menu->getAction(d_trig_channel)->setChecked(true);
}
-int
-ConstellationDisplayForm::getTriggerChannel() const
-{
- return d_trig_channel;
-}
+int ConstellationDisplayForm::getTriggerChannel() const { return d_trig_channel; }
-void
-ConstellationDisplayForm::setTriggerTagKey(QString s)
+void ConstellationDisplayForm::setTriggerTagKey(QString s)
{
- d_trig_tag_key = s.toStdString();
+ d_trig_tag_key = s.toStdString();
}
-void
-ConstellationDisplayForm::setTriggerTagKey(const std::string &key)
+void ConstellationDisplayForm::setTriggerTagKey(const std::string& key)
{
- d_trig_tag_key = key;
- d_tr_tag_key_act->setText(QString().fromStdString(d_trig_tag_key));
+ d_trig_tag_key = key;
+ d_tr_tag_key_act->setText(QString().fromStdString(d_trig_tag_key));
}
-std::string
-ConstellationDisplayForm::getTriggerTagKey() const
-{
- return d_trig_tag_key;
-}
+std::string ConstellationDisplayForm::getTriggerTagKey() const { return d_trig_tag_key; }
diff --git a/gr-qtgui/lib/displayform.cc b/gr-qtgui/lib/displayform.cc
index 4f65fe47f8..23329902fd 100644
--- a/gr-qtgui/lib/displayform.cc
+++ b/gr-qtgui/lib/displayform.cc
@@ -27,373 +27,321 @@
#include <QFileDialog>
DisplayForm::DisplayForm(int nplots, QWidget* parent)
- : QWidget(parent), d_nplots(nplots), d_system_specified_flag(false)
+ : QWidget(parent), d_nplots(nplots), d_system_specified_flag(false)
{
- d_isclosed = false;
- d_axislabels = true;
-
- // Set the initial plot size
- resize(QSize(800, 600));
-
- // Set up a grid that can be turned on/off
- d_grid = new QwtPlotGrid();
- QPen *gridpen = new QPen(Qt::DashLine);
- gridpen->setWidthF(0.25);
- gridpen->setColor(Qt::gray);
- d_grid->setPen(*gridpen);
-
- // Create a set of actions for the menu
- d_stop_act = new QAction("Stop", this);
- d_stop_act->setStatusTip(tr("Start/Stop"));
- connect(d_stop_act, SIGNAL(triggered()), this, SLOT(setStop()));
- d_stop_state = false;
-
- d_grid_act = new QAction("Grid", this);
- d_grid_act->setCheckable(true);
- d_grid_act->setStatusTip(tr("Toggle Grid on/off"));
- connect(d_grid_act, SIGNAL(triggered(bool)),
- this, SLOT(setGrid(bool)));
- d_grid_state = false;
-
- d_axislabelsmenu = new QAction("Axis Labels", this);
- d_axislabelsmenu->setCheckable(true);
- d_axislabelsmenu->setStatusTip(tr("Toggle Axis Labels on/off"));
- connect(d_axislabelsmenu, SIGNAL(triggered(bool)),
- this, SLOT(setAxisLabels(bool)));
-
- // Create a pop-up menu for manipulating the figure
- d_menu_on = true;
- d_menu = new QMenu(this);
- d_menu->addAction(d_stop_act);
- d_menu->addAction(d_grid_act);
- d_menu->addAction(d_axislabelsmenu);
-
- for(unsigned int i = 0; i < d_nplots; ++i) {
- d_line_title_act.push_back(new LineTitleAction(i, this));
- d_line_color_menu.push_back(new LineColorMenu(i, this));
- d_line_width_menu.push_back(new LineWidthMenu(i, this));
- d_line_style_menu.push_back(new LineStyleMenu(i, this));
- d_line_marker_menu.push_back(new LineMarkerMenu(i, this));
- d_marker_alpha_menu.push_back(new MarkerAlphaMenu(i, this));
-
- connect(d_line_title_act[i], SIGNAL(whichTrigger(unsigned int, const QString&)),
- this, SLOT(setLineLabel(unsigned int, const QString&)));
-
- for(int j = 0; j < d_line_color_menu[i]->getNumActions(); j++) {
- connect(d_line_color_menu[i], SIGNAL(whichTrigger(unsigned int, const QString&)),
- this, SLOT(setLineColor(unsigned int, const QString&)));
- }
+ d_isclosed = false;
+ d_axislabels = true;
- for(int j = 0; j < d_line_width_menu[i]->getNumActions(); j++) {
- connect(d_line_width_menu[i], SIGNAL(whichTrigger(unsigned int, unsigned int)),
- this, SLOT(setLineWidth(unsigned int, unsigned int)));
- }
+ // Set the initial plot size
+ resize(QSize(800, 600));
- for(int j = 0; j < d_line_style_menu[i]->getNumActions(); j++) {
- connect(d_line_style_menu[i], SIGNAL(whichTrigger(unsigned int, Qt::PenStyle)),
- this, SLOT(setLineStyle(unsigned int, Qt::PenStyle)));
- }
+ // Set up a grid that can be turned on/off
+ d_grid = new QwtPlotGrid();
+ QPen* gridpen = new QPen(Qt::DashLine);
+ gridpen->setWidthF(0.25);
+ gridpen->setColor(Qt::gray);
+ d_grid->setPen(*gridpen);
- for(int j = 0; j < d_line_marker_menu[i]->getNumActions(); j++) {
- connect(d_line_marker_menu[i], SIGNAL(whichTrigger(unsigned int, QwtSymbol::Style)),
- this, SLOT(setLineMarker(unsigned int, QwtSymbol::Style)));
- }
+ // Create a set of actions for the menu
+ d_stop_act = new QAction("Stop", this);
+ d_stop_act->setStatusTip(tr("Start/Stop"));
+ connect(d_stop_act, SIGNAL(triggered()), this, SLOT(setStop()));
+ d_stop_state = false;
- for(int j = 0; j < d_marker_alpha_menu[i]->getNumActions(); j++) {
- connect(d_marker_alpha_menu[i], SIGNAL(whichTrigger(unsigned int, unsigned int)),
- this, SLOT(setMarkerAlpha(unsigned int, unsigned int)));
+ d_grid_act = new QAction("Grid", this);
+ d_grid_act->setCheckable(true);
+ d_grid_act->setStatusTip(tr("Toggle Grid on/off"));
+ connect(d_grid_act, SIGNAL(triggered(bool)), this, SLOT(setGrid(bool)));
+ d_grid_state = false;
+
+ d_axislabelsmenu = new QAction("Axis Labels", this);
+ d_axislabelsmenu->setCheckable(true);
+ d_axislabelsmenu->setStatusTip(tr("Toggle Axis Labels on/off"));
+ connect(d_axislabelsmenu, SIGNAL(triggered(bool)), this, SLOT(setAxisLabels(bool)));
+
+ // Create a pop-up menu for manipulating the figure
+ d_menu_on = true;
+ d_menu = new QMenu(this);
+ d_menu->addAction(d_stop_act);
+ d_menu->addAction(d_grid_act);
+ d_menu->addAction(d_axislabelsmenu);
+
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ d_line_title_act.push_back(new LineTitleAction(i, this));
+ d_line_color_menu.push_back(new LineColorMenu(i, this));
+ d_line_width_menu.push_back(new LineWidthMenu(i, this));
+ d_line_style_menu.push_back(new LineStyleMenu(i, this));
+ d_line_marker_menu.push_back(new LineMarkerMenu(i, this));
+ d_marker_alpha_menu.push_back(new MarkerAlphaMenu(i, this));
+
+ connect(d_line_title_act[i],
+ SIGNAL(whichTrigger(unsigned int, const QString&)),
+ this,
+ SLOT(setLineLabel(unsigned int, const QString&)));
+
+ for (int j = 0; j < d_line_color_menu[i]->getNumActions(); j++) {
+ connect(d_line_color_menu[i],
+ SIGNAL(whichTrigger(unsigned int, const QString&)),
+ this,
+ SLOT(setLineColor(unsigned int, const QString&)));
+ }
+
+ for (int j = 0; j < d_line_width_menu[i]->getNumActions(); j++) {
+ connect(d_line_width_menu[i],
+ SIGNAL(whichTrigger(unsigned int, unsigned int)),
+ this,
+ SLOT(setLineWidth(unsigned int, unsigned int)));
+ }
+
+ for (int j = 0; j < d_line_style_menu[i]->getNumActions(); j++) {
+ connect(d_line_style_menu[i],
+ SIGNAL(whichTrigger(unsigned int, Qt::PenStyle)),
+ this,
+ SLOT(setLineStyle(unsigned int, Qt::PenStyle)));
+ }
+
+ for (int j = 0; j < d_line_marker_menu[i]->getNumActions(); j++) {
+ connect(d_line_marker_menu[i],
+ SIGNAL(whichTrigger(unsigned int, QwtSymbol::Style)),
+ this,
+ SLOT(setLineMarker(unsigned int, QwtSymbol::Style)));
+ }
+
+ for (int j = 0; j < d_marker_alpha_menu[i]->getNumActions(); j++) {
+ connect(d_marker_alpha_menu[i],
+ SIGNAL(whichTrigger(unsigned int, unsigned int)),
+ this,
+ SLOT(setMarkerAlpha(unsigned int, unsigned int)));
+ }
+
+ d_lines_menu.push_back(new QMenu(tr(""), this));
+ d_lines_menu[i]->addAction(d_line_title_act[i]);
+ d_lines_menu[i]->addMenu(d_line_color_menu[i]);
+ d_lines_menu[i]->addMenu(d_line_width_menu[i]);
+ d_lines_menu[i]->addMenu(d_line_style_menu[i]);
+ d_lines_menu[i]->addMenu(d_line_marker_menu[i]);
+ d_lines_menu[i]->addMenu(d_marker_alpha_menu[i]);
+ d_menu->addMenu(d_lines_menu[i]);
}
- d_lines_menu.push_back(new QMenu(tr(""), this));
- d_lines_menu[i]->addAction(d_line_title_act[i]);
- d_lines_menu[i]->addMenu(d_line_color_menu[i]);
- d_lines_menu[i]->addMenu(d_line_width_menu[i]);
- d_lines_menu[i]->addMenu(d_line_style_menu[i]);
- d_lines_menu[i]->addMenu(d_line_marker_menu[i]);
- d_lines_menu[i]->addMenu(d_marker_alpha_menu[i]);
- d_menu->addMenu(d_lines_menu[i]);
- }
-
- d_samp_rate_act = new PopupMenu("Sample Rate", this);
- d_samp_rate_act->setStatusTip(tr("Set Sample Rate"));
- connect(d_samp_rate_act, SIGNAL(whichTrigger(QString)),
- this, SLOT(setSampleRate(QString)));
- d_menu->addAction(d_samp_rate_act);
-
- d_autoscale_act = new QAction("Auto Scale", this);
- d_autoscale_act->setStatusTip(tr("Autoscale Plot"));
- d_autoscale_act->setCheckable(true);
- connect(d_autoscale_act, SIGNAL(triggered(bool)),
- this, SLOT(autoScale(bool)));
- d_autoscale_state = false;
- d_menu->addAction(d_autoscale_act);
-
- d_save_act = new QAction("Save", this);
- d_save_act->setStatusTip(tr("Save Figure"));
- connect(d_save_act, SIGNAL(triggered()), this, SLOT(saveFigure()));
- d_menu->addAction(d_save_act);
-
- Reset();
+ d_samp_rate_act = new PopupMenu("Sample Rate", this);
+ d_samp_rate_act->setStatusTip(tr("Set Sample Rate"));
+ connect(d_samp_rate_act,
+ SIGNAL(whichTrigger(QString)),
+ this,
+ SLOT(setSampleRate(QString)));
+ d_menu->addAction(d_samp_rate_act);
+
+ d_autoscale_act = new QAction("Auto Scale", this);
+ d_autoscale_act->setStatusTip(tr("Autoscale Plot"));
+ d_autoscale_act->setCheckable(true);
+ connect(d_autoscale_act, SIGNAL(triggered(bool)), this, SLOT(autoScale(bool)));
+ d_autoscale_state = false;
+ d_menu->addAction(d_autoscale_act);
+
+ d_save_act = new QAction("Save", this);
+ d_save_act->setStatusTip(tr("Save Figure"));
+ connect(d_save_act, SIGNAL(triggered()), this, SLOT(saveFigure()));
+ d_menu->addAction(d_save_act);
+
+ Reset();
}
DisplayForm::~DisplayForm()
{
- d_isclosed = true;
+ d_isclosed = true;
- // Qt deletes children when parent is deleted
- // Don't worry about deleting Display Plots - they are deleted when parents are deleted
+ // Qt deletes children when parent is deleted
+ // Don't worry about deleting Display Plots - they are deleted when parents are
+ // deleted
}
-void
-DisplayForm::resizeEvent( QResizeEvent *e )
+void DisplayForm::resizeEvent(QResizeEvent* e)
{
- //QSize s = size();
- //emit d_display_plot->resizeSlot(&s);
+ // QSize s = size();
+ // emit d_display_plot->resizeSlot(&s);
}
-void
-DisplayForm::mousePressEvent( QMouseEvent * e)
+void DisplayForm::mousePressEvent(QMouseEvent* e)
{
- bool ctrloff = Qt::ControlModifier != QApplication::keyboardModifiers();
- if((e->button() == Qt::MidButton) && ctrloff && (d_menu_on)) {
- if(d_stop_state == false)
- d_stop_act->setText(tr("Stop"));
- else
- d_stop_act->setText(tr("Start"));
+ bool ctrloff = Qt::ControlModifier != QApplication::keyboardModifiers();
+ if ((e->button() == Qt::MidButton) && ctrloff && (d_menu_on)) {
+ if (d_stop_state == false)
+ d_stop_act->setText(tr("Stop"));
+ else
+ d_stop_act->setText(tr("Start"));
- // Update the line titles if changed externally
- for(unsigned int i = 0; i < d_nplots; ++i) {
- d_lines_menu[i]->setTitle(d_display_plot->getLineLabel(i));
+ // Update the line titles if changed externally
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ d_lines_menu[i]->setTitle(d_display_plot->getLineLabel(i));
+ }
+ d_menu->exec(e->globalPos());
}
- d_menu->exec(e->globalPos());
- }
}
-void
-DisplayForm::updateGuiTimer()
-{
- d_display_plot->canvas()->update();
-}
+void DisplayForm::updateGuiTimer() { d_display_plot->canvas()->update(); }
-void
-DisplayForm::onPlotPointSelected(const QPointF p)
-{
- emit plotPointSelected(p, 3);
-}
+void DisplayForm::onPlotPointSelected(const QPointF p) { emit plotPointSelected(p, 3); }
-void
-DisplayForm::Reset()
-{
-}
+void DisplayForm::Reset() {}
-bool
-DisplayForm::isClosed() const
-{
- return d_isclosed;
-}
+bool DisplayForm::isClosed() const { return d_isclosed; }
-void
-DisplayForm::enableMenu(bool en)
-{
- d_menu_on = en;
-}
+void DisplayForm::enableMenu(bool en) { d_menu_on = en; }
-void
-DisplayForm::closeEvent(QCloseEvent *e)
+void DisplayForm::closeEvent(QCloseEvent* e)
{
- d_isclosed = true;
- qApp->processEvents();
- QWidget::closeEvent(e);
+ d_isclosed = true;
+ qApp->processEvents();
+ QWidget::closeEvent(e);
}
-void
-DisplayForm::setUpdateTime(double t)
-{
- d_update_time = t;
-}
+void DisplayForm::setUpdateTime(double t) { d_update_time = t; }
-void
-DisplayForm::setTitle(const QString &title)
-{
- d_display_plot->setTitle(title);
-}
+void DisplayForm::setTitle(const QString& title) { d_display_plot->setTitle(title); }
-void
-DisplayForm::setLineLabel(unsigned int which, const QString &label)
+void DisplayForm::setLineLabel(unsigned int which, const QString& label)
{
- d_display_plot->setLineLabel(which, label);
+ d_display_plot->setLineLabel(which, label);
}
-void
-DisplayForm::setLineColor(unsigned int which, const QString &color)
+void DisplayForm::setLineColor(unsigned int which, const QString& color)
{
- QColor c = QColor(color);
- d_display_plot->setLineColor(which, c);
- d_display_plot->replot();
+ QColor c = QColor(color);
+ d_display_plot->setLineColor(which, c);
+ d_display_plot->replot();
}
-void
-DisplayForm::setLineWidth(unsigned int which, unsigned int width)
+void DisplayForm::setLineWidth(unsigned int which, unsigned int width)
{
- d_display_plot->setLineWidth(which, width);
- d_display_plot->replot();
+ d_display_plot->setLineWidth(which, width);
+ d_display_plot->replot();
}
-void
-DisplayForm::setLineStyle(unsigned int which, Qt::PenStyle style)
+void DisplayForm::setLineStyle(unsigned int which, Qt::PenStyle style)
{
- d_display_plot->setLineStyle(which, style);
- d_display_plot->replot();
+ d_display_plot->setLineStyle(which, style);
+ d_display_plot->replot();
}
-void
-DisplayForm::setLineMarker(unsigned int which, QwtSymbol::Style marker)
+void DisplayForm::setLineMarker(unsigned int which, QwtSymbol::Style marker)
{
- d_display_plot->setLineMarker(which, marker);
- d_display_plot->replot();
+ d_display_plot->setLineMarker(which, marker);
+ d_display_plot->replot();
}
-void
-DisplayForm::setMarkerAlpha(unsigned int which, unsigned int alpha)
+void DisplayForm::setMarkerAlpha(unsigned int which, unsigned int alpha)
{
- d_display_plot->setMarkerAlpha(which, alpha);
- d_display_plot->replot();
+ d_display_plot->setMarkerAlpha(which, alpha);
+ d_display_plot->replot();
}
-QString
-DisplayForm::title()
-{
- return d_display_plot->title().text();
-}
+QString DisplayForm::title() { return d_display_plot->title().text(); }
-QString
-DisplayForm::lineLabel(unsigned int which)
+QString DisplayForm::lineLabel(unsigned int which)
{
- return d_display_plot->getLineLabel(which);
+ return d_display_plot->getLineLabel(which);
}
-QString
-DisplayForm::lineColor(unsigned int which)
+QString DisplayForm::lineColor(unsigned int which)
{
- return d_display_plot->getLineColor(which).name();
+ return d_display_plot->getLineColor(which).name();
}
-int
-DisplayForm::lineWidth(unsigned int which)
+int DisplayForm::lineWidth(unsigned int which)
{
- return d_display_plot->getLineWidth(which);
+ return d_display_plot->getLineWidth(which);
}
-Qt::PenStyle
-DisplayForm::lineStyle(unsigned int which)
+Qt::PenStyle DisplayForm::lineStyle(unsigned int which)
{
- return d_display_plot->getLineStyle(which);
+ return d_display_plot->getLineStyle(which);
}
-QwtSymbol::Style
-DisplayForm::lineMarker(unsigned int which)
+QwtSymbol::Style DisplayForm::lineMarker(unsigned int which)
{
- return d_display_plot->getLineMarker(which);
+ return d_display_plot->getLineMarker(which);
}
-int
-DisplayForm::markerAlpha(unsigned int which)
+int DisplayForm::markerAlpha(unsigned int which)
{
- return d_display_plot->getMarkerAlpha(which);
+ return d_display_plot->getMarkerAlpha(which);
}
-void
-DisplayForm::setSampleRate(const QString &rate)
-{
-}
+void DisplayForm::setSampleRate(const QString& rate) {}
-void
-DisplayForm::setStop(bool on)
+void DisplayForm::setStop(bool on)
{
- if(!on) {
- // will auto-detach if already attached.
- d_display_plot->setStop(false);
- d_stop_state = false;
- }
- else {
- d_display_plot->setStop(true);
- d_stop_state = true;
- }
- d_display_plot->replot();
+ if (!on) {
+ // will auto-detach if already attached.
+ d_display_plot->setStop(false);
+ d_stop_state = false;
+ } else {
+ d_display_plot->setStop(true);
+ d_stop_state = true;
+ }
+ d_display_plot->replot();
}
-void
-DisplayForm::setStop()
+void DisplayForm::setStop()
{
- if(d_stop_state == false)
- setStop(true);
- else
- setStop(false);
+ if (d_stop_state == false)
+ setStop(true);
+ else
+ setStop(false);
}
-void
-DisplayForm::setGrid(bool on)
+void DisplayForm::setGrid(bool on)
{
- if(on) {
- // will auto-detach if already attached.
- d_grid->attach(d_display_plot);
- d_grid_state = true;
- }
- else {
- d_grid->detach();
- d_grid_state = false;
- }
- d_grid_act->setChecked(on);
- d_display_plot->replot();
+ if (on) {
+ // will auto-detach if already attached.
+ d_grid->attach(d_display_plot);
+ d_grid_state = true;
+ } else {
+ d_grid->detach();
+ d_grid_state = false;
+ }
+ d_grid_act->setChecked(on);
+ d_display_plot->replot();
}
-void
-DisplayForm::setAxisLabels(bool en)
+void DisplayForm::setAxisLabels(bool en)
{
- d_axislabels = en;
- d_axislabelsmenu->setChecked(en);
- getPlot()->setAxisLabels(d_axislabels);
+ d_axislabels = en;
+ d_axislabelsmenu->setChecked(en);
+ getPlot()->setAxisLabels(d_axislabels);
}
-void
-DisplayForm::saveFigure()
+void DisplayForm::saveFigure()
{
- QPixmap qpix = QPixmap::grabWidget(this);
-
- QString types = QString(tr("JPEG file (*.jpg);;Portable Network Graphics file (*.png);;Bitmap file (*.bmp);;TIFF file (*.tiff)"));
-
- QString filename, filetype;
- QFileDialog *filebox = new QFileDialog(0, "Save Image", "./", types);
- filebox->setViewMode(QFileDialog::Detail);
- if(filebox->exec()) {
- filename = filebox->selectedFiles()[0];
- filetype = filebox->selectedNameFilter();
- }
- else {
- return;
- }
-
- if(filetype.contains(".jpg")) {
- qpix.save(filename, "JPEG");
- }
- else if(filetype.contains(".png")) {
- qpix.save(filename, "PNG");
- }
- else if(filetype.contains(".bmp")) {
- qpix.save(filename, "BMP");
- }
- else if(filetype.contains(".tiff")) {
- qpix.save(filename, "TIFF");
- }
- else {
- qpix.save(filename, "JPEG");
- }
-
- delete filebox;
-}
+ QPixmap qpix = QPixmap::grabWidget(this);
-void
-DisplayForm::disableLegend()
-{
- d_display_plot->disableLegend();
+ QString types = QString(tr("JPEG file (*.jpg);;Portable Network Graphics file "
+ "(*.png);;Bitmap file (*.bmp);;TIFF file (*.tiff)"));
+
+ QString filename, filetype;
+ QFileDialog* filebox = new QFileDialog(0, "Save Image", "./", types);
+ filebox->setViewMode(QFileDialog::Detail);
+ if (filebox->exec()) {
+ filename = filebox->selectedFiles()[0];
+ filetype = filebox->selectedNameFilter();
+ } else {
+ return;
+ }
+
+ if (filetype.contains(".jpg")) {
+ qpix.save(filename, "JPEG");
+ } else if (filetype.contains(".png")) {
+ qpix.save(filename, "PNG");
+ } else if (filetype.contains(".bmp")) {
+ qpix.save(filename, "BMP");
+ } else if (filetype.contains(".tiff")) {
+ qpix.save(filename, "TIFF");
+ } else {
+ qpix.save(filename, "JPEG");
+ }
+
+ delete filebox;
}
+
+void DisplayForm::disableLegend() { d_display_plot->disableLegend(); }
diff --git a/gr-qtgui/lib/edit_box_msg_impl.cc b/gr-qtgui/lib/edit_box_msg_impl.cc
index 296352b268..4b38a59004 100644
--- a/gr-qtgui/lib/edit_box_msg_impl.cc
+++ b/gr-qtgui/lib/edit_box_msg_impl.cc
@@ -33,61 +33,62 @@
#include <boost/lexical_cast.hpp>
namespace gr {
- namespace qtgui {
-
- edit_box_msg::sptr
- edit_box_msg::make(data_type_t type, const std::string &label,
- const std::string &value,
- bool is_pair, bool is_static,
- const std::string &key, QWidget* parent)
- {
- return gnuradio::get_initial_sptr
- (new edit_box_msg_impl(type, value, label, is_pair,
- is_static, key, parent));
+namespace qtgui {
+
+edit_box_msg::sptr edit_box_msg::make(data_type_t type,
+ const std::string& label,
+ const std::string& value,
+ bool is_pair,
+ bool is_static,
+ const std::string& key,
+ QWidget* parent)
+{
+ return gnuradio::get_initial_sptr(
+ new edit_box_msg_impl(type, value, label, is_pair, is_static, key, parent));
+}
+
+edit_box_msg_impl::edit_box_msg_impl(data_type_t type,
+ const std::string& label,
+ const std::string& value,
+ bool is_pair,
+ bool is_static,
+ const std::string& key,
+ QWidget* parent)
+ : block("edit_box_msg", io_signature::make(0, 0, 0), io_signature::make(0, 0, 0)),
+ QObject(parent),
+ d_port(pmt::mp("msg"))
+{
+ // Required now for Qt; argc must be greater than 0 and argv
+ // must have at least one valid character. Must be valid through
+ // life of the qApplication:
+ // http://harmattan-dev.nokia.com/docs/library/html/qt4/qapplication.html
+ d_argc = 1;
+ d_argv = new char;
+ d_argv[0] = '\0';
+
+ if (qApp != NULL) {
+ d_qApplication = qApp;
+ } else {
+ d_qApplication = new QApplication(d_argc, &d_argv);
}
- edit_box_msg_impl::edit_box_msg_impl(data_type_t type, const std::string &label,
- const std::string &value,
- bool is_pair, bool is_static,
- const std::string &key, QWidget* parent)
- : block("edit_box_msg",
- io_signature::make(0, 0, 0),
- io_signature::make(0, 0, 0)),
- QObject(parent),
- d_port(pmt::mp("msg"))
- {
- // Required now for Qt; argc must be greater than 0 and argv
- // must have at least one valid character. Must be valid through
- // life of the qApplication:
- // http://harmattan-dev.nokia.com/docs/library/html/qt4/qapplication.html
- d_argc = 1;
- d_argv = new char;
- d_argv[0] = '\0';
-
- if(qApp != NULL) {
- d_qApplication = qApp;
- }
- else {
- d_qApplication = new QApplication(d_argc, &d_argv);
- }
-
- // If a style sheet is set in the prefs file, enable it here.
- check_set_qss(d_qApplication);
-
- d_is_pair = is_pair;
- d_is_static = is_static;
-
- d_val = new QLineEdit();
- d_val->setObjectName("qtgui_editboxmsg_val"); // used to set background color
- d_val->setText(QString(value.c_str()));
-
- set_type(type);
-
- d_group = new QGroupBox();
- d_vlayout = new QVBoxLayout(parent);
- d_hlayout = new QHBoxLayout(parent);
-
- if(d_is_pair) {
+ // If a style sheet is set in the prefs file, enable it here.
+ check_set_qss(d_qApplication);
+
+ d_is_pair = is_pair;
+ d_is_static = is_static;
+
+ d_val = new QLineEdit();
+ d_val->setObjectName("qtgui_editboxmsg_val"); // used to set background color
+ d_val->setText(QString(value.c_str()));
+
+ set_type(type);
+
+ d_group = new QGroupBox();
+ d_vlayout = new QVBoxLayout(parent);
+ d_hlayout = new QHBoxLayout(parent);
+
+ if (d_is_pair) {
d_key = new QLineEdit();
QString key_text = QString(key.c_str());
@@ -96,35 +97,35 @@ namespace gr {
// If static, we create the d_key object, which we use later
// to be consistent about getting the key string. But we do
// not add it to the layout.
- if(d_is_static) {
- d_key->setEnabled(false);
+ if (d_is_static) {
+ d_key->setEnabled(false);
- QFontMetrics fm = d_key->fontMetrics();
- int width = 15 + fm.width(key_text);
+ QFontMetrics fm = d_key->fontMetrics();
+ int width = 15 + fm.width(key_text);
- d_key->setFixedWidth(width);
+ d_key->setFixedWidth(width);
- // Verify that a default key has been set or emit an error
- if(key.size() == 0) {
- throw std::runtime_error("When using static + pair mode, please set a default key.");
- }
- }
- else {
- // Adding it to the layout if in non-static mode so users
- // can see and update the key.
- d_hlayout->addWidget(d_key);
+ // Verify that a default key has been set or emit an error
+ if (key.size() == 0) {
+ throw std::runtime_error(
+ "When using static + pair mode, please set a default key.");
+ }
+ } else {
+ // Adding it to the layout if in non-static mode so users
+ // can see and update the key.
+ d_hlayout->addWidget(d_key);
}
- }
+ }
- d_label = NULL;
- if(label != "") {
+ d_label = NULL;
+ if (label != "") {
d_label = new QLabel(QString(label.c_str()));
d_vlayout->addWidget(d_label);
- }
+ }
- d_hlayout->addWidget(d_val);
+ d_hlayout->addWidget(d_val);
- if(!d_is_static) {
+ if (!d_is_static) {
// If not static, we can change the key and the data type of
// the value box.
d_type_box = new QComboBox();
@@ -143,424 +144,380 @@ namespace gr {
d_type_box->setCurrentIndex(d_type);
d_hlayout->addWidget(d_type_box);
- QObject::connect(d_type_box, SIGNAL(currentIndexChanged(int)),
- this, SLOT(set_type(int)));
- }
+ QObject::connect(
+ d_type_box, SIGNAL(currentIndexChanged(int)), this, SLOT(set_type(int)));
+ }
- d_vlayout->addItem(d_hlayout);
- d_group->setLayout(d_vlayout);
+ d_vlayout->addItem(d_hlayout);
+ d_group->setLayout(d_vlayout);
- QObject::connect(d_val, SIGNAL(editingFinished()),
- this, SLOT(edit_finished()));
+ QObject::connect(d_val, SIGNAL(editingFinished()), this, SLOT(edit_finished()));
- d_msg = pmt::PMT_NIL;
+ d_msg = pmt::PMT_NIL;
- message_port_register_out(d_port);
- message_port_register_in(pmt::mp("val"));
+ message_port_register_out(d_port);
+ message_port_register_in(pmt::mp("val"));
- set_msg_handler(pmt::mp("val"),
- boost::bind(&edit_box_msg_impl::set_value, this, _1));
- }
+ set_msg_handler(pmt::mp("val"), boost::bind(&edit_box_msg_impl::set_value, this, _1));
+}
- edit_box_msg_impl::~edit_box_msg_impl()
- {
- delete d_argv;
- delete d_group;
- delete d_hlayout;
- delete d_vlayout;
- delete d_val;
- if(d_is_pair)
+edit_box_msg_impl::~edit_box_msg_impl()
+{
+ delete d_argv;
+ delete d_group;
+ delete d_hlayout;
+ delete d_vlayout;
+ delete d_val;
+ if (d_is_pair)
delete d_key;
- if(d_label)
+ if (d_label)
delete d_label;
- }
+}
- bool
- edit_box_msg_impl::start()
- {
- QString text = d_val->text();
- if(!text.isEmpty()) {
+bool edit_box_msg_impl::start()
+{
+ QString text = d_val->text();
+ if (!text.isEmpty()) {
edit_finished();
- }
-
- return block::start();
}
- void
- edit_box_msg_impl::exec_()
- {
- d_qApplication->exec();
- }
+ return block::start();
+}
- QWidget*
- edit_box_msg_impl::qwidget()
- {
- return (QWidget*)d_group;
- }
+void edit_box_msg_impl::exec_() { d_qApplication->exec(); }
+
+QWidget* edit_box_msg_impl::qwidget() { return (QWidget*)d_group; }
#ifdef ENABLE_PYTHON
- PyObject*
- edit_box_msg_impl::pyqwidget()
- {
- PyObject *w = PyLong_FromVoidPtr((void*)d_group);
- PyObject *retarg = Py_BuildValue("N", w);
- return retarg;
- }
+PyObject* edit_box_msg_impl::pyqwidget()
+{
+ PyObject* w = PyLong_FromVoidPtr((void*)d_group);
+ PyObject* retarg = Py_BuildValue("N", w);
+ return retarg;
+}
#else
- void *
- edit_box_msg_impl::pyqwidget()
- {
- return NULL;
- }
+void* edit_box_msg_impl::pyqwidget() { return NULL; }
#endif
- void
- edit_box_msg_impl::set_type(int type)
- {
- set_type(static_cast<data_type_t>(type));
- }
+void edit_box_msg_impl::set_type(int type) { set_type(static_cast<data_type_t>(type)); }
- void
- edit_box_msg_impl::set_type(gr::qtgui::data_type_t type)
- {
- d_type = type;
+void edit_box_msg_impl::set_type(gr::qtgui::data_type_t type)
+{
+ d_type = type;
- switch(d_type) {
- case INT:
- case INT_VEC:
- d_val->setStyleSheet("QLineEdit#qtgui_editboxmsg_val {background-color: #4CAF50;}");
+ switch (d_type) {
+ case INT:
+ case INT_VEC:
+ d_val->setStyleSheet(
+ "QLineEdit#qtgui_editboxmsg_val {background-color: #4CAF50;}");
break;
- case FLOAT:
- case FLOAT_VEC:
- d_val->setStyleSheet("QLineEdit#qtgui_editboxmsg_val {background-color: #F57C00;}");
+ case FLOAT:
+ case FLOAT_VEC:
+ d_val->setStyleSheet(
+ "QLineEdit#qtgui_editboxmsg_val {background-color: #F57C00;}");
break;
- case DOUBLE:
- case DOUBLE_VEC:
- d_val->setStyleSheet("QLineEdit#qtgui_editboxmsg_val {background-color: #00BCD4;}");
+ case DOUBLE:
+ case DOUBLE_VEC:
+ d_val->setStyleSheet(
+ "QLineEdit#qtgui_editboxmsg_val {background-color: #00BCD4;}");
break;
- case COMPLEX:
- case COMPLEX_VEC:
- d_val->setStyleSheet("QLineEdit#qtgui_editboxmsg_val {background-color: #2196F3;}");
+ case COMPLEX:
+ case COMPLEX_VEC:
+ d_val->setStyleSheet(
+ "QLineEdit#qtgui_editboxmsg_val {background-color: #2196F3;}");
break;
- case STRING:
- d_val->setStyleSheet("QLineEdit#qtgui_editboxmsg_val {background-color: #FFFFFF; color: #000000;}");
+ case STRING:
+ d_val->setStyleSheet("QLineEdit#qtgui_editboxmsg_val {background-color: #FFFFFF; "
+ "color: #000000;}");
break;
- }
}
+}
- void
- edit_box_msg_impl::set_value(pmt::pmt_t val)
- {
- // If the contents of the new value are the same as we already
- // had, don't update anything, just exit and move on.
- if(pmt::eqv(val, d_msg)) {
+void edit_box_msg_impl::set_value(pmt::pmt_t val)
+{
+ // If the contents of the new value are the same as we already
+ // had, don't update anything, just exit and move on.
+ if (pmt::eqv(val, d_msg)) {
return;
- }
+ }
- int xi;
- float xf;
- double xd;
- std::string xs;
- gr_complex xc;
+ int xi;
+ float xf;
+ double xd;
+ std::string xs;
+ gr_complex xc;
- d_msg = val;
+ d_msg = val;
- // Only update key if we're expecting a pair
- if(d_is_pair) {
+ // Only update key if we're expecting a pair
+ if (d_is_pair) {
// If we are, make sure that the PMT is actually a pair
- if(pmt::is_pair(val)) {
- pmt::pmt_t key = pmt::car(val);
- std::string skey = pmt::symbol_to_string(key);
-
- // If static, check to make sure that the key of the
- // incoming message matches our key. If it doesn't, emit a
- // warning and exit without changing anything.
- if(d_is_static) {
- std::string cur_key = d_key->text().toStdString();
- if(skey != cur_key) {
- GR_LOG_WARN(d_logger, boost::format("Got key '%1%' but expected '%2%'") \
- % skey % cur_key);
- return;
+ if (pmt::is_pair(val)) {
+ pmt::pmt_t key = pmt::car(val);
+ std::string skey = pmt::symbol_to_string(key);
+
+ // If static, check to make sure that the key of the
+ // incoming message matches our key. If it doesn't, emit a
+ // warning and exit without changing anything.
+ if (d_is_static) {
+ std::string cur_key = d_key->text().toStdString();
+ if (skey != cur_key) {
+ GR_LOG_WARN(d_logger,
+ boost::format("Got key '%1%' but expected '%2%'") % skey %
+ cur_key);
+ return;
+ }
}
- }
- val = pmt::cdr(val);
- d_key->setText(QString(skey.c_str()));
+ val = pmt::cdr(val);
+ d_key->setText(QString(skey.c_str()));
+ } else {
+ GR_LOG_WARN(d_logger, "Did not find PMT pair");
+ return;
}
- else {
- GR_LOG_WARN(d_logger, "Did not find PMT pair");
- return;
- }
- }
+ }
- switch(d_type) {
- case INT:
- if(pmt::is_integer(val)) {
- xi = pmt::to_long(val);
- d_val->setText(QString::number(xi));
- }
- else {
- GR_LOG_WARN(d_logger, "Conversion from integer failed");
- return;
+ switch (d_type) {
+ case INT:
+ if (pmt::is_integer(val)) {
+ xi = pmt::to_long(val);
+ d_val->setText(QString::number(xi));
+ } else {
+ GR_LOG_WARN(d_logger, "Conversion from integer failed");
+ return;
}
break;
- case INT_VEC:
- if(pmt::is_s32vector(val)) {
- QStringList text_list;
- const std::vector<int32_t> xv = pmt::s32vector_elements(val);
- for(size_t i = 0; i < xv.size(); i++) {
- text_list.append(QString::number(xv[i]));
- }
- d_val->setText(text_list.join(", "));
- }
- else {
- GR_LOG_WARN(d_logger, "Conversion from integer vector failed");
- return;
+ case INT_VEC:
+ if (pmt::is_s32vector(val)) {
+ QStringList text_list;
+ const std::vector<int32_t> xv = pmt::s32vector_elements(val);
+ for (size_t i = 0; i < xv.size(); i++) {
+ text_list.append(QString::number(xv[i]));
+ }
+ d_val->setText(text_list.join(", "));
+ } else {
+ GR_LOG_WARN(d_logger, "Conversion from integer vector failed");
+ return;
}
break;
- case FLOAT:
- if(pmt::is_real(val)) {
- xf = pmt::to_float(val);
- d_val->setText(QString::number(xf));
- }
- else {
- GR_LOG_WARN(d_logger, "Conversion from float failed");
- return;
+ case FLOAT:
+ if (pmt::is_real(val)) {
+ xf = pmt::to_float(val);
+ d_val->setText(QString::number(xf));
+ } else {
+ GR_LOG_WARN(d_logger, "Conversion from float failed");
+ return;
}
break;
- case FLOAT_VEC:
- if(pmt::is_f32vector(val)) {
- QStringList text_list;
- const std::vector<float> xv = pmt::f32vector_elements(val);
- for(size_t i = 0; i < xv.size(); i++) {
- text_list.append(QString::number(xv[i]));
- }
- d_val->setText(text_list.join(", "));
- }
- else {
- GR_LOG_WARN(d_logger, "Conversion from float vector failed");
- return;
+ case FLOAT_VEC:
+ if (pmt::is_f32vector(val)) {
+ QStringList text_list;
+ const std::vector<float> xv = pmt::f32vector_elements(val);
+ for (size_t i = 0; i < xv.size(); i++) {
+ text_list.append(QString::number(xv[i]));
+ }
+ d_val->setText(text_list.join(", "));
+ } else {
+ GR_LOG_WARN(d_logger, "Conversion from float vector failed");
+ return;
}
break;
- case DOUBLE:
- if(pmt::is_real(val)) {
- xd = pmt::to_double(val);
- d_val->setText(QString::number(xd));
- }
- else {
- GR_LOG_WARN(d_logger, "Conversion from double failed");
- return;
+ case DOUBLE:
+ if (pmt::is_real(val)) {
+ xd = pmt::to_double(val);
+ d_val->setText(QString::number(xd));
+ } else {
+ GR_LOG_WARN(d_logger, "Conversion from double failed");
+ return;
}
break;
- case DOUBLE_VEC:
- if(pmt::is_f64vector(val)) {
- QStringList text_list;
- const std::vector<double> xv = pmt::f64vector_elements(val);
- for(size_t i = 0; i < xv.size(); i++) {
- text_list.append(QString::number(xv[i]));
- }
- d_val->setText(text_list.join(", "));
- }
- else {
- GR_LOG_WARN(d_logger, "Conversion from double vector failed");
- return;
+ case DOUBLE_VEC:
+ if (pmt::is_f64vector(val)) {
+ QStringList text_list;
+ const std::vector<double> xv = pmt::f64vector_elements(val);
+ for (size_t i = 0; i < xv.size(); i++) {
+ text_list.append(QString::number(xv[i]));
+ }
+ d_val->setText(text_list.join(", "));
+ } else {
+ GR_LOG_WARN(d_logger, "Conversion from double vector failed");
+ return;
}
break;
- case COMPLEX:
- if(pmt::is_complex(val)) {
- xc = pmt::to_complex(val);
- d_val->setText(QString("(%1,%2)").arg(xc.real()).arg(xc.imag()));
- }
- else {
- GR_LOG_WARN(d_logger, "Conversion from complex failed");
- return;
+ case COMPLEX:
+ if (pmt::is_complex(val)) {
+ xc = pmt::to_complex(val);
+ d_val->setText(QString("(%1,%2)").arg(xc.real()).arg(xc.imag()));
+ } else {
+ GR_LOG_WARN(d_logger, "Conversion from complex failed");
+ return;
}
break;
- case COMPLEX_VEC:
- if(pmt::is_c32vector(val)) {
- QStringList text_list;
- const std::vector<gr_complex> xv = pmt::c32vector_elements(val);
- for(size_t i = 0; i < xv.size(); i++) {
- text_list.append(QString("(%1,%2)").arg(xv[i].real()).arg(xv[i].imag()));
- }
- d_val->setText(text_list.join(", "));
- }
- else {
- GR_LOG_WARN(d_logger, "Conversion from complex vector failed");
- return;
+ case COMPLEX_VEC:
+ if (pmt::is_c32vector(val)) {
+ QStringList text_list;
+ const std::vector<gr_complex> xv = pmt::c32vector_elements(val);
+ for (size_t i = 0; i < xv.size(); i++) {
+ text_list.append(QString("(%1,%2)").arg(xv[i].real()).arg(xv[i].imag()));
+ }
+ d_val->setText(text_list.join(", "));
+ } else {
+ GR_LOG_WARN(d_logger, "Conversion from complex vector failed");
+ return;
}
break;
- case STRING:
- if(pmt::is_symbol(val)) {
- xs = pmt::symbol_to_string(val);
- d_val->setText(QString(xs.c_str()));
- }
- else {
- GR_LOG_WARN(d_logger, "Conversion from string failed");
- return;
+ case STRING:
+ if (pmt::is_symbol(val)) {
+ xs = pmt::symbol_to_string(val);
+ d_val->setText(QString(xs.c_str()));
+ } else {
+ GR_LOG_WARN(d_logger, "Conversion from string failed");
+ return;
}
break;
- }
-
- // Emit the new message to pass updates downstream.
- // Loops are prevented by the early exit if d_msg == val.
- message_port_pub(d_port, d_msg);
}
- void
- edit_box_msg_impl::edit_finished()
- {
- QString text = d_val->text();
- bool conv_ok = true;
- int xi;
- float xf;
- double xd;
- std::string xs;
- gr_complex xc;
-
- switch(d_type) {
- case INT:
+ // Emit the new message to pass updates downstream.
+ // Loops are prevented by the early exit if d_msg == val.
+ message_port_pub(d_port, d_msg);
+}
+
+void edit_box_msg_impl::edit_finished()
+{
+ QString text = d_val->text();
+ bool conv_ok = true;
+ int xi;
+ float xf;
+ double xd;
+ std::string xs;
+ gr_complex xc;
+
+ switch (d_type) {
+ case INT:
xi = text.toInt(&conv_ok);
- if(conv_ok) {
- d_msg = pmt::from_long(xi);
- }
- else {
- GR_LOG_WARN(d_logger, "Conversion to integer failed");
- return;
+ if (conv_ok) {
+ d_msg = pmt::from_long(xi);
+ } else {
+ GR_LOG_WARN(d_logger, "Conversion to integer failed");
+ return;
}
break;
- case INT_VEC:
- {
- std::vector<int32_t> xv;
- QStringList text_list = text.split(",");
- for(int i = 0; i < text_list.size(); ++i) {
+ case INT_VEC: {
+ std::vector<int32_t> xv;
+ QStringList text_list = text.split(",");
+ for (int i = 0; i < text_list.size(); ++i) {
QString s = text_list.at(i);
s = s.remove(QChar(' '));
int t = s.toInt(&conv_ok);
- if(conv_ok) {
- xv.push_back(t);
- }
- else {
- GR_LOG_WARN(d_logger, "Conversion to integer vector failed");
- return;
+ if (conv_ok) {
+ xv.push_back(t);
+ } else {
+ GR_LOG_WARN(d_logger, "Conversion to integer vector failed");
+ return;
}
- }
- d_msg = pmt::init_s32vector(xv.size(), xv);
}
- break;
- case FLOAT:
+ d_msg = pmt::init_s32vector(xv.size(), xv);
+ } break;
+ case FLOAT:
xf = text.toFloat(&conv_ok);
- if(conv_ok) {
- d_msg = pmt::from_float(xf);
- }
- else {
- GR_LOG_WARN(d_logger, "Conversion to float failed");
- return;
+ if (conv_ok) {
+ d_msg = pmt::from_float(xf);
+ } else {
+ GR_LOG_WARN(d_logger, "Conversion to float failed");
+ return;
}
break;
- case FLOAT_VEC:
- {
- std::vector<float> xv;
- QStringList text_list = text.split(",");
- for(int i = 0; i < text_list.size(); ++i) {
+ case FLOAT_VEC: {
+ std::vector<float> xv;
+ QStringList text_list = text.split(",");
+ for (int i = 0; i < text_list.size(); ++i) {
QString s = text_list.at(i);
s = s.remove(QChar(' '));
float t = s.toFloat(&conv_ok);
- if(conv_ok) {
- xv.push_back(t);
- }
- else {
- GR_LOG_WARN(d_logger, "Conversion to float vector failed");
- return;
+ if (conv_ok) {
+ xv.push_back(t);
+ } else {
+ GR_LOG_WARN(d_logger, "Conversion to float vector failed");
+ return;
}
- }
- d_msg = pmt::init_f32vector(xv.size(), xv);
}
- break;
- case DOUBLE:
+ d_msg = pmt::init_f32vector(xv.size(), xv);
+ } break;
+ case DOUBLE:
xd = text.toDouble(&conv_ok);
- if(conv_ok) {
- d_msg = pmt::from_double(xd);
- }
- else {
- GR_LOG_WARN(d_logger, "Conversion to double failed");
- return;
+ if (conv_ok) {
+ d_msg = pmt::from_double(xd);
+ } else {
+ GR_LOG_WARN(d_logger, "Conversion to double failed");
+ return;
}
break;
- case DOUBLE_VEC:
- {
- std::vector<double> xv;
- QStringList text_list = text.split(",");
- for(int i = 0; i < text_list.size(); ++i) {
+ case DOUBLE_VEC: {
+ std::vector<double> xv;
+ QStringList text_list = text.split(",");
+ for (int i = 0; i < text_list.size(); ++i) {
QString s = text_list.at(i);
s = s.remove(QChar(' '));
double t = s.toDouble(&conv_ok);
- if(conv_ok) {
- xv.push_back(t);
- }
- else {
- GR_LOG_WARN(d_logger, "Conversion to double vector failed");
- return;
+ if (conv_ok) {
+ xv.push_back(t);
+ } else {
+ GR_LOG_WARN(d_logger, "Conversion to double vector failed");
+ return;
}
- }
- d_msg = pmt::init_f64vector(xv.size(), xv);
}
- break;
- case COMPLEX:
+ d_msg = pmt::init_f64vector(xv.size(), xv);
+ } break;
+ case COMPLEX:
try {
- xc = boost::lexical_cast<gr_complex>(text.toStdString());
- }
- catch(boost::bad_lexical_cast const & e) {
- GR_LOG_WARN(d_logger, boost::format("Conversion to complex failed (%1%)") \
- % e.what());
- return;
+ xc = boost::lexical_cast<gr_complex>(text.toStdString());
+ } catch (boost::bad_lexical_cast const& e) {
+ GR_LOG_WARN(d_logger,
+ boost::format("Conversion to complex failed (%1%)") % e.what());
+ return;
}
d_msg = pmt::from_complex(xc.real(), xc.imag());
break;
- case COMPLEX_VEC:
- {
- std::vector<gr_complex> xv;
- QStringList text_list = text.split(",");
- bool even = false;
- gr_complex c;
- float re, im;
- for(int i = 0; i < text_list.size(); ++i) {
+ case COMPLEX_VEC: {
+ std::vector<gr_complex> xv;
+ QStringList text_list = text.split(",");
+ bool even = false;
+ gr_complex c;
+ float re, im;
+ for (int i = 0; i < text_list.size(); ++i) {
QString s = text_list.at(i);
s = s.remove(QChar(' '));
s = s.remove(QChar(')'));
s = s.remove(QChar('('));
float t = s.toFloat(&conv_ok);
- if(conv_ok) {
- if(even) {
- im = t;
- xv.push_back(gr_complex(re, im));
- even = false;
- }
- else {
- re = t;
- even = true;
- }
- }
- else {
- GR_LOG_WARN(d_logger, "Conversion to complex vector failed");
- return;
+ if (conv_ok) {
+ if (even) {
+ im = t;
+ xv.push_back(gr_complex(re, im));
+ even = false;
+ } else {
+ re = t;
+ even = true;
+ }
+ } else {
+ GR_LOG_WARN(d_logger, "Conversion to complex vector failed");
+ return;
}
- }
- d_msg = pmt::init_c32vector(xv.size(), xv);
}
- break;
- case STRING:
+ d_msg = pmt::init_c32vector(xv.size(), xv);
+ } break;
+ case STRING:
xs = text.toStdString();
d_msg = pmt::intern(xs);
break;
- }
+ }
- if(d_is_pair) {
+ if (d_is_pair) {
std::string key = d_key->text().toStdString();
d_msg = pmt::cons(pmt::intern(key), d_msg);
- }
-
- message_port_pub(d_port, d_msg);
}
- } /* namespace qtgui */
+ message_port_pub(d_port, d_msg);
+}
+
+} /* namespace qtgui */
} /* namespace gr */
diff --git a/gr-qtgui/lib/edit_box_msg_impl.h b/gr-qtgui/lib/edit_box_msg_impl.h
index 6d92a1227e..b53dbbc4f4 100644
--- a/gr-qtgui/lib/edit_box_msg_impl.h
+++ b/gr-qtgui/lib/edit_box_msg_impl.h
@@ -33,63 +33,62 @@
#include <QLabel>
namespace gr {
- namespace qtgui {
-
- class QTGUI_API edit_box_msg_impl
- : public QObject, public edit_box_msg
- {
- Q_OBJECT
-
- private:
- int d_argc;
- char *d_argv;
- data_type_t d_type;
- bool d_is_pair;
- bool d_is_static;
-
- QGroupBox *d_group;
- QVBoxLayout *d_vlayout;
- QHBoxLayout *d_hlayout;
- QLabel *d_label;
- QLineEdit *d_val;
- QLineEdit *d_key;
- QComboBox *d_type_box;
-
- pmt::pmt_t d_msg;
- const pmt::pmt_t d_port;
-
- public:
- edit_box_msg_impl(gr::qtgui::data_type_t type,
- const std::string &value="",
- const std::string &label="",
- bool is_pair=false,
- bool is_static=true,
- const std::string &key="",
- QWidget* parent=0);
- ~edit_box_msg_impl();
-
- // Overload the start method of gr::block to emit a message if a
- // default value is provided.
- bool start();
-
- void exec_();
- QWidget* qwidget();
+namespace qtgui {
+
+class QTGUI_API edit_box_msg_impl : public QObject, public edit_box_msg
+{
+ Q_OBJECT
+
+private:
+ int d_argc;
+ char* d_argv;
+ data_type_t d_type;
+ bool d_is_pair;
+ bool d_is_static;
+
+ QGroupBox* d_group;
+ QVBoxLayout* d_vlayout;
+ QHBoxLayout* d_hlayout;
+ QLabel* d_label;
+ QLineEdit* d_val;
+ QLineEdit* d_key;
+ QComboBox* d_type_box;
+
+ pmt::pmt_t d_msg;
+ const pmt::pmt_t d_port;
+
+public:
+ edit_box_msg_impl(gr::qtgui::data_type_t type,
+ const std::string& value = "",
+ const std::string& label = "",
+ bool is_pair = false,
+ bool is_static = true,
+ const std::string& key = "",
+ QWidget* parent = 0);
+ ~edit_box_msg_impl();
+
+ // Overload the start method of gr::block to emit a message if a
+ // default value is provided.
+ bool start();
+
+ void exec_();
+ QWidget* qwidget();
#ifdef ENABLE_PYTHON
- PyObject* pyqwidget();
+ PyObject* pyqwidget();
#else
- void* pyqwidget();
+ void* pyqwidget();
#endif
- void set_value(pmt::pmt_t val);
+ void set_value(pmt::pmt_t val);
- public slots:
- void edit_finished();
- void set_type(int);
- void set_type(gr::qtgui::data_type_t type);
- };
+public slots:
+ void edit_finished();
+ void set_type(int);
+ void set_type(gr::qtgui::data_type_t type);
+};
- } /* namespace qtgui */
+} /* namespace qtgui */
} /* namespace gr */
#endif /* INCLUDED_QTGUI_EDIT_BOX_MSG_IMPL_H */
diff --git a/gr-qtgui/lib/freq_sink_c_impl.cc b/gr-qtgui/lib/freq_sink_c_impl.cc
index 3f31c90975..576c96a918 100644
--- a/gr-qtgui/lib/freq_sink_c_impl.cc
+++ b/gr-qtgui/lib/freq_sink_c_impl.cc
@@ -35,741 +35,624 @@
#include <string.h>
namespace gr {
- namespace qtgui {
-
- freq_sink_c::sptr
- freq_sink_c::make(int fftsize, int wintype,
- double fc, double bw,
- const std::string &name,
- int nconnections,
- QWidget *parent)
- {
- return gnuradio::get_initial_sptr
- (new freq_sink_c_impl(fftsize, wintype,
- fc, bw, name,
- nconnections,
- parent));
- }
-
- freq_sink_c_impl::freq_sink_c_impl(int fftsize, int wintype,
- double fc, double bw,
- const std::string &name,
- int nconnections,
- QWidget *parent)
- : sync_block("freq_sink_c",
- io_signature::make(0, nconnections, sizeof(gr_complex)),
- io_signature::make(0, 0, 0)),
- d_fftsize(fftsize),
- d_fft_shift(fftsize),
- d_fftavg(1.0),
- d_wintype((filter::firdes::win_type)(wintype)),
- d_center_freq(fc), d_bandwidth(bw), d_name(name),
- d_nconnections(nconnections),
- d_port(pmt::mp("freq")),
- d_port_bw(pmt::mp("bw")),
- d_parent(parent)
- {
- // Required now for Qt; argc must be greater than 0 and argv
- // must have at least one valid character. Must be valid through
- // life of the qApplication:
- // http://harmattan-dev.nokia.com/docs/library/html/qt4/qapplication.html
- d_argc = 1;
- d_argv = new char;
- d_argv[0] = '\0';
-
- // setup bw input port
- message_port_register_in(d_port_bw);
- set_msg_handler(d_port_bw,
- boost::bind(&freq_sink_c_impl::handle_set_bw, this, _1));
-
- // setup output message port to post frequency when display is
- // double-clicked
- message_port_register_out(d_port);
- message_port_register_in(d_port);
- set_msg_handler(d_port,
- boost::bind(&freq_sink_c_impl::handle_set_freq, this, _1));
-
- // setup PDU handling input port
- message_port_register_in(pmt::mp("in"));
- set_msg_handler(pmt::mp("in"),
- boost::bind(&freq_sink_c_impl::handle_pdus, this, _1));
-
- d_main_gui = NULL;
-
- // Perform fftshift operation;
- // this is usually desired when plotting
- d_shift = true;
-
- d_fft = new fft::fft_complex(d_fftsize, true);
- d_fbuf = (float*)volk_malloc(d_fftsize*sizeof(float),
- volk_get_alignment());
- memset(d_fbuf, 0, d_fftsize*sizeof(float));
-
- d_index = 0;
- // save the last "connection" for the PDU memory
- for(int i = 0; i < d_nconnections; i++) {
- d_residbufs.push_back((gr_complex*)volk_malloc(d_fftsize*sizeof(gr_complex),
+namespace qtgui {
+
+freq_sink_c::sptr freq_sink_c::make(int fftsize,
+ int wintype,
+ double fc,
+ double bw,
+ const std::string& name,
+ int nconnections,
+ QWidget* parent)
+{
+ return gnuradio::get_initial_sptr(
+ new freq_sink_c_impl(fftsize, wintype, fc, bw, name, nconnections, parent));
+}
+
+freq_sink_c_impl::freq_sink_c_impl(int fftsize,
+ int wintype,
+ double fc,
+ double bw,
+ const std::string& name,
+ int nconnections,
+ QWidget* parent)
+ : sync_block("freq_sink_c",
+ io_signature::make(0, nconnections, sizeof(gr_complex)),
+ io_signature::make(0, 0, 0)),
+ d_fftsize(fftsize),
+ d_fft_shift(fftsize),
+ d_fftavg(1.0),
+ d_wintype((filter::firdes::win_type)(wintype)),
+ d_center_freq(fc),
+ d_bandwidth(bw),
+ d_name(name),
+ d_nconnections(nconnections),
+ d_port(pmt::mp("freq")),
+ d_port_bw(pmt::mp("bw")),
+ d_parent(parent)
+{
+ // Required now for Qt; argc must be greater than 0 and argv
+ // must have at least one valid character. Must be valid through
+ // life of the qApplication:
+ // http://harmattan-dev.nokia.com/docs/library/html/qt4/qapplication.html
+ d_argc = 1;
+ d_argv = new char;
+ d_argv[0] = '\0';
+
+ // setup bw input port
+ message_port_register_in(d_port_bw);
+ set_msg_handler(d_port_bw, boost::bind(&freq_sink_c_impl::handle_set_bw, this, _1));
+
+ // setup output message port to post frequency when display is
+ // double-clicked
+ message_port_register_out(d_port);
+ message_port_register_in(d_port);
+ set_msg_handler(d_port, boost::bind(&freq_sink_c_impl::handle_set_freq, this, _1));
+
+ // setup PDU handling input port
+ message_port_register_in(pmt::mp("in"));
+ set_msg_handler(pmt::mp("in"), boost::bind(&freq_sink_c_impl::handle_pdus, this, _1));
+
+ d_main_gui = NULL;
+
+ // Perform fftshift operation;
+ // this is usually desired when plotting
+ d_shift = true;
+
+ d_fft = new fft::fft_complex(d_fftsize, true);
+ d_fbuf = (float*)volk_malloc(d_fftsize * sizeof(float), volk_get_alignment());
+ memset(d_fbuf, 0, d_fftsize * sizeof(float));
+
+ d_index = 0;
+ // save the last "connection" for the PDU memory
+ for (int i = 0; i < d_nconnections; i++) {
+ d_residbufs.push_back((gr_complex*)volk_malloc(d_fftsize * sizeof(gr_complex),
volk_get_alignment()));
- d_magbufs.push_back((double*)volk_malloc(d_fftsize*sizeof(double),
- volk_get_alignment()));
+ d_magbufs.push_back(
+ (double*)volk_malloc(d_fftsize * sizeof(double), volk_get_alignment()));
- memset(d_residbufs[i], 0, d_fftsize*sizeof(gr_complex));
- memset(d_magbufs[i], 0, d_fftsize*sizeof(double));
- }
+ memset(d_residbufs[i], 0, d_fftsize * sizeof(gr_complex));
+ memset(d_magbufs[i], 0, d_fftsize * sizeof(double));
+ }
- d_residbufs.push_back((gr_complex*)volk_malloc(d_fftsize*sizeof(gr_complex),
- volk_get_alignment()));
- d_pdu_magbuf = (double*)volk_malloc(d_fftsize*sizeof(double),
- volk_get_alignment());
- d_magbufs.push_back(d_pdu_magbuf);
- memset(d_residbufs[d_nconnections], 0, d_fftsize*sizeof(gr_complex));
- memset(d_pdu_magbuf, 0, d_fftsize*sizeof(double));
+ d_residbufs.push_back(
+ (gr_complex*)volk_malloc(d_fftsize * sizeof(gr_complex), volk_get_alignment()));
+ d_pdu_magbuf = (double*)volk_malloc(d_fftsize * sizeof(double), volk_get_alignment());
+ d_magbufs.push_back(d_pdu_magbuf);
+ memset(d_residbufs[d_nconnections], 0, d_fftsize * sizeof(gr_complex));
+ memset(d_pdu_magbuf, 0, d_fftsize * sizeof(double));
- buildwindow();
+ buildwindow();
- initialize();
+ initialize();
- set_trigger_mode(TRIG_MODE_FREE, 0, 0);
- }
+ set_trigger_mode(TRIG_MODE_FREE, 0, 0);
+}
- freq_sink_c_impl::~freq_sink_c_impl()
- {
- if(!d_main_gui->isClosed())
+freq_sink_c_impl::~freq_sink_c_impl()
+{
+ if (!d_main_gui->isClosed())
d_main_gui->close();
- // +1 to handle PDU buffers; will also take care of d_pdu_magbuf
- for(int i = 0; i < d_nconnections+1; i++) {
- volk_free(d_residbufs[i]);
- volk_free(d_magbufs[i]);
- }
- delete d_fft;
- volk_free(d_fbuf);
-
- delete d_argv;
+ // +1 to handle PDU buffers; will also take care of d_pdu_magbuf
+ for (int i = 0; i < d_nconnections + 1; i++) {
+ volk_free(d_residbufs[i]);
+ volk_free(d_magbufs[i]);
}
+ delete d_fft;
+ volk_free(d_fbuf);
- bool
- freq_sink_c_impl::check_topology(int ninputs, int noutputs)
- {
- return ninputs == d_nconnections;
- }
+ delete d_argv;
+}
+
+bool freq_sink_c_impl::check_topology(int ninputs, int noutputs)
+{
+ return ninputs == d_nconnections;
+}
- void
- freq_sink_c_impl::initialize()
- {
- if(qApp != NULL) {
- d_qApplication = qApp;
- }
- else {
+void freq_sink_c_impl::initialize()
+{
+ if (qApp != NULL) {
+ d_qApplication = qApp;
+ } else {
#if QT_VERSION >= 0x040500 && QT_VERSION < 0x050000
std::string style = prefs::singleton()->get_string("qtgui", "style", "raster");
QApplication::setGraphicsSystem(QString(style.c_str()));
#endif
d_qApplication = new QApplication(d_argc, &d_argv);
- }
+ }
- // If a style sheet is set in the prefs file, enable it here.
- check_set_qss(d_qApplication);
+ // If a style sheet is set in the prefs file, enable it here.
+ check_set_qss(d_qApplication);
- int numplots = (d_nconnections > 0) ? d_nconnections : 1;
- d_main_gui = new FreqDisplayForm(numplots, d_parent);
- set_fft_window(d_wintype);
- set_fft_size(d_fftsize);
- set_frequency_range(d_center_freq, d_bandwidth);
+ int numplots = (d_nconnections > 0) ? d_nconnections : 1;
+ d_main_gui = new FreqDisplayForm(numplots, d_parent);
+ set_fft_window(d_wintype);
+ set_fft_size(d_fftsize);
+ set_frequency_range(d_center_freq, d_bandwidth);
- if(d_name.size() > 0)
+ if (d_name.size() > 0)
set_title(d_name);
- set_output_multiple(d_fftsize);
+ set_output_multiple(d_fftsize);
- // initialize update time to 10 times a second
- set_update_time(0.1);
- }
+ // initialize update time to 10 times a second
+ set_update_time(0.1);
+}
- void
- freq_sink_c_impl::exec_()
- {
- d_qApplication->exec();
- }
+void freq_sink_c_impl::exec_() { d_qApplication->exec(); }
- QWidget*
- freq_sink_c_impl::qwidget()
- {
- return d_main_gui;
- }
+QWidget* freq_sink_c_impl::qwidget() { return d_main_gui; }
#ifdef ENABLE_PYTHON
- PyObject*
- freq_sink_c_impl::pyqwidget()
- {
- PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui);
- PyObject *retarg = Py_BuildValue("N", w);
- return retarg;
- }
+PyObject* freq_sink_c_impl::pyqwidget()
+{
+ PyObject* w = PyLong_FromVoidPtr((void*)d_main_gui);
+ PyObject* retarg = Py_BuildValue("N", w);
+ return retarg;
+}
#else
- void *
- freq_sink_c_impl::pyqwidget()
- {
- return NULL;
- }
+void* freq_sink_c_impl::pyqwidget() { return NULL; }
#endif
- void
- freq_sink_c_impl::set_fft_size(const int fftsize)
- {
- if((fftsize > 16) && (fftsize < 16384))
+void freq_sink_c_impl::set_fft_size(const int fftsize)
+{
+ if ((fftsize > 16) && (fftsize < 16384))
d_main_gui->setFFTSize(fftsize);
- else
+ else
throw std::runtime_error("freq_sink: FFT size must be > 16 and < 16384.");
- }
-
- int
- freq_sink_c_impl::fft_size() const
- {
- return d_fftsize;
- }
-
- void
- freq_sink_c_impl::set_fft_average(const float fftavg)
- {
- d_main_gui->setFFTAverage(fftavg);
- }
-
- float
- freq_sink_c_impl::fft_average() const
- {
- return d_fftavg;
- }
-
- void
- freq_sink_c_impl::set_fft_window(const filter::firdes::win_type win)
- {
- d_main_gui->setFFTWindowType(win);
- }
-
- filter::firdes::win_type
- freq_sink_c_impl::fft_window()
- {
- return d_wintype;
- }
-
- void
- freq_sink_c_impl::set_frequency_range(const double centerfreq,
- const double bandwidth)
- {
- d_center_freq = centerfreq;
- d_bandwidth = bandwidth;
- d_main_gui->setFrequencyRange(d_center_freq, d_bandwidth);
- }
-
- void
- freq_sink_c_impl::set_y_axis(double min, double max)
- {
- d_main_gui->setYaxis(min, max);
- }
-
- void
- freq_sink_c_impl::set_y_label(const std::string &label,
- const std::string &unit)
- {
- d_main_gui->setYLabel(label, unit);
- }
-
- void
- freq_sink_c_impl::set_update_time(double t)
- {
- //convert update time to ticks
- gr::high_res_timer_type tps = gr::high_res_timer_tps();
- d_update_time = t * tps;
- d_main_gui->setUpdateTime(t);
- d_last_time = 0;
- }
-
- void
- freq_sink_c_impl::set_title(const std::string &title)
- {
- d_main_gui->setTitle(title.c_str());
- }
-
- void
- freq_sink_c_impl::set_line_label(unsigned int which, const std::string &label)
- {
- d_main_gui->setLineLabel(which, label.c_str());
- }
-
- void
- freq_sink_c_impl::set_line_color(unsigned int which, const std::string &color)
- {
- d_main_gui->setLineColor(which, color.c_str());
- }
-
- void
- freq_sink_c_impl::set_line_width(unsigned int which, int width)
- {
- d_main_gui->setLineWidth(which, width);
- }
-
- void
- freq_sink_c_impl::set_line_style(unsigned int which, int style)
- {
- d_main_gui->setLineStyle(which, (Qt::PenStyle)style);
- }
-
- void
- freq_sink_c_impl::set_line_marker(unsigned int which, int marker)
- {
- d_main_gui->setLineMarker(which, (QwtSymbol::Style)marker);
- }
-
- void
- freq_sink_c_impl::set_line_alpha(unsigned int which, double alpha)
- {
- d_main_gui->setMarkerAlpha(which, (int)(255.0*alpha));
- }
-
- void
- freq_sink_c_impl::set_size(int width, int height)
- {
- d_main_gui->resize(QSize(width, height));
- }
-
- void
- freq_sink_c_impl::set_trigger_mode(trigger_mode mode,
- float level,
- int channel,
- const std::string &tag_key)
- {
- gr::thread::scoped_lock lock(d_setlock);
-
- d_trigger_mode = mode;
- d_trigger_level = level;
- d_trigger_channel = channel;
- d_trigger_tag_key = pmt::intern(tag_key);
- d_triggered = false;
- d_trigger_count = 0;
-
- d_main_gui->setTriggerMode(d_trigger_mode);
- d_main_gui->setTriggerLevel(d_trigger_level);
- d_main_gui->setTriggerChannel(d_trigger_channel);
- d_main_gui->setTriggerTagKey(tag_key);
-
- _reset();
- }
-
- std::string
- freq_sink_c_impl::title()
- {
- return d_main_gui->title().toStdString();
- }
-
- std::string
- freq_sink_c_impl::line_label(unsigned int which)
- {
- return d_main_gui->lineLabel(which).toStdString();
- }
-
- std::string
- freq_sink_c_impl::line_color(unsigned int which)
- {
- return d_main_gui->lineColor(which).toStdString();
- }
-
- int
- freq_sink_c_impl::line_width(unsigned int which)
- {
- return d_main_gui->lineWidth(which);
- }
-
- int
- freq_sink_c_impl::line_style(unsigned int which)
- {
- return d_main_gui->lineStyle(which);
- }
-
- int
- freq_sink_c_impl::line_marker(unsigned int which)
- {
- return d_main_gui->lineMarker(which);
- }
-
- double
- freq_sink_c_impl::line_alpha(unsigned int which)
- {
- return (double)(d_main_gui->markerAlpha(which))/255.0;
- }
-
- void
- freq_sink_c_impl::enable_menu(bool en)
- {
- d_main_gui->enableMenu(en);
- }
-
- void
- freq_sink_c_impl::enable_grid(bool en)
- {
- d_main_gui->setGrid(en);
- }
-
- void
- freq_sink_c_impl::enable_autoscale(bool en)
- {
- d_main_gui->autoScale(en);
- }
-
- void
- freq_sink_c_impl::enable_axis_labels(bool en)
- {
- d_main_gui->setAxisLabels(en);
- }
-
- void
- freq_sink_c_impl::enable_control_panel(bool en)
- {
- if(en)
+}
+
+int freq_sink_c_impl::fft_size() const { return d_fftsize; }
+
+void freq_sink_c_impl::set_fft_average(const float fftavg)
+{
+ d_main_gui->setFFTAverage(fftavg);
+}
+
+float freq_sink_c_impl::fft_average() const { return d_fftavg; }
+
+void freq_sink_c_impl::set_fft_window(const filter::firdes::win_type win)
+{
+ d_main_gui->setFFTWindowType(win);
+}
+
+filter::firdes::win_type freq_sink_c_impl::fft_window() { return d_wintype; }
+
+void freq_sink_c_impl::set_frequency_range(const double centerfreq,
+ const double bandwidth)
+{
+ d_center_freq = centerfreq;
+ d_bandwidth = bandwidth;
+ d_main_gui->setFrequencyRange(d_center_freq, d_bandwidth);
+}
+
+void freq_sink_c_impl::set_y_axis(double min, double max)
+{
+ d_main_gui->setYaxis(min, max);
+}
+
+void freq_sink_c_impl::set_y_label(const std::string& label, const std::string& unit)
+{
+ d_main_gui->setYLabel(label, unit);
+}
+
+void freq_sink_c_impl::set_update_time(double t)
+{
+ // convert update time to ticks
+ gr::high_res_timer_type tps = gr::high_res_timer_tps();
+ d_update_time = t * tps;
+ d_main_gui->setUpdateTime(t);
+ d_last_time = 0;
+}
+
+void freq_sink_c_impl::set_title(const std::string& title)
+{
+ d_main_gui->setTitle(title.c_str());
+}
+
+void freq_sink_c_impl::set_line_label(unsigned int which, const std::string& label)
+{
+ d_main_gui->setLineLabel(which, label.c_str());
+}
+
+void freq_sink_c_impl::set_line_color(unsigned int which, const std::string& color)
+{
+ d_main_gui->setLineColor(which, color.c_str());
+}
+
+void freq_sink_c_impl::set_line_width(unsigned int which, int width)
+{
+ d_main_gui->setLineWidth(which, width);
+}
+
+void freq_sink_c_impl::set_line_style(unsigned int which, int style)
+{
+ d_main_gui->setLineStyle(which, (Qt::PenStyle)style);
+}
+
+void freq_sink_c_impl::set_line_marker(unsigned int which, int marker)
+{
+ d_main_gui->setLineMarker(which, (QwtSymbol::Style)marker);
+}
+
+void freq_sink_c_impl::set_line_alpha(unsigned int which, double alpha)
+{
+ d_main_gui->setMarkerAlpha(which, (int)(255.0 * alpha));
+}
+
+void freq_sink_c_impl::set_size(int width, int height)
+{
+ d_main_gui->resize(QSize(width, height));
+}
+
+void freq_sink_c_impl::set_trigger_mode(trigger_mode mode,
+ float level,
+ int channel,
+ const std::string& tag_key)
+{
+ gr::thread::scoped_lock lock(d_setlock);
+
+ d_trigger_mode = mode;
+ d_trigger_level = level;
+ d_trigger_channel = channel;
+ d_trigger_tag_key = pmt::intern(tag_key);
+ d_triggered = false;
+ d_trigger_count = 0;
+
+ d_main_gui->setTriggerMode(d_trigger_mode);
+ d_main_gui->setTriggerLevel(d_trigger_level);
+ d_main_gui->setTriggerChannel(d_trigger_channel);
+ d_main_gui->setTriggerTagKey(tag_key);
+
+ _reset();
+}
+
+std::string freq_sink_c_impl::title() { return d_main_gui->title().toStdString(); }
+
+std::string freq_sink_c_impl::line_label(unsigned int which)
+{
+ return d_main_gui->lineLabel(which).toStdString();
+}
+
+std::string freq_sink_c_impl::line_color(unsigned int which)
+{
+ return d_main_gui->lineColor(which).toStdString();
+}
+
+int freq_sink_c_impl::line_width(unsigned int which)
+{
+ return d_main_gui->lineWidth(which);
+}
+
+int freq_sink_c_impl::line_style(unsigned int which)
+{
+ return d_main_gui->lineStyle(which);
+}
+
+int freq_sink_c_impl::line_marker(unsigned int which)
+{
+ return d_main_gui->lineMarker(which);
+}
+
+double freq_sink_c_impl::line_alpha(unsigned int which)
+{
+ return (double)(d_main_gui->markerAlpha(which)) / 255.0;
+}
+
+void freq_sink_c_impl::enable_menu(bool en) { d_main_gui->enableMenu(en); }
+
+void freq_sink_c_impl::enable_grid(bool en) { d_main_gui->setGrid(en); }
+
+void freq_sink_c_impl::enable_autoscale(bool en) { d_main_gui->autoScale(en); }
+
+void freq_sink_c_impl::enable_axis_labels(bool en) { d_main_gui->setAxisLabels(en); }
+
+void freq_sink_c_impl::enable_control_panel(bool en)
+{
+ if (en)
d_main_gui->setupControlPanel();
- else
+ else
d_main_gui->teardownControlPanel();
- }
+}
- void
- freq_sink_c_impl::enable_max_hold(bool en)
- {
- d_main_gui->notifyMaxHold(en);
- }
+void freq_sink_c_impl::enable_max_hold(bool en) { d_main_gui->notifyMaxHold(en); }
- void
- freq_sink_c_impl::enable_min_hold(bool en)
- {
- d_main_gui->notifyMinHold(en);
- }
+void freq_sink_c_impl::enable_min_hold(bool en) { d_main_gui->notifyMinHold(en); }
- void
- freq_sink_c_impl::clear_max_hold()
- {
- d_main_gui->clearMaxHold();
- }
+void freq_sink_c_impl::clear_max_hold() { d_main_gui->clearMaxHold(); }
- void
- freq_sink_c_impl::clear_min_hold()
- {
- d_main_gui->clearMinHold();
- }
+void freq_sink_c_impl::clear_min_hold() { d_main_gui->clearMinHold(); }
- void
- freq_sink_c_impl::disable_legend()
- {
- d_main_gui->disableLegend();
- }
+void freq_sink_c_impl::disable_legend() { d_main_gui->disableLegend(); }
- void
- freq_sink_c_impl::reset()
- {
- gr::thread::scoped_lock lock(d_setlock);
- _reset();
- }
+void freq_sink_c_impl::reset()
+{
+ gr::thread::scoped_lock lock(d_setlock);
+ _reset();
+}
- void
- freq_sink_c_impl::_reset()
- {
- d_trigger_count = 0;
+void freq_sink_c_impl::_reset()
+{
+ d_trigger_count = 0;
- // Reset the trigger.
- if(d_trigger_mode == TRIG_MODE_FREE) {
+ // Reset the trigger.
+ if (d_trigger_mode == TRIG_MODE_FREE) {
d_triggered = true;
- }
- else {
+ } else {
d_triggered = false;
- }
}
+}
- void
- freq_sink_c_impl::fft(float *data_out, const gr_complex *data_in, int size)
- {
- if(d_window.size()) {
- volk_32fc_32f_multiply_32fc(d_fft->get_inbuf(), data_in,
- &d_window.front(), size);
- }
- else {
- memcpy(d_fft->get_inbuf(), data_in, sizeof(gr_complex)*size);
- }
+void freq_sink_c_impl::fft(float* data_out, const gr_complex* data_in, int size)
+{
+ if (d_window.size()) {
+ volk_32fc_32f_multiply_32fc(d_fft->get_inbuf(), data_in, &d_window.front(), size);
+ } else {
+ memcpy(d_fft->get_inbuf(), data_in, sizeof(gr_complex) * size);
+ }
- d_fft->execute(); // compute the fft
+ d_fft->execute(); // compute the fft
- volk_32fc_s32f_x2_power_spectral_density_32f(data_out, d_fft->get_outbuf(),
- size, 1.0, size);
+ volk_32fc_s32f_x2_power_spectral_density_32f(
+ data_out, d_fft->get_outbuf(), size, 1.0, size);
- d_fft_shift.shift(data_out, size);
- }
+ d_fft_shift.shift(data_out, size);
+}
- bool
- freq_sink_c_impl::windowreset()
- {
- gr::thread::scoped_lock lock(d_setlock);
+bool freq_sink_c_impl::windowreset()
+{
+ gr::thread::scoped_lock lock(d_setlock);
- filter::firdes::win_type newwintype;
- newwintype = d_main_gui->getFFTWindowType();
- if(d_wintype != newwintype) {
+ filter::firdes::win_type newwintype;
+ newwintype = d_main_gui->getFFTWindowType();
+ if (d_wintype != newwintype) {
d_wintype = newwintype;
buildwindow();
return true;
- }
- return false;
}
+ return false;
+}
- void
- freq_sink_c_impl::buildwindow()
- {
- d_window.clear();
- if(d_wintype != filter::firdes::WIN_NONE) {
- d_window = filter::firdes::window(d_wintype, d_fftsize, 6.76);
- }
+void freq_sink_c_impl::buildwindow()
+{
+ d_window.clear();
+ if (d_wintype != filter::firdes::WIN_NONE) {
+ d_window = filter::firdes::window(d_wintype, d_fftsize, 6.76);
}
+}
- bool
- freq_sink_c_impl::fftresize()
- {
- gr::thread::scoped_lock lock(d_setlock);
+bool freq_sink_c_impl::fftresize()
+{
+ gr::thread::scoped_lock lock(d_setlock);
- int newfftsize = d_main_gui->getFFTSize();
- d_fftavg = d_main_gui->getFFTAverage();
+ int newfftsize = d_main_gui->getFFTSize();
+ d_fftavg = d_main_gui->getFFTAverage();
- if(newfftsize != d_fftsize) {
- // Resize residbuf and replace data
+ if (newfftsize != d_fftsize) {
+ // Resize residbuf and replace data
// +1 to handle PDU buffers
- for(int i = 0; i < d_nconnections+1; i++) {
- volk_free(d_residbufs[i]);
- volk_free(d_magbufs[i]);
+ for (int i = 0; i < d_nconnections + 1; i++) {
+ volk_free(d_residbufs[i]);
+ volk_free(d_magbufs[i]);
- d_residbufs[i] = (gr_complex*)volk_malloc(newfftsize*sizeof(gr_complex),
- volk_get_alignment());
- d_magbufs[i] = (double*)volk_malloc(newfftsize*sizeof(double),
- volk_get_alignment());
+ d_residbufs[i] = (gr_complex*)volk_malloc(newfftsize * sizeof(gr_complex),
+ volk_get_alignment());
+ d_magbufs[i] =
+ (double*)volk_malloc(newfftsize * sizeof(double), volk_get_alignment());
- memset(d_residbufs[i], 0, newfftsize*sizeof(gr_complex));
- memset(d_magbufs[i], 0, newfftsize*sizeof(double));
- }
+ memset(d_residbufs[i], 0, newfftsize * sizeof(gr_complex));
+ memset(d_magbufs[i], 0, newfftsize * sizeof(double));
+ }
// Update the pointer to the newly allocated memory
d_pdu_magbuf = d_magbufs[d_nconnections];
- // Set new fft size and reset buffer index
- // (throws away any currently held data, but who cares?)
- d_fftsize = newfftsize;
- d_index = 0;
+ // Set new fft size and reset buffer index
+ // (throws away any currently held data, but who cares?)
+ d_fftsize = newfftsize;
+ d_index = 0;
- // Reset window to reflect new size
- buildwindow();
+ // Reset window to reflect new size
+ buildwindow();
- // Reset FFTW plan for new size
- delete d_fft;
- d_fft = new fft::fft_complex(d_fftsize, true);
+ // Reset FFTW plan for new size
+ delete d_fft;
+ d_fft = new fft::fft_complex(d_fftsize, true);
- volk_free(d_fbuf);
- d_fbuf = (float*)volk_malloc(d_fftsize*sizeof(float),
- volk_get_alignment());
- memset(d_fbuf, 0, d_fftsize*sizeof(float));
+ volk_free(d_fbuf);
+ d_fbuf = (float*)volk_malloc(d_fftsize * sizeof(float), volk_get_alignment());
+ memset(d_fbuf, 0, d_fftsize * sizeof(float));
- d_fft_shift.resize(d_fftsize);
+ d_fft_shift.resize(d_fftsize);
d_last_time = 0;
set_output_multiple(d_fftsize);
return true;
- }
- return false;
}
+ return false;
+}
- void
- freq_sink_c_impl::check_clicked()
- {
- if(d_main_gui->checkClicked()) {
+void freq_sink_c_impl::check_clicked()
+{
+ if (d_main_gui->checkClicked()) {
double freq = d_main_gui->getClickedFreq();
- message_port_pub(d_port,
- pmt::cons(d_port,
- pmt::from_double(freq)));
- }
+ message_port_pub(d_port, pmt::cons(d_port, pmt::from_double(freq)));
}
+}
- void
- freq_sink_c_impl::handle_set_freq(pmt::pmt_t msg)
- {
- if(pmt::is_pair(msg)) {
+void freq_sink_c_impl::handle_set_freq(pmt::pmt_t msg)
+{
+ if (pmt::is_pair(msg)) {
pmt::pmt_t x = pmt::cdr(msg);
- if(pmt::is_real(x)) {
- d_center_freq = pmt::to_double(x);
- d_qApplication->postEvent(d_main_gui,
- new SetFreqEvent(d_center_freq, d_bandwidth));
+ if (pmt::is_real(x)) {
+ d_center_freq = pmt::to_double(x);
+ d_qApplication->postEvent(d_main_gui,
+ new SetFreqEvent(d_center_freq, d_bandwidth));
}
- }
}
+}
- void
- freq_sink_c_impl::handle_set_bw(pmt::pmt_t msg)
- {
- if(pmt::is_pair(msg)) {
+void freq_sink_c_impl::handle_set_bw(pmt::pmt_t msg)
+{
+ if (pmt::is_pair(msg)) {
pmt::pmt_t x = pmt::cdr(msg);
- if(pmt::is_real(x)) {
- d_bandwidth = pmt::to_double(x);
- d_qApplication->postEvent(d_main_gui,
- new SetFreqEvent(d_center_freq, d_bandwidth));
+ if (pmt::is_real(x)) {
+ d_bandwidth = pmt::to_double(x);
+ d_qApplication->postEvent(d_main_gui,
+ new SetFreqEvent(d_center_freq, d_bandwidth));
}
- }
- }
+ }
+}
- void
- freq_sink_c_impl::_gui_update_trigger()
- {
- trigger_mode new_trigger_mode = d_main_gui->getTriggerMode();
- d_trigger_level = d_main_gui->getTriggerLevel();
- d_trigger_channel = d_main_gui->getTriggerChannel();
+void freq_sink_c_impl::_gui_update_trigger()
+{
+ trigger_mode new_trigger_mode = d_main_gui->getTriggerMode();
+ d_trigger_level = d_main_gui->getTriggerLevel();
+ d_trigger_channel = d_main_gui->getTriggerChannel();
- std::string tagkey = d_main_gui->getTriggerTagKey();
- d_trigger_tag_key = pmt::intern(tagkey);
+ std::string tagkey = d_main_gui->getTriggerTagKey();
+ d_trigger_tag_key = pmt::intern(tagkey);
- if(new_trigger_mode != d_trigger_mode) {
+ if (new_trigger_mode != d_trigger_mode) {
d_trigger_mode = new_trigger_mode;
_reset();
- }
}
+}
- void
- freq_sink_c_impl::_test_trigger_tags(int start, int nitems)
- {
- uint64_t nr = nitems_read(d_trigger_channel);
- std::vector<gr::tag_t> tags;
- get_tags_in_range(tags, d_trigger_channel,
- nr+start, nr+start+nitems,
- d_trigger_tag_key);
- if(tags.size() > 0) {
+void freq_sink_c_impl::_test_trigger_tags(int start, int nitems)
+{
+ uint64_t nr = nitems_read(d_trigger_channel);
+ std::vector<gr::tag_t> tags;
+ get_tags_in_range(
+ tags, d_trigger_channel, nr + start, nr + start + nitems, d_trigger_tag_key);
+ if (tags.size() > 0) {
d_triggered = true;
d_index = tags[0].offset - nr;
d_trigger_count = 0;
- }
}
+}
- void
- freq_sink_c_impl::_test_trigger_norm(int nitems, std::vector<double*> inputs)
- {
- const double *in = (const double*)inputs[d_trigger_channel];
- for(int i = 0; i < nitems; i++) {
+void freq_sink_c_impl::_test_trigger_norm(int nitems, std::vector<double*> inputs)
+{
+ const double* in = (const double*)inputs[d_trigger_channel];
+ for (int i = 0; i < nitems; i++) {
d_trigger_count++;
// Test if trigger has occurred based on the FFT magnitude and
// channel number. Test if any value is > the level (in dBx).
- if(in[i] > d_trigger_level) {
- d_triggered = true;
- d_trigger_count = 0;
- break;
+ if (in[i] > d_trigger_level) {
+ d_triggered = true;
+ d_trigger_count = 0;
+ break;
}
- }
+ }
- // If using auto trigger mode, trigger periodically even
- // without a trigger event.
- if((d_trigger_mode == TRIG_MODE_AUTO) && (d_trigger_count > d_fftsize)) {
+ // If using auto trigger mode, trigger periodically even
+ // without a trigger event.
+ if ((d_trigger_mode == TRIG_MODE_AUTO) && (d_trigger_count > d_fftsize)) {
d_triggered = true;
d_trigger_count = 0;
- }
}
+}
+
+int freq_sink_c_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const gr_complex* in = (const gr_complex*)input_items[0];
- int
- freq_sink_c_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const gr_complex *in = (const gr_complex*)input_items[0];
-
- // Update the FFT size from the application
- bool updated = false;
- updated |= fftresize();
- updated |= windowreset();
- if(updated)
+ // Update the FFT size from the application
+ bool updated = false;
+ updated |= fftresize();
+ updated |= windowreset();
+ if (updated)
return 0;
- check_clicked();
- _gui_update_trigger();
+ check_clicked();
+ _gui_update_trigger();
- gr::thread::scoped_lock lock(d_setlock);
- for(d_index = 0; d_index < noutput_items; d_index+=d_fftsize) {
+ gr::thread::scoped_lock lock(d_setlock);
+ for (d_index = 0; d_index < noutput_items; d_index += d_fftsize) {
- if((gr::high_res_timer_now() - d_last_time) > d_update_time) {
+ if ((gr::high_res_timer_now() - d_last_time) > d_update_time) {
- // Trigger off tag, if active
- if((d_trigger_mode == TRIG_MODE_TAG) && !d_triggered) {
- _test_trigger_tags(d_index, d_fftsize);
- if(d_triggered) {
- // If not enough from tag position, early exit
- if((d_index + d_fftsize) >= noutput_items)
- return d_index;
+ // Trigger off tag, if active
+ if ((d_trigger_mode == TRIG_MODE_TAG) && !d_triggered) {
+ _test_trigger_tags(d_index, d_fftsize);
+ if (d_triggered) {
+ // If not enough from tag position, early exit
+ if ((d_index + d_fftsize) >= noutput_items)
+ return d_index;
+ }
}
- }
-
- // Perform FFT and shift operations into d_magbufs
- for(int n = 0; n < d_nconnections; n++) {
- in = (const gr_complex*)input_items[n];
- memcpy(d_residbufs[n], &in[d_index], sizeof(gr_complex)*d_fftsize);
- fft(d_fbuf, d_residbufs[n], d_fftsize);
- for(int x = 0; x < d_fftsize; x++) {
- d_magbufs[n][x] = (double)((1.0-d_fftavg)*d_magbufs[n][x] + (d_fftavg)*d_fbuf[x]);
+ // Perform FFT and shift operations into d_magbufs
+ for (int n = 0; n < d_nconnections; n++) {
+ in = (const gr_complex*)input_items[n];
+ memcpy(d_residbufs[n], &in[d_index], sizeof(gr_complex) * d_fftsize);
+
+ fft(d_fbuf, d_residbufs[n], d_fftsize);
+ for (int x = 0; x < d_fftsize; x++) {
+ d_magbufs[n][x] = (double)((1.0 - d_fftavg) * d_magbufs[n][x] +
+ (d_fftavg)*d_fbuf[x]);
+ }
+ // volk_32f_convert_64f(d_magbufs[n], d_fbuf, d_fftsize);
}
- //volk_32f_convert_64f(d_magbufs[n], d_fbuf, d_fftsize);
- }
- // Test trigger off signal power in d_magbufs
- if((d_trigger_mode == TRIG_MODE_NORM) || (d_trigger_mode == TRIG_MODE_AUTO)) {
- _test_trigger_norm(d_fftsize, d_magbufs);
- }
+ // Test trigger off signal power in d_magbufs
+ if ((d_trigger_mode == TRIG_MODE_NORM) ||
+ (d_trigger_mode == TRIG_MODE_AUTO)) {
+ _test_trigger_norm(d_fftsize, d_magbufs);
+ }
- // If a trigger (FREE always triggers), plot and reset state
- if(d_triggered) {
- d_last_time = gr::high_res_timer_now();
- d_qApplication->postEvent(d_main_gui,
- new FreqUpdateEvent(d_magbufs, d_fftsize));
- _reset();
- }
+ // If a trigger (FREE always triggers), plot and reset state
+ if (d_triggered) {
+ d_last_time = gr::high_res_timer_now();
+ d_qApplication->postEvent(d_main_gui,
+ new FreqUpdateEvent(d_magbufs, d_fftsize));
+ _reset();
+ }
}
- }
-
- return noutput_items;
}
+ return noutput_items;
+}
+
- void
- freq_sink_c_impl::handle_pdus(pmt::pmt_t msg)
- {
- size_t len;
- pmt::pmt_t dict, samples;
+void freq_sink_c_impl::handle_pdus(pmt::pmt_t msg)
+{
+ size_t len;
+ pmt::pmt_t dict, samples;
- // Test to make sure this is either a PDU or a uniform vector of
- // samples. Get the samples PMT and the dictionary if it's a PDU.
- // If not, we throw an error and exit.
- if(pmt::is_pair(msg)) {
+ // Test to make sure this is either a PDU or a uniform vector of
+ // samples. Get the samples PMT and the dictionary if it's a PDU.
+ // If not, we throw an error and exit.
+ if (pmt::is_pair(msg)) {
dict = pmt::car(msg);
samples = pmt::cdr(msg);
- }
- else if(pmt::is_uniform_vector(msg)) {
+ } else if (pmt::is_uniform_vector(msg)) {
samples = msg;
- }
- else {
+ } else {
throw std::runtime_error("time_sink_c: message must be either "
"a PDU or a uniform vector of samples.");
- }
+ }
- len = pmt::length(samples);
+ len = pmt::length(samples);
- const gr_complex *in;
- if(pmt::is_c32vector(samples)) {
+ const gr_complex* in;
+ if (pmt::is_c32vector(samples)) {
in = (const gr_complex*)pmt::c32vector_elements(samples, len);
- }
- else {
+ } else {
throw std::runtime_error("freq_sink_c: unknown data type "
"of samples; must be complex.");
- }
+ }
- // Plot if we're past the last update time
- if(gr::high_res_timer_now() - d_last_time > d_update_time) {
+ // Plot if we're past the last update time
+ if (gr::high_res_timer_now() - d_last_time > d_update_time) {
d_last_time = gr::high_res_timer_now();
// Update the FFT size from the application
@@ -783,40 +666,40 @@ namespace gr {
int nffts = static_cast<int>(ceilf(num));
// Clear this as we will be accumulating in the for loop over nffts
- memset(d_pdu_magbuf, 0, sizeof(double)*d_fftsize);
+ memset(d_pdu_magbuf, 0, sizeof(double) * d_fftsize);
size_t min = 0;
size_t max = std::min(d_fftsize, static_cast<int>(len));
- for(int n = 0; n < nffts; n++) {
- // Clear in case (max-min) < d_fftsize
- memset(d_residbufs[d_nconnections], 0x00, sizeof(gr_complex)*d_fftsize);
-
- // Copy in as much of the input samples as we can
- memcpy(d_residbufs[d_nconnections], &in[min], sizeof(gr_complex)*(max-min));
-
- // Apply the window and FFT; copy data into the PDU
- // magnitude buffer.
- fft(d_fbuf, d_residbufs[d_nconnections], d_fftsize);
- for(int x = 0; x < d_fftsize; x++) {
- d_pdu_magbuf[x] += (double)d_fbuf[x];
- }
-
- // Increment our indices; set max up to the number of
- // samples in the input PDU.
- min += fftoverlap;
- max = std::min(max + fftoverlap, len);
+ for (int n = 0; n < nffts; n++) {
+ // Clear in case (max-min) < d_fftsize
+ memset(d_residbufs[d_nconnections], 0x00, sizeof(gr_complex) * d_fftsize);
+
+ // Copy in as much of the input samples as we can
+ memcpy(
+ d_residbufs[d_nconnections], &in[min], sizeof(gr_complex) * (max - min));
+
+ // Apply the window and FFT; copy data into the PDU
+ // magnitude buffer.
+ fft(d_fbuf, d_residbufs[d_nconnections], d_fftsize);
+ for (int x = 0; x < d_fftsize; x++) {
+ d_pdu_magbuf[x] += (double)d_fbuf[x];
+ }
+
+ // Increment our indices; set max up to the number of
+ // samples in the input PDU.
+ min += fftoverlap;
+ max = std::min(max + fftoverlap, len);
}
// Perform the averaging
- for(int x = 0; x < d_fftsize; x++) {
- d_pdu_magbuf[x] /= static_cast<double>(nffts);
+ for (int x = 0; x < d_fftsize; x++) {
+ d_pdu_magbuf[x] /= static_cast<double>(nffts);
}
- //update gui per-pdu
- d_qApplication->postEvent(d_main_gui,
- new FreqUpdateEvent(d_magbufs, d_fftsize));
- }
+ // update gui per-pdu
+ d_qApplication->postEvent(d_main_gui, new FreqUpdateEvent(d_magbufs, d_fftsize));
}
+}
- } /* namespace qtgui */
+} /* namespace qtgui */
} /* namespace gr */
diff --git a/gr-qtgui/lib/freq_sink_c_impl.h b/gr-qtgui/lib/freq_sink_c_impl.h
index 09f8eaf388..ac619bbe31 100644
--- a/gr-qtgui/lib/freq_sink_c_impl.h
+++ b/gr-qtgui/lib/freq_sink_c_impl.h
@@ -32,144 +32,147 @@
#include <gnuradio/qtgui/freqdisplayform.h>
namespace gr {
- namespace qtgui {
-
- class QTGUI_API freq_sink_c_impl : public freq_sink_c
- {
- private:
- void initialize();
-
- int d_fftsize;
- fft::fft_shift<float> d_fft_shift;
- float d_fftavg;
- filter::firdes::win_type d_wintype;
- std::vector<float> d_window;
- double d_center_freq;
- double d_bandwidth;
- std::string d_name;
- int d_nconnections;
-
- const pmt::pmt_t d_port;
- const pmt::pmt_t d_port_bw;
-
- bool d_shift;
- fft::fft_complex *d_fft;
-
- int d_index;
- std::vector<gr_complex*> d_residbufs;
- std::vector<double*> d_magbufs;
- double* d_pdu_magbuf;
- float *d_fbuf;
-
- int d_argc;
- char *d_argv;
- QWidget *d_parent;
- FreqDisplayForm *d_main_gui;
-
- gr::high_res_timer_type d_update_time;
- gr::high_res_timer_type d_last_time;
-
- bool windowreset();
- void buildwindow();
- bool fftresize();
- void check_clicked();
- void fft(float *data_out, const gr_complex *data_in, int size);
-
- // Handles message input port for setting new bandwidth
- // The message is a PMT pair (intern('bw'), double(bw))
- void handle_set_bw(pmt::pmt_t msg);
-
- // Handles message input port for setting new center frequency.
- // The message is a PMT pair (intern('freq'), double(frequency)).
- void handle_set_freq(pmt::pmt_t msg);
-
- // Handles message input port for displaying PDU samples.
- void handle_pdus(pmt::pmt_t msg);
-
- // Members used for triggering scope
- trigger_mode d_trigger_mode;
- float d_trigger_level;
- int d_trigger_channel;
- pmt::pmt_t d_trigger_tag_key;
- bool d_triggered;
- int d_trigger_count;
-
- void _reset();
- void _gui_update_trigger();
- void _test_trigger_tags(int start, int nitems);
- void _test_trigger_norm(int nitems, std::vector<double*> inputs);
-
- public:
- freq_sink_c_impl(int size, int wintype,
- double fc, double bw,
- const std::string &name,
- int nconnections,
- QWidget *parent=NULL);
- ~freq_sink_c_impl();
-
- bool check_topology(int ninputs, int noutputs);
-
- void exec_();
- QWidget* qwidget();
+namespace qtgui {
+
+class QTGUI_API freq_sink_c_impl : public freq_sink_c
+{
+private:
+ void initialize();
+
+ int d_fftsize;
+ fft::fft_shift<float> d_fft_shift;
+ float d_fftavg;
+ filter::firdes::win_type d_wintype;
+ std::vector<float> d_window;
+ double d_center_freq;
+ double d_bandwidth;
+ std::string d_name;
+ int d_nconnections;
+
+ const pmt::pmt_t d_port;
+ const pmt::pmt_t d_port_bw;
+
+ bool d_shift;
+ fft::fft_complex* d_fft;
+
+ int d_index;
+ std::vector<gr_complex*> d_residbufs;
+ std::vector<double*> d_magbufs;
+ double* d_pdu_magbuf;
+ float* d_fbuf;
+
+ int d_argc;
+ char* d_argv;
+ QWidget* d_parent;
+ FreqDisplayForm* d_main_gui;
+
+ gr::high_res_timer_type d_update_time;
+ gr::high_res_timer_type d_last_time;
+
+ bool windowreset();
+ void buildwindow();
+ bool fftresize();
+ void check_clicked();
+ void fft(float* data_out, const gr_complex* data_in, int size);
+
+ // Handles message input port for setting new bandwidth
+ // The message is a PMT pair (intern('bw'), double(bw))
+ void handle_set_bw(pmt::pmt_t msg);
+
+ // Handles message input port for setting new center frequency.
+ // The message is a PMT pair (intern('freq'), double(frequency)).
+ void handle_set_freq(pmt::pmt_t msg);
+
+ // Handles message input port for displaying PDU samples.
+ void handle_pdus(pmt::pmt_t msg);
+
+ // Members used for triggering scope
+ trigger_mode d_trigger_mode;
+ float d_trigger_level;
+ int d_trigger_channel;
+ pmt::pmt_t d_trigger_tag_key;
+ bool d_triggered;
+ int d_trigger_count;
+
+ void _reset();
+ void _gui_update_trigger();
+ void _test_trigger_tags(int start, int nitems);
+ void _test_trigger_norm(int nitems, std::vector<double*> inputs);
+
+public:
+ freq_sink_c_impl(int size,
+ int wintype,
+ double fc,
+ double bw,
+ const std::string& name,
+ int nconnections,
+ QWidget* parent = NULL);
+ ~freq_sink_c_impl();
+
+ bool check_topology(int ninputs, int noutputs);
+
+ void exec_();
+ QWidget* qwidget();
#ifdef ENABLE_PYTHON
- PyObject* pyqwidget();
+ PyObject* pyqwidget();
#else
- void* pyqwidget();
+ void* pyqwidget();
#endif
- void set_fft_size(const int fftsize);
- int fft_size() const;
- void set_fft_average(const float fftavg);
- float fft_average() const;
- void set_fft_window(const filter::firdes::win_type win);
- filter::firdes::win_type fft_window();
-
- void set_frequency_range(const double centerfreq, const double bandwidth);
- void set_y_axis(double min, double max);
-
- void set_update_time(double t);
-
- void set_title(const std::string &title);
- void set_y_label(const std::string &label, const std::string &unit);
- void set_line_label(unsigned int which, const std::string &label);
- void set_line_color(unsigned int which, const std::string &color);
- void set_line_width(unsigned int which, int width);
- void set_line_style(unsigned int which, int style);
- void set_line_marker(unsigned int which, int marker);
- void set_line_alpha(unsigned int which, double alpha);
- void set_trigger_mode(trigger_mode mode,
- float level, int channel,
- const std::string &tag_key="");
-
- std::string title();
- std::string line_label(unsigned int which);
- std::string line_color(unsigned int which);
- int line_width(unsigned int which);
- int line_style(unsigned int which);
- int line_marker(unsigned int which);
- double line_alpha(unsigned int which);
-
- void set_size(int width, int height);
-
- void enable_menu(bool en);
- void enable_grid(bool en);
- void enable_autoscale(bool en);
- void enable_control_panel(bool en);
- void enable_max_hold(bool en);
- void enable_min_hold(bool en);
- void clear_max_hold();
- void clear_min_hold();
- void disable_legend();
- void reset();
- void enable_axis_labels(bool en);
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace qtgui */
+ void set_fft_size(const int fftsize);
+ int fft_size() const;
+ void set_fft_average(const float fftavg);
+ float fft_average() const;
+ void set_fft_window(const filter::firdes::win_type win);
+ filter::firdes::win_type fft_window();
+
+ void set_frequency_range(const double centerfreq, const double bandwidth);
+ void set_y_axis(double min, double max);
+
+ void set_update_time(double t);
+
+ void set_title(const std::string& title);
+ void set_y_label(const std::string& label, const std::string& unit);
+ void set_line_label(unsigned int which, const std::string& label);
+ void set_line_color(unsigned int which, const std::string& color);
+ void set_line_width(unsigned int which, int width);
+ void set_line_style(unsigned int which, int style);
+ void set_line_marker(unsigned int which, int marker);
+ void set_line_alpha(unsigned int which, double alpha);
+ void set_trigger_mode(trigger_mode mode,
+ float level,
+ int channel,
+ const std::string& tag_key = "");
+
+ std::string title();
+ std::string line_label(unsigned int which);
+ std::string line_color(unsigned int which);
+ int line_width(unsigned int which);
+ int line_style(unsigned int which);
+ int line_marker(unsigned int which);
+ double line_alpha(unsigned int which);
+
+ void set_size(int width, int height);
+
+ void enable_menu(bool en);
+ void enable_grid(bool en);
+ void enable_autoscale(bool en);
+ void enable_control_panel(bool en);
+ void enable_max_hold(bool en);
+ void enable_min_hold(bool en);
+ void clear_max_hold();
+ void clear_min_hold();
+ void disable_legend();
+ void reset();
+ void enable_axis_labels(bool en);
+
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
+
+} /* namespace qtgui */
} /* namespace gr */
#endif /* INCLUDED_QTGUI_FREQ_SINK_C_IMPL_H */
diff --git a/gr-qtgui/lib/freq_sink_f_impl.cc b/gr-qtgui/lib/freq_sink_f_impl.cc
index efc03f5f8e..54f40d2453 100644
--- a/gr-qtgui/lib/freq_sink_f_impl.cc
+++ b/gr-qtgui/lib/freq_sink_f_impl.cc
@@ -35,747 +35,627 @@
#include <string.h>
namespace gr {
- namespace qtgui {
-
-
- freq_sink_f::sptr
- freq_sink_f::make(int fftsize, int wintype,
- double fc, double bw,
- const std::string &name,
- int nconnections,
- QWidget *parent)
- {
- return gnuradio::get_initial_sptr
- (new freq_sink_f_impl(fftsize, wintype,
- fc, bw, name,
- nconnections,
- parent));
- }
-
- freq_sink_f_impl::freq_sink_f_impl(int fftsize, int wintype,
- double fc, double bw,
- const std::string &name,
- int nconnections,
- QWidget *parent)
- : sync_block("freq_sink_f",
- io_signature::make(0, nconnections, sizeof(float)),
- io_signature::make(0, 0, 0)),
- d_fftsize(fftsize),
- d_fft_shift(fftsize),
- d_fftavg(1.0),
- d_wintype((filter::firdes::win_type)(wintype)),
- d_center_freq(fc), d_bandwidth(bw), d_name(name),
- d_nconnections(nconnections),
- d_port(pmt::mp("freq")),
- d_port_bw(pmt::mp("bw")),
- d_parent(parent)
- {
- // Required now for Qt; argc must be greater than 0 and argv
- // must have at least one valid character. Must be valid through
- // life of the qApplication:
- // http://harmattan-dev.nokia.com/docs/library/html/qt4/qapplication.html
- d_argc = 1;
- d_argv = new char;
- d_argv[0] = '\0';
-
- // setup bw input port
- message_port_register_in(d_port_bw);
- set_msg_handler(d_port_bw,
- boost::bind(&freq_sink_f_impl::handle_set_bw, this, _1));
-
- // setup output message port to post frequency when display is
- // double-clicked
- message_port_register_out(d_port);
- message_port_register_in(d_port);
- set_msg_handler(d_port,
- boost::bind(&freq_sink_f_impl::handle_set_freq, this, _1));
-
- // setup PDU handling input port
- message_port_register_in(pmt::mp("in"));
- set_msg_handler(pmt::mp("in"),
- boost::bind(&freq_sink_f_impl::handle_pdus, this, _1));
-
- d_main_gui = NULL;
-
- // Perform fftshift operation;
- // this is usually desired when plotting
- d_shift = true;
-
- d_fft = new fft::fft_complex(d_fftsize, true);
- d_fbuf = (float*)volk_malloc(d_fftsize*sizeof(float),
- volk_get_alignment());
- memset(d_fbuf, 0, d_fftsize*sizeof(float));
-
- d_index = 0;
- // save the last "connection" for the PDU memory
- for(int i = 0; i < d_nconnections; i++) {
- d_residbufs.push_back((float*)volk_malloc(d_fftsize*sizeof(float),
- volk_get_alignment()));
- d_magbufs.push_back((double*)volk_malloc(d_fftsize*sizeof(double),
- volk_get_alignment()));
-
- memset(d_residbufs[i], 0, d_fftsize*sizeof(float));
- memset(d_magbufs[i], 0, d_fftsize*sizeof(double));
- }
-
- d_residbufs.push_back((float*)volk_malloc(d_fftsize*sizeof(float),
- volk_get_alignment()));
- d_pdu_magbuf = (double*)volk_malloc(d_fftsize*sizeof(double),
- volk_get_alignment());
- d_magbufs.push_back(d_pdu_magbuf);
- memset(d_residbufs[d_nconnections], 0, d_fftsize*sizeof(float));
- memset(d_pdu_magbuf, 0, d_fftsize*sizeof(double));
-
- buildwindow();
-
- initialize();
-
- set_trigger_mode(TRIG_MODE_FREE, 0, 0);
- }
-
- freq_sink_f_impl::~freq_sink_f_impl()
- {
- if(!d_main_gui->isClosed())
+namespace qtgui {
+
+
+freq_sink_f::sptr freq_sink_f::make(int fftsize,
+ int wintype,
+ double fc,
+ double bw,
+ const std::string& name,
+ int nconnections,
+ QWidget* parent)
+{
+ return gnuradio::get_initial_sptr(
+ new freq_sink_f_impl(fftsize, wintype, fc, bw, name, nconnections, parent));
+}
+
+freq_sink_f_impl::freq_sink_f_impl(int fftsize,
+ int wintype,
+ double fc,
+ double bw,
+ const std::string& name,
+ int nconnections,
+ QWidget* parent)
+ : sync_block("freq_sink_f",
+ io_signature::make(0, nconnections, sizeof(float)),
+ io_signature::make(0, 0, 0)),
+ d_fftsize(fftsize),
+ d_fft_shift(fftsize),
+ d_fftavg(1.0),
+ d_wintype((filter::firdes::win_type)(wintype)),
+ d_center_freq(fc),
+ d_bandwidth(bw),
+ d_name(name),
+ d_nconnections(nconnections),
+ d_port(pmt::mp("freq")),
+ d_port_bw(pmt::mp("bw")),
+ d_parent(parent)
+{
+ // Required now for Qt; argc must be greater than 0 and argv
+ // must have at least one valid character. Must be valid through
+ // life of the qApplication:
+ // http://harmattan-dev.nokia.com/docs/library/html/qt4/qapplication.html
+ d_argc = 1;
+ d_argv = new char;
+ d_argv[0] = '\0';
+
+ // setup bw input port
+ message_port_register_in(d_port_bw);
+ set_msg_handler(d_port_bw, boost::bind(&freq_sink_f_impl::handle_set_bw, this, _1));
+
+ // setup output message port to post frequency when display is
+ // double-clicked
+ message_port_register_out(d_port);
+ message_port_register_in(d_port);
+ set_msg_handler(d_port, boost::bind(&freq_sink_f_impl::handle_set_freq, this, _1));
+
+ // setup PDU handling input port
+ message_port_register_in(pmt::mp("in"));
+ set_msg_handler(pmt::mp("in"), boost::bind(&freq_sink_f_impl::handle_pdus, this, _1));
+
+ d_main_gui = NULL;
+
+ // Perform fftshift operation;
+ // this is usually desired when plotting
+ d_shift = true;
+
+ d_fft = new fft::fft_complex(d_fftsize, true);
+ d_fbuf = (float*)volk_malloc(d_fftsize * sizeof(float), volk_get_alignment());
+ memset(d_fbuf, 0, d_fftsize * sizeof(float));
+
+ d_index = 0;
+ // save the last "connection" for the PDU memory
+ for (int i = 0; i < d_nconnections; i++) {
+ d_residbufs.push_back(
+ (float*)volk_malloc(d_fftsize * sizeof(float), volk_get_alignment()));
+ d_magbufs.push_back(
+ (double*)volk_malloc(d_fftsize * sizeof(double), volk_get_alignment()));
+
+ memset(d_residbufs[i], 0, d_fftsize * sizeof(float));
+ memset(d_magbufs[i], 0, d_fftsize * sizeof(double));
+ }
+
+ d_residbufs.push_back(
+ (float*)volk_malloc(d_fftsize * sizeof(float), volk_get_alignment()));
+ d_pdu_magbuf = (double*)volk_malloc(d_fftsize * sizeof(double), volk_get_alignment());
+ d_magbufs.push_back(d_pdu_magbuf);
+ memset(d_residbufs[d_nconnections], 0, d_fftsize * sizeof(float));
+ memset(d_pdu_magbuf, 0, d_fftsize * sizeof(double));
+
+ buildwindow();
+
+ initialize();
+
+ set_trigger_mode(TRIG_MODE_FREE, 0, 0);
+}
+
+freq_sink_f_impl::~freq_sink_f_impl()
+{
+ if (!d_main_gui->isClosed())
d_main_gui->close();
- // +1 to handle PDU buffers; will also take care of d_pdu_magbuf
- for(int i = 0; i < d_nconnections+1; i++) {
- volk_free(d_residbufs[i]);
- volk_free(d_magbufs[i]);
- }
- delete d_fft;
- volk_free(d_fbuf);
-
- delete d_argv;
+ // +1 to handle PDU buffers; will also take care of d_pdu_magbuf
+ for (int i = 0; i < d_nconnections + 1; i++) {
+ volk_free(d_residbufs[i]);
+ volk_free(d_magbufs[i]);
}
+ delete d_fft;
+ volk_free(d_fbuf);
- bool
- freq_sink_f_impl::check_topology(int ninputs, int noutputs)
- {
- return ninputs == d_nconnections;
- }
+ delete d_argv;
+}
+
+bool freq_sink_f_impl::check_topology(int ninputs, int noutputs)
+{
+ return ninputs == d_nconnections;
+}
- void
- freq_sink_f_impl::initialize()
- {
- if(qApp != NULL) {
- d_qApplication = qApp;
- }
- else {
+void freq_sink_f_impl::initialize()
+{
+ if (qApp != NULL) {
+ d_qApplication = qApp;
+ } else {
#if QT_VERSION >= 0x040500 && QT_VERSION < 0x050000
std::string style = prefs::singleton()->get_string("qtgui", "style", "raster");
QApplication::setGraphicsSystem(QString(style.c_str()));
#endif
- d_qApplication = new QApplication(d_argc, &d_argv);
- }
+ d_qApplication = new QApplication(d_argc, &d_argv);
+ }
- // If a style sheet is set in the prefs file, enable it here.
- check_set_qss(d_qApplication);
+ // If a style sheet is set in the prefs file, enable it here.
+ check_set_qss(d_qApplication);
- int numplots = (d_nconnections > 0) ? d_nconnections : 1;
- d_main_gui = new FreqDisplayForm(numplots, d_parent);
- set_fft_window(d_wintype);
- set_fft_size(d_fftsize);
- set_frequency_range(d_center_freq, d_bandwidth);
+ int numplots = (d_nconnections > 0) ? d_nconnections : 1;
+ d_main_gui = new FreqDisplayForm(numplots, d_parent);
+ set_fft_window(d_wintype);
+ set_fft_size(d_fftsize);
+ set_frequency_range(d_center_freq, d_bandwidth);
- if(d_name.size() > 0)
+ if (d_name.size() > 0)
set_title(d_name);
- set_output_multiple(d_fftsize);
+ set_output_multiple(d_fftsize);
- // initialize update time to 10 times a second
- set_update_time(0.1);
- }
+ // initialize update time to 10 times a second
+ set_update_time(0.1);
+}
- void
- freq_sink_f_impl::exec_()
- {
- d_qApplication->exec();
- }
+void freq_sink_f_impl::exec_() { d_qApplication->exec(); }
- QWidget*
- freq_sink_f_impl::qwidget()
- {
- return d_main_gui;
- }
+QWidget* freq_sink_f_impl::qwidget() { return d_main_gui; }
#ifdef ENABLE_PYTHON
- PyObject*
- freq_sink_f_impl::pyqwidget()
- {
- PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui);
- PyObject *retarg = Py_BuildValue("N", w);
- return retarg;
- }
+PyObject* freq_sink_f_impl::pyqwidget()
+{
+ PyObject* w = PyLong_FromVoidPtr((void*)d_main_gui);
+ PyObject* retarg = Py_BuildValue("N", w);
+ return retarg;
+}
#else
- void *
- freq_sink_f_impl::pyqwidget()
- {
- return NULL;
- }
+void* freq_sink_f_impl::pyqwidget() { return NULL; }
#endif
- void
- freq_sink_f_impl::set_fft_size(const int fftsize)
- {
- if((fftsize > 16) && (fftsize < 16384))
+void freq_sink_f_impl::set_fft_size(const int fftsize)
+{
+ if ((fftsize > 16) && (fftsize < 16384))
d_main_gui->setFFTSize(fftsize);
- else
+ else
throw std::runtime_error("freq_sink: FFT size must be > 16 and < 16384.");
- }
-
- int
- freq_sink_f_impl::fft_size() const
- {
- return d_fftsize;
- }
-
- void
- freq_sink_f_impl::set_fft_average(const float fftavg)
- {
- d_main_gui->setFFTAverage(fftavg);
- }
-
- float
- freq_sink_f_impl::fft_average() const
- {
- return d_fftavg;
- }
-
- void
- freq_sink_f_impl::set_fft_window(const filter::firdes::win_type win)
- {
- d_main_gui->setFFTWindowType(win);
- }
-
- filter::firdes::win_type
- freq_sink_f_impl::fft_window()
- {
- return d_wintype;
- }
-
- void
- freq_sink_f_impl::set_frequency_range(const double centerfreq,
- const double bandwidth)
- {
- d_center_freq = centerfreq;
- d_bandwidth = bandwidth;
- d_main_gui->setFrequencyRange(d_center_freq, d_bandwidth);
- }
-
- void
- freq_sink_f_impl::set_y_axis(double min, double max)
- {
- d_main_gui->setYaxis(min, max);
- }
-
- void
- freq_sink_f_impl::set_y_label(const std::string &label,
- const std::string &unit)
- {
- d_main_gui->setYLabel(label, unit);
- }
-
- void
- freq_sink_f_impl::set_update_time(double t)
- {
- //convert update time to ticks
- gr::high_res_timer_type tps = gr::high_res_timer_tps();
- d_update_time = t * tps;
- d_main_gui->setUpdateTime(t);
- d_last_time = 0;
- }
-
- void
- freq_sink_f_impl::set_title(const std::string &title)
- {
- d_main_gui->setTitle(title.c_str());
- }
-
- void
- freq_sink_f_impl::set_line_label(unsigned int which, const std::string &label)
- {
- d_main_gui->setLineLabel(which, label.c_str());
- }
-
- void
- freq_sink_f_impl::set_line_color(unsigned int which, const std::string &color)
- {
- d_main_gui->setLineColor(which, color.c_str());
- }
-
- void
- freq_sink_f_impl::set_line_width(unsigned int which, int width)
- {
- d_main_gui->setLineWidth(which, width);
- }
-
- void
- freq_sink_f_impl::set_line_style(unsigned int which, int style)
- {
- d_main_gui->setLineStyle(which, (Qt::PenStyle)style);
- }
-
- void
- freq_sink_f_impl::set_line_marker(unsigned int which, int marker)
- {
- d_main_gui->setLineMarker(which, (QwtSymbol::Style)marker);
- }
-
- void
- freq_sink_f_impl::set_line_alpha(unsigned int which, double alpha)
- {
- d_main_gui->setMarkerAlpha(which, (int)(255.0*alpha));
- }
-
- void
- freq_sink_f_impl::set_size(int width, int height)
- {
- d_main_gui->resize(QSize(width, height));
- }
-
- void
- freq_sink_f_impl::set_plot_pos_half(bool half)
- {
- d_main_gui->setPlotPosHalf(half);
- }
-
- void
- freq_sink_f_impl::set_trigger_mode(trigger_mode mode,
- float level,
- int channel,
- const std::string &tag_key)
- {
- gr::thread::scoped_lock lock(d_setlock);
-
- d_trigger_mode = mode;
- d_trigger_level = level;
- d_trigger_channel = channel;
- d_trigger_tag_key = pmt::intern(tag_key);
- d_triggered = false;
- d_trigger_count = 0;
-
- d_main_gui->setTriggerMode(d_trigger_mode);
- d_main_gui->setTriggerLevel(d_trigger_level);
- d_main_gui->setTriggerChannel(d_trigger_channel);
- d_main_gui->setTriggerTagKey(tag_key);
-
- _reset();
- }
-
- std::string
- freq_sink_f_impl::title()
- {
- return d_main_gui->title().toStdString();
- }
-
- std::string
- freq_sink_f_impl::line_label(unsigned int which)
- {
- return d_main_gui->lineLabel(which).toStdString();
- }
-
- std::string
- freq_sink_f_impl::line_color(unsigned int which)
- {
- return d_main_gui->lineColor(which).toStdString();
- }
-
- int
- freq_sink_f_impl::line_width(unsigned int which)
- {
- return d_main_gui->lineWidth(which);
- }
-
- int
- freq_sink_f_impl::line_style(unsigned int which)
- {
- return d_main_gui->lineStyle(which);
- }
-
- int
- freq_sink_f_impl::line_marker(unsigned int which)
- {
- return d_main_gui->lineMarker(which);
- }
+}
+
+int freq_sink_f_impl::fft_size() const { return d_fftsize; }
+
+void freq_sink_f_impl::set_fft_average(const float fftavg)
+{
+ d_main_gui->setFFTAverage(fftavg);
+}
+
+float freq_sink_f_impl::fft_average() const { return d_fftavg; }
+
+void freq_sink_f_impl::set_fft_window(const filter::firdes::win_type win)
+{
+ d_main_gui->setFFTWindowType(win);
+}
+
+filter::firdes::win_type freq_sink_f_impl::fft_window() { return d_wintype; }
+
+void freq_sink_f_impl::set_frequency_range(const double centerfreq,
+ const double bandwidth)
+{
+ d_center_freq = centerfreq;
+ d_bandwidth = bandwidth;
+ d_main_gui->setFrequencyRange(d_center_freq, d_bandwidth);
+}
+
+void freq_sink_f_impl::set_y_axis(double min, double max)
+{
+ d_main_gui->setYaxis(min, max);
+}
+
+void freq_sink_f_impl::set_y_label(const std::string& label, const std::string& unit)
+{
+ d_main_gui->setYLabel(label, unit);
+}
+
+void freq_sink_f_impl::set_update_time(double t)
+{
+ // convert update time to ticks
+ gr::high_res_timer_type tps = gr::high_res_timer_tps();
+ d_update_time = t * tps;
+ d_main_gui->setUpdateTime(t);
+ d_last_time = 0;
+}
+
+void freq_sink_f_impl::set_title(const std::string& title)
+{
+ d_main_gui->setTitle(title.c_str());
+}
+
+void freq_sink_f_impl::set_line_label(unsigned int which, const std::string& label)
+{
+ d_main_gui->setLineLabel(which, label.c_str());
+}
+
+void freq_sink_f_impl::set_line_color(unsigned int which, const std::string& color)
+{
+ d_main_gui->setLineColor(which, color.c_str());
+}
+
+void freq_sink_f_impl::set_line_width(unsigned int which, int width)
+{
+ d_main_gui->setLineWidth(which, width);
+}
+
+void freq_sink_f_impl::set_line_style(unsigned int which, int style)
+{
+ d_main_gui->setLineStyle(which, (Qt::PenStyle)style);
+}
+
+void freq_sink_f_impl::set_line_marker(unsigned int which, int marker)
+{
+ d_main_gui->setLineMarker(which, (QwtSymbol::Style)marker);
+}
+
+void freq_sink_f_impl::set_line_alpha(unsigned int which, double alpha)
+{
+ d_main_gui->setMarkerAlpha(which, (int)(255.0 * alpha));
+}
+
+void freq_sink_f_impl::set_size(int width, int height)
+{
+ d_main_gui->resize(QSize(width, height));
+}
+
+void freq_sink_f_impl::set_plot_pos_half(bool half) { d_main_gui->setPlotPosHalf(half); }
+
+void freq_sink_f_impl::set_trigger_mode(trigger_mode mode,
+ float level,
+ int channel,
+ const std::string& tag_key)
+{
+ gr::thread::scoped_lock lock(d_setlock);
+
+ d_trigger_mode = mode;
+ d_trigger_level = level;
+ d_trigger_channel = channel;
+ d_trigger_tag_key = pmt::intern(tag_key);
+ d_triggered = false;
+ d_trigger_count = 0;
+
+ d_main_gui->setTriggerMode(d_trigger_mode);
+ d_main_gui->setTriggerLevel(d_trigger_level);
+ d_main_gui->setTriggerChannel(d_trigger_channel);
+ d_main_gui->setTriggerTagKey(tag_key);
+
+ _reset();
+}
+
+std::string freq_sink_f_impl::title() { return d_main_gui->title().toStdString(); }
+
+std::string freq_sink_f_impl::line_label(unsigned int which)
+{
+ return d_main_gui->lineLabel(which).toStdString();
+}
+
+std::string freq_sink_f_impl::line_color(unsigned int which)
+{
+ return d_main_gui->lineColor(which).toStdString();
+}
+
+int freq_sink_f_impl::line_width(unsigned int which)
+{
+ return d_main_gui->lineWidth(which);
+}
+
+int freq_sink_f_impl::line_style(unsigned int which)
+{
+ return d_main_gui->lineStyle(which);
+}
+
+int freq_sink_f_impl::line_marker(unsigned int which)
+{
+ return d_main_gui->lineMarker(which);
+}
+
+double freq_sink_f_impl::line_alpha(unsigned int which)
+{
+ return (double)(d_main_gui->markerAlpha(which)) / 255.0;
+}
+
+void freq_sink_f_impl::enable_menu(bool en) { d_main_gui->enableMenu(en); }
+
+void freq_sink_f_impl::enable_grid(bool en) { d_main_gui->setGrid(en); }
+
+void freq_sink_f_impl::enable_autoscale(bool en) { d_main_gui->autoScale(en); }
+
+void freq_sink_f_impl::enable_axis_labels(bool en) { d_main_gui->setAxisLabels(en); }
+
+void freq_sink_f_impl::enable_control_panel(bool en)
+{
+ if (en)
+ d_main_gui->setupControlPanel();
+ else
+ d_main_gui->teardownControlPanel();
+}
- double
- freq_sink_f_impl::line_alpha(unsigned int which)
- {
- return (double)(d_main_gui->markerAlpha(which))/255.0;
- }
+void freq_sink_f_impl::enable_max_hold(bool en) { d_main_gui->notifyMaxHold(en); }
- void
- freq_sink_f_impl::enable_menu(bool en)
- {
- d_main_gui->enableMenu(en);
- }
+void freq_sink_f_impl::enable_min_hold(bool en) { d_main_gui->notifyMinHold(en); }
- void
- freq_sink_f_impl::enable_grid(bool en)
- {
- d_main_gui->setGrid(en);
- }
+void freq_sink_f_impl::clear_max_hold() { d_main_gui->clearMaxHold(); }
- void
- freq_sink_f_impl::enable_autoscale(bool en)
- {
- d_main_gui->autoScale(en);
- }
+void freq_sink_f_impl::clear_min_hold() { d_main_gui->clearMinHold(); }
- void
- freq_sink_f_impl::enable_axis_labels(bool en)
- {
- d_main_gui->setAxisLabels(en);
- }
+void freq_sink_f_impl::disable_legend() { d_main_gui->disableLegend(); }
- void
- freq_sink_f_impl::enable_control_panel(bool en)
- {
- if(en)
- d_main_gui->setupControlPanel();
- else
- d_main_gui->teardownControlPanel();
- }
+void freq_sink_f_impl::reset()
+{
+ gr::thread::scoped_lock lock(d_setlock);
+ _reset();
+}
- void
- freq_sink_f_impl::enable_max_hold(bool en)
- {
- d_main_gui->notifyMaxHold(en);
- }
+void freq_sink_f_impl::_reset()
+{
+ d_trigger_count = 0;
- void
- freq_sink_f_impl::enable_min_hold(bool en)
- {
- d_main_gui->notifyMinHold(en);
- }
-
- void
- freq_sink_f_impl::clear_max_hold()
- {
- d_main_gui->clearMaxHold();
- }
-
- void
- freq_sink_f_impl::clear_min_hold()
- {
- d_main_gui->clearMinHold();
+ // Reset the trigger.
+ if (d_trigger_mode == TRIG_MODE_FREE) {
+ d_triggered = true;
+ } else {
+ d_triggered = false;
}
+}
- void
- freq_sink_f_impl::disable_legend()
- {
- d_main_gui->disableLegend();
- }
+void freq_sink_f_impl::fft(float* data_out, const float* data_in, int size)
+{
+ // float to complex conversion
+ gr_complex* dst = d_fft->get_inbuf();
+ for (int i = 0; i < size; i++)
+ dst[i] = data_in[i];
- void
- freq_sink_f_impl::reset()
- {
- gr::thread::scoped_lock lock(d_setlock);
- _reset();
+ if (d_window.size()) {
+ volk_32fc_32f_multiply_32fc(d_fft->get_inbuf(), dst, &d_window.front(), size);
}
- void
- freq_sink_f_impl::_reset()
- {
- d_trigger_count = 0;
+ d_fft->execute(); // compute the fft
+ volk_32fc_s32f_x2_power_spectral_density_32f(
+ data_out, d_fft->get_outbuf(), size, 1.0, size);
- // Reset the trigger.
- if(d_trigger_mode == TRIG_MODE_FREE) {
- d_triggered = true;
- }
- else {
- d_triggered = false;
- }
- }
-
- void
- freq_sink_f_impl::fft(float *data_out, const float *data_in, int size)
- {
- // float to complex conversion
- gr_complex *dst = d_fft->get_inbuf();
- for (int i = 0; i < size; i++)
- dst[i] = data_in[i];
-
- if(d_window.size()) {
- volk_32fc_32f_multiply_32fc(d_fft->get_inbuf(), dst,
- &d_window.front(), size);
- }
-
- d_fft->execute(); // compute the fft
- volk_32fc_s32f_x2_power_spectral_density_32f(data_out, d_fft->get_outbuf(),
- size, 1.0, size);
-
- d_fft_shift.shift(data_out, size);
- }
+ d_fft_shift.shift(data_out, size);
+}
- bool
- freq_sink_f_impl::windowreset()
- {
- gr::thread::scoped_lock lock(d_setlock);
+bool freq_sink_f_impl::windowreset()
+{
+ gr::thread::scoped_lock lock(d_setlock);
- filter::firdes::win_type newwintype;
- newwintype = d_main_gui->getFFTWindowType();
- if(d_wintype != newwintype) {
+ filter::firdes::win_type newwintype;
+ newwintype = d_main_gui->getFFTWindowType();
+ if (d_wintype != newwintype) {
d_wintype = newwintype;
buildwindow();
return true;
- }
- return false;
}
+ return false;
+}
- void
- freq_sink_f_impl::buildwindow()
- {
- d_window.clear();
- if(d_wintype != filter::firdes::WIN_NONE) {
- d_window = filter::firdes::window(d_wintype, d_fftsize, 6.76);
- }
+void freq_sink_f_impl::buildwindow()
+{
+ d_window.clear();
+ if (d_wintype != filter::firdes::WIN_NONE) {
+ d_window = filter::firdes::window(d_wintype, d_fftsize, 6.76);
}
+}
- bool
- freq_sink_f_impl::fftresize()
- {
- gr::thread::scoped_lock lock(d_setlock);
+bool freq_sink_f_impl::fftresize()
+{
+ gr::thread::scoped_lock lock(d_setlock);
- int newfftsize = d_main_gui->getFFTSize();
- d_fftavg = d_main_gui->getFFTAverage();
+ int newfftsize = d_main_gui->getFFTSize();
+ d_fftavg = d_main_gui->getFFTAverage();
- if(newfftsize != d_fftsize) {
- // Resize residbuf and replace data
+ if (newfftsize != d_fftsize) {
+ // Resize residbuf and replace data
// +1 to handle PDU buffers
- for(int i = 0; i < d_nconnections+1; i++) {
- volk_free(d_residbufs[i]);
- volk_free(d_magbufs[i]);
+ for (int i = 0; i < d_nconnections + 1; i++) {
+ volk_free(d_residbufs[i]);
+ volk_free(d_magbufs[i]);
- d_residbufs[i] = (float*)volk_malloc(newfftsize*sizeof(float),
- volk_get_alignment());
- d_magbufs[i] = (double*)volk_malloc(newfftsize*sizeof(double),
- volk_get_alignment());
+ d_residbufs[i] =
+ (float*)volk_malloc(newfftsize * sizeof(float), volk_get_alignment());
+ d_magbufs[i] =
+ (double*)volk_malloc(newfftsize * sizeof(double), volk_get_alignment());
- memset(d_residbufs[i], 0, newfftsize*sizeof(float));
- memset(d_magbufs[i], 0, newfftsize*sizeof(double));
- }
+ memset(d_residbufs[i], 0, newfftsize * sizeof(float));
+ memset(d_magbufs[i], 0, newfftsize * sizeof(double));
+ }
// Update the pointer to the newly allocated memory
d_pdu_magbuf = d_magbufs[d_nconnections];
- // Set new fft size and reset buffer index
- // (throws away any currently held data, but who cares?)
- d_fftsize = newfftsize;
- d_index = 0;
+ // Set new fft size and reset buffer index
+ // (throws away any currently held data, but who cares?)
+ d_fftsize = newfftsize;
+ d_index = 0;
- // Reset window to reflect new size
- buildwindow();
+ // Reset window to reflect new size
+ buildwindow();
- // Reset FFTW plan for new size
- delete d_fft;
- d_fft = new fft::fft_complex(d_fftsize, true);
+ // Reset FFTW plan for new size
+ delete d_fft;
+ d_fft = new fft::fft_complex(d_fftsize, true);
- volk_free(d_fbuf);
- d_fbuf = (float*)volk_malloc(d_fftsize*sizeof(float),
- volk_get_alignment());
- memset(d_fbuf, 0, d_fftsize*sizeof(float));
+ volk_free(d_fbuf);
+ d_fbuf = (float*)volk_malloc(d_fftsize * sizeof(float), volk_get_alignment());
+ memset(d_fbuf, 0, d_fftsize * sizeof(float));
- d_fft_shift.resize(d_fftsize);
+ d_fft_shift.resize(d_fftsize);
d_last_time = 0;
set_output_multiple(d_fftsize);
return true;
- }
- return false;
}
+ return false;
+}
- void
- freq_sink_f_impl::check_clicked()
- {
- if(d_main_gui->checkClicked()) {
+void freq_sink_f_impl::check_clicked()
+{
+ if (d_main_gui->checkClicked()) {
double freq = d_main_gui->getClickedFreq();
- message_port_pub(d_port,
- pmt::cons(d_port,
- pmt::from_double(freq)));
- }
+ message_port_pub(d_port, pmt::cons(d_port, pmt::from_double(freq)));
}
+}
- void
- freq_sink_f_impl::handle_set_freq(pmt::pmt_t msg)
- {
- if(pmt::is_pair(msg)) {
+void freq_sink_f_impl::handle_set_freq(pmt::pmt_t msg)
+{
+ if (pmt::is_pair(msg)) {
pmt::pmt_t x = pmt::cdr(msg);
- if(pmt::is_real(x)) {
- d_center_freq = pmt::to_double(x);
- d_qApplication->postEvent(d_main_gui,
- new SetFreqEvent(d_center_freq, d_bandwidth));
+ if (pmt::is_real(x)) {
+ d_center_freq = pmt::to_double(x);
+ d_qApplication->postEvent(d_main_gui,
+ new SetFreqEvent(d_center_freq, d_bandwidth));
}
- }
}
+}
- void
- freq_sink_f_impl::handle_set_bw(pmt::pmt_t msg)
- {
- if(pmt::is_pair(msg)) {
+void freq_sink_f_impl::handle_set_bw(pmt::pmt_t msg)
+{
+ if (pmt::is_pair(msg)) {
pmt::pmt_t x = pmt::cdr(msg);
- if(pmt::is_real(x)) {
- d_bandwidth = pmt::to_double(x);
- d_qApplication->postEvent(d_main_gui,
- new SetFreqEvent(d_center_freq, d_bandwidth));
+ if (pmt::is_real(x)) {
+ d_bandwidth = pmt::to_double(x);
+ d_qApplication->postEvent(d_main_gui,
+ new SetFreqEvent(d_center_freq, d_bandwidth));
}
- }
- }
+ }
+}
- void
- freq_sink_f_impl::_gui_update_trigger()
- {
- trigger_mode new_trigger_mode = d_main_gui->getTriggerMode();
- d_trigger_level = d_main_gui->getTriggerLevel();
- d_trigger_channel = d_main_gui->getTriggerChannel();
+void freq_sink_f_impl::_gui_update_trigger()
+{
+ trigger_mode new_trigger_mode = d_main_gui->getTriggerMode();
+ d_trigger_level = d_main_gui->getTriggerLevel();
+ d_trigger_channel = d_main_gui->getTriggerChannel();
- std::string tagkey = d_main_gui->getTriggerTagKey();
- d_trigger_tag_key = pmt::intern(tagkey);
+ std::string tagkey = d_main_gui->getTriggerTagKey();
+ d_trigger_tag_key = pmt::intern(tagkey);
- if(new_trigger_mode != d_trigger_mode) {
+ if (new_trigger_mode != d_trigger_mode) {
d_trigger_mode = new_trigger_mode;
_reset();
- }
}
+}
- void
- freq_sink_f_impl::_test_trigger_tags(int start, int nitems)
- {
- uint64_t nr = nitems_read(d_trigger_channel);
- std::vector<gr::tag_t> tags;
- get_tags_in_range(tags, d_trigger_channel,
- nr+start, nr+start+nitems,
- d_trigger_tag_key);
- if(tags.size() > 0) {
+void freq_sink_f_impl::_test_trigger_tags(int start, int nitems)
+{
+ uint64_t nr = nitems_read(d_trigger_channel);
+ std::vector<gr::tag_t> tags;
+ get_tags_in_range(
+ tags, d_trigger_channel, nr + start, nr + start + nitems, d_trigger_tag_key);
+ if (tags.size() > 0) {
d_triggered = true;
d_index = tags[0].offset - nr;
d_trigger_count = 0;
- }
}
+}
- void
- freq_sink_f_impl::_test_trigger_norm(int nitems, std::vector<double*> inputs)
- {
- const double *in = (const double*)inputs[d_trigger_channel];
- for(int i = 0; i < nitems; i++) {
+void freq_sink_f_impl::_test_trigger_norm(int nitems, std::vector<double*> inputs)
+{
+ const double* in = (const double*)inputs[d_trigger_channel];
+ for (int i = 0; i < nitems; i++) {
d_trigger_count++;
// Test if trigger has occurred based on the FFT magnitude and
// channel number. Test if any value is > the level (in dBx).
- if(in[i] > d_trigger_level) {
- d_triggered = true;
- d_trigger_count = 0;
- break;
+ if (in[i] > d_trigger_level) {
+ d_triggered = true;
+ d_trigger_count = 0;
+ break;
}
- }
+ }
- // If using auto trigger mode, trigger periodically even
- // without a trigger event.
- if((d_trigger_mode == TRIG_MODE_AUTO) && (d_trigger_count > d_fftsize)) {
+ // If using auto trigger mode, trigger periodically even
+ // without a trigger event.
+ if ((d_trigger_mode == TRIG_MODE_AUTO) && (d_trigger_count > d_fftsize)) {
d_triggered = true;
d_trigger_count = 0;
- }
}
+}
+
+int freq_sink_f_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const float* in = (const float*)input_items[0];
- int
- freq_sink_f_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const float *in = (const float*)input_items[0];
-
- // Update the FFT size from the application
- bool updated = false;
- updated |= fftresize();
- updated |= windowreset();
- if(updated)
+ // Update the FFT size from the application
+ bool updated = false;
+ updated |= fftresize();
+ updated |= windowreset();
+ if (updated)
return 0;
- check_clicked();
- _gui_update_trigger();
+ check_clicked();
+ _gui_update_trigger();
- gr::thread::scoped_lock lock(d_setlock);
- for(d_index = 0; d_index < noutput_items; d_index+=d_fftsize) {
+ gr::thread::scoped_lock lock(d_setlock);
+ for (d_index = 0; d_index < noutput_items; d_index += d_fftsize) {
- if((gr::high_res_timer_now() - d_last_time) > d_update_time) {
+ if ((gr::high_res_timer_now() - d_last_time) > d_update_time) {
- // Trigger off tag, if active
- if((d_trigger_mode == TRIG_MODE_TAG) && !d_triggered) {
- _test_trigger_tags(d_index, d_fftsize);
- if(d_triggered) {
- // If not enough from tag position, early exit
- if((d_index + d_fftsize) >= noutput_items)
- return d_index;
+ // Trigger off tag, if active
+ if ((d_trigger_mode == TRIG_MODE_TAG) && !d_triggered) {
+ _test_trigger_tags(d_index, d_fftsize);
+ if (d_triggered) {
+ // If not enough from tag position, early exit
+ if ((d_index + d_fftsize) >= noutput_items)
+ return d_index;
+ }
}
- }
- for(int n = 0; n < d_nconnections; n++) {
- // Fill up residbuf with d_fftsize number of items
- in = (const float*)input_items[n];
- memcpy(d_residbufs[n], &in[d_index], sizeof(float)*d_fftsize);
+ for (int n = 0; n < d_nconnections; n++) {
+ // Fill up residbuf with d_fftsize number of items
+ in = (const float*)input_items[n];
+ memcpy(d_residbufs[n], &in[d_index], sizeof(float) * d_fftsize);
+
+ fft(d_fbuf, d_residbufs[n], d_fftsize);
+ for (int x = 0; x < d_fftsize; x++) {
+ d_magbufs[n][x] = (double)((1.0 - d_fftavg) * d_magbufs[n][x] +
+ (d_fftavg)*d_fbuf[x]);
+ }
+ // volk_32f_convert_64f(d_magbufs[n], d_fbuf, d_fftsize);
+ }
+
+ // Test trigger off signal power in d_magbufs
+ if ((d_trigger_mode == TRIG_MODE_NORM) ||
+ (d_trigger_mode == TRIG_MODE_AUTO)) {
+ _test_trigger_norm(d_fftsize, d_magbufs);
+ }
- fft(d_fbuf, d_residbufs[n], d_fftsize);
- for(int x = 0; x < d_fftsize; x++) {
- d_magbufs[n][x] = (double)((1.0-d_fftavg)*d_magbufs[n][x] + (d_fftavg)*d_fbuf[x]);
+ // If a trigger (FREE always triggers), plot and reset state
+ if (d_triggered) {
+ d_last_time = gr::high_res_timer_now();
+ d_qApplication->postEvent(d_main_gui,
+ new FreqUpdateEvent(d_magbufs, d_fftsize));
+ _reset();
}
- //volk_32f_convert_64f(d_magbufs[n], d_fbuf, d_fftsize);
- }
-
- // Test trigger off signal power in d_magbufs
- if((d_trigger_mode == TRIG_MODE_NORM) || (d_trigger_mode == TRIG_MODE_AUTO)) {
- _test_trigger_norm(d_fftsize, d_magbufs);
- }
-
- // If a trigger (FREE always triggers), plot and reset state
- if(d_triggered) {
- d_last_time = gr::high_res_timer_now();
- d_qApplication->postEvent(d_main_gui,
- new FreqUpdateEvent(d_magbufs, d_fftsize));
- _reset();
- }
- }
- }
-
- return noutput_items;
+ }
}
- void
- freq_sink_f_impl::handle_pdus(pmt::pmt_t msg)
- {
- size_t len;
- pmt::pmt_t dict, samples;
+ return noutput_items;
+}
+
+void freq_sink_f_impl::handle_pdus(pmt::pmt_t msg)
+{
+ size_t len;
+ pmt::pmt_t dict, samples;
- // Test to make sure this is either a PDU or a uniform vector of
- // samples. Get the samples PMT and the dictionary if it's a PDU.
- // If not, we throw an error and exit.
- if(pmt::is_pair(msg)) {
+ // Test to make sure this is either a PDU or a uniform vector of
+ // samples. Get the samples PMT and the dictionary if it's a PDU.
+ // If not, we throw an error and exit.
+ if (pmt::is_pair(msg)) {
dict = pmt::car(msg);
samples = pmt::cdr(msg);
- }
- else if(pmt::is_uniform_vector(msg)) {
+ } else if (pmt::is_uniform_vector(msg)) {
samples = msg;
- }
- else {
+ } else {
throw std::runtime_error("time_sink_c: message must be either "
"a PDU or a uniform vector of samples.");
- }
+ }
- len = pmt::length(samples);
+ len = pmt::length(samples);
- const float *in;
- if(pmt::is_f32vector(samples)) {
+ const float* in;
+ if (pmt::is_f32vector(samples)) {
in = (const float*)pmt::f32vector_elements(samples, len);
- }
- else {
+ } else {
throw std::runtime_error("freq_sink_f: unknown data type "
"of samples; must be float.");
- }
+ }
- // Plot if we're past the last update time
- if(gr::high_res_timer_now() - d_last_time > d_update_time) {
+ // Plot if we're past the last update time
+ if (gr::high_res_timer_now() - d_last_time > d_update_time) {
d_last_time = gr::high_res_timer_now();
// Update the FFT size from the application
@@ -789,40 +669,39 @@ namespace gr {
int nffts = static_cast<int>(ceilf(num));
// Clear this as we will be accumulating in the for loop over nffts
- memset(d_pdu_magbuf, 0, sizeof(double)*d_fftsize);
+ memset(d_pdu_magbuf, 0, sizeof(double) * d_fftsize);
size_t min = 0;
size_t max = std::min(d_fftsize, static_cast<int>(len));
- for(int n = 0; n < nffts; n++) {
- // Clear in case (max-min) < d_fftsize
- memset(d_residbufs[d_nconnections], 0x00, sizeof(float)*d_fftsize);
-
- // Copy in as much of the input samples as we can
- memcpy(d_residbufs[d_nconnections], &in[min], sizeof(float)*(max-min));
-
- // Apply the window and FFT; copy data into the PDU
- // magnitude buffer.
- fft(d_fbuf, d_residbufs[d_nconnections], d_fftsize);
- for(int x = 0; x < d_fftsize; x++) {
- d_pdu_magbuf[x] += (double)d_fbuf[x];
- }
-
- // Increment our indices; set max up to the number of
- // samples in the input PDU.
- min += fftoverlap;
- max = std::min(max + fftoverlap, len);
+ for (int n = 0; n < nffts; n++) {
+ // Clear in case (max-min) < d_fftsize
+ memset(d_residbufs[d_nconnections], 0x00, sizeof(float) * d_fftsize);
+
+ // Copy in as much of the input samples as we can
+ memcpy(d_residbufs[d_nconnections], &in[min], sizeof(float) * (max - min));
+
+ // Apply the window and FFT; copy data into the PDU
+ // magnitude buffer.
+ fft(d_fbuf, d_residbufs[d_nconnections], d_fftsize);
+ for (int x = 0; x < d_fftsize; x++) {
+ d_pdu_magbuf[x] += (double)d_fbuf[x];
+ }
+
+ // Increment our indices; set max up to the number of
+ // samples in the input PDU.
+ min += fftoverlap;
+ max = std::min(max + fftoverlap, len);
}
// Perform the averaging
- for(int x = 0; x < d_fftsize; x++) {
- d_pdu_magbuf[x] /= static_cast<double>(nffts);
+ for (int x = 0; x < d_fftsize; x++) {
+ d_pdu_magbuf[x] /= static_cast<double>(nffts);
}
- //update gui per-pdu
- d_qApplication->postEvent(d_main_gui,
- new FreqUpdateEvent(d_magbufs, d_fftsize));
- }
+ // update gui per-pdu
+ d_qApplication->postEvent(d_main_gui, new FreqUpdateEvent(d_magbufs, d_fftsize));
}
+}
- } /* namespace qtgui */
+} /* namespace qtgui */
} /* namespace gr */
diff --git a/gr-qtgui/lib/freq_sink_f_impl.h b/gr-qtgui/lib/freq_sink_f_impl.h
index 4214943c73..c529ca6d7b 100644
--- a/gr-qtgui/lib/freq_sink_f_impl.h
+++ b/gr-qtgui/lib/freq_sink_f_impl.h
@@ -32,144 +32,147 @@
#include <gnuradio/qtgui/freqdisplayform.h>
namespace gr {
- namespace qtgui {
-
- class QTGUI_API freq_sink_f_impl : public freq_sink_f
- {
- private:
- void initialize();
-
- int d_fftsize;
- fft::fft_shift<float> d_fft_shift;
- float d_fftavg;
- filter::firdes::win_type d_wintype;
- std::vector<float> d_window;
- double d_center_freq;
- double d_bandwidth;
- std::string d_name;
- int d_nconnections;
-
- const pmt::pmt_t d_port;
- const pmt::pmt_t d_port_bw;
-
- bool d_shift;
- fft::fft_complex *d_fft;
-
- int d_index;
- std::vector<float*> d_residbufs;
- std::vector<double*> d_magbufs;
- double* d_pdu_magbuf;
- float *d_fbuf;
-
- int d_argc;
- char *d_argv;
- QWidget *d_parent;
- FreqDisplayForm *d_main_gui;
-
- gr::high_res_timer_type d_update_time;
- gr::high_res_timer_type d_last_time;
-
- bool windowreset();
- void buildwindow();
- bool fftresize();
- void check_clicked();
- void fft(float *data_out, const float *data_in, int size);
-
- // Handles message input port for setting new bandwidth
- // The message is a PMT pair (intern('bw'), double(bw))
- void handle_set_bw(pmt::pmt_t msg);
-
- // Handles message input port for setting new center frequency.
- // The message is a PMT pair (intern('freq'), double(frequency)).
- void handle_set_freq(pmt::pmt_t msg);
-
- // Handles message input port for displaying PDU samples.
- void handle_pdus(pmt::pmt_t msg);
-
- // Members used for triggering scope
- trigger_mode d_trigger_mode;
- float d_trigger_level;
- int d_trigger_channel;
- pmt::pmt_t d_trigger_tag_key;
- bool d_triggered;
- int d_trigger_count;
-
- void _reset();
- void _gui_update_trigger();
- void _test_trigger_tags(int start, int nitems);
- void _test_trigger_norm(int nitems, std::vector<double*> inputs);
-
- public:
- freq_sink_f_impl(int size, int wintype,
- double fc, double bw,
- const std::string &name,
- int nconnections,
- QWidget *parent=NULL);
- ~freq_sink_f_impl();
-
- bool check_topology(int ninputs, int noutputs);
-
- void exec_();
- QWidget* qwidget();
+namespace qtgui {
+
+class QTGUI_API freq_sink_f_impl : public freq_sink_f
+{
+private:
+ void initialize();
+
+ int d_fftsize;
+ fft::fft_shift<float> d_fft_shift;
+ float d_fftavg;
+ filter::firdes::win_type d_wintype;
+ std::vector<float> d_window;
+ double d_center_freq;
+ double d_bandwidth;
+ std::string d_name;
+ int d_nconnections;
+
+ const pmt::pmt_t d_port;
+ const pmt::pmt_t d_port_bw;
+
+ bool d_shift;
+ fft::fft_complex* d_fft;
+
+ int d_index;
+ std::vector<float*> d_residbufs;
+ std::vector<double*> d_magbufs;
+ double* d_pdu_magbuf;
+ float* d_fbuf;
+
+ int d_argc;
+ char* d_argv;
+ QWidget* d_parent;
+ FreqDisplayForm* d_main_gui;
+
+ gr::high_res_timer_type d_update_time;
+ gr::high_res_timer_type d_last_time;
+
+ bool windowreset();
+ void buildwindow();
+ bool fftresize();
+ void check_clicked();
+ void fft(float* data_out, const float* data_in, int size);
+
+ // Handles message input port for setting new bandwidth
+ // The message is a PMT pair (intern('bw'), double(bw))
+ void handle_set_bw(pmt::pmt_t msg);
+
+ // Handles message input port for setting new center frequency.
+ // The message is a PMT pair (intern('freq'), double(frequency)).
+ void handle_set_freq(pmt::pmt_t msg);
+
+ // Handles message input port for displaying PDU samples.
+ void handle_pdus(pmt::pmt_t msg);
+
+ // Members used for triggering scope
+ trigger_mode d_trigger_mode;
+ float d_trigger_level;
+ int d_trigger_channel;
+ pmt::pmt_t d_trigger_tag_key;
+ bool d_triggered;
+ int d_trigger_count;
+
+ void _reset();
+ void _gui_update_trigger();
+ void _test_trigger_tags(int start, int nitems);
+ void _test_trigger_norm(int nitems, std::vector<double*> inputs);
+
+public:
+ freq_sink_f_impl(int size,
+ int wintype,
+ double fc,
+ double bw,
+ const std::string& name,
+ int nconnections,
+ QWidget* parent = NULL);
+ ~freq_sink_f_impl();
+
+ bool check_topology(int ninputs, int noutputs);
+
+ void exec_();
+ QWidget* qwidget();
#ifdef ENABLE_PYTHON
- PyObject* pyqwidget();
+ PyObject* pyqwidget();
#else
- void* pyqwidget();
+ void* pyqwidget();
#endif
- void set_fft_size(const int fftsize);
- int fft_size() const;
- void set_fft_average(const float fftavg);
- float fft_average() const;
- void set_fft_window(const filter::firdes::win_type win);
- filter::firdes::win_type fft_window();
-
- void set_frequency_range(const double centerfreq, const double bandwidth);
- void set_y_axis(double min, double max);
-
- void set_update_time(double t);
- void set_title(const std::string &title);
- void set_y_label(const std::string &label, const std::string &unit);
- void set_line_label(unsigned int which, const std::string &label);
- void set_line_color(unsigned int which, const std::string &color);
- void set_line_width(unsigned int which, int width);
- void set_line_style(unsigned int which, int style);
- void set_line_marker(unsigned int which, int marker);
- void set_line_alpha(unsigned int which, double alpha);
- void set_plot_pos_half(bool half);
- void set_trigger_mode(trigger_mode mode,
- float level, int channel,
- const std::string &tag_key="");
-
- std::string title();
- std::string line_label(unsigned int which);
- std::string line_color(unsigned int which);
- int line_width(unsigned int which);
- int line_style(unsigned int which);
- int line_marker(unsigned int which);
- double line_alpha(unsigned int which);
-
- void set_size(int width, int height);
-
- void enable_menu(bool en);
- void enable_grid(bool en);
- void enable_autoscale(bool en);
- void enable_control_panel(bool en);
- void enable_max_hold(bool en);
- void enable_min_hold(bool en);
- void clear_max_hold();
- void clear_min_hold();
- void disable_legend();
- void reset();
- void enable_axis_labels(bool en);
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace qtgui */
+ void set_fft_size(const int fftsize);
+ int fft_size() const;
+ void set_fft_average(const float fftavg);
+ float fft_average() const;
+ void set_fft_window(const filter::firdes::win_type win);
+ filter::firdes::win_type fft_window();
+
+ void set_frequency_range(const double centerfreq, const double bandwidth);
+ void set_y_axis(double min, double max);
+
+ void set_update_time(double t);
+ void set_title(const std::string& title);
+ void set_y_label(const std::string& label, const std::string& unit);
+ void set_line_label(unsigned int which, const std::string& label);
+ void set_line_color(unsigned int which, const std::string& color);
+ void set_line_width(unsigned int which, int width);
+ void set_line_style(unsigned int which, int style);
+ void set_line_marker(unsigned int which, int marker);
+ void set_line_alpha(unsigned int which, double alpha);
+ void set_plot_pos_half(bool half);
+ void set_trigger_mode(trigger_mode mode,
+ float level,
+ int channel,
+ const std::string& tag_key = "");
+
+ std::string title();
+ std::string line_label(unsigned int which);
+ std::string line_color(unsigned int which);
+ int line_width(unsigned int which);
+ int line_style(unsigned int which);
+ int line_marker(unsigned int which);
+ double line_alpha(unsigned int which);
+
+ void set_size(int width, int height);
+
+ void enable_menu(bool en);
+ void enable_grid(bool en);
+ void enable_autoscale(bool en);
+ void enable_control_panel(bool en);
+ void enable_max_hold(bool en);
+ void enable_min_hold(bool en);
+ void clear_max_hold();
+ void clear_min_hold();
+ void disable_legend();
+ void reset();
+ void enable_axis_labels(bool en);
+
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
+
+} /* namespace qtgui */
} /* namespace gr */
#endif /* INCLUDED_QTGUI_FREQ_SINK_F_IMPL_H */
diff --git a/gr-qtgui/lib/freqcontrolpanel.cc b/gr-qtgui/lib/freqcontrolpanel.cc
index 536bf9a2f8..16c7e260db 100644
--- a/gr-qtgui/lib/freqcontrolpanel.cc
+++ b/gr-qtgui/lib/freqcontrolpanel.cc
@@ -24,284 +24,257 @@
#include <cmath>
-FreqControlPanel::FreqControlPanel(FreqDisplayForm *form)
- : QVBoxLayout(),
- d_parent(form)
+FreqControlPanel::FreqControlPanel(FreqDisplayForm* form) : QVBoxLayout(), d_parent(form)
{
- // Set up the box for trace items
- d_trace_box = new QGroupBox("Trace Options");
- d_trace_layout = new QVBoxLayout;
- d_maxhold_check = new QCheckBox("Max Hold");
- d_minhold_check = new QCheckBox("Min Hold");
-
- d_avg_layout = new QHBoxLayout;
- d_avg_label = new QLabel("Avg:");
- d_slider_max = 100;
- d_slider_min = 1;
- d_slider_step = 1;
- d_avg_slider = new QSlider(Qt::Horizontal);
- d_avg_slider->setRange(d_slider_min, d_slider_max);
- d_avg_slider->setTickInterval(d_slider_step);
- d_avg_slider->setValue(d_slider_max);
- d_avg_layout->addWidget(d_avg_label);
- d_avg_layout->addWidget(d_avg_slider);
-
- // Set up the box for axis items
- d_axes_box = new QGroupBox("Axis Options");
- d_axes_layout = new QVBoxLayout;
-
- d_grid_check = new QCheckBox("Grid");
- d_axislabels_check = new QCheckBox("Axis Labels");
- d_yrange_layout = new QHBoxLayout;
- d_yrange_label = new QLabel("Y Range:");
- d_yrange_plus = new QPushButton("+");
- d_yrange_minus = new QPushButton("-");
- d_yrange_plus->setMaximumWidth(30);
- d_yrange_plus->setMinimumWidth(30);
- d_yrange_minus->setMaximumWidth(30);
- d_yrange_minus->setMinimumWidth(30);
- d_yrange_layout->addWidget(d_yrange_label);
- d_yrange_layout->addWidget(d_yrange_plus);
- d_yrange_layout->addWidget(d_yrange_minus);
-
- d_ymin_layout = new QHBoxLayout;
- d_ymin_label = new QLabel("Ref Level:");
- d_ymin_plus = new QPushButton("+");
- d_ymin_minus = new QPushButton("-");
- d_ymin_plus->setMaximumWidth(30);
- d_ymin_plus->setMinimumWidth(30);
- d_ymin_minus->setMaximumWidth(30);
- d_ymin_minus->setMinimumWidth(30);
- d_ymin_layout->addWidget(d_ymin_label);
- d_ymin_layout->addWidget(d_ymin_plus);
- d_ymin_layout->addWidget(d_ymin_minus);
-
- d_autoscale_button = new QPushButton("Autoscale");
-
-
- // Set up the box for FFT settings
- d_fft_box = new QGroupBox("FFT");
- d_fft_layout = new QVBoxLayout;
- d_fft_size_combo = new QComboBox();
- d_fft_size_combo->addItem("32");
- d_fft_size_combo->addItem("64");
- d_fft_size_combo->addItem("128");
- d_fft_size_combo->addItem("256");
- d_fft_size_combo->addItem("512");
- d_fft_size_combo->addItem("1024");
- d_fft_size_combo->addItem("2048");
- d_fft_size_combo->addItem("4096");
-
- d_fft_win_combo = new QComboBox();
- d_fft_win_combo->addItem("None");
- d_fft_win_combo->addItem("Hamming");
- d_fft_win_combo->addItem("Hann");
- d_fft_win_combo->addItem("Blackman");
- d_fft_win_combo->addItem("Blackman-harris");
- d_fft_win_combo->addItem("Rectangular");
- d_fft_win_combo->addItem("Kaiser");
- d_fft_win_combo->addItem("Flat-top");
-
- // Trigger box setup
- d_trigger_box = new QGroupBox("Trigger");
- d_trigger_layout = new QVBoxLayout;
- d_trigger_mode_combo = new QComboBox();
- d_trigger_mode_combo->addItem("Free");
- d_trigger_mode_combo->addItem("Auto");
- d_trigger_mode_combo->addItem("Normal");
- d_trigger_mode_combo->addItem("Tag");
-
- d_trigger_level_layout = new QHBoxLayout;
- d_trigger_level_label = new QLabel("Level:");
- d_trigger_level_plus = new QPushButton("+");
- d_trigger_level_minus = new QPushButton("-");
- d_trigger_level_plus->setMaximumWidth(30);
- d_trigger_level_minus->setMaximumWidth(30);
- d_trigger_level_layout->addWidget(d_trigger_level_label);
- d_trigger_level_layout->addWidget(d_trigger_level_plus);
- d_trigger_level_layout->addWidget(d_trigger_level_minus);
-
-
- // Set up the box for other items
- d_extras_box = new QGroupBox("Extras");
- d_extras_layout = new QVBoxLayout;
- d_stop_button = new QPushButton("Stop");
- d_stop_button->setCheckable(true);
-
- // Set up the boxes into the layout
- d_trace_layout->addWidget(d_maxhold_check);
- d_trace_layout->addWidget(d_minhold_check);
- d_trace_layout->addLayout(d_avg_layout);
- d_trace_box->setLayout(d_trace_layout);
-
- d_axes_layout->addWidget(d_grid_check);
- d_axes_layout->addWidget(d_axislabels_check);
- d_axes_layout->addLayout(d_yrange_layout);
- d_axes_layout->addLayout(d_ymin_layout);
- d_axes_layout->addWidget(d_autoscale_button);
- d_axes_box->setLayout(d_axes_layout);
-
- d_fft_layout->addWidget(d_fft_size_combo);
- d_fft_layout->addWidget(d_fft_win_combo);
- d_fft_box->setLayout(d_fft_layout);
-
- d_trigger_layout->addWidget(d_trigger_mode_combo);
- d_trigger_layout->addLayout(d_trigger_level_layout);
- d_trigger_box->setLayout(d_trigger_layout);
-
- d_extras_layout->addWidget(d_stop_button);
- d_extras_box->setLayout(d_extras_layout);
-
- addWidget(d_trace_box);
- addWidget(d_axes_box);
- addWidget(d_fft_box);
- addWidget(d_trigger_box);
- addWidget(d_extras_box);
-
- addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum,
- QSizePolicy::Expanding));
-
- connect(d_maxhold_check, SIGNAL(clicked(bool)),
- d_parent, SLOT(notifyMaxHold(bool)));
- connect(d_minhold_check, SIGNAL(clicked(bool)),
- d_parent, SLOT(notifyMinHold(bool)));
-
- connect(d_avg_slider, SIGNAL(valueChanged(int)),
- this, SLOT(notifyAvgSlider(int)));
- connect(this, SIGNAL(signalAvgSlider(float)),
- d_parent, SLOT(setFFTAverage(float)));
-
- connect(d_grid_check, SIGNAL(clicked(bool)),
- d_parent, SLOT(setGrid(bool)));
-
- connect(d_axislabels_check, SIGNAL(clicked(bool)),
- d_parent, SLOT(setAxisLabels(bool)));
-
- connect(d_ymin_plus, SIGNAL(pressed(void)),
- d_parent, SLOT(notifyYAxisPlus(void)));
- connect(d_ymin_minus, SIGNAL(pressed(void)),
- d_parent, SLOT(notifyYAxisMinus(void)));
- connect(d_yrange_plus, SIGNAL(pressed(void)),
- d_parent, SLOT(notifyYRangePlus(void)));
- connect(d_yrange_minus, SIGNAL(pressed(void)),
- d_parent, SLOT(notifyYRangeMinus(void)));
-
- connect(d_autoscale_button, SIGNAL(pressed(void)),
- d_parent, SLOT(autoScaleShot(void)));
-
- connect(d_fft_size_combo, SIGNAL(currentIndexChanged(const QString&)),
- d_parent, SLOT(notifyFFTSize(const QString&)));
- connect(d_fft_win_combo, SIGNAL(currentIndexChanged(const QString&)),
- d_parent, SLOT(notifyFFTWindow(const QString&)));
-
- connect(d_trigger_mode_combo, SIGNAL(currentIndexChanged(const QString&)),
- d_parent, SLOT(notifyTriggerMode(const QString&)));
- connect(d_trigger_level_plus, SIGNAL(pressed(void)),
- d_parent, SLOT(notifyTriggerLevelPlus()));
- connect(d_trigger_level_minus, SIGNAL(pressed(void)),
- d_parent, SLOT(notifyTriggerLevelMinus()));
-
- connect(d_stop_button, SIGNAL(pressed(void)),
- d_parent, SLOT(setStop(void)));
- connect(this, SIGNAL(signalToggleStopButton(void)),
- d_stop_button, SLOT(toggle(void)));
+ // Set up the box for trace items
+ d_trace_box = new QGroupBox("Trace Options");
+ d_trace_layout = new QVBoxLayout;
+ d_maxhold_check = new QCheckBox("Max Hold");
+ d_minhold_check = new QCheckBox("Min Hold");
+
+ d_avg_layout = new QHBoxLayout;
+ d_avg_label = new QLabel("Avg:");
+ d_slider_max = 100;
+ d_slider_min = 1;
+ d_slider_step = 1;
+ d_avg_slider = new QSlider(Qt::Horizontal);
+ d_avg_slider->setRange(d_slider_min, d_slider_max);
+ d_avg_slider->setTickInterval(d_slider_step);
+ d_avg_slider->setValue(d_slider_max);
+ d_avg_layout->addWidget(d_avg_label);
+ d_avg_layout->addWidget(d_avg_slider);
+
+ // Set up the box for axis items
+ d_axes_box = new QGroupBox("Axis Options");
+ d_axes_layout = new QVBoxLayout;
+
+ d_grid_check = new QCheckBox("Grid");
+ d_axislabels_check = new QCheckBox("Axis Labels");
+ d_yrange_layout = new QHBoxLayout;
+ d_yrange_label = new QLabel("Y Range:");
+ d_yrange_plus = new QPushButton("+");
+ d_yrange_minus = new QPushButton("-");
+ d_yrange_plus->setMaximumWidth(30);
+ d_yrange_plus->setMinimumWidth(30);
+ d_yrange_minus->setMaximumWidth(30);
+ d_yrange_minus->setMinimumWidth(30);
+ d_yrange_layout->addWidget(d_yrange_label);
+ d_yrange_layout->addWidget(d_yrange_plus);
+ d_yrange_layout->addWidget(d_yrange_minus);
+
+ d_ymin_layout = new QHBoxLayout;
+ d_ymin_label = new QLabel("Ref Level:");
+ d_ymin_plus = new QPushButton("+");
+ d_ymin_minus = new QPushButton("-");
+ d_ymin_plus->setMaximumWidth(30);
+ d_ymin_plus->setMinimumWidth(30);
+ d_ymin_minus->setMaximumWidth(30);
+ d_ymin_minus->setMinimumWidth(30);
+ d_ymin_layout->addWidget(d_ymin_label);
+ d_ymin_layout->addWidget(d_ymin_plus);
+ d_ymin_layout->addWidget(d_ymin_minus);
+
+ d_autoscale_button = new QPushButton("Autoscale");
+
+
+ // Set up the box for FFT settings
+ d_fft_box = new QGroupBox("FFT");
+ d_fft_layout = new QVBoxLayout;
+ d_fft_size_combo = new QComboBox();
+ d_fft_size_combo->addItem("32");
+ d_fft_size_combo->addItem("64");
+ d_fft_size_combo->addItem("128");
+ d_fft_size_combo->addItem("256");
+ d_fft_size_combo->addItem("512");
+ d_fft_size_combo->addItem("1024");
+ d_fft_size_combo->addItem("2048");
+ d_fft_size_combo->addItem("4096");
+
+ d_fft_win_combo = new QComboBox();
+ d_fft_win_combo->addItem("None");
+ d_fft_win_combo->addItem("Hamming");
+ d_fft_win_combo->addItem("Hann");
+ d_fft_win_combo->addItem("Blackman");
+ d_fft_win_combo->addItem("Blackman-harris");
+ d_fft_win_combo->addItem("Rectangular");
+ d_fft_win_combo->addItem("Kaiser");
+ d_fft_win_combo->addItem("Flat-top");
+
+ // Trigger box setup
+ d_trigger_box = new QGroupBox("Trigger");
+ d_trigger_layout = new QVBoxLayout;
+ d_trigger_mode_combo = new QComboBox();
+ d_trigger_mode_combo->addItem("Free");
+ d_trigger_mode_combo->addItem("Auto");
+ d_trigger_mode_combo->addItem("Normal");
+ d_trigger_mode_combo->addItem("Tag");
+
+ d_trigger_level_layout = new QHBoxLayout;
+ d_trigger_level_label = new QLabel("Level:");
+ d_trigger_level_plus = new QPushButton("+");
+ d_trigger_level_minus = new QPushButton("-");
+ d_trigger_level_plus->setMaximumWidth(30);
+ d_trigger_level_minus->setMaximumWidth(30);
+ d_trigger_level_layout->addWidget(d_trigger_level_label);
+ d_trigger_level_layout->addWidget(d_trigger_level_plus);
+ d_trigger_level_layout->addWidget(d_trigger_level_minus);
+
+
+ // Set up the box for other items
+ d_extras_box = new QGroupBox("Extras");
+ d_extras_layout = new QVBoxLayout;
+ d_stop_button = new QPushButton("Stop");
+ d_stop_button->setCheckable(true);
+
+ // Set up the boxes into the layout
+ d_trace_layout->addWidget(d_maxhold_check);
+ d_trace_layout->addWidget(d_minhold_check);
+ d_trace_layout->addLayout(d_avg_layout);
+ d_trace_box->setLayout(d_trace_layout);
+
+ d_axes_layout->addWidget(d_grid_check);
+ d_axes_layout->addWidget(d_axislabels_check);
+ d_axes_layout->addLayout(d_yrange_layout);
+ d_axes_layout->addLayout(d_ymin_layout);
+ d_axes_layout->addWidget(d_autoscale_button);
+ d_axes_box->setLayout(d_axes_layout);
+
+ d_fft_layout->addWidget(d_fft_size_combo);
+ d_fft_layout->addWidget(d_fft_win_combo);
+ d_fft_box->setLayout(d_fft_layout);
+
+ d_trigger_layout->addWidget(d_trigger_mode_combo);
+ d_trigger_layout->addLayout(d_trigger_level_layout);
+ d_trigger_box->setLayout(d_trigger_layout);
+
+ d_extras_layout->addWidget(d_stop_button);
+ d_extras_box->setLayout(d_extras_layout);
+
+ addWidget(d_trace_box);
+ addWidget(d_axes_box);
+ addWidget(d_fft_box);
+ addWidget(d_trigger_box);
+ addWidget(d_extras_box);
+
+ addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding));
+
+ connect(d_maxhold_check, SIGNAL(clicked(bool)), d_parent, SLOT(notifyMaxHold(bool)));
+ connect(d_minhold_check, SIGNAL(clicked(bool)), d_parent, SLOT(notifyMinHold(bool)));
+
+ connect(d_avg_slider, SIGNAL(valueChanged(int)), this, SLOT(notifyAvgSlider(int)));
+ connect(this, SIGNAL(signalAvgSlider(float)), d_parent, SLOT(setFFTAverage(float)));
+
+ connect(d_grid_check, SIGNAL(clicked(bool)), d_parent, SLOT(setGrid(bool)));
+
+ connect(
+ d_axislabels_check, SIGNAL(clicked(bool)), d_parent, SLOT(setAxisLabels(bool)));
+
+ connect(d_ymin_plus, SIGNAL(pressed(void)), d_parent, SLOT(notifyYAxisPlus(void)));
+ connect(d_ymin_minus, SIGNAL(pressed(void)), d_parent, SLOT(notifyYAxisMinus(void)));
+ connect(d_yrange_plus, SIGNAL(pressed(void)), d_parent, SLOT(notifyYRangePlus(void)));
+ connect(
+ d_yrange_minus, SIGNAL(pressed(void)), d_parent, SLOT(notifyYRangeMinus(void)));
+
+ connect(
+ d_autoscale_button, SIGNAL(pressed(void)), d_parent, SLOT(autoScaleShot(void)));
+
+ connect(d_fft_size_combo,
+ SIGNAL(currentIndexChanged(const QString&)),
+ d_parent,
+ SLOT(notifyFFTSize(const QString&)));
+ connect(d_fft_win_combo,
+ SIGNAL(currentIndexChanged(const QString&)),
+ d_parent,
+ SLOT(notifyFFTWindow(const QString&)));
+
+ connect(d_trigger_mode_combo,
+ SIGNAL(currentIndexChanged(const QString&)),
+ d_parent,
+ SLOT(notifyTriggerMode(const QString&)));
+ connect(d_trigger_level_plus,
+ SIGNAL(pressed(void)),
+ d_parent,
+ SLOT(notifyTriggerLevelPlus()));
+ connect(d_trigger_level_minus,
+ SIGNAL(pressed(void)),
+ d_parent,
+ SLOT(notifyTriggerLevelMinus()));
+
+ connect(d_stop_button, SIGNAL(pressed(void)), d_parent, SLOT(setStop(void)));
+ connect(
+ this, SIGNAL(signalToggleStopButton(void)), d_stop_button, SLOT(toggle(void)));
}
FreqControlPanel::~FreqControlPanel()
{
- removeWidget(d_axes_box);
- removeWidget(d_trace_box);
- removeWidget(d_fft_box);
- removeWidget(d_trigger_box);
- removeWidget(d_extras_box);
- delete d_axes_box;
- delete d_trace_box;
- delete d_fft_box;
- delete d_trigger_box;
- delete d_extras_box;
-
- // All other children of the boxes are automatically deleted.
+ removeWidget(d_axes_box);
+ removeWidget(d_trace_box);
+ removeWidget(d_fft_box);
+ removeWidget(d_trigger_box);
+ removeWidget(d_extras_box);
+ delete d_axes_box;
+ delete d_trace_box;
+ delete d_fft_box;
+ delete d_trigger_box;
+ delete d_extras_box;
+
+ // All other children of the boxes are automatically deleted.
}
-void
-FreqControlPanel::toggleGrid(bool en)
-{
- d_grid_check->setChecked(en);
-}
+void FreqControlPanel::toggleGrid(bool en) { d_grid_check->setChecked(en); }
-void
-FreqControlPanel::toggleAxisLabels(bool en)
-{
- d_axislabels_check->setChecked(en);
-}
+void FreqControlPanel::toggleAxisLabels(bool en) { d_axislabels_check->setChecked(en); }
-void
-FreqControlPanel::toggleMaxHold(bool en)
-{
- d_maxhold_check->setChecked(en);
-}
+void FreqControlPanel::toggleMaxHold(bool en) { d_maxhold_check->setChecked(en); }
-void
-FreqControlPanel::toggleMinHold(bool en)
-{
- d_minhold_check->setChecked(en);
-}
+void FreqControlPanel::toggleMinHold(bool en) { d_minhold_check->setChecked(en); }
-void
-FreqControlPanel::notifyAvgSlider(int val)
+void FreqControlPanel::notifyAvgSlider(int val)
{
- float fval = static_cast<float>(val) / (d_slider_max - d_slider_min + 1);
- emit signalAvgSlider(fval);
- emit signalAvg(true);
+ float fval = static_cast<float>(val) / (d_slider_max - d_slider_min + 1);
+ emit signalAvgSlider(fval);
+ emit signalAvg(true);
}
-void
-FreqControlPanel::setFFTAverage(float val)
+void FreqControlPanel::setFFTAverage(float val)
{
- int slider_val = static_cast<int>(roundf(val * (d_slider_max - d_slider_min + 1)));
- if (slider_val > d_slider_max)
- slider_val = d_slider_max;
- else if (slider_val < d_slider_min)
- slider_val = d_slider_min;
- d_avg_slider->setValue(slider_val);
+ int slider_val = static_cast<int>(roundf(val * (d_slider_max - d_slider_min + 1)));
+ if (slider_val > d_slider_max)
+ slider_val = d_slider_max;
+ else if (slider_val < d_slider_min)
+ slider_val = d_slider_min;
+ d_avg_slider->setValue(slider_val);
}
-void
-FreqControlPanel::toggleFFTSize(int val)
+void FreqControlPanel::toggleFFTSize(int val)
{
- int index = static_cast<int>(round(logf(static_cast<float>(val))/logf(2.0f))) - 5;
- d_fft_size_combo->setCurrentIndex(index);
+ int index = static_cast<int>(round(logf(static_cast<float>(val)) / logf(2.0f))) - 5;
+ d_fft_size_combo->setCurrentIndex(index);
}
-void
-FreqControlPanel::toggleFFTWindow(const gr::filter::firdes::win_type win)
+void FreqControlPanel::toggleFFTWindow(const gr::filter::firdes::win_type win)
{
- if(win == -1)
- d_fft_win_combo->setCurrentIndex(0);
- if(win == gr::filter::firdes::WIN_HAMMING)
- d_fft_win_combo->setCurrentIndex(1);
- else if(win == gr::filter::firdes::WIN_HANN)
- d_fft_win_combo->setCurrentIndex(2);
- else if(win == gr::filter::firdes::WIN_BLACKMAN)
- d_fft_win_combo->setCurrentIndex(3);
- else if(win == gr::filter::firdes::WIN_BLACKMAN_hARRIS)
- d_fft_win_combo->setCurrentIndex(4);
- else if(win == gr::filter::firdes::WIN_RECTANGULAR)
- d_fft_win_combo->setCurrentIndex(5);
- else if(win == gr::filter::firdes::WIN_KAISER)
- d_fft_win_combo->setCurrentIndex(6);
- else if(win == gr::filter::firdes::WIN_FLATTOP)
- d_fft_win_combo->setCurrentIndex(7);
+ if (win == -1)
+ d_fft_win_combo->setCurrentIndex(0);
+ if (win == gr::filter::firdes::WIN_HAMMING)
+ d_fft_win_combo->setCurrentIndex(1);
+ else if (win == gr::filter::firdes::WIN_HANN)
+ d_fft_win_combo->setCurrentIndex(2);
+ else if (win == gr::filter::firdes::WIN_BLACKMAN)
+ d_fft_win_combo->setCurrentIndex(3);
+ else if (win == gr::filter::firdes::WIN_BLACKMAN_hARRIS)
+ d_fft_win_combo->setCurrentIndex(4);
+ else if (win == gr::filter::firdes::WIN_RECTANGULAR)
+ d_fft_win_combo->setCurrentIndex(5);
+ else if (win == gr::filter::firdes::WIN_KAISER)
+ d_fft_win_combo->setCurrentIndex(6);
+ else if (win == gr::filter::firdes::WIN_FLATTOP)
+ d_fft_win_combo->setCurrentIndex(7);
}
-void
-FreqControlPanel::toggleTriggerMode(gr::qtgui::trigger_mode mode)
+void FreqControlPanel::toggleTriggerMode(gr::qtgui::trigger_mode mode)
{
- d_trigger_mode_combo->setCurrentIndex(static_cast<int>(mode));
+ d_trigger_mode_combo->setCurrentIndex(static_cast<int>(mode));
}
-void
-FreqControlPanel::toggleStopButton()
-{
- emit signalToggleStopButton();
-}
+void FreqControlPanel::toggleStopButton() { emit signalToggleStopButton(); }
diff --git a/gr-qtgui/lib/freqdisplayform.cc b/gr-qtgui/lib/freqdisplayform.cc
index 613138d13a..432d30729f 100644
--- a/gr-qtgui/lib/freqdisplayform.cc
+++ b/gr-qtgui/lib/freqdisplayform.cc
@@ -29,510 +29,455 @@
#include <iostream>
FreqDisplayForm::FreqDisplayForm(int nplots, QWidget* parent)
- : DisplayForm(nplots, parent)
-{
- d_int_validator = new QIntValidator(this);
- d_int_validator->setBottom(0);
-
- d_layout = new QGridLayout(this);
- d_display_plot = new FrequencyDisplayPlot(nplots, this);
- d_layout->addWidget(d_display_plot, 0, 0);
-
- d_layout->setColumnStretch(0, 1);
- setLayout(d_layout);
-
- d_controlpanel = NULL;
-
- d_num_real_data_points = 1024;
- d_fftsize = 1024;
- d_fftavg = 1.0;
- d_clicked = false;
- d_clicked_freq = 0;
-
- d_trig_mode = gr::qtgui::TRIG_MODE_FREE;
- d_trig_level = 0;
- d_trig_channel = 0;
- d_trig_tag_key = "";
-
- d_sizemenu = new FFTSizeMenu(this);
- d_avgmenu = new FFTAverageMenu(this);
- d_winmenu = new FFTWindowMenu(this);
- d_menu->addMenu(d_sizemenu);
- d_menu->addMenu(d_avgmenu);
- d_menu->addMenu(d_winmenu);
- connect(d_sizemenu, SIGNAL(whichTrigger(int)),
- this, SLOT(setFFTSize(const int)));
- connect(d_avgmenu, SIGNAL(whichTrigger(float)),
- this, SLOT(setFFTAverage(const float)));
- connect(d_winmenu, SIGNAL(whichTrigger(gr::filter::firdes::win_type)),
- this, SLOT(setFFTWindowType(const gr::filter::firdes::win_type)));
-
- PopupMenu *maxymenu = new PopupMenu("Y Max", this);
- d_menu->addAction(maxymenu);
- connect(maxymenu, SIGNAL(whichTrigger(QString)),
- this, SLOT(setYMax(QString)));
-
- PopupMenu *minymenu = new PopupMenu("Y Min", this);
- d_menu->addAction(minymenu);
- connect(minymenu, SIGNAL(whichTrigger(QString)),
- this, SLOT(setYMin(QString)));
-
- d_maxhold_act = new QAction("Max Hold", this);
- d_maxhold_act->setCheckable(true);
- d_menu->addAction(d_maxhold_act);
- connect(d_maxhold_act, SIGNAL(triggered(bool)),
- this, SLOT(notifyMaxHold(bool)));
- d_minhold_act = new QAction("Min Hold", this);
- d_minhold_act->setCheckable(true);
- d_menu->addAction(d_minhold_act);
- connect(d_minhold_act, SIGNAL(triggered(bool)),
- this, SLOT(notifyMinHold(bool)));
-
- // Set up the trigger menu
- d_triggermenu = new QMenu("Trigger", this);
- d_tr_mode_menu = new TriggerModeMenu(this);
- d_tr_level_act = new PopupMenu("Level", this);
- d_tr_channel_menu = new TriggerChannelMenu(nplots, this);
- d_tr_tag_key_act = new PopupMenu("Tag Key", this);
- d_triggermenu->addMenu(d_tr_mode_menu);
- d_triggermenu->addAction(d_tr_level_act);
- d_triggermenu->addMenu(d_tr_channel_menu);
- d_triggermenu->addAction(d_tr_tag_key_act);
- d_menu->addMenu(d_triggermenu);
-
- d_controlpanelmenu = new QAction("Control Panel", this);
- d_controlpanelmenu->setCheckable(true);
- d_menu->addAction(d_controlpanelmenu);
- connect(d_controlpanelmenu, SIGNAL(triggered(bool)),
- this, SLOT(setupControlPanel(bool)));
-
- setTriggerMode(gr::qtgui::TRIG_MODE_FREE);
- connect(d_tr_mode_menu, SIGNAL(whichTrigger(gr::qtgui::trigger_mode)),
- this, SLOT(setTriggerMode(gr::qtgui::trigger_mode)));
- // updates trigger state by calling set level or set tag key.
- connect(d_tr_mode_menu, SIGNAL(whichTrigger(gr::qtgui::trigger_mode)),
- this, SLOT(updateTrigger(gr::qtgui::trigger_mode)));
-
- setTriggerLevel(0);
- connect(d_tr_level_act, SIGNAL(whichTrigger(QString)),
- this, SLOT(setTriggerLevel(QString)));
- connect(this, SIGNAL(signalTriggerLevel(float)),
- this, SLOT(setTriggerLevel(float)));
-
- setTriggerChannel(0);
- connect(d_tr_channel_menu, SIGNAL(whichTrigger(int)),
- this, SLOT(setTriggerChannel(int)));
-
- setTriggerTagKey(std::string(""));
- connect(d_tr_tag_key_act, SIGNAL(whichTrigger(QString)),
- this, SLOT(setTriggerTagKey(QString)));
-
- connect(this, SIGNAL(signalClearMaxData()),
- getPlot(), SLOT(clearMaxData()));
- connect(this, SIGNAL(signalClearMinData()),
- getPlot(), SLOT(clearMinData()));
- connect(this, SIGNAL(signalSetMaxFFTVisible(bool)),
- getPlot(), SLOT(setMaxFFTVisible(bool)));
- connect(this, SIGNAL(signalSetMinFFTVisible(bool)),
- getPlot(), SLOT(setMinFFTVisible(bool)));
-
- Reset();
-
- connect(d_display_plot, SIGNAL(plotPointSelected(const QPointF)),
- this, SLOT(onPlotPointSelected(const QPointF)));
-
- connect(this, SIGNAL(signalReplot()),
- getPlot(), SLOT(replot()));
+ : DisplayForm(nplots, parent)
+{
+ d_int_validator = new QIntValidator(this);
+ d_int_validator->setBottom(0);
+
+ d_layout = new QGridLayout(this);
+ d_display_plot = new FrequencyDisplayPlot(nplots, this);
+ d_layout->addWidget(d_display_plot, 0, 0);
+
+ d_layout->setColumnStretch(0, 1);
+ setLayout(d_layout);
+
+ d_controlpanel = NULL;
+
+ d_num_real_data_points = 1024;
+ d_fftsize = 1024;
+ d_fftavg = 1.0;
+ d_clicked = false;
+ d_clicked_freq = 0;
+
+ d_trig_mode = gr::qtgui::TRIG_MODE_FREE;
+ d_trig_level = 0;
+ d_trig_channel = 0;
+ d_trig_tag_key = "";
+
+ d_sizemenu = new FFTSizeMenu(this);
+ d_avgmenu = new FFTAverageMenu(this);
+ d_winmenu = new FFTWindowMenu(this);
+ d_menu->addMenu(d_sizemenu);
+ d_menu->addMenu(d_avgmenu);
+ d_menu->addMenu(d_winmenu);
+ connect(d_sizemenu, SIGNAL(whichTrigger(int)), this, SLOT(setFFTSize(const int)));
+ connect(
+ d_avgmenu, SIGNAL(whichTrigger(float)), this, SLOT(setFFTAverage(const float)));
+ connect(d_winmenu,
+ SIGNAL(whichTrigger(gr::filter::firdes::win_type)),
+ this,
+ SLOT(setFFTWindowType(const gr::filter::firdes::win_type)));
+
+ PopupMenu* maxymenu = new PopupMenu("Y Max", this);
+ d_menu->addAction(maxymenu);
+ connect(maxymenu, SIGNAL(whichTrigger(QString)), this, SLOT(setYMax(QString)));
+
+ PopupMenu* minymenu = new PopupMenu("Y Min", this);
+ d_menu->addAction(minymenu);
+ connect(minymenu, SIGNAL(whichTrigger(QString)), this, SLOT(setYMin(QString)));
+
+ d_maxhold_act = new QAction("Max Hold", this);
+ d_maxhold_act->setCheckable(true);
+ d_menu->addAction(d_maxhold_act);
+ connect(d_maxhold_act, SIGNAL(triggered(bool)), this, SLOT(notifyMaxHold(bool)));
+ d_minhold_act = new QAction("Min Hold", this);
+ d_minhold_act->setCheckable(true);
+ d_menu->addAction(d_minhold_act);
+ connect(d_minhold_act, SIGNAL(triggered(bool)), this, SLOT(notifyMinHold(bool)));
+
+ // Set up the trigger menu
+ d_triggermenu = new QMenu("Trigger", this);
+ d_tr_mode_menu = new TriggerModeMenu(this);
+ d_tr_level_act = new PopupMenu("Level", this);
+ d_tr_channel_menu = new TriggerChannelMenu(nplots, this);
+ d_tr_tag_key_act = new PopupMenu("Tag Key", this);
+ d_triggermenu->addMenu(d_tr_mode_menu);
+ d_triggermenu->addAction(d_tr_level_act);
+ d_triggermenu->addMenu(d_tr_channel_menu);
+ d_triggermenu->addAction(d_tr_tag_key_act);
+ d_menu->addMenu(d_triggermenu);
+
+ d_controlpanelmenu = new QAction("Control Panel", this);
+ d_controlpanelmenu->setCheckable(true);
+ d_menu->addAction(d_controlpanelmenu);
+ connect(
+ d_controlpanelmenu, SIGNAL(triggered(bool)), this, SLOT(setupControlPanel(bool)));
+
+ setTriggerMode(gr::qtgui::TRIG_MODE_FREE);
+ connect(d_tr_mode_menu,
+ SIGNAL(whichTrigger(gr::qtgui::trigger_mode)),
+ this,
+ SLOT(setTriggerMode(gr::qtgui::trigger_mode)));
+ // updates trigger state by calling set level or set tag key.
+ connect(d_tr_mode_menu,
+ SIGNAL(whichTrigger(gr::qtgui::trigger_mode)),
+ this,
+ SLOT(updateTrigger(gr::qtgui::trigger_mode)));
+
+ setTriggerLevel(0);
+ connect(d_tr_level_act,
+ SIGNAL(whichTrigger(QString)),
+ this,
+ SLOT(setTriggerLevel(QString)));
+ connect(this, SIGNAL(signalTriggerLevel(float)), this, SLOT(setTriggerLevel(float)));
+
+ setTriggerChannel(0);
+ connect(
+ d_tr_channel_menu, SIGNAL(whichTrigger(int)), this, SLOT(setTriggerChannel(int)));
+
+ setTriggerTagKey(std::string(""));
+ connect(d_tr_tag_key_act,
+ SIGNAL(whichTrigger(QString)),
+ this,
+ SLOT(setTriggerTagKey(QString)));
+
+ connect(this, SIGNAL(signalClearMaxData()), getPlot(), SLOT(clearMaxData()));
+ connect(this, SIGNAL(signalClearMinData()), getPlot(), SLOT(clearMinData()));
+ connect(this,
+ SIGNAL(signalSetMaxFFTVisible(bool)),
+ getPlot(),
+ SLOT(setMaxFFTVisible(bool)));
+ connect(this,
+ SIGNAL(signalSetMinFFTVisible(bool)),
+ getPlot(),
+ SLOT(setMinFFTVisible(bool)));
+
+ Reset();
+
+ connect(d_display_plot,
+ SIGNAL(plotPointSelected(const QPointF)),
+ this,
+ SLOT(onPlotPointSelected(const QPointF)));
+
+ connect(this, SIGNAL(signalReplot()), getPlot(), SLOT(replot()));
}
FreqDisplayForm::~FreqDisplayForm()
{
- // Qt deletes children when parent is deleted
+ // Qt deletes children when parent is deleted
- // Don't worry about deleting Display Plots - they are deleted when parents are deleted
- delete d_int_validator;
+ // Don't worry about deleting Display Plots - they are deleted when parents are
+ // deleted
+ delete d_int_validator;
- teardownControlPanel();
+ teardownControlPanel();
}
-void
-FreqDisplayForm::setupControlPanel(bool en)
-{
- if(en) {
- setupControlPanel();
- }
- else {
- teardownControlPanel();
- }
-}
-
-void
-FreqDisplayForm::setupControlPanel()
-{
- if(d_controlpanel)
- delete d_controlpanel;
-
- // Create the control panel layout
- d_controlpanel = new FreqControlPanel(this);
-
- // Connect action items in menu to controlpanel widgets
- connect(d_grid_act, SIGNAL(triggered(bool)),
- d_controlpanel, SLOT(toggleGrid(bool)));
- connect(d_axislabelsmenu, SIGNAL(triggered(bool)),
- d_controlpanel, SLOT(toggleAxisLabels(bool)));
- connect(d_sizemenu, SIGNAL(whichTrigger(int)),
- d_controlpanel, SLOT(toggleFFTSize(int)));
- connect(d_winmenu, SIGNAL(whichTrigger(gr::filter::firdes::win_type)),
- d_controlpanel, SLOT(toggleFFTWindow(gr::filter::firdes::win_type)));
- connect(this, SIGNAL(signalFFTSize(int)),
- d_controlpanel, SLOT(toggleFFTSize(int)));
- connect(this, SIGNAL(signalFFTWindow(gr::filter::firdes::win_type)),
- d_controlpanel, SLOT(toggleFFTWindow(gr::filter::firdes::win_type)));
- connect(d_maxhold_act, SIGNAL(triggered(bool)),
- d_controlpanel, SLOT(toggleMaxHold(bool)));
- connect(d_minhold_act, SIGNAL(triggered(bool)),
- d_controlpanel, SLOT(toggleMinHold(bool)));
- connect(d_avgmenu, SIGNAL(whichTrigger(float)),
- d_controlpanel, SLOT(setFFTAverage(float)));
- connect(d_tr_mode_menu, SIGNAL(whichTrigger(gr::qtgui::trigger_mode)),
- d_controlpanel, SLOT(toggleTriggerMode(gr::qtgui::trigger_mode)));
- connect(this, SIGNAL(signalTriggerMode(gr::qtgui::trigger_mode)),
- d_controlpanel, SLOT(toggleTriggerMode(gr::qtgui::trigger_mode)));
- connect(d_stop_act, SIGNAL(triggered()),
- d_controlpanel, SLOT(toggleStopButton()));
-
- d_layout->addLayout(d_controlpanel, 0, 1);
-
- d_controlpanel->toggleGrid(d_grid_act->isChecked());
- d_controlpanel->toggleAxisLabels(d_axislabelsmenu->isChecked());
- d_controlpanelmenu->setChecked(true);
- d_controlpanel->toggleTriggerMode(getTriggerMode());
- d_controlpanel->toggleMaxHold(d_maxhold_act->isChecked());
- d_controlpanel->toggleMinHold(d_minhold_act->isChecked());
- d_controlpanel->setFFTAverage(getFFTAverage());
-
- emit signalFFTSize(getFFTSize());
- emit signalFFTWindow(getFFTWindowType());
-}
-
-void
-FreqDisplayForm::teardownControlPanel()
-{
- if(d_controlpanel) {
- d_layout->removeItem(d_controlpanel);
- delete d_controlpanel;
- d_controlpanel = NULL;
- }
- d_controlpanelmenu->setChecked(false);
+void FreqDisplayForm::setupControlPanel(bool en)
+{
+ if (en) {
+ setupControlPanel();
+ } else {
+ teardownControlPanel();
+ }
}
-FrequencyDisplayPlot*
-FreqDisplayForm::getPlot()
+void FreqDisplayForm::setupControlPanel()
{
- return ((FrequencyDisplayPlot*)d_display_plot);
+ if (d_controlpanel)
+ delete d_controlpanel;
+
+ // Create the control panel layout
+ d_controlpanel = new FreqControlPanel(this);
+
+ // Connect action items in menu to controlpanel widgets
+ connect(d_grid_act, SIGNAL(triggered(bool)), d_controlpanel, SLOT(toggleGrid(bool)));
+ connect(d_axislabelsmenu,
+ SIGNAL(triggered(bool)),
+ d_controlpanel,
+ SLOT(toggleAxisLabels(bool)));
+ connect(
+ d_sizemenu, SIGNAL(whichTrigger(int)), d_controlpanel, SLOT(toggleFFTSize(int)));
+ connect(d_winmenu,
+ SIGNAL(whichTrigger(gr::filter::firdes::win_type)),
+ d_controlpanel,
+ SLOT(toggleFFTWindow(gr::filter::firdes::win_type)));
+ connect(this, SIGNAL(signalFFTSize(int)), d_controlpanel, SLOT(toggleFFTSize(int)));
+ connect(this,
+ SIGNAL(signalFFTWindow(gr::filter::firdes::win_type)),
+ d_controlpanel,
+ SLOT(toggleFFTWindow(gr::filter::firdes::win_type)));
+ connect(d_maxhold_act,
+ SIGNAL(triggered(bool)),
+ d_controlpanel,
+ SLOT(toggleMaxHold(bool)));
+ connect(d_minhold_act,
+ SIGNAL(triggered(bool)),
+ d_controlpanel,
+ SLOT(toggleMinHold(bool)));
+ connect(d_avgmenu,
+ SIGNAL(whichTrigger(float)),
+ d_controlpanel,
+ SLOT(setFFTAverage(float)));
+ connect(d_tr_mode_menu,
+ SIGNAL(whichTrigger(gr::qtgui::trigger_mode)),
+ d_controlpanel,
+ SLOT(toggleTriggerMode(gr::qtgui::trigger_mode)));
+ connect(this,
+ SIGNAL(signalTriggerMode(gr::qtgui::trigger_mode)),
+ d_controlpanel,
+ SLOT(toggleTriggerMode(gr::qtgui::trigger_mode)));
+ connect(d_stop_act, SIGNAL(triggered()), d_controlpanel, SLOT(toggleStopButton()));
+
+ d_layout->addLayout(d_controlpanel, 0, 1);
+
+ d_controlpanel->toggleGrid(d_grid_act->isChecked());
+ d_controlpanel->toggleAxisLabels(d_axislabelsmenu->isChecked());
+ d_controlpanelmenu->setChecked(true);
+ d_controlpanel->toggleTriggerMode(getTriggerMode());
+ d_controlpanel->toggleMaxHold(d_maxhold_act->isChecked());
+ d_controlpanel->toggleMinHold(d_minhold_act->isChecked());
+ d_controlpanel->setFFTAverage(getFFTAverage());
+
+ emit signalFFTSize(getFFTSize());
+ emit signalFFTWindow(getFFTWindowType());
}
-void
-FreqDisplayForm::newData(const QEvent *updateEvent)
+void FreqDisplayForm::teardownControlPanel()
{
- FreqUpdateEvent *fevent = (FreqUpdateEvent*)updateEvent;
- const std::vector<double*> dataPoints = fevent->getPoints();
- const uint64_t numDataPoints = fevent->getNumDataPoints();
-
- getPlot()->plotNewData(dataPoints, numDataPoints,
- 0, 0, 0, d_update_time);
+ if (d_controlpanel) {
+ d_layout->removeItem(d_controlpanel);
+ delete d_controlpanel;
+ d_controlpanel = NULL;
+ }
+ d_controlpanelmenu->setChecked(false);
}
-void
-FreqDisplayForm::customEvent( QEvent * e)
+FrequencyDisplayPlot* FreqDisplayForm::getPlot()
{
- if(e->type() == FreqUpdateEvent::Type()) {
- newData(e);
- }
- else if(e->type() == SpectrumFrequencyRangeEventType) {
- SetFreqEvent *fevent = (SetFreqEvent*)e;
- setFrequencyRange(fevent->getCenterFrequency(), fevent->getBandwidth());
- }
+ return ((FrequencyDisplayPlot*)d_display_plot);
}
-int
-FreqDisplayForm::getFFTSize() const
+void FreqDisplayForm::newData(const QEvent* updateEvent)
{
- return d_fftsize;
+ FreqUpdateEvent* fevent = (FreqUpdateEvent*)updateEvent;
+ const std::vector<double*> dataPoints = fevent->getPoints();
+ const uint64_t numDataPoints = fevent->getNumDataPoints();
+
+ getPlot()->plotNewData(dataPoints, numDataPoints, 0, 0, 0, d_update_time);
}
-float
-FreqDisplayForm::getFFTAverage() const
+void FreqDisplayForm::customEvent(QEvent* e)
{
- return d_fftavg;
+ if (e->type() == FreqUpdateEvent::Type()) {
+ newData(e);
+ } else if (e->type() == SpectrumFrequencyRangeEventType) {
+ SetFreqEvent* fevent = (SetFreqEvent*)e;
+ setFrequencyRange(fevent->getCenterFrequency(), fevent->getBandwidth());
+ }
}
-gr::filter::firdes::win_type
-FreqDisplayForm::getFFTWindowType() const
+int FreqDisplayForm::getFFTSize() const { return d_fftsize; }
+
+float FreqDisplayForm::getFFTAverage() const { return d_fftavg; }
+
+gr::filter::firdes::win_type FreqDisplayForm::getFFTWindowType() const
{
- return d_fftwintype;
+ return d_fftwintype;
}
-void
-FreqDisplayForm::setSampleRate(const QString &samprate)
+void FreqDisplayForm::setSampleRate(const QString& samprate)
{
- setFrequencyRange(d_center_freq, samprate.toDouble());
+ setFrequencyRange(d_center_freq, samprate.toDouble());
}
-void
-FreqDisplayForm::setFFTSize(const int newsize)
+void FreqDisplayForm::setFFTSize(const int newsize)
{
- d_fftsize = newsize;
- d_sizemenu->getActionFromSize(newsize)->setChecked(true);
+ d_fftsize = newsize;
+ d_sizemenu->getActionFromSize(newsize)->setChecked(true);
- emit signalReplot();
- emit signalFFTSize(newsize);
+ emit signalReplot();
+ emit signalFFTSize(newsize);
}
-void
-FreqDisplayForm::setFFTAverage(const float newavg)
+void FreqDisplayForm::setFFTAverage(const float newavg)
{
- d_fftavg = newavg;
- d_avgmenu->getActionFromAvg(newavg)->setChecked(true);
- emit signalReplot();
- //emit signalFFTAverage(newavg);
+ d_fftavg = newavg;
+ d_avgmenu->getActionFromAvg(newavg)->setChecked(true);
+ emit signalReplot();
+ // emit signalFFTAverage(newavg);
}
-void
-FreqDisplayForm::setFFTWindowType(const gr::filter::firdes::win_type newwin)
+void FreqDisplayForm::setFFTWindowType(const gr::filter::firdes::win_type newwin)
{
- d_fftwintype = newwin;
- d_winmenu->getActionFromWindow(newwin)->setChecked(true);
- emit signalReplot();
- emit signalFFTWindow(newwin);
+ d_fftwintype = newwin;
+ d_winmenu->getActionFromWindow(newwin)->setChecked(true);
+ emit signalReplot();
+ emit signalFFTWindow(newwin);
}
-void
-FreqDisplayForm::setFrequencyRange(const double centerfreq,
- const double bandwidth)
+void FreqDisplayForm::setFrequencyRange(const double centerfreq, const double bandwidth)
{
- std::string strunits[4] = {"Hz", "kHz", "MHz", "GHz"};
- double units10 = floor(log10(bandwidth));
- double units3 = std::max(floor(units10 / 3.0), 0.0);
- d_units = pow(10, (units10-fmod(units10, 3.0)));
- int iunit = static_cast<int>(units3);
+ std::string strunits[4] = { "Hz", "kHz", "MHz", "GHz" };
+ double units10 = floor(log10(bandwidth));
+ double units3 = std::max(floor(units10 / 3.0), 0.0);
+ d_units = pow(10, (units10 - fmod(units10, 3.0)));
+ int iunit = static_cast<int>(units3);
- d_center_freq = centerfreq;
- d_samp_rate = bandwidth;
+ d_center_freq = centerfreq;
+ d_samp_rate = bandwidth;
- getPlot()->setFrequencyRange(centerfreq, bandwidth,
- d_units, strunits[iunit]);
+ getPlot()->setFrequencyRange(centerfreq, bandwidth, d_units, strunits[iunit]);
}
-void
-FreqDisplayForm::setYaxis(double min, double max)
-{
- getPlot()->setYaxis(min, max);
-}
+void FreqDisplayForm::setYaxis(double min, double max) { getPlot()->setYaxis(min, max); }
-void FreqDisplayForm::setYLabel(const std::string &label,
- const std::string &unit)
+void FreqDisplayForm::setYLabel(const std::string& label, const std::string& unit)
{
- getPlot()->setYLabel(label, unit);
+ getPlot()->setYLabel(label, unit);
}
-void
-FreqDisplayForm::setYMax(const QString &m)
+void FreqDisplayForm::setYMax(const QString& m)
{
- double new_max = m.toDouble();
- double cur_ymin = getPlot()->getYMin();
- if(new_max > cur_ymin)
- setYaxis(cur_ymin, new_max);
+ double new_max = m.toDouble();
+ double cur_ymin = getPlot()->getYMin();
+ if (new_max > cur_ymin)
+ setYaxis(cur_ymin, new_max);
}
-void
-FreqDisplayForm::setYMin(const QString &m)
+void FreqDisplayForm::setYMin(const QString& m)
{
- double new_min = m.toDouble();
- double cur_ymax = getPlot()->getYMax();
- if(new_min < cur_ymax)
- setYaxis(new_min, cur_ymax);
+ double new_min = m.toDouble();
+ double cur_ymax = getPlot()->getYMax();
+ if (new_min < cur_ymax)
+ setYaxis(new_min, cur_ymax);
}
-void
-FreqDisplayForm::autoScale(bool en)
+void FreqDisplayForm::autoScale(bool en)
{
- if(en) {
- d_autoscale_state = true;
- }
- else {
- d_autoscale_state = false;
- }
+ if (en) {
+ d_autoscale_state = true;
+ } else {
+ d_autoscale_state = false;
+ }
- d_autoscale_act->setChecked(en);
- getPlot()->setAutoScale(d_autoscale_state);
- emit signalReplot();
+ d_autoscale_act->setChecked(en);
+ getPlot()->setAutoScale(d_autoscale_state);
+ emit signalReplot();
}
-void
-FreqDisplayForm::autoScaleShot()
+void FreqDisplayForm::autoScaleShot()
{
- getPlot()->setAutoScaleShot();
- emit signalReplot();
+ getPlot()->setAutoScaleShot();
+ emit signalReplot();
}
-void
-FreqDisplayForm::setPlotPosHalf(bool half)
+void FreqDisplayForm::setPlotPosHalf(bool half)
{
- getPlot()->setPlotPosHalf(half);
- emit signalReplot();
+ getPlot()->setPlotPosHalf(half);
+ emit signalReplot();
}
-void
-FreqDisplayForm::clearMaxHold()
-{
- getPlot()->clearMaxData();
-}
+void FreqDisplayForm::clearMaxHold() { getPlot()->clearMaxData(); }
-void
-FreqDisplayForm::clearMinHold()
-{
- getPlot()->clearMinData();
-}
+void FreqDisplayForm::clearMinHold() { getPlot()->clearMinData(); }
-void
-FreqDisplayForm::onPlotPointSelected(const QPointF p)
+void FreqDisplayForm::onPlotPointSelected(const QPointF p)
{
- d_clicked = true;
- d_clicked_freq = d_units*p.x();
+ d_clicked = true;
+ d_clicked_freq = d_units * p.x();
}
-bool
-FreqDisplayForm::checkClicked()
+bool FreqDisplayForm::checkClicked()
{
- if(d_clicked) {
- d_clicked = false;
- return true;
- }
- else {
- return false;
- }
+ if (d_clicked) {
+ d_clicked = false;
+ return true;
+ } else {
+ return false;
+ }
}
-float
-FreqDisplayForm::getClickedFreq() const
-{
- return d_clicked_freq;
-}
+float FreqDisplayForm::getClickedFreq() const { return d_clicked_freq; }
/********************************************************************
* TRIGGER METHODS
*******************************************************************/
-void
-FreqDisplayForm::setTriggerMode(gr::qtgui::trigger_mode mode)
+void FreqDisplayForm::setTriggerMode(gr::qtgui::trigger_mode mode)
{
- d_trig_mode = mode;
- d_tr_mode_menu->getAction(mode)->setChecked(true);
+ d_trig_mode = mode;
+ d_tr_mode_menu->getAction(mode)->setChecked(true);
- if((d_trig_mode == gr::qtgui::TRIG_MODE_AUTO) || (d_trig_mode == gr::qtgui::TRIG_MODE_NORM)) {
- getPlot()->attachTriggerLine(true);
- }
- else {
- getPlot()->attachTriggerLine(false);
- }
+ if ((d_trig_mode == gr::qtgui::TRIG_MODE_AUTO) ||
+ (d_trig_mode == gr::qtgui::TRIG_MODE_NORM)) {
+ getPlot()->attachTriggerLine(true);
+ } else {
+ getPlot()->attachTriggerLine(false);
+ }
- emit signalReplot();
- emit signalTriggerMode(mode);
+ emit signalReplot();
+ emit signalTriggerMode(mode);
}
-void
-FreqDisplayForm::updateTrigger(gr::qtgui::trigger_mode mode)
+void FreqDisplayForm::updateTrigger(gr::qtgui::trigger_mode mode)
{
- // If auto or normal mode, popup trigger level box to set
- if((d_trig_mode == gr::qtgui::TRIG_MODE_AUTO) || (d_trig_mode == gr::qtgui::TRIG_MODE_NORM)) {
- d_tr_level_act->activate(QAction::Trigger);
- getPlot()->attachTriggerLine(true);
- }
- else {
- getPlot()->attachTriggerLine(false);
- }
+ // If auto or normal mode, popup trigger level box to set
+ if ((d_trig_mode == gr::qtgui::TRIG_MODE_AUTO) ||
+ (d_trig_mode == gr::qtgui::TRIG_MODE_NORM)) {
+ d_tr_level_act->activate(QAction::Trigger);
+ getPlot()->attachTriggerLine(true);
+ } else {
+ getPlot()->attachTriggerLine(false);
+ }
- // if tag mode, popup tag key box to set
- if((d_trig_tag_key == "") && (d_trig_mode == gr::qtgui::TRIG_MODE_TAG))
- d_tr_tag_key_act->activate(QAction::Trigger);
+ // if tag mode, popup tag key box to set
+ if ((d_trig_tag_key == "") && (d_trig_mode == gr::qtgui::TRIG_MODE_TAG))
+ d_tr_tag_key_act->activate(QAction::Trigger);
- emit signalReplot();
- emit signalTriggerMode(mode);
+ emit signalReplot();
+ emit signalTriggerMode(mode);
}
-gr::qtgui::trigger_mode
-FreqDisplayForm::getTriggerMode() const
-{
- return d_trig_mode;
-}
+gr::qtgui::trigger_mode FreqDisplayForm::getTriggerMode() const { return d_trig_mode; }
-void
-FreqDisplayForm::setTriggerLevel(QString s)
+void FreqDisplayForm::setTriggerLevel(QString s)
{
- d_trig_level = s.toFloat();
+ d_trig_level = s.toFloat();
- if((d_trig_mode == gr::qtgui::TRIG_MODE_AUTO) || (d_trig_mode == gr::qtgui::TRIG_MODE_NORM)) {
- getPlot()->setTriggerLine(d_trig_level);
- }
+ if ((d_trig_mode == gr::qtgui::TRIG_MODE_AUTO) ||
+ (d_trig_mode == gr::qtgui::TRIG_MODE_NORM)) {
+ getPlot()->setTriggerLine(d_trig_level);
+ }
- emit signalReplot();
+ emit signalReplot();
}
-void
-FreqDisplayForm::setTriggerLevel(float level)
+void FreqDisplayForm::setTriggerLevel(float level)
{
- d_trig_level = level;
- d_tr_level_act->setText(QString().setNum(d_trig_level));
-
- if((d_trig_mode == gr::qtgui::TRIG_MODE_AUTO) || (d_trig_mode == gr::qtgui::TRIG_MODE_NORM)) {
- getPlot()->setTriggerLine(d_trig_level);
- }
+ d_trig_level = level;
+ d_tr_level_act->setText(QString().setNum(d_trig_level));
- emit signalReplot();
-}
+ if ((d_trig_mode == gr::qtgui::TRIG_MODE_AUTO) ||
+ (d_trig_mode == gr::qtgui::TRIG_MODE_NORM)) {
+ getPlot()->setTriggerLine(d_trig_level);
+ }
-float
-FreqDisplayForm::getTriggerLevel() const
-{
- return d_trig_level;
+ emit signalReplot();
}
-void
-FreqDisplayForm::setTriggerChannel(int channel)
-{
- d_trig_channel = channel;
- d_tr_channel_menu->getAction(d_trig_channel)->setChecked(true);
- emit signalReplot();
-}
+float FreqDisplayForm::getTriggerLevel() const { return d_trig_level; }
-int
-FreqDisplayForm::getTriggerChannel() const
+void FreqDisplayForm::setTriggerChannel(int channel)
{
- return d_trig_channel;
+ d_trig_channel = channel;
+ d_tr_channel_menu->getAction(d_trig_channel)->setChecked(true);
+ emit signalReplot();
}
-void
-FreqDisplayForm::setTriggerTagKey(QString s)
-{
- d_trig_tag_key = s.toStdString();
-}
+int FreqDisplayForm::getTriggerChannel() const { return d_trig_channel; }
-void
-FreqDisplayForm::setTriggerTagKey(const std::string &key)
-{
- d_trig_tag_key = key;
- d_tr_tag_key_act->setText(QString().fromStdString(d_trig_tag_key));
- emit signalReplot();
-}
+void FreqDisplayForm::setTriggerTagKey(QString s) { d_trig_tag_key = s.toStdString(); }
-std::string
-FreqDisplayForm::getTriggerTagKey() const
+void FreqDisplayForm::setTriggerTagKey(const std::string& key)
{
- return d_trig_tag_key;
+ d_trig_tag_key = key;
+ d_tr_tag_key_act->setText(QString().fromStdString(d_trig_tag_key));
+ emit signalReplot();
}
+std::string FreqDisplayForm::getTriggerTagKey() const { return d_trig_tag_key; }
/********************************************************************
@@ -540,162 +485,138 @@ FreqDisplayForm::getTriggerTagKey() const
*******************************************************************/
-void
-FreqDisplayForm::notifyYAxisPlus()
+void FreqDisplayForm::notifyYAxisPlus()
{
#if QWT_VERSION < 0x060100
- QwtScaleDiv *ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
- double range = ax->upperBound() - ax->lowerBound();
- double step = range/20.0;
- getPlot()->setYaxis(ax->lowerBound()+step, ax->upperBound()+step);
+ QwtScaleDiv* ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
+ double range = ax->upperBound() - ax->lowerBound();
+ double step = range / 20.0;
+ getPlot()->setYaxis(ax->lowerBound() + step, ax->upperBound() + step);
#else
- QwtScaleDiv ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
- double range = ax.upperBound() - ax.lowerBound();
- double step = range/20.0;
- getPlot()->setYaxis(ax.lowerBound()+step, ax.upperBound()+step);
+ QwtScaleDiv ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
+ double range = ax.upperBound() - ax.lowerBound();
+ double step = range / 20.0;
+ getPlot()->setYaxis(ax.lowerBound() + step, ax.upperBound() + step);
#endif
}
-void
-FreqDisplayForm::notifyYAxisMinus()
+void FreqDisplayForm::notifyYAxisMinus()
{
#if QWT_VERSION < 0x060100
- QwtScaleDiv *ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
- double range = ax->upperBound() - ax->lowerBound();
- double step = range/20.0;
- getPlot()->setYaxis(ax->lowerBound()-step, ax->upperBound()-step);
+ QwtScaleDiv* ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
+ double range = ax->upperBound() - ax->lowerBound();
+ double step = range / 20.0;
+ getPlot()->setYaxis(ax->lowerBound() - step, ax->upperBound() - step);
#else
- QwtScaleDiv ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
- double range = ax.upperBound() - ax.lowerBound();
- double step = range/20.0;
- getPlot()->setYaxis(ax.lowerBound()-step, ax.upperBound()-step);
+ QwtScaleDiv ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
+ double range = ax.upperBound() - ax.lowerBound();
+ double step = range / 20.0;
+ getPlot()->setYaxis(ax.lowerBound() - step, ax.upperBound() - step);
#endif
}
-void
-FreqDisplayForm::notifyYRangePlus()
+void FreqDisplayForm::notifyYRangePlus()
{
#if QWT_VERSION < 0x060100
- QwtScaleDiv *ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
- double range = ax->upperBound() - ax->lowerBound();
- double step = range/20.0;
- getPlot()->setYaxis(ax->lowerBound()-step, ax->upperBound()+step);
+ QwtScaleDiv* ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
+ double range = ax->upperBound() - ax->lowerBound();
+ double step = range / 20.0;
+ getPlot()->setYaxis(ax->lowerBound() - step, ax->upperBound() + step);
#else
- QwtScaleDiv ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
- double range = ax.upperBound() - ax.lowerBound();
- double step = range/20.0;
- getPlot()->setYaxis(ax.lowerBound()-step, ax.upperBound()+step);
+ QwtScaleDiv ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
+ double range = ax.upperBound() - ax.lowerBound();
+ double step = range / 20.0;
+ getPlot()->setYaxis(ax.lowerBound() - step, ax.upperBound() + step);
#endif
}
-void
-FreqDisplayForm::notifyYRangeMinus()
+void FreqDisplayForm::notifyYRangeMinus()
{
#if QWT_VERSION < 0x060100
- QwtScaleDiv *ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
- double range = ax->upperBound() - ax->lowerBound();
- double step = range/20.0;
- getPlot()->setYaxis(ax->lowerBound()+step, ax->upperBound()-step);
+ QwtScaleDiv* ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
+ double range = ax->upperBound() - ax->lowerBound();
+ double step = range / 20.0;
+ getPlot()->setYaxis(ax->lowerBound() + step, ax->upperBound() - step);
#else
- QwtScaleDiv ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
- double range = ax.upperBound() - ax.lowerBound();
- double step = range/20.0;
- getPlot()->setYaxis(ax.lowerBound()+step, ax.upperBound()-step);
+ QwtScaleDiv ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
+ double range = ax.upperBound() - ax.lowerBound();
+ double step = range / 20.0;
+ getPlot()->setYaxis(ax.lowerBound() + step, ax.upperBound() - step);
#endif
}
-void
-FreqDisplayForm::notifyFFTSize(const QString &s)
-{
- setFFTSize(s.toInt());
-}
+void FreqDisplayForm::notifyFFTSize(const QString& s) { setFFTSize(s.toInt()); }
-void
-FreqDisplayForm::notifyFFTWindow(const QString &s)
+void FreqDisplayForm::notifyFFTWindow(const QString& s)
{
- if(s == "None") {
- d_fftwintype = gr::filter::firdes::WIN_NONE;
- }
- else if(s == "Hamming") {
- d_fftwintype = gr::filter::firdes::WIN_HAMMING;
- }
- else if(s == "Hann") {
- d_fftwintype = gr::filter::firdes::WIN_HANN;
- }
- else if(s == "Blackman") {
- d_fftwintype = gr::filter::firdes::WIN_BLACKMAN;
- }
- else if(s == "Blackman-harris") {
- d_fftwintype = gr::filter::firdes::WIN_BLACKMAN_hARRIS;
- }
- else if(s == "Rectangular") {
- d_fftwintype = gr::filter::firdes::WIN_RECTANGULAR;
- }
- else if(s == "Kaiser") {
- d_fftwintype = gr::filter::firdes::WIN_KAISER;
- }
- else if(s == "Flat-top") {
- d_fftwintype = gr::filter::firdes::WIN_FLATTOP;
- }
+ if (s == "None") {
+ d_fftwintype = gr::filter::firdes::WIN_NONE;
+ } else if (s == "Hamming") {
+ d_fftwintype = gr::filter::firdes::WIN_HAMMING;
+ } else if (s == "Hann") {
+ d_fftwintype = gr::filter::firdes::WIN_HANN;
+ } else if (s == "Blackman") {
+ d_fftwintype = gr::filter::firdes::WIN_BLACKMAN;
+ } else if (s == "Blackman-harris") {
+ d_fftwintype = gr::filter::firdes::WIN_BLACKMAN_hARRIS;
+ } else if (s == "Rectangular") {
+ d_fftwintype = gr::filter::firdes::WIN_RECTANGULAR;
+ } else if (s == "Kaiser") {
+ d_fftwintype = gr::filter::firdes::WIN_KAISER;
+ } else if (s == "Flat-top") {
+ d_fftwintype = gr::filter::firdes::WIN_FLATTOP;
+ }
- d_winmenu->getActionFromWindow(d_fftwintype)->setChecked(true);
- emit signalReplot();
+ d_winmenu->getActionFromWindow(d_fftwintype)->setChecked(true);
+ emit signalReplot();
}
-void
-FreqDisplayForm::notifyMaxHold(bool en)
+void FreqDisplayForm::notifyMaxHold(bool en)
{
- d_maxhold_act->setChecked(en);
- emit signalClearMaxData();
- emit signalSetMaxFFTVisible(en);
+ d_maxhold_act->setChecked(en);
+ emit signalClearMaxData();
+ emit signalSetMaxFFTVisible(en);
}
-void
-FreqDisplayForm::notifyMinHold(bool en)
+void FreqDisplayForm::notifyMinHold(bool en)
{
- d_minhold_act->setChecked(en);
- emit signalClearMinData();
- emit signalSetMinFFTVisible(en);
+ d_minhold_act->setChecked(en);
+ emit signalClearMinData();
+ emit signalSetMinFFTVisible(en);
}
-void
-FreqDisplayForm::notifyTriggerMode(const QString &mode)
+void FreqDisplayForm::notifyTriggerMode(const QString& mode)
{
- if(mode == "Free") {
- setTriggerMode(gr::qtgui::TRIG_MODE_FREE);
- }
- else if(mode == "Auto") {
- setTriggerMode(gr::qtgui::TRIG_MODE_AUTO);
- }
- else if(mode == "Normal") {
- setTriggerMode(gr::qtgui::TRIG_MODE_NORM);
- }
- else if(mode == "Tag") {
- setTriggerMode(gr::qtgui::TRIG_MODE_TAG);
- updateTrigger(gr::qtgui::TRIG_MODE_TAG);
- }
+ if (mode == "Free") {
+ setTriggerMode(gr::qtgui::TRIG_MODE_FREE);
+ } else if (mode == "Auto") {
+ setTriggerMode(gr::qtgui::TRIG_MODE_AUTO);
+ } else if (mode == "Normal") {
+ setTriggerMode(gr::qtgui::TRIG_MODE_NORM);
+ } else if (mode == "Tag") {
+ setTriggerMode(gr::qtgui::TRIG_MODE_TAG);
+ updateTrigger(gr::qtgui::TRIG_MODE_TAG);
+ }
}
-void
-FreqDisplayForm::notifyTriggerLevelPlus()
+void FreqDisplayForm::notifyTriggerLevelPlus()
{
- emit signalTriggerLevel(getTriggerLevel() + 1);
+ emit signalTriggerLevel(getTriggerLevel() + 1);
}
-void
-FreqDisplayForm::notifyTriggerLevelMinus()
+void FreqDisplayForm::notifyTriggerLevelMinus()
{
- emit signalTriggerLevel(getTriggerLevel() - 1);
+ emit signalTriggerLevel(getTriggerLevel() - 1);
}
diff --git a/gr-qtgui/lib/histogram_sink_f_impl.cc b/gr-qtgui/lib/histogram_sink_f_impl.cc
index 004ff535a6..133725abc0 100644
--- a/gr-qtgui/lib/histogram_sink_f_impl.cc
+++ b/gr-qtgui/lib/histogram_sink_f_impl.cc
@@ -35,479 +35,390 @@
#include <string.h>
namespace gr {
- namespace qtgui {
-
- histogram_sink_f::sptr
- histogram_sink_f::make(int size, int bins,
- double xmin, double xmax,
- const std::string &name,
- int nconnections,
- QWidget *parent)
- {
- return gnuradio::get_initial_sptr
- (new histogram_sink_f_impl(size, bins, xmin, xmax, name,
- nconnections, parent));
- }
-
- histogram_sink_f_impl::histogram_sink_f_impl(int size, int bins,
- double xmin, double xmax,
- const std::string &name,
- int nconnections,
- QWidget *parent)
- : sync_block("histogram_sink_f",
- io_signature::make(0, nconnections, sizeof(float)),
- io_signature::make(0, 0, 0)),
- d_size(size), d_bins(bins), d_xmin(xmin), d_xmax(xmax), d_name(name),
- d_nconnections(nconnections), d_parent(parent)
- {
- // Required now for Qt; argc must be greater than 0 and argv
- // must have at least one valid character. Must be valid through
- // life of the qApplication:
- // http://harmattan-dev.nokia.com/docs/library/html/qt4/qapplication.html
- d_argc = 1;
- d_argv = new char;
- d_argv[0] = '\0';
-
- d_main_gui = NULL;
-
- d_index = 0;
-
- // setup PDU handling input port
- message_port_register_in(pmt::mp("in"));
- set_msg_handler(pmt::mp("in"),
- boost::bind(&histogram_sink_f_impl::handle_pdus, this, _1));
-
- // +1 for the PDU buffer
- for(int i = 0; i < d_nconnections+1; i++) {
- d_residbufs.push_back((double*)volk_malloc(d_size*sizeof(double),
- volk_get_alignment()));
- memset(d_residbufs[i], 0, d_size*sizeof(double));
- }
-
- // Set alignment properties for VOLK
- const int alignment_multiple =
- volk_get_alignment() / sizeof(gr_complex);
- set_alignment(std::max(1,alignment_multiple));
-
- initialize();
- }
-
- histogram_sink_f_impl::~histogram_sink_f_impl()
- {
- if(!d_main_gui->isClosed())
+namespace qtgui {
+
+histogram_sink_f::sptr histogram_sink_f::make(int size,
+ int bins,
+ double xmin,
+ double xmax,
+ const std::string& name,
+ int nconnections,
+ QWidget* parent)
+{
+ return gnuradio::get_initial_sptr(
+ new histogram_sink_f_impl(size, bins, xmin, xmax, name, nconnections, parent));
+}
+
+histogram_sink_f_impl::histogram_sink_f_impl(int size,
+ int bins,
+ double xmin,
+ double xmax,
+ const std::string& name,
+ int nconnections,
+ QWidget* parent)
+ : sync_block("histogram_sink_f",
+ io_signature::make(0, nconnections, sizeof(float)),
+ io_signature::make(0, 0, 0)),
+ d_size(size),
+ d_bins(bins),
+ d_xmin(xmin),
+ d_xmax(xmax),
+ d_name(name),
+ d_nconnections(nconnections),
+ d_parent(parent)
+{
+ // Required now for Qt; argc must be greater than 0 and argv
+ // must have at least one valid character. Must be valid through
+ // life of the qApplication:
+ // http://harmattan-dev.nokia.com/docs/library/html/qt4/qapplication.html
+ d_argc = 1;
+ d_argv = new char;
+ d_argv[0] = '\0';
+
+ d_main_gui = NULL;
+
+ d_index = 0;
+
+ // setup PDU handling input port
+ message_port_register_in(pmt::mp("in"));
+ set_msg_handler(pmt::mp("in"),
+ boost::bind(&histogram_sink_f_impl::handle_pdus, this, _1));
+
+ // +1 for the PDU buffer
+ for (int i = 0; i < d_nconnections + 1; i++) {
+ d_residbufs.push_back(
+ (double*)volk_malloc(d_size * sizeof(double), volk_get_alignment()));
+ memset(d_residbufs[i], 0, d_size * sizeof(double));
+ }
+
+ // Set alignment properties for VOLK
+ const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
+ set_alignment(std::max(1, alignment_multiple));
+
+ initialize();
+}
+
+histogram_sink_f_impl::~histogram_sink_f_impl()
+{
+ if (!d_main_gui->isClosed())
d_main_gui->close();
- // d_main_gui is a qwidget destroyed with its parent
- for(int i = 0; i < d_nconnections+1; i++) {
- volk_free(d_residbufs[i]);
- }
-
- delete d_argv;
+ // d_main_gui is a qwidget destroyed with its parent
+ for (int i = 0; i < d_nconnections + 1; i++) {
+ volk_free(d_residbufs[i]);
}
- bool
- histogram_sink_f_impl::check_topology(int ninputs, int noutputs)
- {
- return ninputs == d_nconnections;
- }
+ delete d_argv;
+}
- void
- histogram_sink_f_impl::initialize()
- {
- if(qApp != NULL) {
- d_qApplication = qApp;
- }
- else {
+bool histogram_sink_f_impl::check_topology(int ninputs, int noutputs)
+{
+ return ninputs == d_nconnections;
+}
+
+void histogram_sink_f_impl::initialize()
+{
+ if (qApp != NULL) {
+ d_qApplication = qApp;
+ } else {
#if QT_VERSION >= 0x040500 && QT_VERSION < 0x050000
std::string style = prefs::singleton()->get_string("qtgui", "style", "raster");
QApplication::setGraphicsSystem(QString(style.c_str()));
#endif
- d_qApplication = new QApplication(d_argc, &d_argv);
- }
+ d_qApplication = new QApplication(d_argc, &d_argv);
+ }
- // If a style sheet is set in the prefs file, enable it here.
- check_set_qss(d_qApplication);
+ // If a style sheet is set in the prefs file, enable it here.
+ check_set_qss(d_qApplication);
- int numplots = (d_nconnections > 0) ? d_nconnections : 1;
- d_main_gui = new HistogramDisplayForm(numplots, d_parent);
- d_main_gui->setNumBins(d_bins);
- d_main_gui->setNPoints(d_size);
- d_main_gui->setXaxis(d_xmin, d_xmax);
+ int numplots = (d_nconnections > 0) ? d_nconnections : 1;
+ d_main_gui = new HistogramDisplayForm(numplots, d_parent);
+ d_main_gui->setNumBins(d_bins);
+ d_main_gui->setNPoints(d_size);
+ d_main_gui->setXaxis(d_xmin, d_xmax);
- if(d_name.size() > 0)
+ if (d_name.size() > 0)
set_title(d_name);
- // initialize update time to 10 times a second
- set_update_time(0.1);
- }
+ // initialize update time to 10 times a second
+ set_update_time(0.1);
+}
- void
- histogram_sink_f_impl::exec_()
- {
- d_qApplication->exec();
- }
+void histogram_sink_f_impl::exec_() { d_qApplication->exec(); }
- QWidget*
- histogram_sink_f_impl::qwidget()
- {
- return d_main_gui;
- }
+QWidget* histogram_sink_f_impl::qwidget() { return d_main_gui; }
#ifdef ENABLE_PYTHON
- PyObject*
- histogram_sink_f_impl::pyqwidget()
- {
- PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui);
- PyObject *retarg = Py_BuildValue("N", w);
- return retarg;
- }
+PyObject* histogram_sink_f_impl::pyqwidget()
+{
+ PyObject* w = PyLong_FromVoidPtr((void*)d_main_gui);
+ PyObject* retarg = Py_BuildValue("N", w);
+ return retarg;
+}
#else
- void *
- histogram_sink_f_impl::pyqwidget()
- {
- return NULL;
- }
+void* histogram_sink_f_impl::pyqwidget() { return NULL; }
#endif
- void
- histogram_sink_f_impl::set_y_axis(double min, double max)
- {
- d_main_gui->setYaxis(min, max);
- }
-
- void
- histogram_sink_f_impl::set_x_axis(double min, double max)
- {
- d_main_gui->setXaxis(min, max);
- }
-
- void
- histogram_sink_f_impl::set_update_time(double t)
- {
- //convert update time to ticks
- gr::high_res_timer_type tps = gr::high_res_timer_tps();
- d_update_time = t * tps;
- d_main_gui->setUpdateTime(t);
- d_last_time = 0;
- }
-
- void
- histogram_sink_f_impl::set_title(const std::string &title)
- {
- d_main_gui->setTitle(title.c_str());
- }
-
- void
- histogram_sink_f_impl::set_line_label(unsigned int which, const std::string &label)
- {
- d_main_gui->setLineLabel(which, label.c_str());
- }
-
- void
- histogram_sink_f_impl::set_line_color(unsigned int which, const std::string &color)
- {
- d_main_gui->setLineColor(which, color.c_str());
- }
-
- void
- histogram_sink_f_impl::set_line_width(unsigned int which, int width)
- {
- d_main_gui->setLineWidth(which, width);
- }
-
- void
- histogram_sink_f_impl::set_line_style(unsigned int which, int style)
- {
- d_main_gui->setLineStyle(which, (Qt::PenStyle)style);
- }
-
- void
- histogram_sink_f_impl::set_line_marker(unsigned int which, int marker)
- {
- d_main_gui->setLineMarker(which, (QwtSymbol::Style)marker);
- }
-
- void
- histogram_sink_f_impl::set_line_alpha(unsigned int which, double alpha)
- {
- d_main_gui->setMarkerAlpha(which, (int)(255.0*alpha));
- }
+void histogram_sink_f_impl::set_y_axis(double min, double max)
+{
+ d_main_gui->setYaxis(min, max);
+}
+
+void histogram_sink_f_impl::set_x_axis(double min, double max)
+{
+ d_main_gui->setXaxis(min, max);
+}
+
+void histogram_sink_f_impl::set_update_time(double t)
+{
+ // convert update time to ticks
+ gr::high_res_timer_type tps = gr::high_res_timer_tps();
+ d_update_time = t * tps;
+ d_main_gui->setUpdateTime(t);
+ d_last_time = 0;
+}
+
+void histogram_sink_f_impl::set_title(const std::string& title)
+{
+ d_main_gui->setTitle(title.c_str());
+}
+
+void histogram_sink_f_impl::set_line_label(unsigned int which, const std::string& label)
+{
+ d_main_gui->setLineLabel(which, label.c_str());
+}
+
+void histogram_sink_f_impl::set_line_color(unsigned int which, const std::string& color)
+{
+ d_main_gui->setLineColor(which, color.c_str());
+}
+
+void histogram_sink_f_impl::set_line_width(unsigned int which, int width)
+{
+ d_main_gui->setLineWidth(which, width);
+}
+
+void histogram_sink_f_impl::set_line_style(unsigned int which, int style)
+{
+ d_main_gui->setLineStyle(which, (Qt::PenStyle)style);
+}
+
+void histogram_sink_f_impl::set_line_marker(unsigned int which, int marker)
+{
+ d_main_gui->setLineMarker(which, (QwtSymbol::Style)marker);
+}
+
+void histogram_sink_f_impl::set_line_alpha(unsigned int which, double alpha)
+{
+ d_main_gui->setMarkerAlpha(which, (int)(255.0 * alpha));
+}
+
+void histogram_sink_f_impl::set_size(int width, int height)
+{
+ d_main_gui->resize(QSize(width, height));
+}
+
+std::string histogram_sink_f_impl::title() { return d_main_gui->title().toStdString(); }
+
+std::string histogram_sink_f_impl::line_label(unsigned int which)
+{
+ return d_main_gui->lineLabel(which).toStdString();
+}
+
+std::string histogram_sink_f_impl::line_color(unsigned int which)
+{
+ return d_main_gui->lineColor(which).toStdString();
+}
+
+int histogram_sink_f_impl::line_width(unsigned int which)
+{
+ return d_main_gui->lineWidth(which);
+}
+
+int histogram_sink_f_impl::line_style(unsigned int which)
+{
+ return d_main_gui->lineStyle(which);
+}
+
+int histogram_sink_f_impl::line_marker(unsigned int which)
+{
+ return d_main_gui->lineMarker(which);
+}
+
+double histogram_sink_f_impl::line_alpha(unsigned int which)
+{
+ return (double)(d_main_gui->markerAlpha(which)) / 255.0;
+}
+
+void histogram_sink_f_impl::set_nsamps(const int newsize)
+{
+ gr::thread::scoped_lock lock(d_setlock);
+
+ if (newsize != d_size) {
+ // Resize residbuf and replace data
+ for (int i = 0; i < d_nconnections + 1; i++) {
+ volk_free(d_residbufs[i]);
+ d_residbufs[i] =
+ (double*)volk_malloc(newsize * sizeof(double), volk_get_alignment());
+
+ memset(d_residbufs[i], 0, newsize * sizeof(double));
+ }
- void
- histogram_sink_f_impl::set_size(int width, int height)
- {
- d_main_gui->resize(QSize(width, height));
- }
+ // Set new size and reset buffer index
+ // (throws away any currently held data, but who cares?)
+ d_size = newsize;
+ d_index = 0;
- std::string
- histogram_sink_f_impl::title()
- {
- return d_main_gui->title().toStdString();
+ d_main_gui->setNPoints(d_size);
}
+}
- std::string
- histogram_sink_f_impl::line_label(unsigned int which)
- {
- return d_main_gui->lineLabel(which).toStdString();
- }
+void histogram_sink_f_impl::set_bins(const int bins)
+{
+ gr::thread::scoped_lock lock(d_setlock);
+ d_bins = bins;
+ d_main_gui->setNumBins(d_bins);
+}
- std::string
- histogram_sink_f_impl::line_color(unsigned int which)
- {
- return d_main_gui->lineColor(which).toStdString();
- }
+int histogram_sink_f_impl::nsamps() const { return d_size; }
- int
- histogram_sink_f_impl::line_width(unsigned int which)
- {
- return d_main_gui->lineWidth(which);
- }
+int histogram_sink_f_impl::bins() const { return d_bins; }
- int
- histogram_sink_f_impl::line_style(unsigned int which)
- {
- return d_main_gui->lineStyle(which);
- }
+void histogram_sink_f_impl::npoints_resize()
+{
+ int newsize = d_main_gui->getNPoints();
+ set_nsamps(newsize);
+}
- int
- histogram_sink_f_impl::line_marker(unsigned int which)
- {
- return d_main_gui->lineMarker(which);
- }
+void histogram_sink_f_impl::enable_menu(bool en) { d_main_gui->enableMenu(en); }
- double
- histogram_sink_f_impl::line_alpha(unsigned int which)
- {
- return (double)(d_main_gui->markerAlpha(which))/255.0;
- }
+void histogram_sink_f_impl::enable_grid(bool en) { d_main_gui->setGrid(en); }
- void
- histogram_sink_f_impl::set_nsamps(const int newsize)
- {
- gr::thread::scoped_lock lock(d_setlock);
+void histogram_sink_f_impl::enable_axis_labels(bool en) { d_main_gui->setAxisLabels(en); }
- if(newsize != d_size) {
- // Resize residbuf and replace data
- for(int i = 0; i < d_nconnections+1; i++) {
- volk_free(d_residbufs[i]);
- d_residbufs[i] = (double*)volk_malloc(newsize*sizeof(double),
- volk_get_alignment());
+void histogram_sink_f_impl::enable_autoscale(bool en) { d_main_gui->autoScale(en); }
- memset(d_residbufs[i], 0, newsize*sizeof(double));
- }
+void histogram_sink_f_impl::enable_semilogx(bool en) { d_main_gui->setSemilogx(en); }
- // Set new size and reset buffer index
- // (throws away any currently held data, but who cares?)
- d_size = newsize;
- d_index = 0;
+void histogram_sink_f_impl::enable_semilogy(bool en) { d_main_gui->setSemilogy(en); }
- d_main_gui->setNPoints(d_size);
- }
- }
+void histogram_sink_f_impl::enable_accumulate(bool en) { d_main_gui->setAccumulate(en); }
- void
- histogram_sink_f_impl::set_bins(const int bins)
- {
- gr::thread::scoped_lock lock(d_setlock);
- d_bins = bins;
- d_main_gui->setNumBins(d_bins);
- }
+void histogram_sink_f_impl::disable_legend() { d_main_gui->disableLegend(); }
- int
- histogram_sink_f_impl::nsamps() const
- {
- return d_size;
- }
+void histogram_sink_f_impl::autoscalex() { d_main_gui->autoScaleX(); }
- int
- histogram_sink_f_impl::bins() const
- {
- return d_bins;
- }
+void histogram_sink_f_impl::reset() { d_index = 0; }
- void
- histogram_sink_f_impl::npoints_resize()
- {
- int newsize = d_main_gui->getNPoints();
- set_nsamps(newsize);
- }
+int histogram_sink_f_impl::work(int noutput_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];
- void
- histogram_sink_f_impl::enable_menu(bool en)
- {
- d_main_gui->enableMenu(en);
- }
+ npoints_resize();
- void
- histogram_sink_f_impl::enable_grid(bool en)
- {
- d_main_gui->setGrid(en);
- }
+ 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;
- void
- histogram_sink_f_impl::enable_axis_labels(bool en)
- {
- d_main_gui->setAxisLabels(en);
- }
+ // If we have enough input for one full plot, do it
+ if (datasize >= resid) {
- void
- histogram_sink_f_impl::enable_autoscale(bool en)
- {
- d_main_gui->autoScale(en);
- }
-
- void
- histogram_sink_f_impl::enable_semilogx(bool en)
- {
- d_main_gui->setSemilogx(en);
- }
-
- void
- histogram_sink_f_impl::enable_semilogy(bool en)
- {
- d_main_gui->setSemilogy(en);
- }
-
- void
- histogram_sink_f_impl::enable_accumulate(bool en)
- {
- d_main_gui->setAccumulate(en);
- }
+ // Fill up residbufs with d_size number of items
+ for (n = 0; n < d_nconnections; n++) {
+ in = (const float*)input_items[idx++];
+ volk_32f_convert_64f_u(&d_residbufs[n][d_index], &in[j], resid);
+ }
- void
- histogram_sink_f_impl::disable_legend()
- {
- d_main_gui->disableLegend();
- }
+ // Update the plot if its time
+ if (gr::high_res_timer_now() - d_last_time > d_update_time) {
+ d_last_time = gr::high_res_timer_now();
+ d_qApplication->postEvent(d_main_gui,
+ new HistogramUpdateEvent(d_residbufs, d_size));
+ }
- void
- histogram_sink_f_impl::autoscalex()
- {
- d_main_gui->autoScaleX();
+ d_index = 0;
+ j += resid;
+ }
+ // Otherwise, copy what we received into the residbufs for next time
+ // because we set the output_multiple, this should never need to be called
+ else {
+ for (n = 0; n < d_nconnections; n++) {
+ in = (const float*)input_items[idx++];
+ volk_32f_convert_64f_u(&d_residbufs[n][d_index], &in[j], datasize);
+ }
+ d_index += datasize;
+ j += datasize;
+ }
}
- void
- histogram_sink_f_impl::reset()
- {
- d_index = 0;
- }
+ return j;
+}
- int
- histogram_sink_f_impl::work(int noutput_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];
-
- npoints_resize();
-
- 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) {
-
- // Fill up residbufs with d_size number of items
- for(n = 0; n < d_nconnections; n++) {
- in = (const float*)input_items[idx++];
- volk_32f_convert_64f_u(&d_residbufs[n][d_index],
- &in[j], resid);
- }
-
- // Update the plot if its time
- if(gr::high_res_timer_now() - d_last_time > d_update_time) {
- d_last_time = gr::high_res_timer_now();
- d_qApplication->postEvent(d_main_gui,
- new HistogramUpdateEvent(d_residbufs, d_size));
- }
-
- d_index = 0;
- j += resid;
- }
- // Otherwise, copy what we received into the residbufs for next time
- // because we set the output_multiple, this should never need to be called
- else {
- for(n = 0; n < d_nconnections; n++) {
- in = (const float*)input_items[idx++];
- volk_32f_convert_64f_u(&d_residbufs[n][d_index],
- &in[j], datasize);
- }
- d_index += datasize;
- j += datasize;
- }
- }
-
- return j;
- }
+void histogram_sink_f_impl::handle_pdus(pmt::pmt_t msg)
+{
+ size_t len;
+ pmt::pmt_t dict, samples;
- void
- histogram_sink_f_impl::handle_pdus(pmt::pmt_t msg)
- {
- size_t len;
- pmt::pmt_t dict, samples;
-
- // Test to make sure this is either a PDU or a uniform vector of
- // samples. Get the samples PMT and the dictionary if it's a PDU.
- // If not, we throw an error and exit.
- if(pmt::is_pair(msg)) {
+ // Test to make sure this is either a PDU or a uniform vector of
+ // samples. Get the samples PMT and the dictionary if it's a PDU.
+ // If not, we throw an error and exit.
+ if (pmt::is_pair(msg)) {
dict = pmt::car(msg);
samples = pmt::cdr(msg);
- }
- else if(pmt::is_uniform_vector(msg)) {
+ } else if (pmt::is_uniform_vector(msg)) {
samples = msg;
- }
- else {
+ } else {
throw std::runtime_error("time_sink_c: message must be either "
"a PDU or a uniform vector of samples.");
- }
+ }
- len = pmt::length(samples);
+ len = pmt::length(samples);
- const float *in;
- if(pmt::is_f32vector(samples)) {
+ const float* in;
+ if (pmt::is_f32vector(samples)) {
in = (const float*)pmt::f32vector_elements(samples, len);
- }
- else {
+ } else {
throw std::runtime_error("histogram_sink_f: unknown data type "
"of samples; must be float.");
- }
+ }
- // Plot if we're past the last update time
- if(gr::high_res_timer_now() - d_last_time > d_update_time) {
+ // Plot if we're past the last update time
+ if (gr::high_res_timer_now() - d_last_time > d_update_time) {
d_last_time = gr::high_res_timer_now();
npoints_resize();
// Clear the histogram
- if(!d_main_gui->getAccumulate()) {
- d_qApplication->postEvent(d_main_gui, new HistogramClearEvent());
+ if (!d_main_gui->getAccumulate()) {
+ d_qApplication->postEvent(d_main_gui, new HistogramClearEvent());
- // Set to accumulate over length of the current PDU
- d_qApplication->postEvent(d_main_gui, new HistogramSetAccumulator(true));
+ // Set to accumulate over length of the current PDU
+ d_qApplication->postEvent(d_main_gui, new HistogramSetAccumulator(true));
}
float nplots_f = static_cast<float>(len) / static_cast<float>(d_size);
int nplots = static_cast<int>(ceilf(nplots_f));
int idx = 0;
- for(int n = 0; n < nplots; n++) {
- int size = std::min(d_size, (int)(len - idx));
- volk_32f_convert_64f_u(d_residbufs[d_nconnections], &in[idx], size);
+ for (int n = 0; n < nplots; n++) {
+ int size = std::min(d_size, (int)(len - idx));
+ volk_32f_convert_64f_u(d_residbufs[d_nconnections], &in[idx], size);
- d_qApplication->postEvent(d_main_gui,
- new HistogramUpdateEvent(d_residbufs, size));
+ d_qApplication->postEvent(d_main_gui,
+ new HistogramUpdateEvent(d_residbufs, size));
- idx += size;
+ idx += size;
}
- if(!d_main_gui->getAccumulate()) {
- // Turn accumulation off
- d_qApplication->postEvent(d_main_gui, new HistogramSetAccumulator(false));
+ if (!d_main_gui->getAccumulate()) {
+ // Turn accumulation off
+ d_qApplication->postEvent(d_main_gui, new HistogramSetAccumulator(false));
}
- }
}
+}
- } /* namespace qtgui */
+} /* namespace qtgui */
} /* namespace gr */
diff --git a/gr-qtgui/lib/histogram_sink_f_impl.h b/gr-qtgui/lib/histogram_sink_f_impl.h
index 342167714c..a80cb3855c 100644
--- a/gr-qtgui/lib/histogram_sink_f_impl.h
+++ b/gr-qtgui/lib/histogram_sink_f_impl.h
@@ -29,96 +29,98 @@
#include <gnuradio/high_res_timer.h>
namespace gr {
- namespace qtgui {
+namespace qtgui {
- class QTGUI_API histogram_sink_f_impl : public histogram_sink_f
- {
- private:
- void initialize();
+class QTGUI_API histogram_sink_f_impl : public histogram_sink_f
+{
+private:
+ void initialize();
- int d_size;
- int d_bins;
- double d_xmin, d_xmax;
- std::string d_name;
- int d_nconnections;
+ int d_size;
+ int d_bins;
+ double d_xmin, d_xmax;
+ std::string d_name;
+ int d_nconnections;
- int d_index;
- std::vector<double*> d_residbufs;
+ int d_index;
+ std::vector<double*> d_residbufs;
- int d_argc;
- char *d_argv;
- QWidget *d_parent;
- HistogramDisplayForm *d_main_gui;
+ int d_argc;
+ char* d_argv;
+ QWidget* d_parent;
+ HistogramDisplayForm* d_main_gui;
- gr::high_res_timer_type d_update_time;
- gr::high_res_timer_type d_last_time;
+ gr::high_res_timer_type d_update_time;
+ gr::high_res_timer_type d_last_time;
- void npoints_resize();
+ void npoints_resize();
- // Handles message input port for displaying PDU samples.
- void handle_pdus(pmt::pmt_t msg);
+ // Handles message input port for displaying PDU samples.
+ void handle_pdus(pmt::pmt_t msg);
- public:
- histogram_sink_f_impl(int size, int bins,
- double xmin, double xmax,
- const std::string &name,
- int nconnections,
- QWidget *parent=NULL);
- ~histogram_sink_f_impl();
+public:
+ histogram_sink_f_impl(int size,
+ int bins,
+ double xmin,
+ double xmax,
+ const std::string& name,
+ int nconnections,
+ QWidget* parent = NULL);
+ ~histogram_sink_f_impl();
- bool check_topology(int ninputs, int noutputs);
+ bool check_topology(int ninputs, int noutputs);
- void exec_();
- QWidget* qwidget();
+ void exec_();
+ QWidget* qwidget();
#ifdef ENABLE_PYTHON
- PyObject* pyqwidget();
+ PyObject* pyqwidget();
#else
- void* pyqwidget();
+ void* pyqwidget();
#endif
- void set_y_axis(double min, double max);
- void set_x_axis(double min, double max);
- void set_update_time(double t);
- void set_title(const std::string &title);
- void set_line_label(unsigned int which, const std::string &label);
- void set_line_color(unsigned int which, const std::string &color);
- void set_line_width(unsigned int which, int width);
- void set_line_style(unsigned int which, int style);
- void set_line_marker(unsigned int which, int marker);
- void set_line_alpha(unsigned int which, double alpha);
- void set_nsamps(const int newsize);
- void set_bins(const int bins);
- void enable_axis_labels(bool en);
-
- std::string title();
- std::string line_label(unsigned int which);
- std::string line_color(unsigned int which);
- int line_width(unsigned int which);
- int line_style(unsigned int which);
- int line_marker(unsigned int which);
- double line_alpha(unsigned int which);
-
- void set_size(int width, int height);
-
- void enable_menu(bool en);
- void enable_grid(bool en);
- void enable_autoscale(bool en);
- void enable_semilogx(bool en);
- void enable_semilogy(bool en);
- void enable_accumulate(bool en);
- void disable_legend();
- void autoscalex();
- int nsamps() const;
- int bins() const;
- void reset();
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace qtgui */
+ void set_y_axis(double min, double max);
+ void set_x_axis(double min, double max);
+ void set_update_time(double t);
+ void set_title(const std::string& title);
+ void set_line_label(unsigned int which, const std::string& label);
+ void set_line_color(unsigned int which, const std::string& color);
+ void set_line_width(unsigned int which, int width);
+ void set_line_style(unsigned int which, int style);
+ void set_line_marker(unsigned int which, int marker);
+ void set_line_alpha(unsigned int which, double alpha);
+ void set_nsamps(const int newsize);
+ void set_bins(const int bins);
+ void enable_axis_labels(bool en);
+
+ std::string title();
+ std::string line_label(unsigned int which);
+ std::string line_color(unsigned int which);
+ int line_width(unsigned int which);
+ int line_style(unsigned int which);
+ int line_marker(unsigned int which);
+ double line_alpha(unsigned int which);
+
+ void set_size(int width, int height);
+
+ void enable_menu(bool en);
+ void enable_grid(bool en);
+ void enable_autoscale(bool en);
+ void enable_semilogx(bool en);
+ void enable_semilogy(bool en);
+ void enable_accumulate(bool en);
+ void disable_legend();
+ void autoscalex();
+ int nsamps() const;
+ int bins() const;
+ void reset();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
+
+} /* namespace qtgui */
} /* namespace gr */
#endif /* INCLUDED_QTGUI_HISTOGRAM_SINK_F_IMPL_H */
diff --git a/gr-qtgui/lib/histogramdisplayform.cc b/gr-qtgui/lib/histogramdisplayform.cc
index 905a8635b0..35adce39a6 100644
--- a/gr-qtgui/lib/histogramdisplayform.cc
+++ b/gr-qtgui/lib/histogramdisplayform.cc
@@ -28,193 +28,168 @@
#include <iostream>
HistogramDisplayForm::HistogramDisplayForm(int nplots, QWidget* parent)
- : DisplayForm(nplots, parent)
-{
- d_semilogx = false;
- d_semilogy = false;
-
- d_int_validator = new QIntValidator(this);
- d_int_validator->setBottom(0);
-
- d_layout = new QGridLayout(this);
- d_display_plot = new HistogramDisplayPlot(nplots, this);
- d_layout->addWidget(d_display_plot, 0, 0);
- setLayout(d_layout);
-
- d_nptsmenu = new NPointsMenu(this);
- d_menu->addAction(d_nptsmenu);
- connect(d_nptsmenu, SIGNAL(whichTrigger(int)),
- this, SLOT(setNPoints(const int)));
-
- d_nbinsmenu = new NPointsMenu(this);
- d_nbinsmenu->setText("Number of Bins");
- d_menu->addAction(d_nbinsmenu);
- connect(d_nbinsmenu, SIGNAL(whichTrigger(int)),
- this, SLOT(setNumBins(const int)));
-
- d_accum_act = new QAction("Accumulate", this);
- d_accum_act->setCheckable(true);
- d_menu->addAction(d_accum_act);
- connect(d_accum_act, SIGNAL(triggered(bool)),
- this, SLOT(setAccumulate(bool)));
-
- d_menu->removeAction(d_autoscale_act);
- d_autoscale_act->setText(tr("Auto Scale Y"));
- d_autoscale_act->setStatusTip(tr("Autoscale Y-axis"));
- d_autoscale_act->setCheckable(true);
- d_autoscale_act->setChecked(true);
- d_autoscale_state = true;
- d_menu->addAction(d_autoscale_act);
-
- d_autoscalex_act = new QAction("Auto Scale X", this);
- d_autoscalex_act->setStatusTip(tr("Update X-axis scale"));
- d_autoscalex_act->setCheckable(false);
- connect(d_autoscalex_act, SIGNAL(changed()),
- this, SLOT(autoScaleX()));
- d_autoscalex_state = false;
- d_menu->addAction(d_autoscalex_act);
-
-
-// d_semilogxmenu = new QAction("Semilog X", this);
-// d_semilogxmenu->setCheckable(true);
-// d_menu->addAction(d_semilogxmenu);
-// connect(d_semilogxmenu, SIGNAL(triggered(bool)),
-// this, SLOT(setSemilogx(bool)));
-//
-// d_semilogymenu = new QAction("Semilog Y", this);
-// d_semilogymenu->setCheckable(true);
-// d_menu->addAction(d_semilogymenu);
-// connect(d_semilogymenu, SIGNAL(triggered(bool)),
-// this, SLOT(setSemilogy(bool)));
-
- Reset();
-
- connect(d_display_plot, SIGNAL(plotPointSelected(const QPointF)),
- this, SLOT(onPlotPointSelected(const QPointF)));
+ : DisplayForm(nplots, parent)
+{
+ d_semilogx = false;
+ d_semilogy = false;
+
+ d_int_validator = new QIntValidator(this);
+ d_int_validator->setBottom(0);
+
+ d_layout = new QGridLayout(this);
+ d_display_plot = new HistogramDisplayPlot(nplots, this);
+ d_layout->addWidget(d_display_plot, 0, 0);
+ setLayout(d_layout);
+
+ d_nptsmenu = new NPointsMenu(this);
+ d_menu->addAction(d_nptsmenu);
+ connect(d_nptsmenu, SIGNAL(whichTrigger(int)), this, SLOT(setNPoints(const int)));
+
+ d_nbinsmenu = new NPointsMenu(this);
+ d_nbinsmenu->setText("Number of Bins");
+ d_menu->addAction(d_nbinsmenu);
+ connect(d_nbinsmenu, SIGNAL(whichTrigger(int)), this, SLOT(setNumBins(const int)));
+
+ d_accum_act = new QAction("Accumulate", this);
+ d_accum_act->setCheckable(true);
+ d_menu->addAction(d_accum_act);
+ connect(d_accum_act, SIGNAL(triggered(bool)), this, SLOT(setAccumulate(bool)));
+
+ d_menu->removeAction(d_autoscale_act);
+ d_autoscale_act->setText(tr("Auto Scale Y"));
+ d_autoscale_act->setStatusTip(tr("Autoscale Y-axis"));
+ d_autoscale_act->setCheckable(true);
+ d_autoscale_act->setChecked(true);
+ d_autoscale_state = true;
+ d_menu->addAction(d_autoscale_act);
+
+ d_autoscalex_act = new QAction("Auto Scale X", this);
+ d_autoscalex_act->setStatusTip(tr("Update X-axis scale"));
+ d_autoscalex_act->setCheckable(false);
+ connect(d_autoscalex_act, SIGNAL(changed()), this, SLOT(autoScaleX()));
+ d_autoscalex_state = false;
+ d_menu->addAction(d_autoscalex_act);
+
+
+ // d_semilogxmenu = new QAction("Semilog X", this);
+ // d_semilogxmenu->setCheckable(true);
+ // d_menu->addAction(d_semilogxmenu);
+ // connect(d_semilogxmenu, SIGNAL(triggered(bool)),
+ // this, SLOT(setSemilogx(bool)));
+ //
+ // d_semilogymenu = new QAction("Semilog Y", this);
+ // d_semilogymenu->setCheckable(true);
+ // d_menu->addAction(d_semilogymenu);
+ // connect(d_semilogymenu, SIGNAL(triggered(bool)),
+ // this, SLOT(setSemilogy(bool)));
+
+ Reset();
+
+ connect(d_display_plot,
+ SIGNAL(plotPointSelected(const QPointF)),
+ this,
+ SLOT(onPlotPointSelected(const QPointF)));
}
HistogramDisplayForm::~HistogramDisplayForm()
{
- // Qt deletes children when parent is deleted
+ // Qt deletes children when parent is deleted
- // Don't worry about deleting Display Plots - they are deleted when parents are deleted
- delete d_int_validator;
+ // Don't worry about deleting Display Plots - they are deleted when parents are
+ // deleted
+ delete d_int_validator;
}
-HistogramDisplayPlot*
-HistogramDisplayForm::getPlot()
+HistogramDisplayPlot* HistogramDisplayForm::getPlot()
{
- return ((HistogramDisplayPlot*)d_display_plot);
+ return ((HistogramDisplayPlot*)d_display_plot);
}
-void
-HistogramDisplayForm::newData(const QEvent* updateEvent)
+void HistogramDisplayForm::newData(const QEvent* updateEvent)
{
- HistogramUpdateEvent *hevent = (HistogramUpdateEvent*)updateEvent;
- const std::vector<double*> dataPoints = hevent->getDataPoints();
- const uint64_t numDataPoints = hevent->getNumDataPoints();
+ HistogramUpdateEvent* hevent = (HistogramUpdateEvent*)updateEvent;
+ const std::vector<double*> dataPoints = hevent->getDataPoints();
+ const uint64_t numDataPoints = hevent->getNumDataPoints();
- getPlot()->plotNewData(dataPoints,
- numDataPoints,
- d_update_time);
+ getPlot()->plotNewData(dataPoints, numDataPoints, d_update_time);
}
-void
-HistogramDisplayForm::customEvent(QEvent * e)
+void HistogramDisplayForm::customEvent(QEvent* e)
{
- if(e->type() == HistogramUpdateEvent::Type()) {
- newData(e);
- }
- else if(e->type() == HistogramSetAccumulator::Type()) {
- bool en = ((HistogramSetAccumulator*)e)->getAccumulator();
- setAccumulate(en);
- }
- else if(e->type() == HistogramClearEvent::Type()) {
- getPlot()->clear();
- }
+ if (e->type() == HistogramUpdateEvent::Type()) {
+ newData(e);
+ } else if (e->type() == HistogramSetAccumulator::Type()) {
+ bool en = ((HistogramSetAccumulator*)e)->getAccumulator();
+ setAccumulate(en);
+ } else if (e->type() == HistogramClearEvent::Type()) {
+ getPlot()->clear();
+ }
}
-void
-HistogramDisplayForm::setYaxis(double min, double max)
+void HistogramDisplayForm::setYaxis(double min, double max)
{
- getPlot()->setYaxis(min, max);
+ getPlot()->setYaxis(min, max);
}
-void
-HistogramDisplayForm::setXaxis(double min, double max)
+void HistogramDisplayForm::setXaxis(double min, double max)
{
- getPlot()->setXaxis(min, max);
+ getPlot()->setXaxis(min, max);
}
-int
-HistogramDisplayForm::getNPoints() const
-{
- return d_npoints;
-}
+int HistogramDisplayForm::getNPoints() const { return d_npoints; }
-void
-HistogramDisplayForm::setNPoints(const int npoints)
+void HistogramDisplayForm::setNPoints(const int npoints)
{
- d_npoints = npoints;
- d_nptsmenu->setDiagText(npoints);
+ d_npoints = npoints;
+ d_nptsmenu->setDiagText(npoints);
}
-void
-HistogramDisplayForm::autoScale(bool en)
+void HistogramDisplayForm::autoScale(bool en)
{
- d_autoscale_state = en;
- d_autoscale_act->setChecked(en);
- getPlot()->setAutoScale(d_autoscale_state);
- getPlot()->replot();
+ d_autoscale_state = en;
+ d_autoscale_act->setChecked(en);
+ getPlot()->setAutoScale(d_autoscale_state);
+ getPlot()->replot();
}
-void
-HistogramDisplayForm::autoScaleX()
+void HistogramDisplayForm::autoScaleX()
{
- getPlot()->setAutoScaleX();
- getPlot()->replot();
+ getPlot()->setAutoScaleX();
+ getPlot()->replot();
}
-void
-HistogramDisplayForm::setSemilogx(bool en)
+void HistogramDisplayForm::setSemilogx(bool en)
{
- d_semilogx = en;
- d_semilogxmenu->setChecked(en);
- getPlot()->setSemilogx(d_semilogx);
- getPlot()->replot();
+ d_semilogx = en;
+ d_semilogxmenu->setChecked(en);
+ getPlot()->setSemilogx(d_semilogx);
+ getPlot()->replot();
}
-void
-HistogramDisplayForm::setSemilogy(bool en)
+void HistogramDisplayForm::setSemilogy(bool en)
{
- d_semilogy = en;
- d_semilogymenu->setChecked(en);
- getPlot()->setSemilogy(d_semilogy);
- getPlot()->replot();
+ d_semilogy = en;
+ d_semilogymenu->setChecked(en);
+ getPlot()->setSemilogy(d_semilogy);
+ getPlot()->replot();
}
-void
-HistogramDisplayForm::setNumBins(const int bins)
+void HistogramDisplayForm::setNumBins(const int bins)
{
- getPlot()->setNumBins(bins);
- getPlot()->replot();
- d_nbinsmenu->setDiagText(bins);
+ getPlot()->setNumBins(bins);
+ getPlot()->replot();
+ d_nbinsmenu->setDiagText(bins);
}
-void
-HistogramDisplayForm::setAccumulate(bool en)
+void HistogramDisplayForm::setAccumulate(bool en)
{
- // Turn on y-axis autoscaling when turning accumulate on.
- if(en) {
- autoScale(true);
- }
- d_accum_act->setChecked(en);
- getPlot()->setAccumulate(en);
- getPlot()->replot();
+ // Turn on y-axis autoscaling when turning accumulate on.
+ if (en) {
+ autoScale(true);
+ }
+ d_accum_act->setChecked(en);
+ getPlot()->setAccumulate(en);
+ getPlot()->replot();
}
-bool
-HistogramDisplayForm::getAccumulate()
-{
- return getPlot()->getAccumulate();
-}
+bool HistogramDisplayForm::getAccumulate() { return getPlot()->getAccumulate(); }
diff --git a/gr-qtgui/lib/number_sink_impl.cc b/gr-qtgui/lib/number_sink_impl.cc
index 9eb52a159a..05c8355554 100644
--- a/gr-qtgui/lib/number_sink_impl.cc
+++ b/gr-qtgui/lib/number_sink_impl.cc
@@ -40,363 +40,297 @@
#include <float.h>
namespace std {
- using ::_finite;
+using ::_finite;
}
#endif
namespace gr {
- namespace qtgui {
-
- number_sink::sptr
- number_sink::make(size_t itemsize,
- float average,
- graph_t graph_type,
- int nconnections,
- QWidget *parent)
- {
- return gnuradio::get_initial_sptr
- (new number_sink_impl(itemsize, average,
- graph_type, nconnections, parent));
- }
+namespace qtgui {
+
+number_sink::sptr number_sink::make(
+ size_t itemsize, float average, graph_t graph_type, int nconnections, QWidget* parent)
+{
+ return gnuradio::get_initial_sptr(
+ new number_sink_impl(itemsize, average, graph_type, nconnections, parent));
+}
- number_sink_impl::number_sink_impl(size_t itemsize,
- float average,
- graph_t graph_type,
- int nconnections,
- QWidget *parent)
- : sync_block("number_sink",
- io_signature::make(nconnections, nconnections, itemsize),
- io_signature::make(0, 0, 0)),
- d_itemsize(itemsize), d_average(average),
- d_type(graph_type), d_nconnections(nconnections), d_parent(parent),
- d_avg_value(nconnections), d_iir(nconnections)
- {
- for(int n = 0; n < d_nconnections; n++) {
+number_sink_impl::number_sink_impl(
+ size_t itemsize, float average, graph_t graph_type, int nconnections, QWidget* parent)
+ : sync_block("number_sink",
+ io_signature::make(nconnections, nconnections, itemsize),
+ io_signature::make(0, 0, 0)),
+ d_itemsize(itemsize),
+ d_average(average),
+ d_type(graph_type),
+ d_nconnections(nconnections),
+ d_parent(parent),
+ d_avg_value(nconnections),
+ d_iir(nconnections)
+{
+ for (int n = 0; n < d_nconnections; n++) {
d_avg_value[n] = 0;
d_iir[n].set_taps(d_average);
- }
+ }
- // Required now for Qt; argc must be greater than 0 and argv
- // must have at least one valid character. Must be valid through
- // life of the qApplication:
- // http://harmattan-dev.nokia.com/docs/library/html/qt4/qapplication.html
- d_argc = 1;
- d_argv = new char;
- d_argv[0] = '\0';
+ // Required now for Qt; argc must be greater than 0 and argv
+ // must have at least one valid character. Must be valid through
+ // life of the qApplication:
+ // http://harmattan-dev.nokia.com/docs/library/html/qt4/qapplication.html
+ d_argc = 1;
+ d_argv = new char;
+ d_argv[0] = '\0';
- d_main_gui = NULL;
+ d_main_gui = NULL;
- // Set alignment properties for VOLK
- const int alignment_multiple =
- volk_get_alignment() / d_itemsize;
- set_alignment(std::max(1,alignment_multiple));
+ // Set alignment properties for VOLK
+ const int alignment_multiple = volk_get_alignment() / d_itemsize;
+ set_alignment(std::max(1, alignment_multiple));
- initialize();
- }
+ initialize();
+}
- number_sink_impl::~number_sink_impl()
- {
- //if(!d_main_gui->isClosed())
- // d_main_gui->close();
+number_sink_impl::~number_sink_impl()
+{
+ // if(!d_main_gui->isClosed())
+ // d_main_gui->close();
- delete d_argv;
- }
+ delete d_argv;
+}
- bool
- number_sink_impl::check_topology(int ninputs, int noutputs)
- {
- return ninputs == d_nconnections;
- }
+bool number_sink_impl::check_topology(int ninputs, int noutputs)
+{
+ return ninputs == d_nconnections;
+}
- void
- number_sink_impl::initialize()
- {
- if(qApp != NULL) {
- d_qApplication = qApp;
- }
- else {
- d_qApplication = new QApplication(d_argc, &d_argv);
- }
+void number_sink_impl::initialize()
+{
+ if (qApp != NULL) {
+ d_qApplication = qApp;
+ } else {
+ d_qApplication = new QApplication(d_argc, &d_argv);
+ }
- d_main_gui = new NumberDisplayForm(d_nconnections, d_type, d_parent);
+ d_main_gui = new NumberDisplayForm(d_nconnections, d_type, d_parent);
- // initialize update time to 10 times a second
- set_update_time(0.1);
- }
+ // initialize update time to 10 times a second
+ set_update_time(0.1);
+}
- void
- number_sink_impl::exec_()
- {
- d_qApplication->exec();
- }
+void number_sink_impl::exec_() { d_qApplication->exec(); }
- QWidget*
- number_sink_impl::qwidget()
- {
- return d_main_gui;
- }
+QWidget* number_sink_impl::qwidget() { return d_main_gui; }
#ifdef ENABLE_PYTHON
- PyObject*
- number_sink_impl::pyqwidget()
- {
- PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui);
- PyObject *retarg = Py_BuildValue("N", w);
- return retarg;
- }
+PyObject* number_sink_impl::pyqwidget()
+{
+ PyObject* w = PyLong_FromVoidPtr((void*)d_main_gui);
+ PyObject* retarg = Py_BuildValue("N", w);
+ return retarg;
+}
#else
- void *
- number_sink_impl::pyqwidget()
- {
- return NULL;
- }
+void* number_sink_impl::pyqwidget() { return NULL; }
#endif
- void
- number_sink_impl::set_update_time(double t)
- {
- //convert update time to ticks
- gr::high_res_timer_type tps = gr::high_res_timer_tps();
- d_main_gui->setUpdateTime(t);
- d_update_time = t * tps;
- d_last_time = 0;
- }
+void number_sink_impl::set_update_time(double t)
+{
+ // convert update time to ticks
+ gr::high_res_timer_type tps = gr::high_res_timer_tps();
+ d_main_gui->setUpdateTime(t);
+ d_update_time = t * tps;
+ d_last_time = 0;
+}
- void
- number_sink_impl::set_average(const float avg)
- {
- d_average = avg;
- for(int n = 0; n < d_nconnections; n++) {
+void number_sink_impl::set_average(const float avg)
+{
+ d_average = avg;
+ for (int n = 0; n < d_nconnections; n++) {
d_avg_value[n] = 0;
d_iir[n].set_taps(d_average);
- }
}
+}
- void
- number_sink_impl::set_graph_type(const graph_t type)
- {
- d_main_gui->setGraphType(type);
- }
+void number_sink_impl::set_graph_type(const graph_t type)
+{
+ d_main_gui->setGraphType(type);
+}
- void
- number_sink_impl::set_color(unsigned int which,
- const std::string &min,
- const std::string &max)
- {
- d_main_gui->setColor(which,
- QColor(min.c_str()),
- QColor(max.c_str()));
- }
+void number_sink_impl::set_color(unsigned int which,
+ const std::string& min,
+ const std::string& max)
+{
+ d_main_gui->setColor(which, QColor(min.c_str()), QColor(max.c_str()));
+}
- void
- number_sink_impl::set_color(unsigned int which, int min, int max)
- {
- d_main_gui->setColor(which, QColor(min), QColor(max));
- }
+void number_sink_impl::set_color(unsigned int which, int min, int max)
+{
+ d_main_gui->setColor(which, QColor(min), QColor(max));
+}
- void
- number_sink_impl::set_label(unsigned int which, const std::string &label)
- {
- d_main_gui->setLabel(which, label);
- }
+void number_sink_impl::set_label(unsigned int which, const std::string& label)
+{
+ d_main_gui->setLabel(which, label);
+}
- void
- number_sink_impl::set_min(unsigned int which, float min)
- {
- d_main_gui->setScaleMin(which, min);
- }
+void number_sink_impl::set_min(unsigned int which, float min)
+{
+ d_main_gui->setScaleMin(which, min);
+}
- void
- number_sink_impl::set_max(unsigned int which, float max)
- {
- d_main_gui->setScaleMax(which, max);
- }
+void number_sink_impl::set_max(unsigned int which, float max)
+{
+ d_main_gui->setScaleMax(which, max);
+}
- void
- number_sink_impl::set_title(const std::string &title)
- {
- d_main_gui->setTitle(title);
- }
+void number_sink_impl::set_title(const std::string& title)
+{
+ d_main_gui->setTitle(title);
+}
- void
- number_sink_impl::set_unit(unsigned int which, const std::string &unit)
- {
- d_main_gui->setUnit(which, unit);
- }
+void number_sink_impl::set_unit(unsigned int which, const std::string& unit)
+{
+ d_main_gui->setUnit(which, unit);
+}
- void
- number_sink_impl::set_factor(unsigned int which, float factor)
- {
- d_main_gui->setFactor(which, factor);
- }
+void number_sink_impl::set_factor(unsigned int which, float factor)
+{
+ d_main_gui->setFactor(which, factor);
+}
- float
- number_sink_impl::average() const
- {
- return d_average;
- }
+float number_sink_impl::average() const { return d_average; }
- graph_t
- number_sink_impl::graph_type() const
- {
- return d_main_gui->graphType();
- }
+graph_t number_sink_impl::graph_type() const { return d_main_gui->graphType(); }
- std::string
- number_sink_impl::color_min(unsigned int which) const
- {
- return d_main_gui->colorMin(which).name().toStdString();
- }
+std::string number_sink_impl::color_min(unsigned int which) const
+{
+ return d_main_gui->colorMin(which).name().toStdString();
+}
- std::string
- number_sink_impl::color_max(unsigned int which) const
- {
- return d_main_gui->colorMax(which).name().toStdString();
- }
+std::string number_sink_impl::color_max(unsigned int which) const
+{
+ return d_main_gui->colorMax(which).name().toStdString();
+}
- std::string
- number_sink_impl::label(unsigned int which) const
- {
- return d_main_gui->label(which);
- }
+std::string number_sink_impl::label(unsigned int which) const
+{
+ return d_main_gui->label(which);
+}
- float
- number_sink_impl::min(unsigned int which) const
- {
- return d_main_gui->scaleMin(which);
- }
+float number_sink_impl::min(unsigned int which) const
+{
+ return d_main_gui->scaleMin(which);
+}
- float
- number_sink_impl::max(unsigned int which) const
- {
- return d_main_gui->scaleMax(which);
- }
+float number_sink_impl::max(unsigned int which) const
+{
+ return d_main_gui->scaleMax(which);
+}
- std::string
- number_sink_impl::title() const
- {
- return d_main_gui->title();
- }
+std::string number_sink_impl::title() const { return d_main_gui->title(); }
- std::string
- number_sink_impl::unit(unsigned int which) const
- {
- return d_main_gui->unit(which);
- }
+std::string number_sink_impl::unit(unsigned int which) const
+{
+ return d_main_gui->unit(which);
+}
- float
- number_sink_impl::factor(unsigned int which) const
- {
- return d_main_gui->factor(which);
- }
+float number_sink_impl::factor(unsigned int which) const
+{
+ return d_main_gui->factor(which);
+}
- void
- number_sink_impl::enable_menu(bool en)
- {
- //d_main_gui->enableMenu(en);
- }
+void number_sink_impl::enable_menu(bool en)
+{
+ // d_main_gui->enableMenu(en);
+}
- void
- number_sink_impl::enable_autoscale(bool en)
- {
- d_main_gui->autoScale(en);
- }
+void number_sink_impl::enable_autoscale(bool en) { d_main_gui->autoScale(en); }
- void
- number_sink_impl::reset()
- {
- gr::thread::scoped_lock lock(d_setlock);
- _reset();
- }
+void number_sink_impl::reset()
+{
+ gr::thread::scoped_lock lock(d_setlock);
+ _reset();
+}
- void
- number_sink_impl::_reset()
- {
- }
+void number_sink_impl::_reset() {}
- void
- number_sink_impl::_gui_update_trigger()
- {
- // Only update the time if different than the current interval
- // add some slop in cpu ticks for double comparison
- gr::high_res_timer_type tps = gr::high_res_timer_tps();
- double t = d_main_gui->updateTime();
- if((d_update_time < (tps*t-10)) || ((tps*t+10) < d_update_time)) {
+void number_sink_impl::_gui_update_trigger()
+{
+ // Only update the time if different than the current interval
+ // add some slop in cpu ticks for double comparison
+ gr::high_res_timer_type tps = gr::high_res_timer_tps();
+ double t = d_main_gui->updateTime();
+ if ((d_update_time < (tps * t - 10)) || ((tps * t + 10) < d_update_time)) {
set_update_time(t);
- }
+ }
- float a = d_main_gui->average();
- if(a != d_average) {
+ float a = d_main_gui->average();
+ if (a != d_average) {
set_average(a);
- }
}
+}
- float
- number_sink_impl::get_item(const void *input_items, int n)
- {
- char *inc;
- short *ins;
- float *inf;
+float number_sink_impl::get_item(const void* input_items, int n)
+{
+ char* inc;
+ short* ins;
+ float* inf;
- switch(d_itemsize) {
- case(1):
+ switch (d_itemsize) {
+ case (1):
inc = (char*)input_items;
return static_cast<float>(inc[n]);
break;
- case(2):
+ case (2):
ins = (short*)input_items;
return static_cast<float>(ins[n]);
break;
- case(4):
+ case (4):
inf = (float*)input_items;
return static_cast<float>(inf[n]);
break;
- default:
+ default:
throw std::runtime_error("item size not supported");
- }
- return 0;
}
+ return 0;
+}
- int
- number_sink_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- gr::thread::scoped_lock lock(d_setlock);
-
- _gui_update_trigger();
-
- if(d_average > 0) {
- for(int n = 0; n < d_nconnections; n++) {
- for(int i = 0; i < noutput_items; i++) {
- float x = get_item(input_items[n], i);
- if(std::isfinite(x))
- d_avg_value[n] = d_iir[n].filter(x);
- }
+int number_sink_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ gr::thread::scoped_lock lock(d_setlock);
+
+ _gui_update_trigger();
+
+ if (d_average > 0) {
+ for (int n = 0; n < d_nconnections; n++) {
+ for (int i = 0; i < noutput_items; i++) {
+ float x = get_item(input_items[n], i);
+ if (std::isfinite(x))
+ d_avg_value[n] = d_iir[n].filter(x);
+ }
}
- }
+ }
- // Plot if we are able to update
- if((gr::high_res_timer_now() - d_last_time) > d_update_time) {
+ // Plot if we are able to update
+ if ((gr::high_res_timer_now() - d_last_time) > d_update_time) {
d_last_time = gr::high_res_timer_now();
std::vector<float> d(d_nconnections);
- if(d_average > 0) {
- for(int n = 0; n < d_nconnections; n++)
- d[n] = d_avg_value[n];
+ if (d_average > 0) {
+ for (int n = 0; n < d_nconnections; n++)
+ d[n] = d_avg_value[n];
+ } else {
+ for (int n = 0; n < d_nconnections; n++) {
+ float x = get_item(input_items[n], 0);
+ if (std::isfinite(x))
+ d[n] = x;
+ }
}
- else {
- for(int n = 0; n < d_nconnections; n++) {
- float x = get_item(input_items[n], 0);
- if(std::isfinite(x))
- d[n] = x;
- }
- }
- d_qApplication->postEvent(d_main_gui,
- new NumberUpdateEvent(d));
- }
-
- return noutput_items;;
+ d_qApplication->postEvent(d_main_gui, new NumberUpdateEvent(d));
}
- } /* namespace qtgui */
+ return noutput_items;
+ ;
+}
+
+} /* namespace qtgui */
} /* namespace gr */
diff --git a/gr-qtgui/lib/number_sink_impl.h b/gr-qtgui/lib/number_sink_impl.h
index 4b92f15969..8a1ba06635 100644
--- a/gr-qtgui/lib/number_sink_impl.h
+++ b/gr-qtgui/lib/number_sink_impl.h
@@ -30,94 +30,92 @@
#include <gnuradio/high_res_timer.h>
namespace gr {
- namespace qtgui {
+namespace qtgui {
- class QTGUI_API number_sink_impl : public number_sink
- {
- private:
- void initialize();
+class QTGUI_API number_sink_impl : public number_sink
+{
+private:
+ void initialize();
- size_t d_itemsize;
- float d_average;
- graph_t d_type;
- int d_nconnections;
+ size_t d_itemsize;
+ float d_average;
+ graph_t d_type;
+ int d_nconnections;
- int d_index, d_start, d_end;
- std::vector<double*> d_buffers;
- std::vector< std::vector<gr::tag_t> > d_tags;
+ int d_index, d_start, d_end;
+ std::vector<double*> d_buffers;
+ std::vector<std::vector<gr::tag_t>> d_tags;
- int d_argc;
- char *d_argv;
- QWidget *d_parent;
- NumberDisplayForm *d_main_gui;
+ int d_argc;
+ char* d_argv;
+ QWidget* d_parent;
+ NumberDisplayForm* d_main_gui;
- std::vector<float> d_avg_value;
- std::vector<filter::single_pole_iir<float,float,float> > d_iir;
+ std::vector<float> d_avg_value;
+ std::vector<filter::single_pole_iir<float, float, float>> d_iir;
- gr::high_res_timer_type d_update_time;
- gr::high_res_timer_type d_last_time;
+ gr::high_res_timer_type d_update_time;
+ gr::high_res_timer_type d_last_time;
- void _reset();
- void _npoints_resize();
- void _gui_update_trigger();
+ void _reset();
+ void _npoints_resize();
+ void _gui_update_trigger();
- float get_item(const void *input_items, int n);
+ float get_item(const void* input_items, int n);
- public:
- number_sink_impl(size_t itemsize,
- float average=0,
- graph_t graph_type=NUM_GRAPH_HORIZ,
- int nconnections=1,
- QWidget *parent=NULL);
- ~number_sink_impl();
+public:
+ number_sink_impl(size_t itemsize,
+ float average = 0,
+ graph_t graph_type = NUM_GRAPH_HORIZ,
+ int nconnections = 1,
+ QWidget* parent = NULL);
+ ~number_sink_impl();
- bool check_topology(int ninputs, int noutputs);
+ bool check_topology(int ninputs, int noutputs);
- void exec_();
- QWidget* qwidget();
+ void exec_();
+ QWidget* qwidget();
#ifdef ENABLE_PYTHON
- PyObject* pyqwidget();
+ PyObject* pyqwidget();
#else
- void* pyqwidget();
+ void* pyqwidget();
#endif
- void set_update_time(double t);
- void set_average(const float avg);
- void set_graph_type(const graph_t type);
- void set_color(unsigned int which,
- const std::string &min,
- const std::string &max);
- void set_color(unsigned int which, int min, int max);
- void set_label(unsigned int which, const std::string &label);
- void set_min(unsigned int which, float min);
- void set_max(unsigned int which, float max);
- void set_title(const std::string &title);
- void set_unit(unsigned int which, const std::string &unit);
- void set_factor(unsigned int which, float factor);
-
- float average() const;
- graph_t graph_type() const;
- std::string color_min(unsigned int which) const;
- std::string color_max(unsigned int which) const;
- std::string label(unsigned int which) const;
- float min(unsigned int which) const;
- float max(unsigned int which) const;
- std::string title() const;
- std::string unit(unsigned int which) const;
- float factor(unsigned int which) const;
-
- void enable_menu(bool en);
- void enable_autoscale(bool en=true);
-
- void reset();
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace qtgui */
+ void set_update_time(double t);
+ void set_average(const float avg);
+ void set_graph_type(const graph_t type);
+ void set_color(unsigned int which, const std::string& min, const std::string& max);
+ void set_color(unsigned int which, int min, int max);
+ void set_label(unsigned int which, const std::string& label);
+ void set_min(unsigned int which, float min);
+ void set_max(unsigned int which, float max);
+ void set_title(const std::string& title);
+ void set_unit(unsigned int which, const std::string& unit);
+ void set_factor(unsigned int which, float factor);
+
+ float average() const;
+ graph_t graph_type() const;
+ std::string color_min(unsigned int which) const;
+ std::string color_max(unsigned int which) const;
+ std::string label(unsigned int which) const;
+ float min(unsigned int which) const;
+ float max(unsigned int which) const;
+ std::string title() const;
+ std::string unit(unsigned int which) const;
+ float factor(unsigned int which) const;
+
+ void enable_menu(bool en);
+ void enable_autoscale(bool en = true);
+
+ void reset();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
+
+} /* namespace qtgui */
} /* namespace gr */
#endif /* INCLUDED_QTGUI_NUMBER_SINK_IMPL_H */
diff --git a/gr-qtgui/lib/numberdisplayform.cc b/gr-qtgui/lib/numberdisplayform.cc
index db462525c6..6fa0657546 100644
--- a/gr-qtgui/lib/numberdisplayform.cc
+++ b/gr-qtgui/lib/numberdisplayform.cc
@@ -29,492 +29,434 @@
#include <cmath>
#include <iostream>
-NumberDisplayForm::NumberDisplayForm(int nplots, gr::qtgui::graph_t type,
- QWidget* parent)
- : QWidget(parent)
-{
- d_nplots = nplots;
- d_graph_type = type;
- d_title = new QLabel(QString(""));
- d_layout = new QGridLayout(this);
- for(unsigned int i = 0; i < d_nplots; ++i) {
- d_min.push_back(+1e32);
- d_max.push_back(-1e32);
- d_label.push_back(new QLabel(QString("Data %1").arg(i)));
- d_unit.push_back("");
- d_factor.push_back(1);
- d_text_box.push_back(new QLabel(QString("0")));
-
- d_indicator.push_back(new QwtThermo());
- d_indicator[i]->setScale(-1, 1);
+NumberDisplayForm::NumberDisplayForm(int nplots, gr::qtgui::graph_t type, QWidget* parent)
+ : QWidget(parent)
+{
+ d_nplots = nplots;
+ d_graph_type = type;
+ d_title = new QLabel(QString(""));
+ d_layout = new QGridLayout(this);
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ d_min.push_back(+1e32);
+ d_max.push_back(-1e32);
+ d_label.push_back(new QLabel(QString("Data %1").arg(i)));
+ d_unit.push_back("");
+ d_factor.push_back(1);
+ d_text_box.push_back(new QLabel(QString("0")));
+
+ d_indicator.push_back(new QwtThermo());
+ d_indicator[i]->setScale(-1, 1);
#if QWT_VERSION < 0x060100
#else
- d_indicator[i]->setOriginMode(QwtThermo::OriginCustom);
- d_indicator[i]->setOrigin(0.0);
+ d_indicator[i]->setOriginMode(QwtThermo::OriginCustom);
+ d_indicator[i]->setOrigin(0.0);
#endif /* if QWT_VERSION < 0x060100 */
- switch(type) {
- case(gr::qtgui::NUM_GRAPH_HORIZ):
+ switch (type) {
+ case (gr::qtgui::NUM_GRAPH_HORIZ):
#if QWT_VERSION < 0x060100
- d_indicator[i]->setOrientation(Qt::Horizontal, QwtThermo::BottomScale);
+ d_indicator[i]->setOrientation(Qt::Horizontal, QwtThermo::BottomScale);
#else
- d_indicator[i]->setOrientation(Qt::Horizontal);
+ d_indicator[i]->setOrientation(Qt::Horizontal);
#endif /* if QWT_VERSION < 0x060100 */
- d_layout->addWidget(d_label[i], 2*i, 0);
- d_layout->addWidget(d_text_box[i], 2*i, 1);
- d_layout->addWidget(d_indicator[i], 2*i+1, 1);
- break;
- case(gr::qtgui::NUM_GRAPH_VERT):
+ d_layout->addWidget(d_label[i], 2 * i, 0);
+ d_layout->addWidget(d_text_box[i], 2 * i, 1);
+ d_layout->addWidget(d_indicator[i], 2 * i + 1, 1);
+ break;
+ case (gr::qtgui::NUM_GRAPH_VERT):
#if QWT_VERSION < 0x060100
- d_indicator[i]->setOrientation(Qt::Vertical, QwtThermo::LeftScale);
+ d_indicator[i]->setOrientation(Qt::Vertical, QwtThermo::LeftScale);
#else
- d_indicator[i]->setOrientation(Qt::Vertical);
+ d_indicator[i]->setOrientation(Qt::Vertical);
#endif /* if QWT_VERSION < 0x060100 */
- d_layout->addWidget(d_label[i], 0, i);
- d_layout->addWidget(d_text_box[i], 1, i);
- d_layout->addWidget(d_indicator[i], 2, i);
- break;
- case(gr::qtgui::NUM_GRAPH_NONE):
- default:
- d_layout->addWidget(d_label[i], 0, i);
- d_layout->addWidget(d_text_box[i], 1, i);
+ d_layout->addWidget(d_label[i], 0, i);
+ d_layout->addWidget(d_text_box[i], 1, i);
+ d_layout->addWidget(d_indicator[i], 2, i);
+ break;
+ case (gr::qtgui::NUM_GRAPH_NONE):
+ default:
+ d_layout->addWidget(d_label[i], 0, i);
+ d_layout->addWidget(d_text_box[i], 1, i);
+ }
+
+ setColor(i, QColor("black"), QColor("black"));
+ }
+
+ d_avg = 0.0;
+ d_update_time = 0.1;
+
+ d_menu_on = true;
+ d_menu = new QMenu(this);
+
+ // Create a set of actions for the menu
+ d_stop_act = new QAction("Stop", this);
+ d_stop_act->setStatusTip(tr("Start/Stop"));
+ connect(d_stop_act, SIGNAL(triggered()), this, SLOT(setStop()));
+ d_stop_state = false;
+ d_menu->addAction(d_stop_act);
+
+ // Menu items for each number line
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ d_label_act.push_back(new LineTitleAction(i, this));
+ connect(d_label_act[i],
+ SIGNAL(whichTrigger(unsigned int, const QString&)),
+ this,
+ SLOT(setLabel(unsigned int, const QString&)));
+
+ d_label_menu.push_back(new QMenu(tr(""), this));
+ d_label_menu[i]->addAction(d_label_act[i]);
+
+ d_color_menu.push_back(new NumberColorMapMenu(i, this));
+ connect(d_color_menu[i],
+ SIGNAL(whichTrigger(unsigned int, const QColor&, const QColor&)),
+ this,
+ SLOT(setColor(unsigned int, const QColor&, const QColor&)));
+ d_label_menu[i]->addMenu(d_color_menu[i]);
+
+ d_factor_act.push_back(new ItemFloatAct(i, "Factor", this));
+ connect(d_factor_act[i],
+ SIGNAL(whichTrigger(unsigned int, float)),
+ this,
+ SLOT(setFactor(unsigned int, float)));
+ d_label_menu[i]->addAction(d_factor_act[i]);
+
+ d_menu->addMenu(d_label_menu[i]);
}
- setColor(i, QColor("black"), QColor("black"));
- }
-
- d_avg = 0.0;
- d_update_time = 0.1;
-
- d_menu_on = true;
- d_menu = new QMenu(this);
-
- // Create a set of actions for the menu
- d_stop_act = new QAction("Stop", this);
- d_stop_act->setStatusTip(tr("Start/Stop"));
- connect(d_stop_act, SIGNAL(triggered()), this, SLOT(setStop()));
- d_stop_state = false;
- d_menu->addAction(d_stop_act);
-
- // Menu items for each number line
- for(unsigned int i = 0; i < d_nplots; ++i) {
- d_label_act.push_back(new LineTitleAction(i, this));
- connect(d_label_act[i], SIGNAL(whichTrigger(unsigned int, const QString&)),
- this, SLOT(setLabel(unsigned int, const QString&)));
-
- d_label_menu.push_back(new QMenu(tr(""), this));
- d_label_menu[i]->addAction(d_label_act[i]);
-
- d_color_menu.push_back(new NumberColorMapMenu(i, this));
- connect(d_color_menu[i], SIGNAL(whichTrigger(unsigned int, const QColor&, const QColor&)),
- this, SLOT(setColor(unsigned int, const QColor&, const QColor&)));
- d_label_menu[i]->addMenu(d_color_menu[i]);
-
- d_factor_act.push_back(new ItemFloatAct(i, "Factor", this));
- connect(d_factor_act[i], SIGNAL(whichTrigger(unsigned int, float)),
- this, SLOT(setFactor(unsigned int, float)));
- d_label_menu[i]->addAction(d_factor_act[i]);
-
- d_menu->addMenu(d_label_menu[i]);
- }
-
- d_avg_menu = new FFTAverageMenu(this);
- d_avg_menu->setTitle("Average");
- d_avg_menu->setHigh(0.001);
- d_avg_menu->setMedium(0.01);
- d_avg_menu->setLow(0.1);
- connect(d_avg_menu, SIGNAL(whichTrigger(float)),
- this, SLOT(setAverage(const float)));
- d_menu->addMenu(d_avg_menu);
-
- d_layout_menu = new NumberLayoutMenu(this);
- connect(d_layout_menu, SIGNAL(whichTrigger(gr::qtgui::graph_t)),
- this, SLOT(setGraphType(const gr::qtgui::graph_t)));
- d_menu->addMenu(d_layout_menu);
-
- d_autoscale_act = new QAction("Auto Scale", this);
- d_autoscale_act->setCheckable(true);
- connect(d_autoscale_act, SIGNAL(triggered(bool)),
- this, SLOT(autoScale(bool)));
- d_autoscale_state = false;
- d_menu->addAction(d_autoscale_act);
-
- d_update_time_menu = new PopupMenu("Update Time", this);
- connect(d_update_time_menu, SIGNAL(whichTrigger(QString)),
- this, SLOT(setUpdateTime(QString)));
- d_menu->addAction(d_update_time_menu);
-
- d_save_act = new QAction("Save", this);
- d_save_act->setStatusTip(tr("Save Figure"));
- connect(d_save_act, SIGNAL(triggered()), this, SLOT(saveFigure()));
- d_menu->addAction(d_save_act);
-
- setLayout(d_layout);
+ d_avg_menu = new FFTAverageMenu(this);
+ d_avg_menu->setTitle("Average");
+ d_avg_menu->setHigh(0.001);
+ d_avg_menu->setMedium(0.01);
+ d_avg_menu->setLow(0.1);
+ connect(d_avg_menu, SIGNAL(whichTrigger(float)), this, SLOT(setAverage(const float)));
+ d_menu->addMenu(d_avg_menu);
+
+ d_layout_menu = new NumberLayoutMenu(this);
+ connect(d_layout_menu,
+ SIGNAL(whichTrigger(gr::qtgui::graph_t)),
+ this,
+ SLOT(setGraphType(const gr::qtgui::graph_t)));
+ d_menu->addMenu(d_layout_menu);
+
+ d_autoscale_act = new QAction("Auto Scale", this);
+ d_autoscale_act->setCheckable(true);
+ connect(d_autoscale_act, SIGNAL(triggered(bool)), this, SLOT(autoScale(bool)));
+ d_autoscale_state = false;
+ d_menu->addAction(d_autoscale_act);
+
+ d_update_time_menu = new PopupMenu("Update Time", this);
+ connect(d_update_time_menu,
+ SIGNAL(whichTrigger(QString)),
+ this,
+ SLOT(setUpdateTime(QString)));
+ d_menu->addAction(d_update_time_menu);
+
+ d_save_act = new QAction("Save", this);
+ d_save_act->setStatusTip(tr("Save Figure"));
+ connect(d_save_act, SIGNAL(triggered()), this, SLOT(saveFigure()));
+ d_menu->addAction(d_save_act);
+
+ setLayout(d_layout);
}
NumberDisplayForm::~NumberDisplayForm()
{
- // Qt deletes children when parent is deleted
+ // Qt deletes children when parent is deleted
}
-void
-NumberDisplayForm::mousePressEvent(QMouseEvent * e)
+void NumberDisplayForm::mousePressEvent(QMouseEvent* e)
{
- bool ctrloff = Qt::ControlModifier != QApplication::keyboardModifiers();
- if((e->button() == Qt::MidButton) && ctrloff && (d_menu_on)) {
- if(d_stop_state == false)
- d_stop_act->setText(tr("Stop"));
- else
- d_stop_act->setText(tr("Start"));
+ bool ctrloff = Qt::ControlModifier != QApplication::keyboardModifiers();
+ if ((e->button() == Qt::MidButton) && ctrloff && (d_menu_on)) {
+ if (d_stop_state == false)
+ d_stop_act->setText(tr("Stop"));
+ else
+ d_stop_act->setText(tr("Start"));
- // Update the line titles if changed externally
- for(unsigned int i = 0; i < d_nplots; ++i) {
- d_label_menu[i]->setTitle(label(i).c_str());
+ // Update the line titles if changed externally
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ d_label_menu[i]->setTitle(label(i).c_str());
+ }
+ d_menu->exec(e->globalPos());
}
- d_menu->exec(e->globalPos());
- }
}
-void
-NumberDisplayForm::setStop(bool on)
+void NumberDisplayForm::setStop(bool on)
{
- if(!on) {
- d_stop_state = false;
- }
- else {
- d_stop_state = true;
- }
+ if (!on) {
+ d_stop_state = false;
+ } else {
+ d_stop_state = true;
+ }
}
-void
-NumberDisplayForm::setStop()
+void NumberDisplayForm::setStop()
{
- if(d_stop_state == false)
- setStop(true);
- else
- setStop(false);
+ if (d_stop_state == false)
+ setStop(true);
+ else
+ setStop(false);
}
-void
-NumberDisplayForm::saveFigure()
+void NumberDisplayForm::saveFigure()
{
- QPixmap qpix = QPixmap::grabWidget(this);
-
- QString types = QString(tr("JPEG file (*.jpg);;Portable Network Graphics file (*.png);;Bitmap file (*.bmp);;TIFF file (*.tiff)"));
-
- QString filename, filetype;
- QFileDialog *filebox = new QFileDialog(0, "Save Image", "./", types);
- filebox->setViewMode(QFileDialog::Detail);
- if(filebox->exec()) {
- filename = filebox->selectedFiles()[0];
- filetype = filebox->selectedNameFilter();
- }
- else {
- return;
- }
-
- if(filetype.contains(".jpg")) {
- qpix.save(filename, "JPEG");
- }
- else if(filetype.contains(".png")) {
- qpix.save(filename, "PNG");
- }
- else if(filetype.contains(".bmp")) {
- qpix.save(filename, "BMP");
- }
- else if(filetype.contains(".tiff")) {
- qpix.save(filename, "TIFF");
- }
- else {
- qpix.save(filename, "JPEG");
- }
-
- delete filebox;
+ QPixmap qpix = QPixmap::grabWidget(this);
+
+ QString types = QString(tr("JPEG file (*.jpg);;Portable Network Graphics file "
+ "(*.png);;Bitmap file (*.bmp);;TIFF file (*.tiff)"));
+
+ QString filename, filetype;
+ QFileDialog* filebox = new QFileDialog(0, "Save Image", "./", types);
+ filebox->setViewMode(QFileDialog::Detail);
+ if (filebox->exec()) {
+ filename = filebox->selectedFiles()[0];
+ filetype = filebox->selectedNameFilter();
+ } else {
+ return;
+ }
+
+ if (filetype.contains(".jpg")) {
+ qpix.save(filename, "JPEG");
+ } else if (filetype.contains(".png")) {
+ qpix.save(filename, "PNG");
+ } else if (filetype.contains(".bmp")) {
+ qpix.save(filename, "BMP");
+ } else if (filetype.contains(".tiff")) {
+ qpix.save(filename, "TIFF");
+ } else {
+ qpix.save(filename, "JPEG");
+ }
+
+ delete filebox;
}
-void
-NumberDisplayForm::newData(const QEvent* updateEvent)
+void NumberDisplayForm::newData(const QEvent* updateEvent)
{
- if(!d_stop_state) {
- NumberUpdateEvent *tevent = (NumberUpdateEvent*)updateEvent;
- const std::vector<float> samples = tevent->getSamples();
-
- for(unsigned int i = 0; i < d_nplots; ++i) {
- float f = d_factor[i]*samples[i];
- d_text_box[i]->setText(QString("%1 %2").arg(f, 4, ' ').\
- arg(QString(d_unit[i].c_str())));
- d_indicator[i]->setValue(f);
- d_min[i] = std::min(d_min[i], f);
- d_max[i] = std::max(d_max[i], f);
-
- if(d_autoscale_state) {
- d_indicator[i]->setScale(d_min[i], d_max[i]);
- }
- }
+ if (!d_stop_state) {
+ NumberUpdateEvent* tevent = (NumberUpdateEvent*)updateEvent;
+ const std::vector<float> samples = tevent->getSamples();
+
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ float f = d_factor[i] * samples[i];
+ d_text_box[i]->setText(
+ QString("%1 %2").arg(f, 4, ' ').arg(QString(d_unit[i].c_str())));
+ d_indicator[i]->setValue(f);
+ d_min[i] = std::min(d_min[i], f);
+ d_max[i] = std::max(d_max[i], f);
- }
+ if (d_autoscale_state) {
+ d_indicator[i]->setScale(d_min[i], d_max[i]);
+ }
+ }
+ }
}
-void
-NumberDisplayForm::customEvent(QEvent * e)
+void NumberDisplayForm::customEvent(QEvent* e)
{
- if(e->type() == NumberUpdateEvent::Type()) {
- newData(e);
- }
+ if (e->type() == NumberUpdateEvent::Type()) {
+ newData(e);
+ }
}
-void
-NumberDisplayForm::setGraphType(const gr::qtgui::graph_t type)
+void NumberDisplayForm::setGraphType(const gr::qtgui::graph_t type)
{
- int off = 0;
-
- // Remove all widgets from the layout
- QLayoutItem *item;
- while((item = d_layout->takeAt(0)) != NULL) {
- d_layout->removeItem(item);
- }
-
- // If we have a title, add it at the 0,0 grid point (top left)
- // set off = 1 to offset the rest of the widgets
- if(d_title->text().length() > 0) {
- d_layout->addWidget(d_title, 0, 0);
- off = 1;
- }
-
- d_graph_type = type;
- for(unsigned int i = 0; i < d_nplots; ++i) {
- switch(d_graph_type) {
- case(gr::qtgui::NUM_GRAPH_HORIZ):
+ int off = 0;
+
+ // Remove all widgets from the layout
+ QLayoutItem* item;
+ while ((item = d_layout->takeAt(0)) != NULL) {
+ d_layout->removeItem(item);
+ }
+
+ // If we have a title, add it at the 0,0 grid point (top left)
+ // set off = 1 to offset the rest of the widgets
+ if (d_title->text().length() > 0) {
+ d_layout->addWidget(d_title, 0, 0);
+ off = 1;
+ }
+
+ d_graph_type = type;
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ switch (d_graph_type) {
+ case (gr::qtgui::NUM_GRAPH_HORIZ):
#if QWT_VERSION < 0x060100
- d_indicator[i]->setOrientation(Qt::Horizontal, QwtThermo::BottomScale);
+ d_indicator[i]->setOrientation(Qt::Horizontal, QwtThermo::BottomScale);
#else
- d_indicator[i]->setOrientation(Qt::Horizontal);
+ d_indicator[i]->setOrientation(Qt::Horizontal);
#endif /* if QWT_VERSION < 0x060100 */
- d_indicator[i]->setVisible(true);
- d_layout->addWidget(d_label[i], 2*i+off, 0);
- d_layout->addWidget(d_text_box[i], 2*i+off, 1);
- d_layout->addWidget(d_indicator[i], 2*i+1+off, 1);
- break;
- case(gr::qtgui::NUM_GRAPH_VERT):
+ d_indicator[i]->setVisible(true);
+ d_layout->addWidget(d_label[i], 2 * i + off, 0);
+ d_layout->addWidget(d_text_box[i], 2 * i + off, 1);
+ d_layout->addWidget(d_indicator[i], 2 * i + 1 + off, 1);
+ break;
+ case (gr::qtgui::NUM_GRAPH_VERT):
#if QWT_VERSION < 0x060100
- d_indicator[i]->setOrientation(Qt::Vertical, QwtThermo::LeftScale);
+ d_indicator[i]->setOrientation(Qt::Vertical, QwtThermo::LeftScale);
#else
- d_indicator[i]->setOrientation(Qt::Vertical);
+ d_indicator[i]->setOrientation(Qt::Vertical);
#endif /* if QWT_VERSION < 0x060100 */
- d_indicator[i]->setVisible(true);
- d_layout->addWidget(d_label[i], 0+off, i);
- d_layout->addWidget(d_text_box[i], 1+off, i);
- d_layout->addWidget(d_indicator[i], 2+off, i);
- break;
- case(gr::qtgui::NUM_GRAPH_NONE):
- default:
- d_indicator[i]->setVisible(false);
- d_layout->addWidget(d_label[i], 0+off, i);
- d_layout->addWidget(d_text_box[i], 1+off, i);
- break;
+ d_indicator[i]->setVisible(true);
+ d_layout->addWidget(d_label[i], 0 + off, i);
+ d_layout->addWidget(d_text_box[i], 1 + off, i);
+ d_layout->addWidget(d_indicator[i], 2 + off, i);
+ break;
+ case (gr::qtgui::NUM_GRAPH_NONE):
+ default:
+ d_indicator[i]->setVisible(false);
+ d_layout->addWidget(d_label[i], 0 + off, i);
+ d_layout->addWidget(d_text_box[i], 1 + off, i);
+ break;
+ }
}
- }
-
}
-void
-NumberDisplayForm::setColor(unsigned int which, const QColor &min, const QColor &max)
+void NumberDisplayForm::setColor(unsigned int which, const QColor& min, const QColor& max)
{
- QwtLinearColorMap *map = new QwtLinearColorMap();
- map->setColorInterval(min, max);
+ QwtLinearColorMap* map = new QwtLinearColorMap();
+ map->setColorInterval(min, max);
#if QWT_VERSION < 0x060000
- d_indicator[which]->setFillColor(max);
+ d_indicator[which]->setFillColor(max);
#else
- d_indicator[which]->setColorMap(map);
+ d_indicator[which]->setColorMap(map);
#endif /* QWT_VERSION < 0x060000 */
}
-void
-NumberDisplayForm::setColorMin(unsigned int which, QString min)
+void NumberDisplayForm::setColorMin(unsigned int which, QString min)
{
- setColor(which, QColor(min), colorMax(which));
+ setColor(which, QColor(min), colorMax(which));
}
-void
-NumberDisplayForm::setColorMax(unsigned int which, QString max)
+void NumberDisplayForm::setColorMax(unsigned int which, QString max)
{
- setColor(which, colorMin(which), QColor(max));
+ setColor(which, colorMin(which), QColor(max));
}
-void
-NumberDisplayForm::setLabel(unsigned int which, const std::string &label)
+void NumberDisplayForm::setLabel(unsigned int which, const std::string& label)
{
- d_label[which]->setText(label.c_str());
+ d_label[which]->setText(label.c_str());
}
-void
-NumberDisplayForm::setLabel(unsigned int which, QString label)
+void NumberDisplayForm::setLabel(unsigned int which, QString label)
{
- d_label[which]->setText(label);
+ d_label[which]->setText(label);
}
-void
-NumberDisplayForm::setAverage(const float avg)
-{
- d_avg = avg;
-}
+void NumberDisplayForm::setAverage(const float avg) { d_avg = avg; }
-void
-NumberDisplayForm::setUpdateTime(const float time)
-{
- d_update_time = time;
-}
+void NumberDisplayForm::setUpdateTime(const float time) { d_update_time = time; }
-void
-NumberDisplayForm::setUpdateTime(QString time)
-{
- setUpdateTime(time.toFloat());
-}
+void NumberDisplayForm::setUpdateTime(QString time) { setUpdateTime(time.toFloat()); }
-void
-NumberDisplayForm::setScale(unsigned int which, int min, int max)
+void NumberDisplayForm::setScale(unsigned int which, int min, int max)
{
- d_min[which] = min;
- d_max[which] = max;
- d_indicator[which]->setScale(min, max);
+ d_min[which] = min;
+ d_max[which] = max;
+ d_indicator[which]->setScale(min, max);
#if QWT_VERSION < 0x060100
- d_indicator[which]->setRange(min, max);
+ d_indicator[which]->setRange(min, max);
#endif
}
-void
-NumberDisplayForm::setScaleMin(unsigned int which, int min)
+void NumberDisplayForm::setScaleMin(unsigned int which, int min)
{
- setScale(which, min, d_max[which]);
+ setScale(which, min, d_max[which]);
}
-void
-NumberDisplayForm::setScaleMax(unsigned int which, int max)
+void NumberDisplayForm::setScaleMax(unsigned int which, int max)
{
- setScale(which, d_min[which], max);
+ setScale(which, d_min[which], max);
}
-gr::qtgui::graph_t
-NumberDisplayForm::graphType() const
-{
- return d_graph_type;
-}
+gr::qtgui::graph_t NumberDisplayForm::graphType() const { return d_graph_type; }
-QColor
-NumberDisplayForm::colorMin(unsigned int which) const
+QColor NumberDisplayForm::colorMin(unsigned int which) const
{
#if QWT_VERSION < 0x060000
- return d_indicator[which]->fillColor();
+ return d_indicator[which]->fillColor();
#else
- QwtLinearColorMap *map = static_cast<QwtLinearColorMap*>(d_indicator[which]->colorMap());
- return map->color1();
+ QwtLinearColorMap* map =
+ static_cast<QwtLinearColorMap*>(d_indicator[which]->colorMap());
+ return map->color1();
#endif /* QWT_VERSION < 0x060000 */
}
-QColor
-NumberDisplayForm::colorMax(unsigned int which) const
+QColor NumberDisplayForm::colorMax(unsigned int which) const
{
#if QWT_VERSION < 0x060000
- return d_indicator[which]->fillColor();
+ return d_indicator[which]->fillColor();
#else
- QwtLinearColorMap *map = static_cast<QwtLinearColorMap*>(d_indicator[which]->colorMap());
- return map->color2();
+ QwtLinearColorMap* map =
+ static_cast<QwtLinearColorMap*>(d_indicator[which]->colorMap());
+ return map->color2();
#endif /* QWT_VERSION < 0x060000 */
}
-std::string
-NumberDisplayForm::label(unsigned int which) const
+std::string NumberDisplayForm::label(unsigned int which) const
{
- return d_label[which]->text().toStdString();
+ return d_label[which]->text().toStdString();
}
-float
-NumberDisplayForm::average() const
-{
- return d_avg;
-}
+float NumberDisplayForm::average() const { return d_avg; }
-float
-NumberDisplayForm::updateTime() const
-{
- return d_update_time;
-}
+float NumberDisplayForm::updateTime() const { return d_update_time; }
-int
-NumberDisplayForm::scaleMin(unsigned int which)
-{
- return d_min[which];
-}
+int NumberDisplayForm::scaleMin(unsigned int which) { return d_min[which]; }
-int
-NumberDisplayForm::scaleMax(unsigned int which)
-{
- return d_max[which];
-}
+int NumberDisplayForm::scaleMax(unsigned int which) { return d_max[which]; }
-void
-NumberDisplayForm::autoScale(bool on)
+void NumberDisplayForm::autoScale(bool on)
{
- d_autoscale_state = on;
- d_autoscale_act->setChecked(on);
-
- // Reset the autoscale limits
- for(unsigned int i = 0; i < d_nplots; ++i) {
- d_min[i] = +1e32;
- d_max[i] = -1e32;
- }
-}
+ d_autoscale_state = on;
+ d_autoscale_act->setChecked(on);
-std::string
-NumberDisplayForm::title() const
-{
- return d_title->text().toStdString();
+ // Reset the autoscale limits
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ d_min[i] = +1e32;
+ d_max[i] = -1e32;
+ }
}
-void
-NumberDisplayForm::setTitle(const std::string &title)
+std::string NumberDisplayForm::title() const { return d_title->text().toStdString(); }
+
+void NumberDisplayForm::setTitle(const std::string& title)
{
- std::string t = title;
- if(t.length() > 0)
- t = "<b><FONT SIZE=4>" + title + "</b>";
- d_title->setText(QString(t.c_str()));
- setGraphType(d_graph_type);
+ std::string t = title;
+ if (t.length() > 0)
+ t = "<b><FONT SIZE=4>" + title + "</b>";
+ d_title->setText(QString(t.c_str()));
+ setGraphType(d_graph_type);
}
-std::string
-NumberDisplayForm::unit(unsigned int which) const
+std::string NumberDisplayForm::unit(unsigned int which) const
{
- if(static_cast<size_t>(which) >= d_unit.size())
- throw std::runtime_error("NumberDisplayForm::units: invalid 'which'.\n");
+ if (static_cast<size_t>(which) >= d_unit.size())
+ throw std::runtime_error("NumberDisplayForm::units: invalid 'which'.\n");
- return d_unit[which];
+ return d_unit[which];
}
-void
-NumberDisplayForm::setUnit(unsigned int which, const std::string &unit)
+void NumberDisplayForm::setUnit(unsigned int which, const std::string& unit)
{
- if(static_cast<size_t>(which) >= d_unit.size())
- throw std::runtime_error("NumberDisplayForm::setUnits: invalid 'which'.\n");
+ if (static_cast<size_t>(which) >= d_unit.size())
+ throw std::runtime_error("NumberDisplayForm::setUnits: invalid 'which'.\n");
- d_unit[which] = unit;
+ d_unit[which] = unit;
}
-float
-NumberDisplayForm::factor(unsigned int which) const
+float NumberDisplayForm::factor(unsigned int which) const
{
- if(static_cast<size_t>(which) >= d_factor.size())
- throw std::runtime_error("NumberDisplayForm::factor: invalid 'which'.\n");
+ if (static_cast<size_t>(which) >= d_factor.size())
+ throw std::runtime_error("NumberDisplayForm::factor: invalid 'which'.\n");
- return d_factor[which];
+ return d_factor[which];
}
-void
-NumberDisplayForm::setFactor(unsigned int which, float factor)
+void NumberDisplayForm::setFactor(unsigned int which, float factor)
{
- if(static_cast<size_t>(which) >= d_factor.size())
- throw std::runtime_error("NumberDisplayForm::setFactor: invalid 'which'.\n");
+ if (static_cast<size_t>(which) >= d_factor.size())
+ throw std::runtime_error("NumberDisplayForm::setFactor: invalid 'which'.\n");
- d_factor[which] = factor;
+ d_factor[which] = factor;
}
diff --git a/gr-qtgui/lib/plot_raster.cc b/gr-qtgui/lib/plot_raster.cc
index f565977d5b..a339ec64bb 100644
--- a/gr-qtgui/lib/plot_raster.cc
+++ b/gr-qtgui/lib/plot_raster.cc
@@ -37,43 +37,35 @@
typedef QVector<QRgb> QwtColorTable;
-class PlotTimeRasterImage: public QImage
+class PlotTimeRasterImage : public QImage
{
// This class hides some Qt3/Qt4 API differences
public:
- PlotTimeRasterImage(const QSize &size, QwtColorMap::Format format):
- QImage(size, format == QwtColorMap::RGB
- ? QImage::Format_ARGB32 : QImage::Format_Indexed8 )
- {
- }
-
- PlotTimeRasterImage(const QImage &other):
- QImage(other)
- {
- }
-
- void initColorTable(const QImage& other)
- {
- setColorTable(other.colorTable());
- }
+ PlotTimeRasterImage(const QSize& size, QwtColorMap::Format format)
+ : QImage(size,
+ format == QwtColorMap::RGB ? QImage::Format_ARGB32
+ : QImage::Format_Indexed8)
+ {
+ }
+
+ PlotTimeRasterImage(const QImage& other) : QImage(other) {}
+
+ void initColorTable(const QImage& other) { setColorTable(other.colorTable()); }
};
class PlotTimeRaster::PrivateData
{
public:
- PrivateData()
- {
- data = NULL;
- colorMap = new QwtLinearColorMap();
- }
-
- ~PrivateData()
- {
- delete colorMap;
- }
-
- TimeRasterData *data;
- QwtColorMap *colorMap;
+ PrivateData()
+ {
+ data = NULL;
+ colorMap = new QwtLinearColorMap();
+ }
+
+ ~PrivateData() { delete colorMap; }
+
+ TimeRasterData* data;
+ QwtColorMap* colorMap;
};
/*!
@@ -87,8 +79,7 @@ public:
\sa QwtPlotItem::setItemAttribute(), QwtPlotItem::setZ()
*/
-PlotTimeRaster::PlotTimeRaster(const QString &title)
- : QwtPlotRasterItem(title)
+PlotTimeRaster::PlotTimeRaster(const QString& title) : QwtPlotRasterItem(title)
{
d_data = new PrivateData();
@@ -99,29 +90,14 @@ PlotTimeRaster::PlotTimeRaster(const QString &title)
}
//! Destructor
-PlotTimeRaster::~PlotTimeRaster()
-{
- delete d_data;
-}
+PlotTimeRaster::~PlotTimeRaster() { delete d_data; }
-const TimeRasterData*
-PlotTimeRaster::data()const
-{
- return d_data->data;
-}
+const TimeRasterData* PlotTimeRaster::data() const { return d_data->data; }
-void
-PlotTimeRaster::setData(TimeRasterData *data)
-{
- d_data->data = data;
-}
+void PlotTimeRaster::setData(TimeRasterData* data) { d_data->data = data; }
//! \return QwtPlotItem::Rtti_PlotSpectrogram
-int
-PlotTimeRaster::rtti() const
-{
- return QwtPlotItem::Rtti_PlotGrid;
-}
+int PlotTimeRaster::rtti() const { return QwtPlotItem::Rtti_PlotGrid; }
/*!
Change the color map
@@ -134,8 +110,7 @@ PlotTimeRaster::rtti() const
\sa colorMap(), QwtScaleWidget::setColorBarEnabled(),
QwtScaleWidget::setColorMap()
*/
-void
-PlotTimeRaster::setColorMap(const QwtColorMap *map)
+void PlotTimeRaster::setColorMap(const QwtColorMap* map)
{
delete d_data->colorMap;
d_data->colorMap = (QwtColorMap*)map;
@@ -148,10 +123,7 @@ PlotTimeRaster::setColorMap(const QwtColorMap *map)
\return Color Map used for mapping the intensity values to colors
\sa setColorMap()
*/
-const QwtColorMap &PlotTimeRaster::colorMap() const
-{
- return *d_data->colorMap;
-}
+const QwtColorMap& PlotTimeRaster::colorMap() const { return *d_data->colorMap; }
/*!
\return Bounding rect of the data
@@ -160,7 +132,7 @@ const QwtColorMap &PlotTimeRaster::colorMap() const
#if QWT_VERSION < 0x060000
QwtDoubleRect PlotTimeRaster::boundingRect() const
{
- return d_data->data->boundingRect();
+ return d_data->data->boundingRect();
}
#endif
@@ -174,9 +146,9 @@ QwtDoubleRect PlotTimeRaster::boundingRect() const
\return data().rasterHint(rect)
*/
#if QWT_VERSION < 0x060000
-QSize PlotTimeRaster::rasterHint(const QwtDoubleRect &rect) const
+QSize PlotTimeRaster::rasterHint(const QwtDoubleRect& rect) const
{
- return d_data->data->rasterHint(rect);
+ return d_data->data->rasterHint(rect);
}
#endif
@@ -198,135 +170,132 @@ QSize PlotTimeRaster::rasterHint(const QwtDoubleRect &rect) const
QwtColorMap::colorIndex()
*/
#if QWT_VERSION < 0x060000
-QImage PlotTimeRaster::renderImage(const QwtScaleMap &xMap,
- const QwtScaleMap &yMap,
- const QwtDoubleRect &area) const
+QImage PlotTimeRaster::renderImage(const QwtScaleMap& xMap,
+ const QwtScaleMap& yMap,
+ const QwtDoubleRect& area) const
#else
-QImage PlotTimeRaster::renderImage(const QwtScaleMap &xMap,
- const QwtScaleMap &yMap,
- const QRectF &area,
- const QSize &size) const
+QImage PlotTimeRaster::renderImage(const QwtScaleMap& xMap,
+ const QwtScaleMap& yMap,
+ const QRectF& area,
+ const QSize& size) const
#endif
{
- if(area.isEmpty())
- return QImage();
+ if (area.isEmpty())
+ return QImage();
#if QWT_VERSION < 0x060000
- QRect rect = transform(xMap, yMap, area);
- const QSize res = d_data->data->rasterHint(area);
+ QRect rect = transform(xMap, yMap, area);
+ const QSize res = d_data->data->rasterHint(area);
#else
- QRect rect = QwtScaleMap::transform(xMap, yMap, area).toRect();
- const QSize res(-1,-1);
+ QRect rect = QwtScaleMap::transform(xMap, yMap, area).toRect();
+ const QSize res(-1, -1);
#endif
- QwtScaleMap xxMap = xMap;
- QwtScaleMap yyMap = yMap;
-
- if(res.isValid()) {
- /*
- It is useless to render an image with a higher resolution
- than the data offers. Of course someone will have to
- scale this image later into the size of the given rect, but f.e.
- in case of postscript this will done on the printer.
- */
- rect.setSize(rect.size().boundedTo(res));
-
- int px1 = rect.x();
- int px2 = rect.x() + rect.width();
- if(xMap.p1() > xMap.p2())
- qSwap(px1, px2);
-
- double sx1 = area.x();
- double sx2 = area.x() + area.width();
- if(xMap.s1() > xMap.s2())
- qSwap(sx1, sx2);
-
- int py1 = rect.y();
- int py2 = rect.y() + rect.height();
- if(yMap.p1() > yMap.p2())
- qSwap(py1, py2);
-
- double sy1 = area.y();
- double sy2 = area.y() + area.height();
- if(yMap.s1() > yMap.s2())
- qSwap(sy1, sy2);
-
- xxMap.setPaintInterval(px1, px2);
- xxMap.setScaleInterval(sx1, sx2);
- yyMap.setPaintInterval(py1, py2);
- yyMap.setScaleInterval(sy1, sy2);
- }
-
- PlotTimeRasterImage image(rect.size(), d_data->colorMap->format());
+ QwtScaleMap xxMap = xMap;
+ QwtScaleMap yyMap = yMap;
+
+ if (res.isValid()) {
+ /*
+ It is useless to render an image with a higher resolution
+ than the data offers. Of course someone will have to
+ scale this image later into the size of the given rect, but f.e.
+ in case of postscript this will done on the printer.
+ */
+ rect.setSize(rect.size().boundedTo(res));
+
+ int px1 = rect.x();
+ int px2 = rect.x() + rect.width();
+ if (xMap.p1() > xMap.p2())
+ qSwap(px1, px2);
+
+ double sx1 = area.x();
+ double sx2 = area.x() + area.width();
+ if (xMap.s1() > xMap.s2())
+ qSwap(sx1, sx2);
+
+ int py1 = rect.y();
+ int py2 = rect.y() + rect.height();
+ if (yMap.p1() > yMap.p2())
+ qSwap(py1, py2);
+
+ double sy1 = area.y();
+ double sy2 = area.y() + area.height();
+ if (yMap.s1() > yMap.s2())
+ qSwap(sy1, sy2);
+
+ xxMap.setPaintInterval(px1, px2);
+ xxMap.setScaleInterval(sx1, sx2);
+ yyMap.setPaintInterval(py1, py2);
+ yyMap.setScaleInterval(sy1, sy2);
+ }
+
+ PlotTimeRasterImage image(rect.size(), d_data->colorMap->format());
#if QWT_VERSION < 0x060000
- const QwtDoubleInterval intensityRange = d_data->data->range();
+ const QwtDoubleInterval intensityRange = d_data->data->range();
#else
- const QwtInterval intensityRange = d_data->data->interval(Qt::ZAxis);
+ const QwtInterval intensityRange = d_data->data->interval(Qt::ZAxis);
#endif
- if(!intensityRange.isValid())
- return image;
+ if (!intensityRange.isValid())
+ return image;
- d_data->data->initRaster(area, rect.size());
+ d_data->data->initRaster(area, rect.size());
- if(d_data->colorMap->format() == QwtColorMap::RGB) {
- for(int y = rect.top(); y <= rect.bottom(); y++) {
- const double ty = yyMap.invTransform(y);
+ if (d_data->colorMap->format() == QwtColorMap::RGB) {
+ for (int y = rect.top(); y <= rect.bottom(); y++) {
+ const double ty = yyMap.invTransform(y);
- QRgb *line = (QRgb *)image.scanLine(y - rect.top());
+ QRgb* line = (QRgb*)image.scanLine(y - rect.top());
- for(int x = rect.left(); x <= rect.right(); x++) {
- const double tx = xxMap.invTransform(x);
+ for (int x = rect.left(); x <= rect.right(); x++) {
+ const double tx = xxMap.invTransform(x);
- *line++ = d_data->colorMap->rgb(intensityRange,
- d_data->data->value(tx, ty));
- }
- }
- d_data->data->incrementResidual();
- }
- else if(d_data->colorMap->format() == QwtColorMap::Indexed) {
- image.setColorTable(d_data->colorMap->colorTable(intensityRange));
+ *line++ =
+ d_data->colorMap->rgb(intensityRange, d_data->data->value(tx, ty));
+ }
+ }
+ d_data->data->incrementResidual();
+ } else if (d_data->colorMap->format() == QwtColorMap::Indexed) {
+ image.setColorTable(d_data->colorMap->colorTable(intensityRange));
- for(int y = rect.top(); y <= rect.bottom(); y++) {
- const double ty = yyMap.invTransform(y);
+ for (int y = rect.top(); y <= rect.bottom(); y++) {
+ const double ty = yyMap.invTransform(y);
- unsigned char *line = image.scanLine(y - rect.top());
- for(int x = rect.left(); x <= rect.right(); x++) {
- const double tx = xxMap.invTransform(x);
+ unsigned char* line = image.scanLine(y - rect.top());
+ for (int x = rect.left(); x <= rect.right(); x++) {
+ const double tx = xxMap.invTransform(x);
- *line++ = d_data->colorMap->colorIndex(intensityRange,
- d_data->data->value(tx, ty));
- }
+ *line++ = d_data->colorMap->colorIndex(intensityRange,
+ d_data->data->value(tx, ty));
+ }
+ }
}
- }
- d_data->data->discardRaster();
+ d_data->data->discardRaster();
- // Mirror the image in case of inverted maps
+ // Mirror the image in case of inverted maps
- const bool hInvert = xxMap.p1() > xxMap.p2();
- const bool vInvert = yyMap.p1() > yyMap.p2();
- if(hInvert || vInvert) {
- image = image.mirrored(hInvert, vInvert);
- }
+ const bool hInvert = xxMap.p1() > xxMap.p2();
+ const bool vInvert = yyMap.p1() > yyMap.p2();
+ if (hInvert || vInvert) {
+ image = image.mirrored(hInvert, vInvert);
+ }
- return image;
+ return image;
}
#if QWT_VERSION < 0x060000
-QwtDoubleInterval
-PlotTimeRaster::interval(Qt::Axis ax) const
+QwtDoubleInterval PlotTimeRaster::interval(Qt::Axis ax) const
{
- return d_data->data->range();
+ return d_data->data->range();
}
#else
-QwtInterval
-PlotTimeRaster::interval(Qt::Axis ax) const
+QwtInterval PlotTimeRaster::interval(Qt::Axis ax) const
{
- return d_data->data->interval(ax);
+ return d_data->data->interval(ax);
}
#endif
@@ -342,11 +311,10 @@ PlotTimeRaster::interval(Qt::Axis ax) const
QwtPlotRasterItem::draw, drawContourLines
*/
-void PlotTimeRaster::draw(QPainter *painter,
- const QwtScaleMap &xMap,
- const QwtScaleMap &yMap,
- const QRect &canvasRect) const
+void PlotTimeRaster::draw(QPainter* painter,
+ const QwtScaleMap& xMap,
+ const QwtScaleMap& yMap,
+ const QRect& canvasRect) const
{
- QwtPlotRasterItem::draw(painter, xMap, yMap, canvasRect);
+ QwtPlotRasterItem::draw(painter, xMap, yMap, canvasRect);
}
-
diff --git a/gr-qtgui/lib/plot_waterfall.cc b/gr-qtgui/lib/plot_waterfall.cc
index ccc4b74c4b..4f9ba9ecf2 100644
--- a/gr-qtgui/lib/plot_waterfall.cc
+++ b/gr-qtgui/lib/plot_waterfall.cc
@@ -35,42 +35,34 @@
typedef QVector<QRgb> QwtColorTable;
-class PlotWaterfallImage: public QImage
+class PlotWaterfallImage : public QImage
{
// This class hides some Qt3/Qt4 API differences
public:
- PlotWaterfallImage(const QSize &size, QwtColorMap::Format format):
- QImage(size, format == QwtColorMap::RGB
- ? QImage::Format_ARGB32 : QImage::Format_Indexed8 )
- {
- }
-
- PlotWaterfallImage(const QImage &other):
- QImage(other)
- {
- }
-
- void initColorTable(const QImage& other)
- {
- setColorTable(other.colorTable());
- }
+ PlotWaterfallImage(const QSize& size, QwtColorMap::Format format)
+ : QImage(size,
+ format == QwtColorMap::RGB ? QImage::Format_ARGB32
+ : QImage::Format_Indexed8)
+ {
+ }
+
+ PlotWaterfallImage(const QImage& other) : QImage(other) {}
+
+ void initColorTable(const QImage& other) { setColorTable(other.colorTable()); }
};
class PlotWaterfall::PrivateData
{
public:
- PrivateData()
- {
- data = NULL;
- colorMap = new QwtLinearColorMap();
- }
- ~PrivateData()
- {
- delete colorMap;
- }
-
- WaterfallData *data;
- QwtColorMap *colorMap;
+ PrivateData()
+ {
+ data = NULL;
+ colorMap = new QwtLinearColorMap();
+ }
+ ~PrivateData() { delete colorMap; }
+
+ WaterfallData* data;
+ QwtColorMap* colorMap;
};
/*!
@@ -84,13 +76,13 @@ public:
\sa QwtPlotItem::setItemAttribute(), QwtPlotItem::setZ()
*/
-PlotWaterfall::PlotWaterfall(WaterfallData* data, const QString &title):
- QwtPlotRasterItem(title)
+PlotWaterfall::PlotWaterfall(WaterfallData* data, const QString& title)
+ : QwtPlotRasterItem(title)
{
d_data = new PrivateData();
d_data->data = data;
-// setCachePolicy(QwtPlotRasterItem::PaintCache);
+ // setCachePolicy(QwtPlotRasterItem::PaintCache);
setItemAttribute(QwtPlotItem::AutoScale, true);
setItemAttribute(QwtPlotItem::Legend, false);
@@ -99,20 +91,12 @@ PlotWaterfall::PlotWaterfall(WaterfallData* data, const QString &title):
}
//! Destructor
-PlotWaterfall::~PlotWaterfall()
-{
- delete d_data;
-}
+PlotWaterfall::~PlotWaterfall() { delete d_data; }
-const WaterfallData* PlotWaterfall::data()const{
- return d_data->data;
-}
+const WaterfallData* PlotWaterfall::data() const { return d_data->data; }
//! \return QwtPlotItem::Rtti_PlotSpectrogram
-int PlotWaterfall::rtti() const
-{
- return QwtPlotItem::Rtti_PlotSpectrogram;
-}
+int PlotWaterfall::rtti() const { return QwtPlotItem::Rtti_PlotSpectrogram; }
/*!
Change the color map
@@ -125,7 +109,7 @@ int PlotWaterfall::rtti() const
\sa colorMap(), QwtScaleWidget::setColorBarEnabled(),
QwtScaleWidget::setColorMap()
*/
-void PlotWaterfall::setColorMap(const QwtColorMap &colorMap)
+void PlotWaterfall::setColorMap(const QwtColorMap& colorMap)
{
delete d_data->colorMap;
#if QWT_VERSION < 0x060000
@@ -140,20 +124,14 @@ void PlotWaterfall::setColorMap(const QwtColorMap &colorMap)
\return Color Map used for mapping the intensity values to colors
\sa setColorMap()
*/
-const QwtColorMap &PlotWaterfall::colorMap() const
-{
- return *d_data->colorMap;
-}
+const QwtColorMap& PlotWaterfall::colorMap() const { return *d_data->colorMap; }
/*!
\return Bounding rect of the data
\sa QwtRasterData::boundingRect
*/
#if QWT_VERSION < 0x060000
-QwtDoubleRect PlotWaterfall::boundingRect() const
-{
- return d_data->data->boundingRect();
-}
+QwtDoubleRect PlotWaterfall::boundingRect() const { return d_data->data->boundingRect(); }
#endif
/*!
@@ -166,9 +144,9 @@ QwtDoubleRect PlotWaterfall::boundingRect() const
\return data().rasterHint(rect)
*/
#if QWT_VERSION < 0x060000
-QSize PlotWaterfall::rasterHint(const QwtDoubleRect &rect) const
+QSize PlotWaterfall::rasterHint(const QwtDoubleRect& rect) const
{
- return d_data->data->rasterHint(rect);
+ return d_data->data->rasterHint(rect);
}
#endif
@@ -190,58 +168,57 @@ QSize PlotWaterfall::rasterHint(const QwtDoubleRect &rect) const
QwtColorMap::colorIndex()
*/
#if QWT_VERSION < 0x060000
-QImage PlotWaterfall::renderImage(const QwtScaleMap &xMap,
- const QwtScaleMap &yMap,
- const QwtDoubleRect &area) const
+QImage PlotWaterfall::renderImage(const QwtScaleMap& xMap,
+ const QwtScaleMap& yMap,
+ const QwtDoubleRect& area) const
#else
-QImage PlotWaterfall::renderImage(const QwtScaleMap &xMap,
- const QwtScaleMap &yMap,
- const QRectF &area,
- const QSize &size) const
+QImage PlotWaterfall::renderImage(const QwtScaleMap& xMap,
+ const QwtScaleMap& yMap,
+ const QRectF& area,
+ const QSize& size) const
#endif
{
- if ( area.isEmpty() )
+ if (area.isEmpty())
return QImage();
#if QWT_VERSION < 0x060000
QRect rect = transform(xMap, yMap, area);
const QSize res = d_data->data->rasterHint(area);
#else
- QRect rect(0,0,0,0);
- const QSize res(0,0);
+ QRect rect(0, 0, 0, 0);
+ const QSize res(0, 0);
#endif
QwtScaleMap xxMap = xMap;
QwtScaleMap yyMap = yMap;
- if ( res.isValid() )
- {
+ if (res.isValid()) {
/*
It is useless to render an image with a higher resolution
than the data offers. Of course someone will have to
scale this image later into the size of the given rect, but f.e.
in case of postscript this will done on the printer.
- */
+ */
rect.setSize(rect.size().boundedTo(res));
int px1 = rect.x();
int px2 = rect.x() + rect.width();
- if ( xMap.p1() > xMap.p2() )
+ if (xMap.p1() > xMap.p2())
qSwap(px1, px2);
double sx1 = area.x();
double sx2 = area.x() + area.width();
- if ( xMap.s1() > xMap.s2() )
+ if (xMap.s1() > xMap.s2())
qSwap(sx1, sx2);
int py1 = rect.y();
int py2 = rect.y() + rect.height();
- if ( yMap.p1() > yMap.p2() )
+ if (yMap.p1() > yMap.p2())
qSwap(py1, py2);
double sy1 = area.y();
double sy2 = area.y() + area.height();
- if ( yMap.s1() > yMap.s2() )
+ if (yMap.s1() > yMap.s2())
qSwap(sy1, sy2);
xxMap.setPaintInterval(px1, px2);
@@ -257,42 +234,35 @@ QImage PlotWaterfall::renderImage(const QwtScaleMap &xMap,
#else
const QwtInterval intensityRange = d_data->data->interval(Qt::ZAxis);
#endif
- if ( !intensityRange.isValid() )
+ if (!intensityRange.isValid())
return image;
d_data->data->initRaster(area, rect.size());
- if ( d_data->colorMap->format() == QwtColorMap::RGB )
- {
- for ( int y = rect.top(); y <= rect.bottom(); y++ )
- {
+ if (d_data->colorMap->format() == QwtColorMap::RGB) {
+ for (int y = rect.top(); y <= rect.bottom(); y++) {
const double ty = yyMap.invTransform(y);
- QRgb *line = (QRgb *)image.scanLine(y - rect.top());
- for ( int x = rect.left(); x <= rect.right(); x++ )
- {
+ QRgb* line = (QRgb*)image.scanLine(y - rect.top());
+ for (int x = rect.left(); x <= rect.right(); x++) {
const double tx = xxMap.invTransform(x);
- *line++ = d_data->colorMap->rgb(intensityRange,
- d_data->data->value(tx, ty));
+ *line++ =
+ d_data->colorMap->rgb(intensityRange, d_data->data->value(tx, ty));
}
}
- }
- else if ( d_data->colorMap->format() == QwtColorMap::Indexed )
- {
+ } else if (d_data->colorMap->format() == QwtColorMap::Indexed) {
image.setColorTable(d_data->colorMap->colorTable(intensityRange));
- for ( int y = rect.top(); y <= rect.bottom(); y++ )
- {
+ for (int y = rect.top(); y <= rect.bottom(); y++) {
const double ty = yyMap.invTransform(y);
- unsigned char *line = image.scanLine(y - rect.top());
- for ( int x = rect.left(); x <= rect.right(); x++ )
- {
+ unsigned char* line = image.scanLine(y - rect.top());
+ for (int x = rect.left(); x <= rect.right(); x++) {
const double tx = xxMap.invTransform(x);
*line++ = d_data->colorMap->colorIndex(intensityRange,
- d_data->data->value(tx, ty));
+ d_data->data->value(tx, ty));
}
}
}
@@ -303,9 +273,8 @@ QImage PlotWaterfall::renderImage(const QwtScaleMap &xMap,
const bool hInvert = xxMap.p1() > xxMap.p2();
const bool vInvert = yyMap.p1() < yyMap.p2();
- if ( hInvert || vInvert )
- {
- image = image.mirrored(hInvert, vInvert);
+ if (hInvert || vInvert) {
+ image = image.mirrored(hInvert, vInvert);
}
return image;
@@ -323,11 +292,10 @@ QImage PlotWaterfall::renderImage(const QwtScaleMap &xMap,
QwtPlotRasterItem::draw, drawContourLines
*/
-void PlotWaterfall::draw(QPainter *painter,
- const QwtScaleMap &xMap,
- const QwtScaleMap &yMap,
- const QRect &canvasRect) const
+void PlotWaterfall::draw(QPainter* painter,
+ const QwtScaleMap& xMap,
+ const QwtScaleMap& yMap,
+ const QRect& canvasRect) const
{
QwtPlotRasterItem::draw(painter, xMap, yMap, canvasRect);
}
-
diff --git a/gr-qtgui/lib/qtgui_util.cc b/gr-qtgui/lib/qtgui_util.cc
index 4201022f40..3432ad302f 100644
--- a/gr-qtgui/lib/qtgui_util.cc
+++ b/gr-qtgui/lib/qtgui_util.cc
@@ -29,36 +29,33 @@
#include <QCoreApplication>
#include <qapplication.h>
-QString
-get_qt_style_sheet(QString filename)
+QString get_qt_style_sheet(QString filename)
{
- QString sstext;
- QFile ss(filename);
- if(!ss.open(QIODevice::ReadOnly | QIODevice::Text)) {
- return sstext;
- }
+ QString sstext;
+ QFile ss(filename);
+ if (!ss.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ return sstext;
+ }
- QTextStream sstream(&ss);
- while(!sstream.atEnd()) {
- sstext += sstream.readLine();
- }
- ss.close();
+ QTextStream sstream(&ss);
+ while (!sstream.atEnd()) {
+ sstext += sstream.readLine();
+ }
+ ss.close();
- return sstext;
+ return sstext;
}
QwtPickerDblClickPointMachine::QwtPickerDblClickPointMachine()
#if QWT_VERSION < 0x060000
- : QwtPickerMachine ()
+ : QwtPickerMachine()
#else
- : QwtPickerMachine (PointSelection)
+ : QwtPickerMachine(PointSelection)
#endif
{
}
-QwtPickerDblClickPointMachine::~QwtPickerDblClickPointMachine()
-{
-}
+QwtPickerDblClickPointMachine::~QwtPickerDblClickPointMachine() {}
#if QWT_VERSION < 0x060000
#define CMDLIST_TYPE QwtPickerMachine::CommandList
@@ -66,52 +63,49 @@ QwtPickerDblClickPointMachine::~QwtPickerDblClickPointMachine()
#define CMDLIST_TYPE QList<QwtPickerMachine::Command>
#endif
CMDLIST_TYPE
-QwtPickerDblClickPointMachine::transition(const QwtEventPattern &eventPattern,
- const QEvent *e)
+QwtPickerDblClickPointMachine::transition(const QwtEventPattern& eventPattern,
+ const QEvent* e)
{
- CMDLIST_TYPE cmdList;
- switch(e->type()) {
+ CMDLIST_TYPE cmdList;
+ switch (e->type()) {
case QEvent::MouseButtonDblClick:
- if ( eventPattern.mouseMatch(QwtEventPattern::MouseSelect1,
- (const QMouseEvent *)e) ) {
- cmdList += QwtPickerMachine::Begin;
- cmdList += QwtPickerMachine::Append;
- cmdList += QwtPickerMachine::End;
- }
- break;
- default:
- break;
- }
- return cmdList;
+ if (eventPattern.mouseMatch(QwtEventPattern::MouseSelect1,
+ (const QMouseEvent*)e)) {
+ cmdList += QwtPickerMachine::Begin;
+ cmdList += QwtPickerMachine::Append;
+ cmdList += QwtPickerMachine::End;
+ }
+ break;
+ default:
+ break;
+ }
+ return cmdList;
}
#if QWT_VERSION < 0x060100
QwtDblClickPlotPicker::QwtDblClickPlotPicker(QwtPlotCanvas* canvas)
-#else /* QWT_VERSION < 0x060100 */
+#else /* QWT_VERSION < 0x060100 */
QwtDblClickPlotPicker::QwtDblClickPlotPicker(QWidget* canvas)
#endif /* QWT_VERSION < 0x060100 */
- : QwtPlotPicker(canvas)
+ : QwtPlotPicker(canvas)
{
#if QWT_VERSION < 0x060000
- setSelectionFlags(QwtPicker::PointSelection);
+ setSelectionFlags(QwtPicker::PointSelection);
#endif
}
-QwtDblClickPlotPicker::~QwtDblClickPlotPicker()
-{
-}
+QwtDblClickPlotPicker::~QwtDblClickPlotPicker() {}
-QwtPickerMachine*
-QwtDblClickPlotPicker::stateMachine(int n) const
+QwtPickerMachine* QwtDblClickPlotPicker::stateMachine(int n) const
{
- return new QwtPickerDblClickPointMachine;
+ return new QwtPickerDblClickPointMachine;
}
-void check_set_qss(QApplication *app){
- std::string qssfile = gr::prefs::singleton()->get_string("qtgui","qss","");
- if(qssfile.size() > 0) {
+void check_set_qss(QApplication* app)
+{
+ std::string qssfile = gr::prefs::singleton()->get_string("qtgui", "qss", "");
+ if (qssfile.size() > 0) {
QString sstext = get_qt_style_sheet(QString(qssfile.c_str()));
app->setStyleSheet(sstext);
- }
+ }
}
-
diff --git a/gr-qtgui/lib/sink_c_impl.cc b/gr-qtgui/lib/sink_c_impl.cc
index 2cabbee058..0caa2f0782 100644
--- a/gr-qtgui/lib/sink_c_impl.cc
+++ b/gr-qtgui/lib/sink_c_impl.cc
@@ -34,376 +34,345 @@
#include <string.h>
namespace gr {
- namespace qtgui {
-
- sink_c::sptr
- sink_c::make(int fftsize, int wintype,
- double fc, double bw,
- const std::string &name,
- bool plotfreq, bool plotwaterfall,
- bool plottime, bool plotconst,
- QWidget *parent)
- {
- return gnuradio::get_initial_sptr
- (new sink_c_impl(fftsize, wintype,
- fc, bw, name,
- plotfreq, plotwaterfall,
- plottime, plotconst,
- parent));
- }
+namespace qtgui {
+
+sink_c::sptr sink_c::make(int fftsize,
+ int wintype,
+ double fc,
+ double bw,
+ const std::string& name,
+ bool plotfreq,
+ bool plotwaterfall,
+ bool plottime,
+ bool plotconst,
+ QWidget* parent)
+{
+ return gnuradio::get_initial_sptr(new sink_c_impl(fftsize,
+ wintype,
+ fc,
+ bw,
+ name,
+ plotfreq,
+ plotwaterfall,
+ plottime,
+ plotconst,
+ parent));
+}
- sink_c_impl::sink_c_impl(int fftsize, int wintype,
- double fc, double bw,
- const std::string &name,
- bool plotfreq, bool plotwaterfall,
- bool plottime, bool plotconst,
- QWidget *parent)
- : block("sink_c",
- io_signature::make(1, -1, sizeof(gr_complex)),
- io_signature::make(0, 0, 0)),
- d_fftsize(fftsize),
- d_wintype((filter::firdes::win_type)(wintype)),
- d_center_freq(fc), d_bandwidth(bw), d_name(name),
- d_port(pmt::mp("freq")),
- d_plotfreq(plotfreq), d_plotwaterfall(plotwaterfall),
- d_plottime(plottime), d_plotconst(plotconst),
- d_parent(parent)
- {
- // Required now for Qt; argc must be greater than 0 and argv
- // must have at least one valid character. Must be valid through
- // life of the qApplication:
- // http://harmattan-dev.nokia.com/docs/library/html/qt4/qapplication.html
- d_argc = 1;
- d_argv = new char;
- d_argv[0] = '\0';
-
- // setup output message port to post frequency when display is
- // double-clicked
- message_port_register_out(d_port);
- message_port_register_in(d_port);
- set_msg_handler(d_port,
- boost::bind(&sink_c_impl::handle_set_freq, this, _1));
-
- d_main_gui = NULL;
-
- // Perform fftshift operation;
- // this is usually desired when plotting
- d_shift = true;
-
- d_fft = new fft::fft_complex(d_fftsize, true);
-
- d_index = 0;
- d_residbuf = (gr_complex*)volk_malloc(d_fftsize*sizeof(gr_complex),
- volk_get_alignment());
- d_magbuf = (float*)volk_malloc(d_fftsize*sizeof(float),
- volk_get_alignment());
-
- buildwindow();
-
- initialize();
- }
+sink_c_impl::sink_c_impl(int fftsize,
+ int wintype,
+ double fc,
+ double bw,
+ const std::string& name,
+ bool plotfreq,
+ bool plotwaterfall,
+ bool plottime,
+ bool plotconst,
+ QWidget* parent)
+ : block("sink_c",
+ io_signature::make(1, -1, sizeof(gr_complex)),
+ io_signature::make(0, 0, 0)),
+ d_fftsize(fftsize),
+ d_wintype((filter::firdes::win_type)(wintype)),
+ d_center_freq(fc),
+ d_bandwidth(bw),
+ d_name(name),
+ d_port(pmt::mp("freq")),
+ d_plotfreq(plotfreq),
+ d_plotwaterfall(plotwaterfall),
+ d_plottime(plottime),
+ d_plotconst(plotconst),
+ d_parent(parent)
+{
+ // Required now for Qt; argc must be greater than 0 and argv
+ // must have at least one valid character. Must be valid through
+ // life of the qApplication:
+ // http://harmattan-dev.nokia.com/docs/library/html/qt4/qapplication.html
+ d_argc = 1;
+ d_argv = new char;
+ d_argv[0] = '\0';
+
+ // setup output message port to post frequency when display is
+ // double-clicked
+ message_port_register_out(d_port);
+ message_port_register_in(d_port);
+ set_msg_handler(d_port, boost::bind(&sink_c_impl::handle_set_freq, this, _1));
+
+ d_main_gui = NULL;
+
+ // Perform fftshift operation;
+ // this is usually desired when plotting
+ d_shift = true;
+
+ d_fft = new fft::fft_complex(d_fftsize, true);
+
+ d_index = 0;
+ d_residbuf =
+ (gr_complex*)volk_malloc(d_fftsize * sizeof(gr_complex), volk_get_alignment());
+ d_magbuf = (float*)volk_malloc(d_fftsize * sizeof(float), volk_get_alignment());
+
+ buildwindow();
+
+ initialize();
+}
- sink_c_impl::~sink_c_impl()
- {
- delete d_main_gui;
- delete d_fft;
- delete d_argv;
- volk_free(d_residbuf);
- volk_free(d_magbuf);
- }
+sink_c_impl::~sink_c_impl()
+{
+ delete d_main_gui;
+ delete d_fft;
+ delete d_argv;
+ volk_free(d_residbuf);
+ volk_free(d_magbuf);
+}
- bool
- sink_c_impl::check_topology(int ninputs, int noutputs)
- {
- return ninputs == 1;
- }
+bool sink_c_impl::check_topology(int ninputs, int noutputs) { return ninputs == 1; }
- void
- sink_c_impl::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_fftsize, 8191);
- }
+void sink_c_impl::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_fftsize, 8191);
}
+}
- void
- sink_c_impl::initialize()
- {
- if(qApp != NULL) {
- d_qApplication = qApp;
- }
- else {
+void sink_c_impl::initialize()
+{
+ if (qApp != NULL) {
+ d_qApplication = qApp;
+ } else {
#if QT_VERSION >= 0x040500 && QT_VERSION < 0x050000
std::string style = prefs::singleton()->get_string("qtgui", "style", "raster");
QApplication::setGraphicsSystem(QString(style.c_str()));
#endif
- d_qApplication = new QApplication(d_argc, &d_argv);
- }
+ d_qApplication = new QApplication(d_argc, &d_argv);
+ }
- // If a style sheet is set in the prefs file, enable it here.
- check_set_qss(d_qApplication);
+ // If a style sheet is set in the prefs file, enable it here.
+ check_set_qss(d_qApplication);
- if(d_center_freq < 0) {
- throw std::runtime_error("sink_c_impl: Received bad center frequency.\n");
- }
+ if (d_center_freq < 0) {
+ throw std::runtime_error("sink_c_impl: Received bad center frequency.\n");
+ }
- uint64_t maxBufferSize = 32768;
- d_main_gui = new SpectrumGUIClass(maxBufferSize, d_fftsize,
- d_center_freq,
- -d_bandwidth,
- d_bandwidth);
+ uint64_t maxBufferSize = 32768;
+ d_main_gui = new SpectrumGUIClass(
+ maxBufferSize, d_fftsize, d_center_freq, -d_bandwidth, d_bandwidth);
- d_main_gui->setDisplayTitle(d_name);
- d_main_gui->setWindowType((int)d_wintype);
- set_fft_size(d_fftsize);
+ d_main_gui->setDisplayTitle(d_name);
+ d_main_gui->setWindowType((int)d_wintype);
+ set_fft_size(d_fftsize);
- d_main_gui->openSpectrumWindow(d_parent,
- d_plotfreq, d_plotwaterfall,
- d_plottime, d_plotconst);
+ d_main_gui->openSpectrumWindow(
+ d_parent, d_plotfreq, d_plotwaterfall, d_plottime, d_plotconst);
- // initialize update time to 10 times a second
- set_update_time(0.5);
+ // initialize update time to 10 times a second
+ set_update_time(0.5);
- d_last_update = gr::high_res_timer_now();
- d_update_active = false;
- }
+ d_last_update = gr::high_res_timer_now();
+ d_update_active = false;
+}
- void
- sink_c_impl::exec_()
- {
- d_qApplication->exec();
- }
+void sink_c_impl::exec_() { d_qApplication->exec(); }
- QWidget*
- sink_c_impl::qwidget()
- {
- return d_main_gui->qwidget();
- }
+QWidget* sink_c_impl::qwidget() { return d_main_gui->qwidget(); }
#ifdef ENABLE_PYTHON
- PyObject*
- sink_c_impl::pyqwidget()
- {
- PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui->qwidget());
- PyObject *retarg = Py_BuildValue("N", w);
- return retarg;
- }
+PyObject* sink_c_impl::pyqwidget()
+{
+ PyObject* w = PyLong_FromVoidPtr((void*)d_main_gui->qwidget());
+ PyObject* retarg = Py_BuildValue("N", w);
+ return retarg;
+}
#else
- void *
- sink_c_impl::pyqwidget()
- {
- return NULL;
- }
+void* sink_c_impl::pyqwidget() { return NULL; }
#endif
- void
- sink_c_impl::set_fft_size(const int fftsize)
- {
- d_fftsize = fftsize;
- d_main_gui->setFFTSize(fftsize);
- }
+void sink_c_impl::set_fft_size(const int fftsize)
+{
+ d_fftsize = fftsize;
+ d_main_gui->setFFTSize(fftsize);
+}
- int
- sink_c_impl::fft_size() const
- {
- return d_fftsize;
- }
+int sink_c_impl::fft_size() const { return d_fftsize; }
- void
- sink_c_impl::set_frequency_range(const double centerfreq,
- const double bandwidth)
- {
- d_center_freq = centerfreq;
- d_bandwidth = bandwidth;
- d_main_gui->setFrequencyRange(d_center_freq,
- -d_bandwidth,
- d_bandwidth);
- }
+void sink_c_impl::set_frequency_range(const double centerfreq, const double bandwidth)
+{
+ d_center_freq = centerfreq;
+ d_bandwidth = bandwidth;
+ d_main_gui->setFrequencyRange(d_center_freq, -d_bandwidth, d_bandwidth);
+}
- void
- sink_c_impl::set_fft_power_db(double min, double max)
- {
- d_main_gui->setFrequencyAxis(min, max);
- }
+void sink_c_impl::set_fft_power_db(double min, double max)
+{
+ d_main_gui->setFrequencyAxis(min, max);
+}
- void
- sink_c_impl::enable_rf_freq(bool en)
- {
- d_main_gui->enableRFFreq(en);
- }
+void sink_c_impl::enable_rf_freq(bool en) { d_main_gui->enableRFFreq(en); }
- /*
- void
- sink_c_impl::set_time_domain_axis(double min, double max)
- {
- d_main_gui->setTimeDomainAxis(min, max);
- }
+/*
+void
+sink_c_impl::set_time_domain_axis(double min, double max)
+{
+ d_main_gui->setTimeDomainAxis(min, max);
+}
- void
- sink_c_impl::set_constellation_axis(double xmin, double xmax,
- double ymin, double ymax)
- {
- d_main_gui->setConstellationAxis(xmin, xmax, ymin, ymax);
- }
+void
+sink_c_impl::set_constellation_axis(double xmin, double xmax,
+ double ymin, double ymax)
+{
+ d_main_gui->setConstellationAxis(xmin, xmax, ymin, ymax);
+}
- void
- sink_c_impl::set_constellation_pen_size(int size)
- {
- d_main_gui->setConstellationPenSize(size);
- }
- */
+void
+sink_c_impl::set_constellation_pen_size(int size)
+{
+ d_main_gui->setConstellationPenSize(size);
+}
+*/
+
+void sink_c_impl::set_update_time(double t)
+{
+ d_update_time = t * gr::high_res_timer_tps();
+ d_main_gui->setUpdateTime(t);
+}
- void
- sink_c_impl::set_update_time(double t)
- {
- d_update_time = t * gr::high_res_timer_tps();
- d_main_gui->setUpdateTime(t);
+void sink_c_impl::fft(float* data_out, const gr_complex* data_in, int size)
+{
+ if (d_window.size()) {
+ volk_32fc_32f_multiply_32fc(d_fft->get_inbuf(), data_in, &d_window.front(), size);
+ } else {
+ memcpy(d_fft->get_inbuf(), data_in, sizeof(gr_complex) * size);
}
- void
- sink_c_impl::fft(float *data_out, const gr_complex *data_in, int size)
- {
- if (d_window.size()) {
- volk_32fc_32f_multiply_32fc(d_fft->get_inbuf(), data_in,
- &d_window.front(), size);
- }
- else {
- memcpy (d_fft->get_inbuf(), data_in, sizeof(gr_complex)*size);
- }
-
- d_fft->execute (); // compute the fft
- volk_32fc_s32f_x2_power_spectral_density_32f(data_out, d_fft->get_outbuf(),
- size, 1.0, size);
+ d_fft->execute(); // compute the fft
+ volk_32fc_s32f_x2_power_spectral_density_32f(
+ data_out, d_fft->get_outbuf(), size, 1.0, size);
}
- void
- sink_c_impl::windowreset()
- {
- filter::firdes::win_type newwintype;
- newwintype = (filter::firdes::win_type)d_main_gui->getWindowType();
- if(d_wintype != newwintype) {
- d_wintype = newwintype;
- buildwindow();
- }
+void sink_c_impl::windowreset()
+{
+ filter::firdes::win_type newwintype;
+ newwintype = (filter::firdes::win_type)d_main_gui->getWindowType();
+ if (d_wintype != newwintype) {
+ d_wintype = newwintype;
+ buildwindow();
}
+}
- void
- sink_c_impl::buildwindow()
- {
- d_window.clear();
- if(d_wintype != 0) {
- d_window = filter::firdes::window(d_wintype, d_fftsize, 6.76);
- }
+void sink_c_impl::buildwindow()
+{
+ d_window.clear();
+ if (d_wintype != 0) {
+ d_window = filter::firdes::window(d_wintype, d_fftsize, 6.76);
}
+}
- void
- sink_c_impl::fftresize()
- {
- int newfftsize = d_main_gui->getFFTSize();
+void sink_c_impl::fftresize()
+{
+ int newfftsize = d_main_gui->getFFTSize();
- if(newfftsize != d_fftsize) {
+ if (newfftsize != d_fftsize) {
- // Resize residbuf and replace data
+ // Resize residbuf and replace data
volk_free(d_residbuf);
- d_residbuf = (gr_complex*)volk_malloc(newfftsize*sizeof(gr_complex),
+ d_residbuf = (gr_complex*)volk_malloc(newfftsize * sizeof(gr_complex),
volk_get_alignment());
volk_free(d_magbuf);
- d_magbuf = (float*)volk_malloc(newfftsize*sizeof(float),
- volk_get_alignment());
+ d_magbuf = (float*)volk_malloc(newfftsize * sizeof(float), volk_get_alignment());
- // Set new fft size and reset buffer index
- // (throws away any currently held data, but who cares?)
- d_fftsize = newfftsize;
- d_index = 0;
+ // Set new fft size and reset buffer index
+ // (throws away any currently held data, but who cares?)
+ d_fftsize = newfftsize;
+ d_index = 0;
- // Reset window to reflect new size
- buildwindow();
+ // Reset window to reflect new size
+ buildwindow();
- // Reset FFTW plan for new size
- delete d_fft;
- d_fft = new fft::fft_complex (d_fftsize, true);
- }
+ // Reset FFTW plan for new size
+ delete d_fft;
+ d_fft = new fft::fft_complex(d_fftsize, true);
}
+}
- void
- sink_c_impl::check_clicked()
- {
- if(d_main_gui->checkClicked()) {
+void sink_c_impl::check_clicked()
+{
+ if (d_main_gui->checkClicked()) {
double freq = d_main_gui->getClickedFreq();
- message_port_pub(d_port,
- pmt::cons(d_port,
- pmt::from_double(freq)));
- }
+ message_port_pub(d_port, pmt::cons(d_port, pmt::from_double(freq)));
}
+}
- void
- sink_c_impl::handle_set_freq(pmt::pmt_t msg)
- {
- if(pmt::is_pair(msg)) {
+void sink_c_impl::handle_set_freq(pmt::pmt_t msg)
+{
+ if (pmt::is_pair(msg)) {
pmt::pmt_t x = pmt::cdr(msg);
- if(pmt::is_real(x)) {
- d_center_freq = pmt::to_double(x);
- set_frequency_range(d_center_freq, d_bandwidth);
+ if (pmt::is_real(x)) {
+ d_center_freq = pmt::to_double(x);
+ set_frequency_range(d_center_freq, d_bandwidth);
}
- }
}
+}
- int
- sink_c_impl::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];
-
- // Update the FFT size from the application
- fftresize();
- windowreset();
- check_clicked();
-
- for(int i=0; i < noutput_items; i+=d_fftsize) {
- unsigned int datasize = noutput_items - i;
- unsigned int resid = d_fftsize-d_index;
-
- if (!d_update_active && (gr::high_res_timer_now() - d_last_update) < d_update_time) {
- consume_each(noutput_items);
- return noutput_items;
- }
- else {
- d_last_update = gr::high_res_timer_now();
- d_update_active = true;
- }
-
- // If we have enough input for one full FFT, do it
- if(datasize >= resid) {
- const gr::high_res_timer_type currentTime = gr::high_res_timer_now();
-
- // 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;
- fft(d_magbuf, d_residbuf, d_fftsize);
-
- d_main_gui->updateWindow(true, d_magbuf, d_fftsize,
- NULL, 0, (float*)d_residbuf, d_fftsize,
- currentTime, true);
- d_update_active = false;
- }
- // 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;
+int sink_c_impl::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];
+
+ // Update the FFT size from the application
+ fftresize();
+ windowreset();
+ check_clicked();
+
+ for (int i = 0; i < noutput_items; i += d_fftsize) {
+ unsigned int datasize = noutput_items - i;
+ unsigned int resid = d_fftsize - d_index;
+
+ if (!d_update_active &&
+ (gr::high_res_timer_now() - d_last_update) < d_update_time) {
+ consume_each(noutput_items);
+ return noutput_items;
+ } else {
+ d_last_update = gr::high_res_timer_now();
+ d_update_active = true;
+ }
+
+ // If we have enough input for one full FFT, do it
+ if (datasize >= resid) {
+ const gr::high_res_timer_type currentTime = gr::high_res_timer_now();
+
+ // 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;
+ fft(d_magbuf, d_residbuf, d_fftsize);
+
+ d_main_gui->updateWindow(true,
+ d_magbuf,
+ d_fftsize,
+ NULL,
+ 0,
+ (float*)d_residbuf,
+ d_fftsize,
+ currentTime,
+ true);
+ d_update_active = false;
+ }
+ // 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;
+ }
}
- } /* namespace qtgui */
+ consume_each(j);
+ return j;
+}
+
+} /* namespace qtgui */
} /* namespace gr */
diff --git a/gr-qtgui/lib/sink_c_impl.h b/gr-qtgui/lib/sink_c_impl.h
index 6531478403..a016a1404f 100644
--- a/gr-qtgui/lib/sink_c_impl.h
+++ b/gr-qtgui/lib/sink_c_impl.h
@@ -31,94 +31,97 @@
#include <gnuradio/qtgui/SpectrumGUIClass.h>
namespace gr {
- namespace qtgui {
-
- class QTGUI_API sink_c_impl : public sink_c
- {
- private:
- void forecast(int noutput_items, gr_vector_int &ninput_items_required);
-
- void initialize();
-
- int d_fftsize;
- filter::firdes::win_type d_wintype;
- std::vector<float> d_window;
- double d_center_freq;
- double d_bandwidth;
- std::string d_name;
- gr::high_res_timer_type d_last_update;
- bool d_update_active;
-
- const pmt::pmt_t d_port;
-
- bool d_shift;
- fft::fft_complex *d_fft;
-
- int d_index;
- gr_complex *d_residbuf;
- float *d_magbuf;
-
- bool d_plotfreq, d_plotwaterfall, d_plottime, d_plotconst;
-
- gr::high_res_timer_type d_update_time;
-
- int d_argc;
- char *d_argv;
- QWidget *d_parent;
- SpectrumGUIClass *d_main_gui;
-
- void windowreset();
- void buildwindow();
- void fftresize();
- void check_clicked();
- void fft(float *data_out, const gr_complex *data_in, int size);
-
- // Handles message input port for setting new center frequency.
- // The message is a PMT pair (intern('freq'), double(frequency)).
- void handle_set_freq(pmt::pmt_t msg);
-
- public:
- sink_c_impl(int fftsize, int wintype,
- double fc, double bw,
- const std::string &name,
- bool plotfreq, bool plotwaterfall,
- bool plottime, bool plotconst,
- QWidget *parent);
- ~sink_c_impl();
-
- bool check_topology(int ninputs, int noutputs);
-
- void exec_();
- QWidget* qwidget();
+namespace qtgui {
+
+class QTGUI_API sink_c_impl : public sink_c
+{
+private:
+ void forecast(int noutput_items, gr_vector_int& ninput_items_required);
+
+ void initialize();
+
+ int d_fftsize;
+ filter::firdes::win_type d_wintype;
+ std::vector<float> d_window;
+ double d_center_freq;
+ double d_bandwidth;
+ std::string d_name;
+ gr::high_res_timer_type d_last_update;
+ bool d_update_active;
+
+ const pmt::pmt_t d_port;
+
+ bool d_shift;
+ fft::fft_complex* d_fft;
+
+ int d_index;
+ gr_complex* d_residbuf;
+ float* d_magbuf;
+
+ bool d_plotfreq, d_plotwaterfall, d_plottime, d_plotconst;
+
+ gr::high_res_timer_type d_update_time;
+
+ int d_argc;
+ char* d_argv;
+ QWidget* d_parent;
+ SpectrumGUIClass* d_main_gui;
+
+ void windowreset();
+ void buildwindow();
+ void fftresize();
+ void check_clicked();
+ void fft(float* data_out, const gr_complex* data_in, int size);
+
+ // Handles message input port for setting new center frequency.
+ // The message is a PMT pair (intern('freq'), double(frequency)).
+ void handle_set_freq(pmt::pmt_t msg);
+
+public:
+ sink_c_impl(int fftsize,
+ int wintype,
+ double fc,
+ double bw,
+ const std::string& name,
+ bool plotfreq,
+ bool plotwaterfall,
+ bool plottime,
+ bool plotconst,
+ QWidget* parent);
+ ~sink_c_impl();
+
+ bool check_topology(int ninputs, int noutputs);
+
+ void exec_();
+ QWidget* qwidget();
#ifdef ENABLE_PYTHON
- PyObject* pyqwidget();
+ PyObject* pyqwidget();
#else
- void* pyqwidget();
+ void* pyqwidget();
#endif
- void set_fft_size(const int fftsize);
- int fft_size() const;
+ void set_fft_size(const int fftsize);
+ int fft_size() const;
- void set_frequency_range(const double centerfreq,
- const double bandwidth);
- void set_fft_power_db(double min, double max);
- void enable_rf_freq(bool en);
+ void set_frequency_range(const double centerfreq, const double bandwidth);
+ void set_fft_power_db(double min, double max);
+ void enable_rf_freq(bool en);
- //void set_time_domain_axis(double min, double max);
- //void set_constellation_axis(double xmin, double xmax,
- // double ymin, double ymax);
- //void set_constellation_pen_size(int size);
+ // void set_time_domain_axis(double min, double max);
+ // void set_constellation_axis(double xmin, double xmax,
+ // double ymin, double ymax);
+ // void set_constellation_pen_size(int size);
- void set_update_time(double t);
+ void set_update_time(double t);
- int general_work(int noutput_items,
- gr_vector_int &ninput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
+ int general_work(int noutput_items,
+ gr_vector_int& ninput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace qtgui */
+} /* namespace qtgui */
} /* namespace gr */
#endif /* INCLUDED_QTGUI_SINK_C_IMPL_H */
diff --git a/gr-qtgui/lib/sink_f_impl.cc b/gr-qtgui/lib/sink_f_impl.cc
index 6f152b5f90..635e293a0f 100644
--- a/gr-qtgui/lib/sink_f_impl.cc
+++ b/gr-qtgui/lib/sink_f_impl.cc
@@ -34,361 +34,329 @@
#include <string.h>
namespace gr {
- namespace qtgui {
-
- sink_f::sptr
- sink_f::make(int fftsize, int wintype,
- double fc, double bw,
- const std::string &name,
- bool plotfreq, bool plotwaterfall,
- bool plottime, bool plotconst,
- QWidget *parent)
- {
- return gnuradio::get_initial_sptr
- (new sink_f_impl(fftsize, wintype,
- fc, bw, name,
- plotfreq, plotwaterfall,
- plottime, plotconst,
- parent));
+namespace qtgui {
+
+sink_f::sptr sink_f::make(int fftsize,
+ int wintype,
+ double fc,
+ double bw,
+ const std::string& name,
+ bool plotfreq,
+ bool plotwaterfall,
+ bool plottime,
+ bool plotconst,
+ QWidget* parent)
+{
+ return gnuradio::get_initial_sptr(new sink_f_impl(fftsize,
+ wintype,
+ fc,
+ bw,
+ name,
+ plotfreq,
+ plotwaterfall,
+ plottime,
+ plotconst,
+ parent));
+}
+
+sink_f_impl::sink_f_impl(int fftsize,
+ int wintype,
+ double fc,
+ double bw,
+ const std::string& name,
+ bool plotfreq,
+ bool plotwaterfall,
+ bool plottime,
+ bool plotconst,
+ QWidget* parent)
+ : block(
+ "sink_f", io_signature::make(1, 1, sizeof(float)), io_signature::make(0, 0, 0)),
+ d_fftsize(fftsize),
+ d_wintype((filter::firdes::win_type)(wintype)),
+ d_center_freq(fc),
+ d_bandwidth(bw),
+ d_name(name),
+ d_port(pmt::mp("freq")),
+ d_plotfreq(plotfreq),
+ d_plotwaterfall(plotwaterfall),
+ d_plottime(plottime),
+ d_plotconst(plotconst),
+ d_parent(parent)
+{
+ // Required now for Qt; argc must be greater than 0 and argv
+ // must have at least one valid character. Must be valid through
+ // life of the qApplication:
+ // http://harmattan-dev.nokia.com/docs/library/html/qt4/qapplication.html
+ d_argc = 1;
+ d_argv = new char;
+ d_argv[0] = '\0';
+
+ // setup output message port to post frequency when display is
+ // double-clicked
+ message_port_register_out(d_port);
+ message_port_register_in(d_port);
+ set_msg_handler(d_port, boost::bind(&sink_f_impl::handle_set_freq, this, _1));
+
+ d_main_gui = NULL;
+
+ // Perform fftshift operation;
+ // this is usually desired when plotting
+ d_shift = true;
+
+ d_fft = new fft::fft_complex(d_fftsize, true);
+
+ d_index = 0;
+ d_residbuf = (float*)volk_malloc(d_fftsize * sizeof(float), volk_get_alignment());
+ d_magbuf = (float*)volk_malloc(d_fftsize * sizeof(float), volk_get_alignment());
+
+ buildwindow();
+
+ initialize();
+}
+
+sink_f_impl::~sink_f_impl()
+{
+ delete d_main_gui;
+ delete d_fft;
+ delete d_argv;
+ volk_free(d_residbuf);
+ volk_free(d_magbuf);
+}
+
+bool sink_f_impl::check_topology(int ninputs, int noutputs) { return ninputs == 1; }
+
+void sink_f_impl::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_fftsize, 8191);
}
+}
- sink_f_impl::sink_f_impl(int fftsize, int wintype,
- double fc, double bw,
- const std::string &name,
- bool plotfreq, bool plotwaterfall,
- bool plottime, bool plotconst,
- QWidget *parent)
- : block("sink_f",
- io_signature::make(1, 1, sizeof(float)),
- io_signature::make (0, 0, 0)),
- d_fftsize(fftsize),
- d_wintype((filter::firdes::win_type)(wintype)),
- d_center_freq(fc), d_bandwidth(bw), d_name(name),
- d_port(pmt::mp("freq")),
- d_plotfreq(plotfreq), d_plotwaterfall(plotwaterfall),
- d_plottime(plottime), d_plotconst(plotconst),
- d_parent(parent)
- {
- // Required now for Qt; argc must be greater than 0 and argv
- // must have at least one valid character. Must be valid through
- // life of the qApplication:
- // http://harmattan-dev.nokia.com/docs/library/html/qt4/qapplication.html
- d_argc = 1;
- d_argv = new char;
- d_argv[0] = '\0';
-
- // setup output message port to post frequency when display is
- // double-clicked
- message_port_register_out(d_port);
- message_port_register_in(d_port);
- set_msg_handler(d_port,
- boost::bind(&sink_f_impl::handle_set_freq, this, _1));
-
- d_main_gui = NULL;
-
- // Perform fftshift operation;
- // this is usually desired when plotting
- d_shift = true;
-
- d_fft = new fft::fft_complex(d_fftsize, true);
-
- d_index = 0;
- d_residbuf = (float*)volk_malloc(d_fftsize*sizeof(float),
- volk_get_alignment());
- d_magbuf = (float*)volk_malloc(d_fftsize*sizeof(float),
- volk_get_alignment());
-
- buildwindow();
-
- initialize();
- }
-
- sink_f_impl::~sink_f_impl()
- {
- delete d_main_gui;
- delete d_fft;
- delete d_argv;
- volk_free(d_residbuf);
- volk_free(d_magbuf);
- }
-
- bool
- sink_f_impl::check_topology(int ninputs, int noutputs)
- {
- return ninputs == 1;
- }
-
- void
- sink_f_impl::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_fftsize, 8191);
- }
- }
-
- void
- sink_f_impl::initialize()
- {
- if(qApp != NULL) {
- d_qApplication = qApp;
- }
- else {
+void sink_f_impl::initialize()
+{
+ if (qApp != NULL) {
+ d_qApplication = qApp;
+ } else {
#if QT_VERSION >= 0x040500 && QT_VERSION < 0x050000
std::string style = prefs::singleton()->get_string("qtgui", "style", "raster");
QApplication::setGraphicsSystem(QString(style.c_str()));
#endif
- d_qApplication = new QApplication(d_argc, &d_argv);
- }
-
- // If a style sheet is set in the prefs file, enable it here.
- check_set_qss(d_qApplication);
-
- uint64_t maxBufferSize = 32768;
- d_main_gui = new SpectrumGUIClass(maxBufferSize, d_fftsize,
- d_center_freq,
- -d_bandwidth,
- d_bandwidth);
- d_main_gui->setDisplayTitle(d_name);
- d_main_gui->setWindowType((int)d_wintype);
- set_fft_size(d_fftsize);
-
- d_main_gui->openSpectrumWindow(d_parent,
- d_plotfreq, d_plotwaterfall,
- d_plottime, d_plotconst);
-
- // initialize update time to 10 times a second
- set_update_time(0.1);
+ d_qApplication = new QApplication(d_argc, &d_argv);
}
- void
- sink_f_impl::exec_()
- {
- d_qApplication->exec();
- }
+ // If a style sheet is set in the prefs file, enable it here.
+ check_set_qss(d_qApplication);
- QWidget*
- sink_f_impl::qwidget()
- {
- return d_main_gui->qwidget();
- }
+ uint64_t maxBufferSize = 32768;
+ d_main_gui = new SpectrumGUIClass(
+ maxBufferSize, d_fftsize, d_center_freq, -d_bandwidth, d_bandwidth);
+ d_main_gui->setDisplayTitle(d_name);
+ d_main_gui->setWindowType((int)d_wintype);
+ set_fft_size(d_fftsize);
-#ifdef ENABLE_PYTHON
- PyObject*
- sink_f_impl::pyqwidget()
- {
- PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui->qwidget());
- PyObject *retarg = Py_BuildValue("N", w);
- return retarg;
- }
-#else
- void *
- sink_f_impl::pyqwidget()
- {
- return NULL;
- }
-#endif
+ d_main_gui->openSpectrumWindow(
+ d_parent, d_plotfreq, d_plotwaterfall, d_plottime, d_plotconst);
- void
- sink_f_impl::set_fft_size(const int fftsize)
- {
- d_fftsize = fftsize;
- d_main_gui->setFFTSize(fftsize);
- }
+ // initialize update time to 10 times a second
+ set_update_time(0.1);
+}
- int
- sink_f_impl::fft_size() const
- {
- return d_fftsize;
- }
+void sink_f_impl::exec_() { d_qApplication->exec(); }
- void
- sink_f_impl::set_frequency_range(const double centerfreq,
- const double bandwidth)
- {
- d_center_freq = centerfreq;
- d_bandwidth = bandwidth;
- d_main_gui->setFrequencyRange(d_center_freq,
- -d_bandwidth,
- d_bandwidth);
- }
+QWidget* sink_f_impl::qwidget() { return d_main_gui->qwidget(); }
- void
- sink_f_impl::set_fft_power_db(double min, double max)
- {
- d_main_gui->setFrequencyAxis(min, max);
- }
+#ifdef ENABLE_PYTHON
+PyObject* sink_f_impl::pyqwidget()
+{
+ PyObject* w = PyLong_FromVoidPtr((void*)d_main_gui->qwidget());
+ PyObject* retarg = Py_BuildValue("N", w);
+ return retarg;
+}
+#else
+void* sink_f_impl::pyqwidget() { return NULL; }
+#endif
- void
- sink_f_impl::enable_rf_freq(bool en)
- {
- d_main_gui->enableRFFreq(en);
- }
+void sink_f_impl::set_fft_size(const int fftsize)
+{
+ d_fftsize = fftsize;
+ d_main_gui->setFFTSize(fftsize);
+}
- /*
- void
- sink_f_impl::set_time_domain_axis(double min, double max)
- {
- d_main_gui->setTimeDomainAxis(min, max);
- }
+int sink_f_impl::fft_size() const { return d_fftsize; }
- void
- sink_f_impl::set_constellation_axis(double xmin, double xmax,
- double ymin, double ymax)
- {
- d_main_gui->setConstellationAxis(xmin, xmax, ymin, ymax);
- }
+void sink_f_impl::set_frequency_range(const double centerfreq, const double bandwidth)
+{
+ d_center_freq = centerfreq;
+ d_bandwidth = bandwidth;
+ d_main_gui->setFrequencyRange(d_center_freq, -d_bandwidth, d_bandwidth);
+}
- void
- sink_f_impl::set_constellation_pen_size(int size)
- {
- d_main_gui->setConstellationPenSize(size);
- }
- */
+void sink_f_impl::set_fft_power_db(double min, double max)
+{
+ d_main_gui->setFrequencyAxis(min, max);
+}
- void
- sink_f_impl::set_update_time(double t)
- {
- d_update_time = t;
- d_main_gui->setUpdateTime(d_update_time);
- }
+void sink_f_impl::enable_rf_freq(bool en) { d_main_gui->enableRFFreq(en); }
- void
- sink_f_impl::fft(float *data_out, const float *data_in, int size)
- {
- if (d_window.size()) {
- gr_complex *dst = d_fft->get_inbuf();
- for (int i = 0; i < size; i++) // apply window
- dst[i] = data_in[i] * d_window[i];
- }
- else {
- gr_complex *dst = d_fft->get_inbuf();
- for (int i = 0; i < size; i++) // float to complex conversion
- dst[i] = data_in[i];
- }
-
- d_fft->execute (); // compute the fft
- volk_32fc_s32f_x2_power_spectral_density_32f(data_out, d_fft->get_outbuf(),
- size, 1.0, size);
+/*
+void
+sink_f_impl::set_time_domain_axis(double min, double max)
+{
+ d_main_gui->setTimeDomainAxis(min, max);
+}
+
+void
+sink_f_impl::set_constellation_axis(double xmin, double xmax,
+ double ymin, double ymax)
+{
+ d_main_gui->setConstellationAxis(xmin, xmax, ymin, ymax);
+}
+
+void
+sink_f_impl::set_constellation_pen_size(int size)
+{
+ d_main_gui->setConstellationPenSize(size);
+}
+*/
+
+void sink_f_impl::set_update_time(double t)
+{
+ d_update_time = t;
+ d_main_gui->setUpdateTime(d_update_time);
+}
+
+void sink_f_impl::fft(float* data_out, const float* data_in, int size)
+{
+ if (d_window.size()) {
+ gr_complex* dst = d_fft->get_inbuf();
+ for (int i = 0; i < size; i++) // apply window
+ dst[i] = data_in[i] * d_window[i];
+ } else {
+ gr_complex* dst = d_fft->get_inbuf();
+ for (int i = 0; i < size; i++) // float to complex conversion
+ dst[i] = data_in[i];
}
- void
- sink_f_impl::windowreset()
- {
- filter::firdes::win_type newwintype;
- newwintype = (filter::firdes::win_type)d_main_gui->getWindowType();
- if(d_wintype != newwintype) {
- d_wintype = newwintype;
- buildwindow();
- }
+ d_fft->execute(); // compute the fft
+ volk_32fc_s32f_x2_power_spectral_density_32f(
+ data_out, d_fft->get_outbuf(), size, 1.0, size);
+}
+
+void sink_f_impl::windowreset()
+{
+ filter::firdes::win_type newwintype;
+ newwintype = (filter::firdes::win_type)d_main_gui->getWindowType();
+ if (d_wintype != newwintype) {
+ d_wintype = newwintype;
+ buildwindow();
}
+}
- void
- sink_f_impl::buildwindow()
- {
- d_window.clear();
- if(d_wintype != 0) {
- d_window = filter::firdes::window(d_wintype, d_fftsize, 6.76);
- }
+void sink_f_impl::buildwindow()
+{
+ d_window.clear();
+ if (d_wintype != 0) {
+ d_window = filter::firdes::window(d_wintype, d_fftsize, 6.76);
}
+}
- void
- sink_f_impl::fftresize()
- {
- int newfftsize = d_main_gui->getFFTSize();
+void sink_f_impl::fftresize()
+{
+ int newfftsize = d_main_gui->getFFTSize();
- if(newfftsize != d_fftsize) {
+ if (newfftsize != d_fftsize) {
- // Resize residbuf and replace data
+ // Resize residbuf and replace data
volk_free(d_residbuf);
- d_residbuf = (float*)volk_malloc(newfftsize*sizeof(float),
- volk_get_alignment());
+ d_residbuf =
+ (float*)volk_malloc(newfftsize * sizeof(float), volk_get_alignment());
volk_free(d_magbuf);
- d_magbuf = (float*)volk_malloc(newfftsize*sizeof(float),
- volk_get_alignment());
+ d_magbuf = (float*)volk_malloc(newfftsize * sizeof(float), volk_get_alignment());
- // Set new fft size and reset buffer index
- // (throws away any currently held data, but who cares?)
- d_fftsize = newfftsize;
- d_index = 0;
+ // Set new fft size and reset buffer index
+ // (throws away any currently held data, but who cares?)
+ d_fftsize = newfftsize;
+ d_index = 0;
- // Reset window to reflect new size
- buildwindow();
+ // Reset window to reflect new size
+ buildwindow();
- // Reset FFTW plan for new size
- delete d_fft;
- d_fft = new fft::fft_complex (d_fftsize, true);
- }
+ // Reset FFTW plan for new size
+ delete d_fft;
+ d_fft = new fft::fft_complex(d_fftsize, true);
}
+}
- void
- sink_f_impl::check_clicked()
- {
- if(d_main_gui->checkClicked()) {
+void sink_f_impl::check_clicked()
+{
+ if (d_main_gui->checkClicked()) {
double freq = d_main_gui->getClickedFreq();
- message_port_pub(d_port,
- pmt::cons(d_port,
- pmt::from_double(freq)));
- }
+ message_port_pub(d_port, pmt::cons(d_port, pmt::from_double(freq)));
}
+}
- void
- sink_f_impl::handle_set_freq(pmt::pmt_t msg)
- {
- if(pmt::is_pair(msg)) {
+void sink_f_impl::handle_set_freq(pmt::pmt_t msg)
+{
+ if (pmt::is_pair(msg)) {
pmt::pmt_t x = pmt::cdr(msg);
- if(pmt::is_real(x)) {
- d_center_freq = pmt::to_double(x);
- set_frequency_range(d_center_freq, d_bandwidth);
+ if (pmt::is_real(x)) {
+ d_center_freq = pmt::to_double(x);
+ set_frequency_range(d_center_freq, d_bandwidth);
}
- }
}
-
- int
- sink_f_impl::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 float *in = (const float*)input_items[0];
-
- // Update the FFT size from the application
- fftresize();
- windowreset();
- check_clicked();
-
- for(int i=0; i < noutput_items; i+=d_fftsize) {
- unsigned int datasize = noutput_items - i;
- unsigned int resid = d_fftsize-d_index;
-
- // If we have enough input for one full FFT, do it
- if(datasize >= resid) {
- const gr::high_res_timer_type currentTime = gr::high_res_timer_now();
-
- // Fill up residbuf with d_fftsize number of items
- memcpy(d_residbuf+d_index, &in[j], sizeof(float)*resid);
- d_index = 0;
-
- j += resid;
- fft(d_magbuf, d_residbuf, d_fftsize);
-
- d_main_gui->updateWindow(true, d_magbuf, d_fftsize,
- (float*)d_residbuf, d_fftsize, NULL, 0,
- currentTime, true);
- }
- // Otherwise, copy what we received into the residbuf for next time
- else {
- memcpy(d_residbuf+d_index, &in[j], sizeof(float)*datasize);
- d_index += datasize;
- j += datasize;
- }
- }
-
- consume_each(j);
- return j;
+}
+
+int sink_f_impl::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 float* in = (const float*)input_items[0];
+
+ // Update the FFT size from the application
+ fftresize();
+ windowreset();
+ check_clicked();
+
+ for (int i = 0; i < noutput_items; i += d_fftsize) {
+ unsigned int datasize = noutput_items - i;
+ unsigned int resid = d_fftsize - d_index;
+
+ // If we have enough input for one full FFT, do it
+ if (datasize >= resid) {
+ const gr::high_res_timer_type currentTime = gr::high_res_timer_now();
+
+ // Fill up residbuf with d_fftsize number of items
+ memcpy(d_residbuf + d_index, &in[j], sizeof(float) * resid);
+ d_index = 0;
+
+ j += resid;
+ fft(d_magbuf, d_residbuf, d_fftsize);
+
+ d_main_gui->updateWindow(true,
+ d_magbuf,
+ d_fftsize,
+ (float*)d_residbuf,
+ d_fftsize,
+ NULL,
+ 0,
+ currentTime,
+ true);
+ }
+ // Otherwise, copy what we received into the residbuf for next time
+ else {
+ memcpy(d_residbuf + d_index, &in[j], sizeof(float) * datasize);
+ d_index += datasize;
+ j += datasize;
+ }
}
- } /* namespace qtgui */
+ consume_each(j);
+ return j;
+}
+
+} /* namespace qtgui */
} /* namespace gr */
diff --git a/gr-qtgui/lib/sink_f_impl.h b/gr-qtgui/lib/sink_f_impl.h
index 080fcdf85a..ed37a703d2 100644
--- a/gr-qtgui/lib/sink_f_impl.h
+++ b/gr-qtgui/lib/sink_f_impl.h
@@ -31,92 +31,95 @@
#include <gnuradio/qtgui/SpectrumGUIClass.h>
namespace gr {
- namespace qtgui {
+namespace qtgui {
- class QTGUI_API sink_f_impl : public sink_f
- {
- private:
- void forecast(int noutput_items, gr_vector_int &ninput_items_required);
+class QTGUI_API sink_f_impl : public sink_f
+{
+private:
+ void forecast(int noutput_items, gr_vector_int& ninput_items_required);
- void initialize();
+ void initialize();
- int d_fftsize;
- filter::firdes::win_type d_wintype;
- std::vector<float> d_window;
- double d_center_freq;
- double d_bandwidth;
- std::string d_name;
+ int d_fftsize;
+ filter::firdes::win_type d_wintype;
+ std::vector<float> d_window;
+ double d_center_freq;
+ double d_bandwidth;
+ std::string d_name;
- const pmt::pmt_t d_port;
+ const pmt::pmt_t d_port;
- bool d_shift;
- fft::fft_complex *d_fft;
+ bool d_shift;
+ fft::fft_complex* d_fft;
- int d_index;
- float *d_residbuf;
- float *d_magbuf;
+ int d_index;
+ float* d_residbuf;
+ float* d_magbuf;
- bool d_plotfreq, d_plotwaterfall, d_plottime, d_plotconst;
+ bool d_plotfreq, d_plotwaterfall, d_plottime, d_plotconst;
- double d_update_time;
+ double d_update_time;
- int d_argc;
- char *d_argv;
- QWidget *d_parent;
- SpectrumGUIClass *d_main_gui;
+ int d_argc;
+ char* d_argv;
+ QWidget* d_parent;
+ SpectrumGUIClass* d_main_gui;
- void windowreset();
- void buildwindow();
- void fftresize();
- void check_clicked();
- void fft(float *data_out, const float *data_in, int size);
+ void windowreset();
+ void buildwindow();
+ void fftresize();
+ void check_clicked();
+ void fft(float* data_out, const float* data_in, int size);
- // Handles message input port for setting new center frequency.
- // The message is a PMT pair (intern('freq'), double(frequency)).
- void handle_set_freq(pmt::pmt_t msg);
+ // Handles message input port for setting new center frequency.
+ // The message is a PMT pair (intern('freq'), double(frequency)).
+ void handle_set_freq(pmt::pmt_t msg);
- public:
- sink_f_impl(int fftsize, int wintype,
- double fc, double bw,
- const std::string &name,
- bool plotfreq, bool plotwaterfall,
- bool plottime, bool plotconst,
- QWidget *parent);
- ~sink_f_impl();
+public:
+ sink_f_impl(int fftsize,
+ int wintype,
+ double fc,
+ double bw,
+ const std::string& name,
+ bool plotfreq,
+ bool plotwaterfall,
+ bool plottime,
+ bool plotconst,
+ QWidget* parent);
+ ~sink_f_impl();
- bool check_topology(int ninputs, int noutputs);
+ bool check_topology(int ninputs, int noutputs);
- void exec_();
- QWidget* qwidget();
+ void exec_();
+ QWidget* qwidget();
#ifdef ENABLE_PYTHON
- PyObject* pyqwidget();
+ PyObject* pyqwidget();
#else
- void* pyqwidget();
+ void* pyqwidget();
#endif
- void set_fft_size(const int fftsize);
- int fft_size() const;
+ void set_fft_size(const int fftsize);
+ int fft_size() const;
- void set_frequency_range(const double centerfreq,
- const double bandwidth);
- void set_fft_power_db(double min, double max);
- void enable_rf_freq(bool en);
+ void set_frequency_range(const double centerfreq, const double bandwidth);
+ void set_fft_power_db(double min, double max);
+ void enable_rf_freq(bool en);
- //void set_time_domain_axis(double min, double max);
- //void set_constellation_axis(double xmin, double xmax,
- // double ymin, double ymax);
- //void set_constellation_pen_size(int size);
+ // void set_time_domain_axis(double min, double max);
+ // void set_constellation_axis(double xmin, double xmax,
+ // double ymin, double ymax);
+ // void set_constellation_pen_size(int size);
- void set_update_time(double t);
+ void set_update_time(double t);
- int general_work(int noutput_items,
- gr_vector_int &ninput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
+ int general_work(int noutput_items,
+ gr_vector_int& ninput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace qtgui */
+} /* namespace qtgui */
} /* namespace gr */
#endif /* INCLUDED_QTGUI_SINK_F_IMPL_H */
diff --git a/gr-qtgui/lib/spectrumUpdateEvents.cc b/gr-qtgui/lib/spectrumUpdateEvents.cc
index 383332ce14..90d631c361 100644
--- a/gr-qtgui/lib/spectrumUpdateEvents.cc
+++ b/gr-qtgui/lib/spectrumUpdateEvents.cc
@@ -26,407 +26,323 @@
#include <gnuradio/qtgui/spectrumUpdateEvents.h>
SpectrumUpdateEvent::SpectrumUpdateEvent(const float* fftPoints,
- const uint64_t numFFTDataPoints,
- const double* realTimeDomainPoints,
- const double* imagTimeDomainPoints,
- const uint64_t numTimeDomainDataPoints,
- const gr::high_res_timer_type dataTimestamp,
- const bool repeatDataFlag,
- const bool lastOfMultipleUpdateFlag,
- const gr::high_res_timer_type generatedTimestamp,
- const int droppedFFTFrames)
- : QEvent(QEvent::Type(SpectrumUpdateEventType))
-{
- if(numFFTDataPoints < 1) {
- _numFFTDataPoints = 1;
- }
- else {
- _numFFTDataPoints = numFFTDataPoints;
- }
-
- if(numTimeDomainDataPoints < 1) {
- _numTimeDomainDataPoints = 1;
- }
- else {
- _numTimeDomainDataPoints = numTimeDomainDataPoints;
- }
-
- _fftPoints = new float[_numFFTDataPoints];
- _fftPoints[0] = 0;
- memcpy(_fftPoints, fftPoints, numFFTDataPoints*sizeof(float));
-
- _realDataTimeDomainPoints = new double[_numTimeDomainDataPoints];
- memset(_realDataTimeDomainPoints, 0x0, _numTimeDomainDataPoints*sizeof(double));
- if(numTimeDomainDataPoints > 0) {
- memcpy(_realDataTimeDomainPoints, realTimeDomainPoints,
- numTimeDomainDataPoints*sizeof(double));
- }
-
- _imagDataTimeDomainPoints = new double[_numTimeDomainDataPoints];
- memset(_imagDataTimeDomainPoints, 0x0, _numTimeDomainDataPoints*sizeof(double));
- if(numTimeDomainDataPoints > 0) {
- memcpy(_imagDataTimeDomainPoints, imagTimeDomainPoints,
- numTimeDomainDataPoints*sizeof(double));
- }
- _dataTimestamp = dataTimestamp;
- _repeatDataFlag = repeatDataFlag;
- _lastOfMultipleUpdateFlag = lastOfMultipleUpdateFlag;
- _eventGeneratedTimestamp = generatedTimestamp;
- _droppedFFTFrames = droppedFFTFrames;
+ const uint64_t numFFTDataPoints,
+ const double* realTimeDomainPoints,
+ const double* imagTimeDomainPoints,
+ const uint64_t numTimeDomainDataPoints,
+ const gr::high_res_timer_type dataTimestamp,
+ const bool repeatDataFlag,
+ const bool lastOfMultipleUpdateFlag,
+ const gr::high_res_timer_type generatedTimestamp,
+ const int droppedFFTFrames)
+ : QEvent(QEvent::Type(SpectrumUpdateEventType))
+{
+ if (numFFTDataPoints < 1) {
+ _numFFTDataPoints = 1;
+ } else {
+ _numFFTDataPoints = numFFTDataPoints;
+ }
+
+ if (numTimeDomainDataPoints < 1) {
+ _numTimeDomainDataPoints = 1;
+ } else {
+ _numTimeDomainDataPoints = numTimeDomainDataPoints;
+ }
+
+ _fftPoints = new float[_numFFTDataPoints];
+ _fftPoints[0] = 0;
+ memcpy(_fftPoints, fftPoints, numFFTDataPoints * sizeof(float));
+
+ _realDataTimeDomainPoints = new double[_numTimeDomainDataPoints];
+ memset(_realDataTimeDomainPoints, 0x0, _numTimeDomainDataPoints * sizeof(double));
+ if (numTimeDomainDataPoints > 0) {
+ memcpy(_realDataTimeDomainPoints,
+ realTimeDomainPoints,
+ numTimeDomainDataPoints * sizeof(double));
+ }
+
+ _imagDataTimeDomainPoints = new double[_numTimeDomainDataPoints];
+ memset(_imagDataTimeDomainPoints, 0x0, _numTimeDomainDataPoints * sizeof(double));
+ if (numTimeDomainDataPoints > 0) {
+ memcpy(_imagDataTimeDomainPoints,
+ imagTimeDomainPoints,
+ numTimeDomainDataPoints * sizeof(double));
+ }
+ _dataTimestamp = dataTimestamp;
+ _repeatDataFlag = repeatDataFlag;
+ _lastOfMultipleUpdateFlag = lastOfMultipleUpdateFlag;
+ _eventGeneratedTimestamp = generatedTimestamp;
+ _droppedFFTFrames = droppedFFTFrames;
}
SpectrumUpdateEvent::~SpectrumUpdateEvent()
{
- delete[] _fftPoints;
- delete[] _realDataTimeDomainPoints;
- delete[] _imagDataTimeDomainPoints;
+ delete[] _fftPoints;
+ delete[] _realDataTimeDomainPoints;
+ delete[] _imagDataTimeDomainPoints;
}
-const float*
-SpectrumUpdateEvent::getFFTPoints() const
-{
- return _fftPoints;
-}
+const float* SpectrumUpdateEvent::getFFTPoints() const { return _fftPoints; }
-const double*
-SpectrumUpdateEvent::getRealTimeDomainPoints() const
+const double* SpectrumUpdateEvent::getRealTimeDomainPoints() const
{
- return _realDataTimeDomainPoints;
+ return _realDataTimeDomainPoints;
}
-const double*
-SpectrumUpdateEvent::getImagTimeDomainPoints() const
+const double* SpectrumUpdateEvent::getImagTimeDomainPoints() const
{
- return _imagDataTimeDomainPoints;
+ return _imagDataTimeDomainPoints;
}
-uint64_t
-SpectrumUpdateEvent::getNumFFTDataPoints() const
-{
- return _numFFTDataPoints;
-}
+uint64_t SpectrumUpdateEvent::getNumFFTDataPoints() const { return _numFFTDataPoints; }
-uint64_t
-SpectrumUpdateEvent::getNumTimeDomainDataPoints() const
+uint64_t SpectrumUpdateEvent::getNumTimeDomainDataPoints() const
{
- return _numTimeDomainDataPoints;
+ return _numTimeDomainDataPoints;
}
-gr::high_res_timer_type
-SpectrumUpdateEvent::getDataTimestamp() const
+gr::high_res_timer_type SpectrumUpdateEvent::getDataTimestamp() const
{
- return _dataTimestamp;
+ return _dataTimestamp;
}
-bool
-SpectrumUpdateEvent::getRepeatDataFlag() const
-{
- return _repeatDataFlag;
-}
+bool SpectrumUpdateEvent::getRepeatDataFlag() const { return _repeatDataFlag; }
-bool
-SpectrumUpdateEvent::getLastOfMultipleUpdateFlag() const
+bool SpectrumUpdateEvent::getLastOfMultipleUpdateFlag() const
{
- return _lastOfMultipleUpdateFlag;
+ return _lastOfMultipleUpdateFlag;
}
-gr::high_res_timer_type
-SpectrumUpdateEvent::getEventGeneratedTimestamp() const
+gr::high_res_timer_type SpectrumUpdateEvent::getEventGeneratedTimestamp() const
{
- return _eventGeneratedTimestamp;
+ return _eventGeneratedTimestamp;
}
-int
-SpectrumUpdateEvent::getDroppedFFTFrames() const
-{
- return _droppedFFTFrames;
-}
+int SpectrumUpdateEvent::getDroppedFFTFrames() const { return _droppedFFTFrames; }
SpectrumWindowCaptionEvent::SpectrumWindowCaptionEvent(const QString& newLbl)
- : QEvent(QEvent::Type(SpectrumWindowCaptionEventType))
+ : QEvent(QEvent::Type(SpectrumWindowCaptionEventType))
{
- _labelString = newLbl;
+ _labelString = newLbl;
}
-SpectrumWindowCaptionEvent::~SpectrumWindowCaptionEvent()
-{
-}
+SpectrumWindowCaptionEvent::~SpectrumWindowCaptionEvent() {}
-QString
-SpectrumWindowCaptionEvent::getLabel()
-{
- return _labelString;
-}
+QString SpectrumWindowCaptionEvent::getLabel() { return _labelString; }
SpectrumWindowResetEvent::SpectrumWindowResetEvent()
- : QEvent(QEvent::Type(SpectrumWindowResetEventType))
+ : QEvent(QEvent::Type(SpectrumWindowResetEventType))
{
}
-SpectrumWindowResetEvent::~SpectrumWindowResetEvent()
-{
-}
+SpectrumWindowResetEvent::~SpectrumWindowResetEvent() {}
SpectrumFrequencyRangeEvent::SpectrumFrequencyRangeEvent(const double centerFreq,
- const double startFreq,
- const double stopFreq)
- : QEvent(QEvent::Type(SpectrumFrequencyRangeEventType))
+ const double startFreq,
+ const double stopFreq)
+ : QEvent(QEvent::Type(SpectrumFrequencyRangeEventType))
{
- _centerFrequency = centerFreq;
- _startFrequency = startFreq;
- _stopFrequency = stopFreq;
+ _centerFrequency = centerFreq;
+ _startFrequency = startFreq;
+ _stopFrequency = stopFreq;
}
-SpectrumFrequencyRangeEvent::~SpectrumFrequencyRangeEvent()
-{
-}
+SpectrumFrequencyRangeEvent::~SpectrumFrequencyRangeEvent() {}
-double
-SpectrumFrequencyRangeEvent::GetCenterFrequency() const
+double SpectrumFrequencyRangeEvent::GetCenterFrequency() const
{
- return _centerFrequency;
+ return _centerFrequency;
}
-double
-SpectrumFrequencyRangeEvent::GetStartFrequency() const
-{
- return _startFrequency;
-}
+double SpectrumFrequencyRangeEvent::GetStartFrequency() const { return _startFrequency; }
-double
-SpectrumFrequencyRangeEvent::GetStopFrequency() const
-{
- return _stopFrequency;
-}
+double SpectrumFrequencyRangeEvent::GetStopFrequency() const { return _stopFrequency; }
/***************************************************************************/
TimeUpdateEvent::TimeUpdateEvent(const std::vector<double*> timeDomainPoints,
- const uint64_t numTimeDomainDataPoints,
- const std::vector< std::vector<gr::tag_t> > tags)
- : QEvent(QEvent::Type(SpectrumUpdateEventType))
-{
- if(numTimeDomainDataPoints < 1) {
- _numTimeDomainDataPoints = 1;
- }
- else {
- _numTimeDomainDataPoints = numTimeDomainDataPoints;
- }
-
- _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));
+ const uint64_t numTimeDomainDataPoints,
+ const std::vector<std::vector<gr::tag_t>> tags)
+ : QEvent(QEvent::Type(SpectrumUpdateEventType))
+{
+ if (numTimeDomainDataPoints < 1) {
+ _numTimeDomainDataPoints = 1;
+ } else {
+ _numTimeDomainDataPoints = numTimeDomainDataPoints;
}
- }
- _tags = tags;
+ _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));
+ }
+ }
+
+ _tags = tags;
}
TimeUpdateEvent::~TimeUpdateEvent()
{
- for(size_t i = 0; i < _nplots; i++) {
- delete[] _dataTimeDomainPoints[i];
- }
+ for (size_t i = 0; i < _nplots; i++) {
+ delete[] _dataTimeDomainPoints[i];
+ }
}
-const std::vector<double*>
-TimeUpdateEvent::getTimeDomainPoints() const
+const std::vector<double*> TimeUpdateEvent::getTimeDomainPoints() const
{
- return _dataTimeDomainPoints;
+ return _dataTimeDomainPoints;
}
-uint64_t
-TimeUpdateEvent::getNumTimeDomainDataPoints() const
+uint64_t TimeUpdateEvent::getNumTimeDomainDataPoints() const
{
- return _numTimeDomainDataPoints;
+ return _numTimeDomainDataPoints;
}
-const std::vector< std::vector<gr::tag_t> >
-TimeUpdateEvent::getTags() const
+const std::vector<std::vector<gr::tag_t>> TimeUpdateEvent::getTags() const
{
- return _tags;
+ return _tags;
}
/***************************************************************************/
FreqUpdateEvent::FreqUpdateEvent(const std::vector<double*> dataPoints,
- const uint64_t numDataPoints)
- : QEvent(QEvent::Type(SpectrumUpdateEventType))
-{
- if(numDataPoints < 1) {
- _numDataPoints = 1;
- }
- else {
- _numDataPoints = numDataPoints;
- }
-
- _nplots = dataPoints.size();
- for(size_t i = 0; i < _nplots; i++) {
- _dataPoints.push_back(new double[_numDataPoints]);
- if(numDataPoints > 0) {
- memcpy(_dataPoints[i], dataPoints[i],
- _numDataPoints*sizeof(double));
+ const uint64_t numDataPoints)
+ : QEvent(QEvent::Type(SpectrumUpdateEventType))
+{
+ if (numDataPoints < 1) {
+ _numDataPoints = 1;
+ } else {
+ _numDataPoints = numDataPoints;
}
- }
-}
-FreqUpdateEvent::~FreqUpdateEvent()
-{
- for(size_t i = 0; i < _nplots; i++) {
- delete[] _dataPoints[i];
- }
+ _nplots = dataPoints.size();
+ for (size_t i = 0; i < _nplots; i++) {
+ _dataPoints.push_back(new double[_numDataPoints]);
+ if (numDataPoints > 0) {
+ memcpy(_dataPoints[i], dataPoints[i], _numDataPoints * sizeof(double));
+ }
+ }
}
-const std::vector<double*>
-FreqUpdateEvent::getPoints() const
+FreqUpdateEvent::~FreqUpdateEvent()
{
- return _dataPoints;
+ for (size_t i = 0; i < _nplots; i++) {
+ delete[] _dataPoints[i];
+ }
}
-uint64_t
-FreqUpdateEvent::getNumDataPoints() const
-{
- return _numDataPoints;
-}
+const std::vector<double*> FreqUpdateEvent::getPoints() const { return _dataPoints; }
+uint64_t FreqUpdateEvent::getNumDataPoints() const { return _numDataPoints; }
-SetFreqEvent::SetFreqEvent(const double centerFreq,
- const double bandwidth)
- : QEvent(QEvent::Type(SpectrumFrequencyRangeEventType))
+SetFreqEvent::SetFreqEvent(const double centerFreq, const double bandwidth)
+ : QEvent(QEvent::Type(SpectrumFrequencyRangeEventType))
{
- _centerFrequency = centerFreq;
- _bandwidth = bandwidth;
+ _centerFrequency = centerFreq;
+ _bandwidth = bandwidth;
}
-SetFreqEvent::~SetFreqEvent()
-{
-}
+SetFreqEvent::~SetFreqEvent() {}
-double
-SetFreqEvent::getCenterFrequency() const
-{
- return _centerFrequency;
-}
+double SetFreqEvent::getCenterFrequency() const { return _centerFrequency; }
-double
-SetFreqEvent::getBandwidth() const
-{
- return _bandwidth;
-}
+double SetFreqEvent::getBandwidth() const { return _bandwidth; }
/***************************************************************************/
ConstUpdateEvent::ConstUpdateEvent(const std::vector<double*> realDataPoints,
- const std::vector<double*> imagDataPoints,
- const uint64_t numDataPoints)
- : QEvent(QEvent::Type(SpectrumUpdateEventType))
-{
- if(numDataPoints < 1) {
- _numDataPoints = 1;
- }
- else {
- _numDataPoints = numDataPoints;
- }
-
- _nplots = realDataPoints.size();
- for(size_t i = 0; i < _nplots; i++) {
- _realDataPoints.push_back(new double[_numDataPoints]);
- _imagDataPoints.push_back(new double[_numDataPoints]);
- if(numDataPoints > 0) {
- memcpy(_realDataPoints[i], realDataPoints[i],
- _numDataPoints*sizeof(double));
- memcpy(_imagDataPoints[i], imagDataPoints[i],
- _numDataPoints*sizeof(double));
+ const std::vector<double*> imagDataPoints,
+ const uint64_t numDataPoints)
+ : QEvent(QEvent::Type(SpectrumUpdateEventType))
+{
+ if (numDataPoints < 1) {
+ _numDataPoints = 1;
+ } else {
+ _numDataPoints = numDataPoints;
+ }
+
+ _nplots = realDataPoints.size();
+ for (size_t i = 0; i < _nplots; i++) {
+ _realDataPoints.push_back(new double[_numDataPoints]);
+ _imagDataPoints.push_back(new double[_numDataPoints]);
+ if (numDataPoints > 0) {
+ memcpy(
+ _realDataPoints[i], realDataPoints[i], _numDataPoints * sizeof(double));
+ memcpy(
+ _imagDataPoints[i], imagDataPoints[i], _numDataPoints * sizeof(double));
+ }
}
- }
}
ConstUpdateEvent::~ConstUpdateEvent()
{
- for(size_t i = 0; i < _nplots; i++) {
- delete[] _realDataPoints[i];
- delete[] _imagDataPoints[i];
- }
+ for (size_t i = 0; i < _nplots; i++) {
+ delete[] _realDataPoints[i];
+ delete[] _imagDataPoints[i];
+ }
}
-const std::vector<double*>
-ConstUpdateEvent::getRealPoints() const
+const std::vector<double*> ConstUpdateEvent::getRealPoints() const
{
- return _realDataPoints;
+ return _realDataPoints;
}
-const std::vector<double*>
-ConstUpdateEvent::getImagPoints() const
+const std::vector<double*> ConstUpdateEvent::getImagPoints() const
{
- return _imagDataPoints;
+ return _imagDataPoints;
}
-uint64_t
-ConstUpdateEvent::getNumDataPoints() const
-{
- return _numDataPoints;
-}
+uint64_t ConstUpdateEvent::getNumDataPoints() const { return _numDataPoints; }
/***************************************************************************/
WaterfallUpdateEvent::WaterfallUpdateEvent(const std::vector<double*> dataPoints,
- const uint64_t numDataPoints,
- const gr::high_res_timer_type dataTimestamp)
- : QEvent(QEvent::Type(SpectrumUpdateEventType))
-{
- if(numDataPoints < 1) {
- _numDataPoints = 1;
- }
- else {
- _numDataPoints = numDataPoints;
- }
-
- _nplots = dataPoints.size();
- for(size_t i = 0; i < _nplots; i++) {
- _dataPoints.push_back(new double[_numDataPoints]);
- if(numDataPoints > 0) {
- memcpy(_dataPoints[i], dataPoints[i],
- _numDataPoints*sizeof(double));
+ const uint64_t numDataPoints,
+ const gr::high_res_timer_type dataTimestamp)
+ : QEvent(QEvent::Type(SpectrumUpdateEventType))
+{
+ if (numDataPoints < 1) {
+ _numDataPoints = 1;
+ } else {
+ _numDataPoints = numDataPoints;
}
- }
- _dataTimestamp = dataTimestamp;
+ _nplots = dataPoints.size();
+ for (size_t i = 0; i < _nplots; i++) {
+ _dataPoints.push_back(new double[_numDataPoints]);
+ if (numDataPoints > 0) {
+ memcpy(_dataPoints[i], dataPoints[i], _numDataPoints * sizeof(double));
+ }
+ }
+
+ _dataTimestamp = dataTimestamp;
}
WaterfallUpdateEvent::~WaterfallUpdateEvent()
{
- for(size_t i = 0; i < _nplots; i++) {
- delete[] _dataPoints[i];
- }
+ for (size_t i = 0; i < _nplots; i++) {
+ delete[] _dataPoints[i];
+ }
}
-const std::vector<double*>
-WaterfallUpdateEvent::getPoints() const
-{
- return _dataPoints;
-}
+const std::vector<double*> WaterfallUpdateEvent::getPoints() const { return _dataPoints; }
-uint64_t
-WaterfallUpdateEvent::getNumDataPoints() const
-{
- return _numDataPoints;
-}
+uint64_t WaterfallUpdateEvent::getNumDataPoints() const { return _numDataPoints; }
-gr::high_res_timer_type
-WaterfallUpdateEvent::getDataTimestamp() const
+gr::high_res_timer_type WaterfallUpdateEvent::getDataTimestamp() const
{
- return _dataTimestamp;
+ return _dataTimestamp;
}
@@ -434,151 +350,107 @@ WaterfallUpdateEvent::getDataTimestamp() const
TimeRasterUpdateEvent::TimeRasterUpdateEvent(const std::vector<double*> dataPoints,
- const uint64_t numDataPoints)
- : QEvent(QEvent::Type(SpectrumUpdateEventType))
-{
- if(numDataPoints < 1) {
- _numDataPoints = 1;
- }
- else {
- _numDataPoints = numDataPoints;
- }
-
- _nplots = dataPoints.size();
- for(size_t i = 0; i < _nplots; i++) {
- _dataPoints.push_back(new double[_numDataPoints]);
- if(numDataPoints > 0) {
- memcpy(_dataPoints[i], dataPoints[i],
- _numDataPoints*sizeof(double));
+ const uint64_t numDataPoints)
+ : QEvent(QEvent::Type(SpectrumUpdateEventType))
+{
+ if (numDataPoints < 1) {
+ _numDataPoints = 1;
+ } else {
+ _numDataPoints = numDataPoints;
}
- }
-}
-TimeRasterUpdateEvent::~TimeRasterUpdateEvent()
-{
- for(size_t i = 0; i < _nplots; i++) {
- delete[] _dataPoints[i];
- }
+ _nplots = dataPoints.size();
+ for (size_t i = 0; i < _nplots; i++) {
+ _dataPoints.push_back(new double[_numDataPoints]);
+ if (numDataPoints > 0) {
+ memcpy(_dataPoints[i], dataPoints[i], _numDataPoints * sizeof(double));
+ }
+ }
}
-const std::vector<double*>
-TimeRasterUpdateEvent::getPoints() const
+TimeRasterUpdateEvent::~TimeRasterUpdateEvent()
{
- return _dataPoints;
+ for (size_t i = 0; i < _nplots; i++) {
+ delete[] _dataPoints[i];
+ }
}
-uint64_t
-TimeRasterUpdateEvent::getNumDataPoints() const
+const std::vector<double*> TimeRasterUpdateEvent::getPoints() const
{
- return _numDataPoints;
+ return _dataPoints;
}
+uint64_t TimeRasterUpdateEvent::getNumDataPoints() const { return _numDataPoints; }
-
-TimeRasterSetSize::TimeRasterSetSize(const double nrows,
- const double ncols)
- : QEvent(QEvent::Type(SpectrumUpdateEventType+1)),
- _nrows(nrows), _ncols(ncols)
+TimeRasterSetSize::TimeRasterSetSize(const double nrows, const double ncols)
+ : QEvent(QEvent::Type(SpectrumUpdateEventType + 1)), _nrows(nrows), _ncols(ncols)
{
}
-TimeRasterSetSize::~TimeRasterSetSize()
-{
-}
+TimeRasterSetSize::~TimeRasterSetSize() {}
-double
-TimeRasterSetSize::nRows() const
-{
- return _nrows;
-}
+double TimeRasterSetSize::nRows() const { return _nrows; }
-double
-TimeRasterSetSize::nCols() const
-{
- return _ncols;
-}
+double TimeRasterSetSize::nCols() const { return _ncols; }
/***************************************************************************/
HistogramUpdateEvent::HistogramUpdateEvent(const std::vector<double*> points,
const uint64_t npoints)
- : QEvent(QEvent::Type(SpectrumUpdateEventType))
-{
- if(npoints < 1) {
- _npoints = 1;
- }
- else {
- _npoints = npoints;
- }
-
- _nplots = points.size();
- for(size_t i = 0; i < _nplots; i++) {
- _points.push_back(new double[_npoints]);
- if(npoints > 0) {
- memcpy(_points[i], points[i], _npoints*sizeof(double));
+ : QEvent(QEvent::Type(SpectrumUpdateEventType))
+{
+ if (npoints < 1) {
+ _npoints = 1;
+ } else {
+ _npoints = npoints;
+ }
+
+ _nplots = points.size();
+ for (size_t i = 0; i < _nplots; i++) {
+ _points.push_back(new double[_npoints]);
+ if (npoints > 0) {
+ memcpy(_points[i], points[i], _npoints * sizeof(double));
+ }
}
- }
}
HistogramUpdateEvent::~HistogramUpdateEvent()
{
- for(size_t i = 0; i < _nplots; i++) {
- delete[] _points[i];
- }
+ for (size_t i = 0; i < _nplots; i++) {
+ delete[] _points[i];
+ }
}
-const std::vector<double*>
-HistogramUpdateEvent::getDataPoints() const
-{
- return _points;
-}
+const std::vector<double*> HistogramUpdateEvent::getDataPoints() const { return _points; }
-uint64_t
-HistogramUpdateEvent::getNumDataPoints() const
-{
- return _npoints;
-}
+uint64_t HistogramUpdateEvent::getNumDataPoints() const { return _npoints; }
HistogramSetAccumulator::HistogramSetAccumulator(const bool en)
- : QEvent(QEvent::Type(SpectrumUpdateEventType+1)),
- _en(en)
+ : QEvent(QEvent::Type(SpectrumUpdateEventType + 1)), _en(en)
{
}
-HistogramSetAccumulator::~HistogramSetAccumulator()
-{
-}
-
-bool
-HistogramSetAccumulator::getAccumulator() const
-{
- return _en;
-}
+HistogramSetAccumulator::~HistogramSetAccumulator() {}
+bool HistogramSetAccumulator::getAccumulator() const { return _en; }
/***************************************************************************/
NumberUpdateEvent::NumberUpdateEvent(const std::vector<float> samples)
- : QEvent(QEvent::Type(SpectrumUpdateEventType))
+ : QEvent(QEvent::Type(SpectrumUpdateEventType))
{
- _samples = samples;
- _nplots = samples.size();
+ _samples = samples;
+ _nplots = samples.size();
}
-NumberUpdateEvent::~NumberUpdateEvent()
-{
-}
+NumberUpdateEvent::~NumberUpdateEvent() {}
-const std::vector<float>
-NumberUpdateEvent::getSamples() const
-{
- return _samples;
-}
+const std::vector<float> NumberUpdateEvent::getSamples() const { return _samples; }
#endif /* SPECTRUM_UPDATE_EVENTS_C */
diff --git a/gr-qtgui/lib/spectrumdisplayform.cc b/gr-qtgui/lib/spectrumdisplayform.cc
index fcc6561f3b..68db7be975 100644
--- a/gr-qtgui/lib/spectrumdisplayform.cc
+++ b/gr-qtgui/lib/spectrumdisplayform.cc
@@ -28,126 +28,139 @@
#include <cmath>
-SpectrumDisplayForm::SpectrumDisplayForm(QWidget* parent)
- : QWidget(parent)
+SpectrumDisplayForm::SpectrumDisplayForm(QWidget* parent) : QWidget(parent)
{
- setupUi(this);
+ setupUi(this);
- d_clicked = false;
- d_clicked_freq = 0;
+ d_clicked = false;
+ d_clicked_freq = 0;
- _systemSpecifiedFlag = false;
- _intValidator = new QIntValidator(this);
- _intValidator->setBottom(0);
- _frequencyDisplayPlot = new FrequencyDisplayPlot(1, FrequencyPlotDisplayFrame);
- _waterfallDisplayPlot = new WaterfallDisplayPlot(1, WaterfallPlotDisplayFrame);
- _timeDomainDisplayPlot = new TimeDomainDisplayPlot(2, TimeDomainDisplayFrame);
- _constellationDisplayPlot = new ConstellationDisplayPlot(1, ConstellationDisplayFrame);
- _numRealDataPoints = 1024;
- _realFFTDataPoints = new double[_numRealDataPoints];
- _averagedValues = new double[_numRealDataPoints];
- _historyVector = new std::vector<double*>;
+ _systemSpecifiedFlag = false;
+ _intValidator = new QIntValidator(this);
+ _intValidator->setBottom(0);
+ _frequencyDisplayPlot = new FrequencyDisplayPlot(1, FrequencyPlotDisplayFrame);
+ _waterfallDisplayPlot = new WaterfallDisplayPlot(1, WaterfallPlotDisplayFrame);
+ _timeDomainDisplayPlot = new TimeDomainDisplayPlot(2, TimeDomainDisplayFrame);
+ _constellationDisplayPlot =
+ new ConstellationDisplayPlot(1, ConstellationDisplayFrame);
+ _numRealDataPoints = 1024;
+ _realFFTDataPoints = new double[_numRealDataPoints];
+ _averagedValues = new double[_numRealDataPoints];
+ _historyVector = new std::vector<double*>;
- _timeDomainDisplayPlot->setLineLabel(0, "real");
- _timeDomainDisplayPlot->setLineLabel(1, "imag");
+ _timeDomainDisplayPlot->setLineLabel(0, "real");
+ _timeDomainDisplayPlot->setLineLabel(1, "imag");
- AvgLineEdit->setRange(0, 500); // Set range of Average box value from 0 to 500
- minHoldCheckBox_toggled( false );
- maxHoldCheckBox_toggled( false );
+ AvgLineEdit->setRange(0, 500); // Set range of Average box value from 0 to 500
+ minHoldCheckBox_toggled(false);
+ maxHoldCheckBox_toggled(false);
#if QWT_VERSION < 0x060100
- WaterfallMaximumIntensitySlider->setRange(-200, 0);
- WaterfallMinimumIntensitySlider->setRange(-200, 0);
- WaterfallMinimumIntensitySlider->setValue(-200);
-#else /* QWT_VERSION < 0x060100 */
- WaterfallMaximumIntensitySlider->setScale(-200, 0);
- WaterfallMinimumIntensitySlider->setScale(-200, 0);
- WaterfallMinimumIntensitySlider->setValue(-200);
+ WaterfallMaximumIntensitySlider->setRange(-200, 0);
+ WaterfallMinimumIntensitySlider->setRange(-200, 0);
+ WaterfallMinimumIntensitySlider->setValue(-200);
+#else /* QWT_VERSION < 0x060100 */
+ WaterfallMaximumIntensitySlider->setScale(-200, 0);
+ WaterfallMinimumIntensitySlider->setScale(-200, 0);
+ WaterfallMinimumIntensitySlider->setValue(-200);
#endif /* QWT_VERSION < 0x060100 */
- WaterfallMaximumIntensitySlider->setOrientation(Qt::Horizontal);
- WaterfallMinimumIntensitySlider->setOrientation(Qt::Horizontal);
+ WaterfallMaximumIntensitySlider->setOrientation(Qt::Horizontal);
+ WaterfallMinimumIntensitySlider->setOrientation(Qt::Horizontal);
- _peakFrequency = 0;
- _peakAmplitude = -HUGE_VAL;
+ _peakFrequency = 0;
+ _peakAmplitude = -HUGE_VAL;
- _noiseFloorAmplitude = -HUGE_VAL;
+ _noiseFloorAmplitude = -HUGE_VAL;
- connect(_waterfallDisplayPlot, SIGNAL(updatedLowerIntensityLevel(const double)),
- _frequencyDisplayPlot, SLOT(setLowerIntensityLevel(const double)));
- connect(_waterfallDisplayPlot, SIGNAL(updatedUpperIntensityLevel(const double)),
- _frequencyDisplayPlot, SLOT(setUpperIntensityLevel(const double)));
+ connect(_waterfallDisplayPlot,
+ SIGNAL(updatedLowerIntensityLevel(const double)),
+ _frequencyDisplayPlot,
+ SLOT(setLowerIntensityLevel(const double)));
+ connect(_waterfallDisplayPlot,
+ SIGNAL(updatedUpperIntensityLevel(const double)),
+ _frequencyDisplayPlot,
+ SLOT(setUpperIntensityLevel(const double)));
- _frequencyDisplayPlot->setLowerIntensityLevel(-200);
- _frequencyDisplayPlot->setUpperIntensityLevel(-200);
+ _frequencyDisplayPlot->setLowerIntensityLevel(-200);
+ _frequencyDisplayPlot->setUpperIntensityLevel(-200);
- // Load up the acceptable FFT sizes...
- FFTSizeComboBox->clear();
- for(long fftSize = SpectrumGUIClass::MIN_FFT_SIZE; fftSize <= SpectrumGUIClass::MAX_FFT_SIZE; fftSize *= 2){
- FFTSizeComboBox->insertItem(FFTSizeComboBox->count(), QString("%1").arg(fftSize));
- }
- reset();
+ // Load up the acceptable FFT sizes...
+ FFTSizeComboBox->clear();
+ for (long fftSize = SpectrumGUIClass::MIN_FFT_SIZE;
+ fftSize <= SpectrumGUIClass::MAX_FFT_SIZE;
+ fftSize *= 2) {
+ FFTSizeComboBox->insertItem(FFTSizeComboBox->count(), QString("%1").arg(fftSize));
+ }
+ reset();
- toggleTabFrequency(false);
- toggleTabWaterfall(false);
- toggleTabTime(false);
- toggleTabConstellation(false);
+ toggleTabFrequency(false);
+ toggleTabWaterfall(false);
+ toggleTabTime(false);
+ toggleTabConstellation(false);
- _historyEntry = 0;
- _historyEntryCount = 0;
+ _historyEntry = 0;
+ _historyEntryCount = 0;
- // Create a timer to update plots at the specified rate
- displayTimer = new QTimer(this);
- connect(displayTimer, SIGNAL(timeout()), this, SLOT(updateGuiTimer()));
+ // Create a timer to update plots at the specified rate
+ displayTimer = new QTimer(this);
+ connect(displayTimer, SIGNAL(timeout()), this, SLOT(updateGuiTimer()));
- // Connect double click signals up
- connect(_frequencyDisplayPlot, SIGNAL(plotPointSelected(const QPointF)),
- this, SLOT(onFFTPlotPointSelected(const QPointF)));
+ // Connect double click signals up
+ connect(_frequencyDisplayPlot,
+ SIGNAL(plotPointSelected(const QPointF)),
+ this,
+ SLOT(onFFTPlotPointSelected(const QPointF)));
- connect(_waterfallDisplayPlot, SIGNAL(plotPointSelected(const QPointF)),
- this, SLOT(onWFallPlotPointSelected(const QPointF)));
+ connect(_waterfallDisplayPlot,
+ SIGNAL(plotPointSelected(const QPointF)),
+ this,
+ SLOT(onWFallPlotPointSelected(const QPointF)));
- connect(_timeDomainDisplayPlot, SIGNAL(plotPointSelected(const QPointF)),
- this, SLOT(onTimePlotPointSelected(const QPointF)));
+ connect(_timeDomainDisplayPlot,
+ SIGNAL(plotPointSelected(const QPointF)),
+ this,
+ SLOT(onTimePlotPointSelected(const QPointF)));
- connect(_constellationDisplayPlot, SIGNAL(plotPointSelected(const QPointF)),
- this, SLOT(onConstPlotPointSelected(const QPointF)));
+ connect(_constellationDisplayPlot,
+ SIGNAL(plotPointSelected(const QPointF)),
+ this,
+ SLOT(onConstPlotPointSelected(const QPointF)));
}
SpectrumDisplayForm::~SpectrumDisplayForm()
{
- // Qt deletes children when parent is deleted
+ // Qt deletes children when parent is deleted
- // Don't worry about deleting Display Plots - they are deleted when parents are deleted
- delete _intValidator;
+ // Don't worry about deleting Display Plots - they are deleted when parents are
+ // deleted
+ delete _intValidator;
- delete[] _realFFTDataPoints;
- delete[] _averagedValues;
+ delete[] _realFFTDataPoints;
+ delete[] _averagedValues;
- for(unsigned int count = 0; count < _historyVector->size(); count++){
- delete[] _historyVector->operator[](count);
- }
+ for (unsigned int count = 0; count < _historyVector->size(); count++) {
+ delete[] _historyVector->operator[](count);
+ }
- delete _historyVector;
+ delete _historyVector;
- displayTimer->stop();
- delete displayTimer;
+ displayTimer->stop();
+ delete displayTimer;
}
-void
-SpectrumDisplayForm::setSystem(SpectrumGUIClass * newSystem,
- const uint64_t numFFTDataPoints,
- const uint64_t numTimeDomainDataPoints)
+void SpectrumDisplayForm::setSystem(SpectrumGUIClass* newSystem,
+ const uint64_t numFFTDataPoints,
+ const uint64_t numTimeDomainDataPoints)
{
- resizeBuffers(numFFTDataPoints, numTimeDomainDataPoints);
+ resizeBuffers(numFFTDataPoints, numTimeDomainDataPoints);
- if(newSystem != NULL) {
- _system = newSystem;
- _systemSpecifiedFlag = true;
- }
- else {
- _systemSpecifiedFlag = false;
- }
+ if (newSystem != NULL) {
+ _system = newSystem;
+ _systemSpecifiedFlag = true;
+ } else {
+ _systemSpecifiedFlag = false;
+ }
}
/***********************************************************************
@@ -157,663 +170,633 @@ SpectrumDisplayForm::setSystem(SpectrumGUIClass * newSystem,
* Doing the "FFT shift" to put 0Hz at the center of the plot
* I feel like this might want to be part of the sink block
**********************************************************************/
-static void fftshift_and_sum(double *outFFT, const float *inFFT,
- uint64_t num_points, double &sum_mean,
- double &peak_ampl, int &peak_bin)
-{
- const float* inptr = inFFT+num_points/2;
- double* outptr = outFFT;
-
- sum_mean = 0;
- peak_ampl = -HUGE_VAL;
- peak_bin = 0;
-
- // Run this twice to perform the fftshift operation on the data here as well
- for(uint64_t point = 0; point < num_points/2; point++) {
- float pt = (*inptr);
- *outptr = pt;
- if(*outptr > peak_ampl) {
- peak_bin = point;
- peak_ampl = *outptr;
- }
- sum_mean += *outptr;
-
- inptr++;
- outptr++;
- }
-
- // This loop takes the first half of the input data and puts it in the
- // second half of the plotted data
- inptr = inFFT;
- for(uint64_t point = 0; point < num_points/2; point++) {
- float pt = (*inptr);
- *outptr = pt;
- if(*outptr > peak_ampl) {
- peak_bin = point;
- peak_ampl = *outptr;
- }
- sum_mean += *outptr;
-
- inptr++;
- outptr++;
- }
-}
-
-void
-SpectrumDisplayForm::newFrequencyData( const SpectrumUpdateEvent* spectrumUpdateEvent)
-{
- //_lastSpectrumEvent = (SpectrumUpdateEvent)(*spectrumUpdateEvent);
- const float* fftMagDataPoints = spectrumUpdateEvent->getFFTPoints();
- const uint64_t numFFTDataPoints = spectrumUpdateEvent->getNumFFTDataPoints();
- const uint64_t numTimeDomainDataPoints = spectrumUpdateEvent->getNumTimeDomainDataPoints();
- const gr::high_res_timer_type dataTimestamp = spectrumUpdateEvent->getDataTimestamp();
- const bool repeatDataFlag = spectrumUpdateEvent->getRepeatDataFlag();
- const bool lastOfMultipleUpdatesFlag = spectrumUpdateEvent->getLastOfMultipleUpdateFlag();
- const gr::high_res_timer_type generatedTimestamp = spectrumUpdateEvent->getEventGeneratedTimestamp();
- double* realTimeDomainDataPoints = (double*)spectrumUpdateEvent->getRealTimeDomainPoints();
- double* imagTimeDomainDataPoints = (double*)spectrumUpdateEvent->getImagTimeDomainPoints();
-
- std::vector<double*> 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);
-
- const double fftBinSize = (_stopFrequency-_startFrequency) /
- static_cast<double>(numFFTDataPoints);
-
- //this does the fftshift, conversion to double, and calculation of sum, peak amplitude, peak freq.
- double sum_mean, peak_ampl;
- int peak_bin;
- fftshift_and_sum(_realFFTDataPoints, fftMagDataPoints, numFFTDataPoints, sum_mean, peak_ampl, peak_bin);
- double peak_freq = peak_bin * fftBinSize;
-
- // Don't update the averaging history if this is repeated data
- if(!repeatDataFlag){
- _averageHistory(_realFFTDataPoints);
-
- // Only use the local info if we are not repeating data
- _peakAmplitude = peak_ampl;
- _peakFrequency = peak_freq;
-
- // calculate the spectral mean
- // +20 because for the comparison below we only want to throw out bins
- // that are significantly higher (and would, thus, affect the mean more)
- const double meanAmplitude = (sum_mean / numFFTDataPoints) + 20.0;
-
- // now throw out any bins higher than the mean
- sum_mean = 0.0;
- uint64_t newNumDataPoints = numFFTDataPoints;
- for(uint64_t number = 0; number < numFFTDataPoints; number++){
- if (_realFFTDataPoints[number] <= meanAmplitude)
- sum_mean += _realFFTDataPoints[number];
- else
- newNumDataPoints--;
+static void fftshift_and_sum(double* outFFT,
+ const float* inFFT,
+ uint64_t num_points,
+ double& sum_mean,
+ double& peak_ampl,
+ int& peak_bin)
+{
+ const float* inptr = inFFT + num_points / 2;
+ double* outptr = outFFT;
+
+ sum_mean = 0;
+ peak_ampl = -HUGE_VAL;
+ peak_bin = 0;
+
+ // Run this twice to perform the fftshift operation on the data here as well
+ for (uint64_t point = 0; point < num_points / 2; point++) {
+ float pt = (*inptr);
+ *outptr = pt;
+ if (*outptr > peak_ampl) {
+ peak_bin = point;
+ peak_ampl = *outptr;
+ }
+ sum_mean += *outptr;
+
+ inptr++;
+ outptr++;
}
- if (newNumDataPoints == 0) // in the odd case that all
- _noiseFloorAmplitude = meanAmplitude; // amplitudes are equal!
- else
- _noiseFloorAmplitude = sum_mean / newNumDataPoints;
- }
-
- if(lastOfMultipleUpdatesFlag){
- int tabindex = SpectrumTypeTab->currentIndex();
- if(tabindex == d_plot_fft) {
- _frequencyDisplayPlot->plotNewData(_averagedValues, numFFTDataPoints,
- _noiseFloorAmplitude, _peakFrequency,
- _peakAmplitude, d_update_time);
- }
- if(tabindex == d_plot_time) {
- _timeDomainDisplayPlot->plotNewData(timeDomainDataPoints,
- numTimeDomainDataPoints,
- d_update_time);
- }
- if(tabindex == d_plot_constellation) {
- _constellationDisplayPlot->plotNewData(realTimeDomainDataPoints,
- imagTimeDomainDataPoints,
- numTimeDomainDataPoints,
- d_update_time);
+ // This loop takes the first half of the input data and puts it in the
+ // second half of the plotted data
+ inptr = inFFT;
+ for (uint64_t point = 0; point < num_points / 2; point++) {
+ float pt = (*inptr);
+ *outptr = pt;
+ if (*outptr > peak_ampl) {
+ peak_bin = point;
+ peak_ampl = *outptr;
+ }
+ sum_mean += *outptr;
+
+ inptr++;
+ outptr++;
}
+}
- // Don't update the repeated data for the waterfall
- if(!repeatDataFlag){
- if(tabindex == d_plot_waterfall) {
- _waterfallDisplayPlot->plotNewData(_realFFTDataPoints, numFFTDataPoints,
- d_update_time, dataTimestamp,
- spectrumUpdateEvent->getDroppedFFTFrames());
- }
+void SpectrumDisplayForm::newFrequencyData(const SpectrumUpdateEvent* spectrumUpdateEvent)
+{
+ //_lastSpectrumEvent = (SpectrumUpdateEvent)(*spectrumUpdateEvent);
+ const float* fftMagDataPoints = spectrumUpdateEvent->getFFTPoints();
+ const uint64_t numFFTDataPoints = spectrumUpdateEvent->getNumFFTDataPoints();
+ const uint64_t numTimeDomainDataPoints =
+ spectrumUpdateEvent->getNumTimeDomainDataPoints();
+ const gr::high_res_timer_type dataTimestamp = spectrumUpdateEvent->getDataTimestamp();
+ const bool repeatDataFlag = spectrumUpdateEvent->getRepeatDataFlag();
+ const bool lastOfMultipleUpdatesFlag =
+ spectrumUpdateEvent->getLastOfMultipleUpdateFlag();
+ const gr::high_res_timer_type generatedTimestamp =
+ spectrumUpdateEvent->getEventGeneratedTimestamp();
+ double* realTimeDomainDataPoints =
+ (double*)spectrumUpdateEvent->getRealTimeDomainPoints();
+ double* imagTimeDomainDataPoints =
+ (double*)spectrumUpdateEvent->getImagTimeDomainPoints();
+
+ std::vector<double*> 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);
+
+ const double fftBinSize =
+ (_stopFrequency - _startFrequency) / static_cast<double>(numFFTDataPoints);
+
+ // this does the fftshift, conversion to double, and calculation of sum, peak
+ // amplitude, peak freq.
+ double sum_mean, peak_ampl;
+ int peak_bin;
+ fftshift_and_sum(_realFFTDataPoints,
+ fftMagDataPoints,
+ numFFTDataPoints,
+ sum_mean,
+ peak_ampl,
+ peak_bin);
+ double peak_freq = peak_bin * fftBinSize;
+
+ // Don't update the averaging history if this is repeated data
+ if (!repeatDataFlag) {
+ _averageHistory(_realFFTDataPoints);
+
+ // Only use the local info if we are not repeating data
+ _peakAmplitude = peak_ampl;
+ _peakFrequency = peak_freq;
+
+ // calculate the spectral mean
+ // +20 because for the comparison below we only want to throw out bins
+ // that are significantly higher (and would, thus, affect the mean more)
+ const double meanAmplitude = (sum_mean / numFFTDataPoints) + 20.0;
+
+ // now throw out any bins higher than the mean
+ sum_mean = 0.0;
+ uint64_t newNumDataPoints = numFFTDataPoints;
+ for (uint64_t number = 0; number < numFFTDataPoints; number++) {
+ if (_realFFTDataPoints[number] <= meanAmplitude)
+ sum_mean += _realFFTDataPoints[number];
+ else
+ newNumDataPoints--;
+ }
+
+ if (newNumDataPoints == 0) // in the odd case that all
+ _noiseFloorAmplitude = meanAmplitude; // amplitudes are equal!
+ else
+ _noiseFloorAmplitude = sum_mean / newNumDataPoints;
}
- // Tell the system the GUI has been updated
- if(_systemSpecifiedFlag){
- _system->setLastGUIUpdateTime(generatedTimestamp);
- _system->decrementPendingGUIUpdateEvents();
+ if (lastOfMultipleUpdatesFlag) {
+ int tabindex = SpectrumTypeTab->currentIndex();
+ if (tabindex == d_plot_fft) {
+ _frequencyDisplayPlot->plotNewData(_averagedValues,
+ numFFTDataPoints,
+ _noiseFloorAmplitude,
+ _peakFrequency,
+ _peakAmplitude,
+ d_update_time);
+ }
+ if (tabindex == d_plot_time) {
+ _timeDomainDisplayPlot->plotNewData(
+ timeDomainDataPoints, numTimeDomainDataPoints, d_update_time);
+ }
+ if (tabindex == d_plot_constellation) {
+ _constellationDisplayPlot->plotNewData(realTimeDomainDataPoints,
+ imagTimeDomainDataPoints,
+ numTimeDomainDataPoints,
+ d_update_time);
+ }
+
+ // Don't update the repeated data for the waterfall
+ if (!repeatDataFlag) {
+ if (tabindex == d_plot_waterfall) {
+ _waterfallDisplayPlot->plotNewData(
+ _realFFTDataPoints,
+ numFFTDataPoints,
+ d_update_time,
+ dataTimestamp,
+ spectrumUpdateEvent->getDroppedFFTFrames());
+ }
+ }
+
+ // Tell the system the GUI has been updated
+ if (_systemSpecifiedFlag) {
+ _system->setLastGUIUpdateTime(generatedTimestamp);
+ _system->decrementPendingGUIUpdateEvents();
+ }
}
- }
}
-void
-SpectrumDisplayForm::resizeEvent( QResizeEvent *e )
+void SpectrumDisplayForm::resizeEvent(QResizeEvent* e)
{
- QSize s;
- s.setWidth(FrequencyPlotDisplayFrame->width());
- s.setHeight(FrequencyPlotDisplayFrame->height());
- emit _frequencyDisplayPlot->resizeSlot(&s);
+ QSize s;
+ s.setWidth(FrequencyPlotDisplayFrame->width());
+ s.setHeight(FrequencyPlotDisplayFrame->height());
+ emit _frequencyDisplayPlot->resizeSlot(&s);
- s.setWidth(TimeDomainDisplayFrame->width());
- s.setHeight(TimeDomainDisplayFrame->height());
- emit _timeDomainDisplayPlot->resizeSlot(&s);
+ s.setWidth(TimeDomainDisplayFrame->width());
+ s.setHeight(TimeDomainDisplayFrame->height());
+ emit _timeDomainDisplayPlot->resizeSlot(&s);
- s.setWidth(WaterfallPlotDisplayFrame->width());
- s.setHeight(WaterfallPlotDisplayFrame->height());
- emit _waterfallDisplayPlot->resizeSlot(&s);
+ s.setWidth(WaterfallPlotDisplayFrame->width());
+ s.setHeight(WaterfallPlotDisplayFrame->height());
+ emit _waterfallDisplayPlot->resizeSlot(&s);
- s.setWidth(ConstellationDisplayFrame->width());
- s.setHeight(ConstellationDisplayFrame->height());
- emit _constellationDisplayPlot->resizeSlot(&s);
+ s.setWidth(ConstellationDisplayFrame->width());
+ s.setHeight(ConstellationDisplayFrame->height());
+ emit _constellationDisplayPlot->resizeSlot(&s);
}
-void
-SpectrumDisplayForm::customEvent( QEvent * e)
+void SpectrumDisplayForm::customEvent(QEvent* e)
{
- if(e->type() == QEvent::User+3){
- if(_systemSpecifiedFlag){
- WindowComboBox->setCurrentIndex(_system->getWindowType());
- FFTSizeComboBox->setCurrentIndex(_system->getFFTSizeIndex());
- }
+ if (e->type() == QEvent::User + 3) {
+ if (_systemSpecifiedFlag) {
+ WindowComboBox->setCurrentIndex(_system->getWindowType());
+ FFTSizeComboBox->setCurrentIndex(_system->getFFTSizeIndex());
+ }
- waterfallMinimumIntensityChangedCB(WaterfallMinimumIntensitySlider->value());
- waterfallMaximumIntensityChangedCB(WaterfallMaximumIntensitySlider->value());
+ waterfallMinimumIntensityChangedCB(WaterfallMinimumIntensitySlider->value());
+ waterfallMaximumIntensityChangedCB(WaterfallMaximumIntensitySlider->value());
- // Clear any previous display
- reset();
- }
- else if(e->type() == SpectrumUpdateEventType) {
- SpectrumUpdateEvent* spectrumUpdateEvent = (SpectrumUpdateEvent*)e;
- newFrequencyData(spectrumUpdateEvent);
- }
- else if(e->type() == SpectrumWindowCaptionEventType) {
- setWindowTitle(((SpectrumWindowCaptionEvent*)e)->getLabel());
- }
- else if(e->type() == SpectrumWindowResetEventType) {
- reset();
- if(_systemSpecifiedFlag){
- _system->resetPendingGUIUpdateEvents();
- }
- }
- else if(e->type() == SpectrumFrequencyRangeEventType) {
- _startFrequency = ((SpectrumFrequencyRangeEvent*)e)->GetStartFrequency();
- _stopFrequency = ((SpectrumFrequencyRangeEvent*)e)->GetStopFrequency();
- _centerFrequency = ((SpectrumFrequencyRangeEvent*)e)->GetCenterFrequency();
+ // Clear any previous display
+ reset();
+ } else if (e->type() == SpectrumUpdateEventType) {
+ SpectrumUpdateEvent* spectrumUpdateEvent = (SpectrumUpdateEvent*)e;
+ newFrequencyData(spectrumUpdateEvent);
+ } else if (e->type() == SpectrumWindowCaptionEventType) {
+ setWindowTitle(((SpectrumWindowCaptionEvent*)e)->getLabel());
+ } else if (e->type() == SpectrumWindowResetEventType) {
+ reset();
+ if (_systemSpecifiedFlag) {
+ _system->resetPendingGUIUpdateEvents();
+ }
+ } else if (e->type() == SpectrumFrequencyRangeEventType) {
+ _startFrequency = ((SpectrumFrequencyRangeEvent*)e)->GetStartFrequency();
+ _stopFrequency = ((SpectrumFrequencyRangeEvent*)e)->GetStopFrequency();
+ _centerFrequency = ((SpectrumFrequencyRangeEvent*)e)->GetCenterFrequency();
- useRFFrequenciesCB(UseRFFrequenciesCheckBox->isChecked());
- }
+ useRFFrequenciesCB(UseRFFrequenciesCheckBox->isChecked());
+ }
}
-void
-SpectrumDisplayForm::updateGuiTimer()
+void SpectrumDisplayForm::updateGuiTimer()
{
- // This is called by the displayTimer and redraws the canvases of
- // all of the plots.
- _frequencyDisplayPlot->canvas()->update();
- _waterfallDisplayPlot->canvas()->update();
- _timeDomainDisplayPlot->canvas()->update();
- _constellationDisplayPlot->canvas()->update();
+ // This is called by the displayTimer and redraws the canvases of
+ // all of the plots.
+ _frequencyDisplayPlot->canvas()->update();
+ _waterfallDisplayPlot->canvas()->update();
+ _timeDomainDisplayPlot->canvas()->update();
+ _constellationDisplayPlot->canvas()->update();
}
-void
-SpectrumDisplayForm::avgLineEdit_valueChanged( int value )
-{
- setAverageCount(value);
-}
+void SpectrumDisplayForm::avgLineEdit_valueChanged(int value) { setAverageCount(value); }
-void
-SpectrumDisplayForm::maxHoldCheckBox_toggled( bool newState )
+void SpectrumDisplayForm::maxHoldCheckBox_toggled(bool newState)
{
- MaxHoldResetBtn->setEnabled(newState);
- _frequencyDisplayPlot->setMaxFFTVisible(newState);
- maxHoldResetBtn_clicked();
+ MaxHoldResetBtn->setEnabled(newState);
+ _frequencyDisplayPlot->setMaxFFTVisible(newState);
+ maxHoldResetBtn_clicked();
}
-void
-SpectrumDisplayForm::minHoldCheckBox_toggled( bool newState )
+void SpectrumDisplayForm::minHoldCheckBox_toggled(bool newState)
{
- MinHoldResetBtn->setEnabled(newState);
- _frequencyDisplayPlot->setMinFFTVisible(newState);
- minHoldResetBtn_clicked();
+ MinHoldResetBtn->setEnabled(newState);
+ _frequencyDisplayPlot->setMinFFTVisible(newState);
+ minHoldResetBtn_clicked();
}
-void
-SpectrumDisplayForm::minHoldResetBtn_clicked()
+void SpectrumDisplayForm::minHoldResetBtn_clicked()
{
- _frequencyDisplayPlot->clearMinData();
- _frequencyDisplayPlot->replot();
+ _frequencyDisplayPlot->clearMinData();
+ _frequencyDisplayPlot->replot();
}
-void
-SpectrumDisplayForm::maxHoldResetBtn_clicked()
+void SpectrumDisplayForm::maxHoldResetBtn_clicked()
{
- _frequencyDisplayPlot->clearMaxData();
- _frequencyDisplayPlot->replot();
+ _frequencyDisplayPlot->clearMaxData();
+ _frequencyDisplayPlot->replot();
}
-void
-SpectrumDisplayForm::tabChanged(int index)
+void SpectrumDisplayForm::tabChanged(int index)
{
- // This might be dangerous to call this with NULL
- resizeEvent(NULL);
+ // This might be dangerous to call this with NULL
+ resizeEvent(NULL);
}
-void
-SpectrumDisplayForm::setFrequencyRange(const double newCenterFrequency,
- const double newStartFrequency,
- const double newStopFrequency)
+void SpectrumDisplayForm::setFrequencyRange(const double newCenterFrequency,
+ const double newStartFrequency,
+ const double newStopFrequency)
{
- double fcenter;
- if(UseRFFrequenciesCheckBox->isChecked()) {
- fcenter = newCenterFrequency;
- }
- else {
- fcenter = 0;
- }
-
- double fdiff = std::max(fabs(newStartFrequency), fabs(newStopFrequency));
- if(fdiff > 0) {
- std::string strunits[4] = {"Hz", "kHz", "MHz", "GHz"};
- std::string strtime[4] = {"sec", "ms", "us", "ns"};
- double units10 = floor(log10(fdiff));
- double units3 = std::max(floor(units10 / 3.0), 0.0);
- d_units = pow(10, (units10-fmod(units10, 3.0)));
- int iunit = static_cast<int>(units3);
-
- _startFrequency = newStartFrequency;
- _stopFrequency = newStopFrequency;
- _centerFrequency = newCenterFrequency;
+ double fcenter;
+ if (UseRFFrequenciesCheckBox->isChecked()) {
+ fcenter = newCenterFrequency;
+ } else {
+ fcenter = 0;
+ }
- _frequencyDisplayPlot->setFrequencyRange(fcenter, fdiff,
- d_units, strunits[iunit]);
- _waterfallDisplayPlot->setFrequencyRange(fcenter, fdiff,
- d_units, strunits[iunit]);
- _timeDomainDisplayPlot->setSampleRate((_stopFrequency - _startFrequency)/2.0,
- d_units, strtime[iunit]);
- }
+ double fdiff = std::max(fabs(newStartFrequency), fabs(newStopFrequency));
+ if (fdiff > 0) {
+ std::string strunits[4] = { "Hz", "kHz", "MHz", "GHz" };
+ std::string strtime[4] = { "sec", "ms", "us", "ns" };
+ double units10 = floor(log10(fdiff));
+ double units3 = std::max(floor(units10 / 3.0), 0.0);
+ d_units = pow(10, (units10 - fmod(units10, 3.0)));
+ int iunit = static_cast<int>(units3);
+
+ _startFrequency = newStartFrequency;
+ _stopFrequency = newStopFrequency;
+ _centerFrequency = newCenterFrequency;
+
+ _frequencyDisplayPlot->setFrequencyRange(
+ fcenter, fdiff, d_units, strunits[iunit]);
+ _waterfallDisplayPlot->setFrequencyRange(
+ fcenter, fdiff, d_units, strunits[iunit]);
+ _timeDomainDisplayPlot->setSampleRate(
+ (_stopFrequency - _startFrequency) / 2.0, d_units, strtime[iunit]);
+ }
}
-int
-SpectrumDisplayForm::getAverageCount()
-{
- return _historyVector->size();
-}
+int SpectrumDisplayForm::getAverageCount() { return _historyVector->size(); }
-void
-SpectrumDisplayForm::setAverageCount(const int newCount)
+void SpectrumDisplayForm::setAverageCount(const int newCount)
{
- if(newCount > -1) {
- if(newCount != static_cast<int>(_historyVector->size())) {
- std::vector<double*>::iterator pos;
- while(newCount < static_cast<int>(_historyVector->size())) {
- pos = _historyVector->begin();
- delete[] (*pos);
- _historyVector->erase(pos);
- }
+ if (newCount > -1) {
+ if (newCount != static_cast<int>(_historyVector->size())) {
+ std::vector<double*>::iterator pos;
+ while (newCount < static_cast<int>(_historyVector->size())) {
+ pos = _historyVector->begin();
+ delete[](*pos);
+ _historyVector->erase(pos);
+ }
- while(newCount > static_cast<int>(_historyVector->size())) {
- _historyVector->push_back(new double[_numRealDataPoints]);
- }
- averageDataReset();
- }
- }
-}
-
-void
-SpectrumDisplayForm::_averageHistory(const double* newBuffer)
-{
- if(_numRealDataPoints > 0) {
- if(_historyVector->size() > 0) {
- memcpy(_historyVector->operator[](_historyEntry), newBuffer,
- _numRealDataPoints*sizeof(double));
-
- // Increment the next location to store data
- _historyEntryCount++;
- if(_historyEntryCount > static_cast<int>(_historyVector->size())) {
- _historyEntryCount = _historyVector->size();
- }
- _historyEntry += 1;
- _historyEntry = _historyEntry % _historyVector->size();
-
- // Total up and then average the values
- double sum;
- for(uint64_t location = 0; location < _numRealDataPoints; location++) {
- sum = 0;
- for(int number = 0; number < _historyEntryCount; number++) {
- sum += _historyVector->operator[](number)[location];
- }
- _averagedValues[location] = sum/static_cast<double>(_historyEntryCount);
- }
+ while (newCount > static_cast<int>(_historyVector->size())) {
+ _historyVector->push_back(new double[_numRealDataPoints]);
+ }
+ averageDataReset();
+ }
}
- else {
- memcpy(_averagedValues, newBuffer, _numRealDataPoints*sizeof(double));
+}
+
+void SpectrumDisplayForm::_averageHistory(const double* newBuffer)
+{
+ if (_numRealDataPoints > 0) {
+ if (_historyVector->size() > 0) {
+ memcpy(_historyVector->operator[](_historyEntry),
+ newBuffer,
+ _numRealDataPoints * sizeof(double));
+
+ // Increment the next location to store data
+ _historyEntryCount++;
+ if (_historyEntryCount > static_cast<int>(_historyVector->size())) {
+ _historyEntryCount = _historyVector->size();
+ }
+ _historyEntry += 1;
+ _historyEntry = _historyEntry % _historyVector->size();
+
+ // Total up and then average the values
+ double sum;
+ for (uint64_t location = 0; location < _numRealDataPoints; location++) {
+ sum = 0;
+ for (int number = 0; number < _historyEntryCount; number++) {
+ sum += _historyVector->operator[](number)[location];
+ }
+ _averagedValues[location] = sum / static_cast<double>(_historyEntryCount);
+ }
+ } else {
+ memcpy(_averagedValues, newBuffer, _numRealDataPoints * sizeof(double));
+ }
}
- }
}
-void
-SpectrumDisplayForm::resizeBuffers(const uint64_t numFFTDataPoints,
- const uint64_t /*numTimeDomainDataPoints*/)
+void SpectrumDisplayForm::resizeBuffers(const uint64_t numFFTDataPoints,
+ const uint64_t /*numTimeDomainDataPoints*/)
{
- // Convert from Complex to Real for certain Displays
- if(_numRealDataPoints != numFFTDataPoints) {
- _numRealDataPoints = numFFTDataPoints;
- delete[] _realFFTDataPoints;
- delete[] _averagedValues;
+ // Convert from Complex to Real for certain Displays
+ if (_numRealDataPoints != numFFTDataPoints) {
+ _numRealDataPoints = numFFTDataPoints;
+ delete[] _realFFTDataPoints;
+ delete[] _averagedValues;
- _realFFTDataPoints = new double[_numRealDataPoints];
- _averagedValues = new double[_numRealDataPoints];
- memset(_realFFTDataPoints, 0x0, _numRealDataPoints*sizeof(double));
+ _realFFTDataPoints = new double[_numRealDataPoints];
+ _averagedValues = new double[_numRealDataPoints];
+ memset(_realFFTDataPoints, 0x0, _numRealDataPoints * sizeof(double));
- const int historySize = _historyVector->size();
- setAverageCount(0); // Clear the existing history
- setAverageCount(historySize);
+ const int historySize = _historyVector->size();
+ setAverageCount(0); // Clear the existing history
+ setAverageCount(historySize);
- reset();
- }
+ reset();
+ }
}
-void
-SpectrumDisplayForm::reset()
+void SpectrumDisplayForm::reset()
{
- averageDataReset();
+ averageDataReset();
- _waterfallDisplayPlot->resetAxis();
+ _waterfallDisplayPlot->resetAxis();
}
-void
-SpectrumDisplayForm::averageDataReset()
+void SpectrumDisplayForm::averageDataReset()
{
- _historyEntry = 0;
- _historyEntryCount = 0;
+ _historyEntry = 0;
+ _historyEntryCount = 0;
- memset(_averagedValues, 0x0, _numRealDataPoints*sizeof(double));
+ memset(_averagedValues, 0x0, _numRealDataPoints * sizeof(double));
- maxHoldResetBtn_clicked();
- minHoldResetBtn_clicked();
+ maxHoldResetBtn_clicked();
+ minHoldResetBtn_clicked();
}
-void
-SpectrumDisplayForm::closeEvent(QCloseEvent *e)
+void SpectrumDisplayForm::closeEvent(QCloseEvent* e)
{
- if(_systemSpecifiedFlag){
- _system->setWindowOpenFlag(false);
- }
+ if (_systemSpecifiedFlag) {
+ _system->setWindowOpenFlag(false);
+ }
- qApp->processEvents();
+ qApp->processEvents();
- QWidget::closeEvent(e); //equivalent to e->accept()
+ QWidget::closeEvent(e); // equivalent to e->accept()
}
-void
-SpectrumDisplayForm::windowTypeChanged(int newItem)
+void SpectrumDisplayForm::windowTypeChanged(int newItem)
{
- if(_systemSpecifiedFlag) {
- _system->setWindowType(newItem);
- }
+ if (_systemSpecifiedFlag) {
+ _system->setWindowType(newItem);
+ }
}
-void
-SpectrumDisplayForm::useRFFrequenciesCB(bool useRFFlag)
+void SpectrumDisplayForm::useRFFrequenciesCB(bool useRFFlag)
{
- setFrequencyRange(_centerFrequency, _startFrequency, _stopFrequency);
+ setFrequencyRange(_centerFrequency, _startFrequency, _stopFrequency);
}
-void
-SpectrumDisplayForm::toggleRFFrequencies(bool en)
+void SpectrumDisplayForm::toggleRFFrequencies(bool en)
{
- UseRFFrequenciesCheckBox->setChecked(en);
+ UseRFFrequenciesCheckBox->setChecked(en);
}
-void
-SpectrumDisplayForm::waterfallMaximumIntensityChangedCB(double newValue)
+void SpectrumDisplayForm::waterfallMaximumIntensityChangedCB(double newValue)
{
- if(newValue > WaterfallMinimumIntensitySlider->value()) {
- WaterfallMaximumIntensityLabel->setText(QString("%1 dB").arg(newValue, 0, 'f', 0));
- }
- else{
- WaterfallMinimumIntensitySlider->setValue(newValue - 2);
- }
+ if (newValue > WaterfallMinimumIntensitySlider->value()) {
+ WaterfallMaximumIntensityLabel->setText(
+ QString("%1 dB").arg(newValue, 0, 'f', 0));
+ } else {
+ WaterfallMinimumIntensitySlider->setValue(newValue - 2);
+ }
- _waterfallDisplayPlot->setIntensityRange(WaterfallMinimumIntensitySlider->value(),
- WaterfallMaximumIntensitySlider->value());
+ _waterfallDisplayPlot->setIntensityRange(WaterfallMinimumIntensitySlider->value(),
+ WaterfallMaximumIntensitySlider->value());
}
-void
-SpectrumDisplayForm::waterfallMinimumIntensityChangedCB( double newValue )
+void SpectrumDisplayForm::waterfallMinimumIntensityChangedCB(double newValue)
{
- if(newValue < WaterfallMaximumIntensitySlider->value()){
- WaterfallMinimumIntensityLabel->setText(QString("%1 dB").arg(newValue, 0, 'f', 0));
- }
- else{
- WaterfallMaximumIntensitySlider->setValue(newValue + 2);
- }
+ if (newValue < WaterfallMaximumIntensitySlider->value()) {
+ WaterfallMinimumIntensityLabel->setText(
+ QString("%1 dB").arg(newValue, 0, 'f', 0));
+ } else {
+ WaterfallMaximumIntensitySlider->setValue(newValue + 2);
+ }
- _waterfallDisplayPlot->setIntensityRange(WaterfallMinimumIntensitySlider->value(),
- WaterfallMaximumIntensitySlider->value());
+ _waterfallDisplayPlot->setIntensityRange(WaterfallMinimumIntensitySlider->value(),
+ WaterfallMaximumIntensitySlider->value());
}
-void
-SpectrumDisplayForm::fftComboBoxSelectedCB(const QString &fftSizeString)
+void SpectrumDisplayForm::fftComboBoxSelectedCB(const QString& fftSizeString)
{
- if(_systemSpecifiedFlag){
- _system->setFFTSize(fftSizeString.toLong());
- }
+ if (_systemSpecifiedFlag) {
+ _system->setFFTSize(fftSizeString.toLong());
+ }
}
-void
-SpectrumDisplayForm::waterfallAutoScaleBtnCB()
+void SpectrumDisplayForm::waterfallAutoScaleBtnCB()
{
- double minimumIntensity = _noiseFloorAmplitude - 5;
- double maximumIntensity = _peakAmplitude + 10;
+ double minimumIntensity = _noiseFloorAmplitude - 5;
+ double maximumIntensity = _peakAmplitude + 10;
#if QWT_VERSION < 0x060100
- if(minimumIntensity < WaterfallMinimumIntensitySlider->minValue()) {
- minimumIntensity = WaterfallMinimumIntensitySlider->minValue();
- }
- WaterfallMinimumIntensitySlider->setValue(minimumIntensity);
- if(maximumIntensity > WaterfallMaximumIntensitySlider->maxValue()) {
- maximumIntensity = WaterfallMaximumIntensitySlider->maxValue();
- }
-#else /* QWT_VERSION < 0x060100 */
- if(minimumIntensity < WaterfallMinimumIntensitySlider->lowerBound()) {
- minimumIntensity = WaterfallMinimumIntensitySlider->lowerBound();
- }
- WaterfallMinimumIntensitySlider->setValue(minimumIntensity);
- if(maximumIntensity > WaterfallMaximumIntensitySlider->upperBound()) {
- maximumIntensity = WaterfallMaximumIntensitySlider->upperBound();
- }
-#endif /* QWT_VERSION < 0x060100 */
-
- WaterfallMaximumIntensitySlider->setValue(maximumIntensity);
- waterfallMaximumIntensityChangedCB(maximumIntensity);
-}
-
-void
-SpectrumDisplayForm::waterfallIntensityColorTypeChanged( int newType )
-{
- QColor lowIntensityColor;
- QColor highIntensityColor;
- if(newType == INTENSITY_COLOR_MAP_TYPE_USER_DEFINED){
- // Select the Low Intensity Color
- lowIntensityColor = _waterfallDisplayPlot->getUserDefinedLowIntensityColor();
- if(!lowIntensityColor.isValid()){
- lowIntensityColor = Qt::black;
+ if (minimumIntensity < WaterfallMinimumIntensitySlider->minValue()) {
+ minimumIntensity = WaterfallMinimumIntensitySlider->minValue();
+ }
+ WaterfallMinimumIntensitySlider->setValue(minimumIntensity);
+ if (maximumIntensity > WaterfallMaximumIntensitySlider->maxValue()) {
+ maximumIntensity = WaterfallMaximumIntensitySlider->maxValue();
}
- QMessageBox::information(this, "Low Intensity Color Selection", "In the next window, select the low intensity color for the waterfall display", QMessageBox::Ok);
- lowIntensityColor = QColorDialog::getColor(lowIntensityColor, this);
+#else /* QWT_VERSION < 0x060100 */
+ if (minimumIntensity < WaterfallMinimumIntensitySlider->lowerBound()) {
+ minimumIntensity = WaterfallMinimumIntensitySlider->lowerBound();
+ }
+ WaterfallMinimumIntensitySlider->setValue(minimumIntensity);
+ if (maximumIntensity > WaterfallMaximumIntensitySlider->upperBound()) {
+ maximumIntensity = WaterfallMaximumIntensitySlider->upperBound();
+ }
+#endif /* QWT_VERSION < 0x060100 */
- // Select the High Intensity Color
- highIntensityColor = _waterfallDisplayPlot->getUserDefinedHighIntensityColor();
- if(!highIntensityColor.isValid()){
- highIntensityColor = Qt::white;
+ WaterfallMaximumIntensitySlider->setValue(maximumIntensity);
+ waterfallMaximumIntensityChangedCB(maximumIntensity);
+}
+
+void SpectrumDisplayForm::waterfallIntensityColorTypeChanged(int newType)
+{
+ QColor lowIntensityColor;
+ QColor highIntensityColor;
+ if (newType == INTENSITY_COLOR_MAP_TYPE_USER_DEFINED) {
+ // Select the Low Intensity Color
+ lowIntensityColor = _waterfallDisplayPlot->getUserDefinedLowIntensityColor();
+ if (!lowIntensityColor.isValid()) {
+ lowIntensityColor = Qt::black;
+ }
+ QMessageBox::information(this,
+ "Low Intensity Color Selection",
+ "In the next window, select the low intensity color for "
+ "the waterfall display",
+ QMessageBox::Ok);
+ lowIntensityColor = QColorDialog::getColor(lowIntensityColor, this);
+
+ // Select the High Intensity Color
+ highIntensityColor = _waterfallDisplayPlot->getUserDefinedHighIntensityColor();
+ if (!highIntensityColor.isValid()) {
+ highIntensityColor = Qt::white;
+ }
+ QMessageBox::information(this,
+ "High Intensity Color Selection",
+ "In the next window, select the high intensity color "
+ "for the waterfall display",
+ QMessageBox::Ok);
+ highIntensityColor = QColorDialog::getColor(highIntensityColor, this);
}
- QMessageBox::information(this, "High Intensity Color Selection", "In the next window, select the high intensity color for the waterfall display", QMessageBox::Ok);
- highIntensityColor = QColorDialog::getColor(highIntensityColor, this);
- }
- _waterfallDisplayPlot->setIntensityColorMapType(0, newType, lowIntensityColor, highIntensityColor);
+ _waterfallDisplayPlot->setIntensityColorMapType(
+ 0, newType, lowIntensityColor, highIntensityColor);
}
-void
-SpectrumDisplayForm::toggleTabFrequency(const bool state)
+void SpectrumDisplayForm::toggleTabFrequency(const bool state)
{
- if(state == true) {
- if(d_plot_fft == -1) {
- SpectrumTypeTab->addTab(FrequencyPage, "Frequency Display");
- d_plot_fft = SpectrumTypeTab->count()-1;
+ if (state == true) {
+ if (d_plot_fft == -1) {
+ SpectrumTypeTab->addTab(FrequencyPage, "Frequency Display");
+ d_plot_fft = SpectrumTypeTab->count() - 1;
+ }
+ } else {
+ SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(FrequencyPage));
+ d_plot_fft = -1;
}
- }
- else {
- SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(FrequencyPage));
- d_plot_fft = -1;
- }
}
-void
-SpectrumDisplayForm::toggleTabWaterfall(const bool state)
+void SpectrumDisplayForm::toggleTabWaterfall(const bool state)
{
- if(state == true) {
- if(d_plot_waterfall == -1) {
- SpectrumTypeTab->addTab(WaterfallPage, "Waterfall Display");
- d_plot_waterfall = SpectrumTypeTab->count()-1;
+ if (state == true) {
+ if (d_plot_waterfall == -1) {
+ SpectrumTypeTab->addTab(WaterfallPage, "Waterfall Display");
+ d_plot_waterfall = SpectrumTypeTab->count() - 1;
+ }
+ } else {
+ SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(WaterfallPage));
+ d_plot_waterfall = -1;
}
- }
- else {
- SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(WaterfallPage));
- d_plot_waterfall = -1;
- }
}
-void
-SpectrumDisplayForm::toggleTabTime(const bool state)
+void SpectrumDisplayForm::toggleTabTime(const bool state)
{
- if(state == true) {
- if(d_plot_time == -1) {
- SpectrumTypeTab->addTab(TimeDomainPage, "Time Domain Display");
- d_plot_time = SpectrumTypeTab->count()-1;
+ if (state == true) {
+ if (d_plot_time == -1) {
+ SpectrumTypeTab->addTab(TimeDomainPage, "Time Domain Display");
+ d_plot_time = SpectrumTypeTab->count() - 1;
+ }
+ } else {
+ SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(TimeDomainPage));
+ d_plot_time = -1;
}
- }
- else {
- SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(TimeDomainPage));
- d_plot_time = -1;
- }
}
-void
-SpectrumDisplayForm::toggleTabConstellation(const bool state)
+void SpectrumDisplayForm::toggleTabConstellation(const bool state)
{
- if(state == true) {
- if(d_plot_constellation == -1) {
- SpectrumTypeTab->addTab(ConstellationPage, "Constellation Display");
- d_plot_constellation = SpectrumTypeTab->count()-1;
+ if (state == true) {
+ if (d_plot_constellation == -1) {
+ SpectrumTypeTab->addTab(ConstellationPage, "Constellation Display");
+ d_plot_constellation = SpectrumTypeTab->count() - 1;
+ }
+ } else {
+ SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(ConstellationPage));
+ d_plot_constellation = -1;
}
- }
- else {
- SpectrumTypeTab->removeTab(SpectrumTypeTab->indexOf(ConstellationPage));
- d_plot_constellation = -1;
- }
}
-void
-SpectrumDisplayForm::setTimeDomainAxis(double min, double max)
+void SpectrumDisplayForm::setTimeDomainAxis(double min, double max)
{
- _timeDomainDisplayPlot->setYaxis(min, max);
+ _timeDomainDisplayPlot->setYaxis(min, max);
}
-void
-SpectrumDisplayForm::setConstellationAxis(double xmin, double xmax,
- double ymin, double ymax)
+void SpectrumDisplayForm::setConstellationAxis(double xmin,
+ double xmax,
+ double ymin,
+ double ymax)
{
- _constellationDisplayPlot->set_axis(xmin, xmax, ymin, ymax);
+ _constellationDisplayPlot->set_axis(xmin, xmax, ymin, ymax);
}
-void
-SpectrumDisplayForm::setConstellationPenSize(int size)
+void SpectrumDisplayForm::setConstellationPenSize(int size)
{
- _constellationDisplayPlot->set_pen_size( size );
+ _constellationDisplayPlot->set_pen_size(size);
}
-void
-SpectrumDisplayForm::setFrequencyAxis(double min, double max)
+void SpectrumDisplayForm::setFrequencyAxis(double min, double max)
{
- _frequencyDisplayPlot->setYaxis(min, max);
+ _frequencyDisplayPlot->setYaxis(min, max);
}
-void
-SpectrumDisplayForm::setUpdateTime(double t)
+void SpectrumDisplayForm::setUpdateTime(double t)
{
- d_update_time = t;
- // QTimer class takes millisecond input
- displayTimer->start(d_update_time*1000);
+ d_update_time = t;
+ // QTimer class takes millisecond input
+ displayTimer->start(d_update_time * 1000);
}
-void
-SpectrumDisplayForm::onFFTPlotPointSelected(const QPointF p)
+void SpectrumDisplayForm::onFFTPlotPointSelected(const QPointF p)
{
- d_clicked = true;
- d_clicked_freq = d_units*p.x();
+ d_clicked = true;
+ d_clicked_freq = d_units * p.x();
- setFrequencyRange(d_clicked_freq, _startFrequency, _stopFrequency);
+ setFrequencyRange(d_clicked_freq, _startFrequency, _stopFrequency);
}
-void
-SpectrumDisplayForm::onWFallPlotPointSelected(const QPointF p)
+void SpectrumDisplayForm::onWFallPlotPointSelected(const QPointF p)
{
- d_clicked = true;
- d_clicked_freq = d_units*p.x();
+ d_clicked = true;
+ d_clicked_freq = d_units * p.x();
- setFrequencyRange(d_clicked_freq, _startFrequency, _stopFrequency);
+ setFrequencyRange(d_clicked_freq, _startFrequency, _stopFrequency);
}
-void
-SpectrumDisplayForm::onTimePlotPointSelected(const QPointF p)
+void SpectrumDisplayForm::onTimePlotPointSelected(const QPointF p)
{
- //emit plotPointSelected(p, 3);
+ // emit plotPointSelected(p, 3);
}
-void
-SpectrumDisplayForm::onConstPlotPointSelected(const QPointF p)
+void SpectrumDisplayForm::onConstPlotPointSelected(const QPointF p)
{
- //emit plotPointSelected(p, 4);
+ // emit plotPointSelected(p, 4);
}
-bool
-SpectrumDisplayForm::checkClicked()
+bool SpectrumDisplayForm::checkClicked()
{
- if(d_clicked) {
- d_clicked = false;
- return true;
- }
- else {
- return false;
- }
+ if (d_clicked) {
+ d_clicked = false;
+ return true;
+ } else {
+ return false;
+ }
}
-float
-SpectrumDisplayForm::getClickedFreq() const
-{
- return d_clicked_freq;
-}
+float SpectrumDisplayForm::getClickedFreq() const { return d_clicked_freq; }
diff --git a/gr-qtgui/lib/timeRasterGlobalData.cc b/gr-qtgui/lib/timeRasterGlobalData.cc
index 18d8b8daef..5f9d097077 100644
--- a/gr-qtgui/lib/timeRasterGlobalData.cc
+++ b/gr-qtgui/lib/timeRasterGlobalData.cc
@@ -31,211 +31,189 @@
TimeRasterData::TimeRasterData(const double rows, const double cols)
#if QWT_VERSION < 0x060000
- : QwtRasterData(QwtDoubleRect(0, 0, rows, cols))
+ : QwtRasterData(QwtDoubleRect(0, 0, rows, cols))
#else
: QwtRasterData()
#endif
{
- d_nitems = 0;
- d_rows = rows;
- d_cols = cols;
- d_resid = 0;
+ d_nitems = 0;
+ d_rows = rows;
+ d_cols = cols;
+ d_resid = 0;
- // We add 1 here so we always have the next row already started
- // (helps when d_cols is fractional and we have to slide).
- d_totalitems = static_cast<int>((d_rows+1)*floor(d_cols));
- d_data_size = d_totalitems + static_cast<int>(floor(d_cols));
+ // We add 1 here so we always have the next row already started
+ // (helps when d_cols is fractional and we have to slide).
+ d_totalitems = static_cast<int>((d_rows + 1) * floor(d_cols));
+ d_data_size = d_totalitems + static_cast<int>(floor(d_cols));
- d_intensityRange = QwtDoubleInterval(0.0, 10.0);
- d_data = new double[d_data_size];
+ d_intensityRange = QwtDoubleInterval(0.0, 10.0);
+ d_data = new double[d_data_size];
#if QWT_VERSION >= 0x060000
- setInterval(Qt::XAxis, QwtInterval(0, cols));
- setInterval(Qt::YAxis, QwtInterval(0, rows));
- setInterval(Qt::ZAxis, QwtInterval(0.0, 10.0));
+ setInterval(Qt::XAxis, QwtInterval(0, cols));
+ setInterval(Qt::YAxis, QwtInterval(0, rows));
+ setInterval(Qt::ZAxis, QwtInterval(0.0, 10.0));
#endif
- reset();
+ reset();
}
-TimeRasterData::~TimeRasterData()
-{
- delete [] d_data;
-}
+TimeRasterData::~TimeRasterData() { delete[] d_data; }
void TimeRasterData::reset()
{
- d_resid = 0;
- d_nitems = 0;
- memset(d_data, 0x0, d_data_size*sizeof(double));
+ d_resid = 0;
+ d_nitems = 0;
+ memset(d_data, 0x0, d_data_size * sizeof(double));
}
void TimeRasterData::copy(const TimeRasterData* rhs)
{
#if QWT_VERSION < 0x060000
- if((d_cols != rhs->getNumCols()) ||
- (boundingRect() != rhs->boundingRect()) ){
- d_cols = rhs->getNumCols();
- d_rows = rhs->getNumRows();
- d_totalitems = static_cast<int>((d_rows+1)*floor(d_cols));
- d_data_size = d_totalitems + static_cast<int>(floor(d_cols));
- setBoundingRect(rhs->boundingRect());
- delete [] d_data;
- d_data = new double[d_data_size];
- }
+ if ((d_cols != rhs->getNumCols()) || (boundingRect() != rhs->boundingRect())) {
+ d_cols = rhs->getNumCols();
+ d_rows = rhs->getNumRows();
+ d_totalitems = static_cast<int>((d_rows + 1) * floor(d_cols));
+ d_data_size = d_totalitems + static_cast<int>(floor(d_cols));
+ setBoundingRect(rhs->boundingRect());
+ delete[] d_data;
+ d_data = new double[d_data_size];
+ }
#else
- if((d_cols != rhs->getNumCols()) || (d_rows != rhs->getNumRows())) {
- d_cols = rhs->getNumCols();
- d_rows = rhs->getNumRows();
- d_totalitems = static_cast<int>((d_rows+1)*floor(d_cols));
- d_data_size = d_totalitems + static_cast<int>(floor(d_cols));
- delete [] d_data;
- d_data = new double[d_data_size];
- }
+ if ((d_cols != rhs->getNumCols()) || (d_rows != rhs->getNumRows())) {
+ d_cols = rhs->getNumCols();
+ d_rows = rhs->getNumRows();
+ d_totalitems = static_cast<int>((d_rows + 1) * floor(d_cols));
+ d_data_size = d_totalitems + static_cast<int>(floor(d_cols));
+ delete[] d_data;
+ d_data = new double[d_data_size];
+ }
#endif
- reset();
+ reset();
#if QWT_VERSION < 0x060000
- setRange(rhs->range());
+ setRange(rhs->range());
#else
- setInterval(Qt::XAxis, rhs->interval(Qt::XAxis));
- setInterval(Qt::YAxis, rhs->interval(Qt::YAxis));
- setInterval(Qt::ZAxis, rhs->interval(Qt::ZAxis));
+ setInterval(Qt::XAxis, rhs->interval(Qt::XAxis));
+ setInterval(Qt::YAxis, rhs->interval(Qt::YAxis));
+ setInterval(Qt::ZAxis, rhs->interval(Qt::ZAxis));
#endif
}
void TimeRasterData::resizeData(const double rows, const double cols)
{
#if QWT_VERSION < 0x060000
- if((cols != getNumCols()) || (boundingRect().width() != cols) ||
- (rows != getNumRows()) || (boundingRect().height() != cols)) {
- setBoundingRect(QwtDoubleRect(0, 0, cols, rows));
- d_cols = cols;
- d_rows = rows;
- d_totalitems = static_cast<int>((d_rows+1)*floor(d_cols));
- d_data_size = d_totalitems + static_cast<int>(floor(d_cols));
- delete [] d_data;
- d_data = new double[d_data_size];
- }
+ if ((cols != getNumCols()) || (boundingRect().width() != cols) ||
+ (rows != getNumRows()) || (boundingRect().height() != cols)) {
+ setBoundingRect(QwtDoubleRect(0, 0, cols, rows));
+ d_cols = cols;
+ d_rows = rows;
+ d_totalitems = static_cast<int>((d_rows + 1) * floor(d_cols));
+ d_data_size = d_totalitems + static_cast<int>(floor(d_cols));
+ delete[] d_data;
+ d_data = new double[d_data_size];
+ }
#else
- if((cols != getNumCols()) || (interval(Qt::XAxis).width() != cols) ||
- (rows != getNumRows()) || (interval(Qt::YAxis).width() != rows)) {
+ if ((cols != getNumCols()) || (interval(Qt::XAxis).width() != cols) ||
+ (rows != getNumRows()) || (interval(Qt::YAxis).width() != rows)) {
- setInterval(Qt::XAxis, QwtInterval(0, cols));
- setInterval(Qt::YAxis, QwtInterval(0, rows));
+ setInterval(Qt::XAxis, QwtInterval(0, cols));
+ setInterval(Qt::YAxis, QwtInterval(0, rows));
- d_cols = cols;
- d_rows = rows;
- d_totalitems = static_cast<int>((d_rows+1)*floor(d_cols));
- d_data_size = d_totalitems + static_cast<int>(floor(d_cols));
+ d_cols = cols;
+ d_rows = rows;
+ d_totalitems = static_cast<int>((d_rows + 1) * floor(d_cols));
+ d_data_size = d_totalitems + static_cast<int>(floor(d_cols));
- delete [] d_data;
- d_data = new double[d_data_size];
- }
+ delete[] d_data;
+ d_data = new double[d_data_size];
+ }
#endif
- reset();
+ reset();
}
-QwtRasterData *TimeRasterData::copy() const
+QwtRasterData* TimeRasterData::copy() const
{
#if QWT_VERSION < 0x060000
- TimeRasterData* returnData = \
- new TimeRasterData(d_cols, d_rows);
+ TimeRasterData* returnData = new TimeRasterData(d_cols, d_rows);
#else
- TimeRasterData* returnData = \
- new TimeRasterData(d_cols, d_rows);
+ TimeRasterData* returnData = new TimeRasterData(d_cols, d_rows);
#endif
- returnData->copy(this);
- return returnData;
+ returnData->copy(this);
+ return returnData;
}
#if QWT_VERSION < 0x060000
-QwtDoubleInterval TimeRasterData::range() const
-{
- return d_intensityRange;
-}
+QwtDoubleInterval TimeRasterData::range() const { return d_intensityRange; }
void TimeRasterData::setRange(const QwtDoubleInterval& newRange)
{
- d_intensityRange = newRange;
+ d_intensityRange = newRange;
}
#endif
-double
-TimeRasterData::value(double x, double y) const
+double TimeRasterData::value(double x, double y) const
{
- double returnValue = 0.0;
+ double returnValue = 0.0;
#if QWT_VERSION < 0x060000
- double top = boundingRect().top();
- double bottom = top - boundingRect().height();
- double left = boundingRect().left();
- double right = left - boundingRect().width();
+ double top = boundingRect().top();
+ double bottom = top - boundingRect().height();
+ double left = boundingRect().left();
+ double right = left - boundingRect().width();
#else
- double top = interval(Qt::YAxis).maxValue();
- double bottom = interval(Qt::YAxis).minValue();
- double left = interval(Qt::XAxis).minValue();
- double right = interval(Qt::XAxis).maxValue();
+ double top = interval(Qt::YAxis).maxValue();
+ double bottom = interval(Qt::YAxis).minValue();
+ double left = interval(Qt::XAxis).minValue();
+ double right = interval(Qt::XAxis).maxValue();
#endif
- if((x < left) || (x > right) || (y < bottom) || (y > top))
- return 0.0;
+ if ((x < left) || (x > right) || (y < bottom) || (y > top))
+ return 0.0;
- double _y = floor(top - y);
- double _loc = _y*(d_cols) + x + d_resid;
- int location = static_cast<int>(_loc);
+ double _y = floor(top - y);
+ double _loc = _y * (d_cols) + x + d_resid;
+ int location = static_cast<int>(_loc);
- if((location > -1) && (location < d_data_size)) {
- returnValue = d_data[location];
- }
+ if ((location > -1) && (location < d_data_size)) {
+ returnValue = d_data[location];
+ }
- return returnValue;
+ return returnValue;
}
-void
-TimeRasterData::incrementResidual()
+void TimeRasterData::incrementResidual()
{
- // After a full set of rows are drawn, we want to add up the
- // residual due to any fractional value of d_cols to appropriately
- // shift the next data in.
- double icols = floor(d_cols);
- d_resid = fmod(d_resid + (d_cols - icols) * d_rows, icols);
+ // After a full set of rows are drawn, we want to add up the
+ // residual due to any fractional value of d_cols to appropriately
+ // shift the next data in.
+ double icols = floor(d_cols);
+ d_resid = fmod(d_resid + (d_cols - icols) * d_rows, icols);
}
-double
-TimeRasterData::getNumCols() const
-{
- return d_cols;
-}
+double TimeRasterData::getNumCols() const { return d_cols; }
-double
-TimeRasterData::getNumRows() const
-{
- return d_rows;
-}
+double TimeRasterData::getNumRows() const { return d_rows; }
-void
-TimeRasterData::addData(const double* data,
- const int dataSize)
+void TimeRasterData::addData(const double* data, const int dataSize)
{
- int cols = static_cast<int>(d_cols);
- if(dataSize == cols) {
- if(d_nitems < d_totalitems) {
- memcpy(&d_data[d_nitems], data, cols*sizeof(double));
- d_nitems += cols;
- }
- else {
- memcpy(&d_data[d_nitems], data, cols*sizeof(double));
- memmove(d_data, &d_data[cols], d_totalitems*sizeof(double));
+ int cols = static_cast<int>(d_cols);
+ if (dataSize == cols) {
+ if (d_nitems < d_totalitems) {
+ memcpy(&d_data[d_nitems], data, cols * sizeof(double));
+ d_nitems += cols;
+ } else {
+ memcpy(&d_data[d_nitems], data, cols * sizeof(double));
+ memmove(d_data, &d_data[cols], d_totalitems * sizeof(double));
+ }
}
- }
}
#endif /* TIMERASTER_GLOBAL_DATA_CPP */
diff --git a/gr-qtgui/lib/time_raster_sink_b_impl.cc b/gr-qtgui/lib/time_raster_sink_b_impl.cc
index ac2518068e..c08e95a8d4 100644
--- a/gr-qtgui/lib/time_raster_sink_b_impl.cc
+++ b/gr-qtgui/lib/time_raster_sink_b_impl.cc
@@ -34,517 +34,425 @@
#include <string.h>
namespace gr {
- namespace qtgui {
-
- time_raster_sink_b::sptr
- time_raster_sink_b::make(double samp_rate,
- double rows, double cols,
- const std::vector<float> &mult,
- const std::vector<float> &offset,
- const std::string &name,
- int nconnections,
- QWidget *parent)
- {
- return gnuradio::get_initial_sptr
- (new time_raster_sink_b_impl(samp_rate,
- rows, cols,
- mult, offset,
- name,
- nconnections,
- parent));
- }
-
- time_raster_sink_b_impl::time_raster_sink_b_impl(double samp_rate,
- double rows, double cols,
- const std::vector<float> &mult,
- const std::vector<float> &offset,
- const std::string &name,
- int nconnections,
- QWidget *parent)
- : sync_block("time_raster_sink_b",
- io_signature::make(0, nconnections, sizeof(char)),
- io_signature::make(0, 0, 0)),
- d_name(name), d_nconnections(nconnections), d_parent(parent),
- d_rows(rows), d_cols(cols),
- d_mult(std::vector<float>(nconnections+1,1)),
- d_offset(std::vector<float>(nconnections+1,0)),
- d_samp_rate(samp_rate)
- {
- // Required now for Qt; argc must be greater than 0 and argv
- // must have at least one valid character. Must be valid through
- // life of the qApplication:
- // http://harmattan-dev.nokia.com/docs/library/html/qt4/qapplication.html
- d_argc = 1;
- d_argv = new char;
- d_argv[0] = '\0';
-
- d_main_gui = NULL;
-
- d_index = 0;
-
- // setup PDU handling input port
- message_port_register_in(pmt::mp("in"));
- set_msg_handler(pmt::mp("in"),
- boost::bind(&time_raster_sink_b_impl::handle_pdus, this, _1));
-
- d_scale = 1.0f;
-
- d_icols = static_cast<int>(ceil(d_cols));
- d_tmpflt = (float*)volk_malloc(d_icols*sizeof(float),
- volk_get_alignment());
- memset(d_tmpflt, 0, d_icols*sizeof(float));
-
- // +1 for the PDU buffer
- for(int i = 0; i < d_nconnections+1; i++) {
- d_residbufs.push_back((double*)volk_malloc(d_icols*sizeof(double),
- volk_get_alignment()));
- memset(d_residbufs[i], 0, d_icols*sizeof(double));
- }
-
- set_multiplier(mult);
- set_offset(offset);
-
- initialize();
- }
-
- time_raster_sink_b_impl::~time_raster_sink_b_impl()
- {
- if(!d_main_gui->isClosed())
+namespace qtgui {
+
+time_raster_sink_b::sptr time_raster_sink_b::make(double samp_rate,
+ double rows,
+ double cols,
+ const std::vector<float>& mult,
+ const std::vector<float>& offset,
+ const std::string& name,
+ int nconnections,
+ QWidget* parent)
+{
+ return gnuradio::get_initial_sptr(new time_raster_sink_b_impl(
+ samp_rate, rows, cols, mult, offset, name, nconnections, parent));
+}
+
+time_raster_sink_b_impl::time_raster_sink_b_impl(double samp_rate,
+ double rows,
+ double cols,
+ const std::vector<float>& mult,
+ const std::vector<float>& offset,
+ const std::string& name,
+ int nconnections,
+ QWidget* parent)
+ : sync_block("time_raster_sink_b",
+ io_signature::make(0, nconnections, sizeof(char)),
+ io_signature::make(0, 0, 0)),
+ d_name(name),
+ d_nconnections(nconnections),
+ d_parent(parent),
+ d_rows(rows),
+ d_cols(cols),
+ d_mult(std::vector<float>(nconnections + 1, 1)),
+ d_offset(std::vector<float>(nconnections + 1, 0)),
+ d_samp_rate(samp_rate)
+{
+ // Required now for Qt; argc must be greater than 0 and argv
+ // must have at least one valid character. Must be valid through
+ // life of the qApplication:
+ // http://harmattan-dev.nokia.com/docs/library/html/qt4/qapplication.html
+ d_argc = 1;
+ d_argv = new char;
+ d_argv[0] = '\0';
+
+ d_main_gui = NULL;
+
+ d_index = 0;
+
+ // setup PDU handling input port
+ message_port_register_in(pmt::mp("in"));
+ set_msg_handler(pmt::mp("in"),
+ boost::bind(&time_raster_sink_b_impl::handle_pdus, this, _1));
+
+ d_scale = 1.0f;
+
+ d_icols = static_cast<int>(ceil(d_cols));
+ d_tmpflt = (float*)volk_malloc(d_icols * sizeof(float), volk_get_alignment());
+ memset(d_tmpflt, 0, d_icols * sizeof(float));
+
+ // +1 for the PDU buffer
+ for (int i = 0; i < d_nconnections + 1; i++) {
+ d_residbufs.push_back(
+ (double*)volk_malloc(d_icols * sizeof(double), volk_get_alignment()));
+ memset(d_residbufs[i], 0, d_icols * sizeof(double));
+ }
+
+ set_multiplier(mult);
+ set_offset(offset);
+
+ initialize();
+}
+
+time_raster_sink_b_impl::~time_raster_sink_b_impl()
+{
+ if (!d_main_gui->isClosed())
d_main_gui->close();
- volk_free(d_tmpflt);
- for(int i = 0; i < d_nconnections+1; i++) {
- volk_free(d_residbufs[i]);
- }
-
- delete d_argv;
+ volk_free(d_tmpflt);
+ for (int i = 0; i < d_nconnections + 1; i++) {
+ volk_free(d_residbufs[i]);
}
- bool
- time_raster_sink_b_impl::check_topology(int ninputs, int noutputs)
- {
- return ninputs == d_nconnections;
- }
+ delete d_argv;
+}
+
+bool time_raster_sink_b_impl::check_topology(int ninputs, int noutputs)
+{
+ return ninputs == d_nconnections;
+}
- void
- time_raster_sink_b_impl::initialize()
- {
- if(qApp != NULL) {
- d_qApplication = qApp;
- }
- else {
+void time_raster_sink_b_impl::initialize()
+{
+ if (qApp != NULL) {
+ d_qApplication = qApp;
+ } else {
#if QT_VERSION >= 0x040500 && QT_VERSION < 0x050000
std::string style = prefs::singleton()->get_string("qtgui", "style", "raster");
QApplication::setGraphicsSystem(QString(style.c_str()));
#endif
- d_qApplication = new QApplication(d_argc, &d_argv);
- }
-
- // If a style sheet is set in the prefs file, enable it here.
- check_set_qss(d_qApplication);
-
- // Create time raster plot; as a bit input, we expect to see 1's
- // and 0's from each stream, so we set the maximum intensity
- // (zmax) to the number of connections so after adding the
- // streams, the max will be the max of 1's from all streams.
- int numplots = (d_nconnections > 0) ? d_nconnections : 1;
- d_main_gui = new TimeRasterDisplayForm(numplots,
- d_samp_rate,
- d_rows, d_cols,
- 1, d_parent);
-
- if(d_name.size() > 0)
+ d_qApplication = new QApplication(d_argc, &d_argv);
+ }
+
+ // If a style sheet is set in the prefs file, enable it here.
+ check_set_qss(d_qApplication);
+
+ // Create time raster plot; as a bit input, we expect to see 1's
+ // and 0's from each stream, so we set the maximum intensity
+ // (zmax) to the number of connections so after adding the
+ // streams, the max will be the max of 1's from all streams.
+ int numplots = (d_nconnections > 0) ? d_nconnections : 1;
+ d_main_gui =
+ new TimeRasterDisplayForm(numplots, d_samp_rate, d_rows, d_cols, 1, d_parent);
+
+ if (d_name.size() > 0)
set_title(d_name);
- // initialize update time to 10 times a second
- set_update_time(0.1);
- }
+ // initialize update time to 10 times a second
+ set_update_time(0.1);
+}
- void
- time_raster_sink_b_impl::exec_()
- {
- d_qApplication->exec();
- }
+void time_raster_sink_b_impl::exec_() { d_qApplication->exec(); }
- QWidget*
- time_raster_sink_b_impl::qwidget()
- {
- return d_main_gui;
- }
+QWidget* time_raster_sink_b_impl::qwidget() { return d_main_gui; }
#ifdef ENABLE_PYTHON
- PyObject*
- time_raster_sink_b_impl::pyqwidget()
- {
- PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui);
- PyObject *retarg = Py_BuildValue("N", w);
- return retarg;
- }
+PyObject* time_raster_sink_b_impl::pyqwidget()
+{
+ PyObject* w = PyLong_FromVoidPtr((void*)d_main_gui);
+ PyObject* retarg = Py_BuildValue("N", w);
+ return retarg;
+}
#else
- void *
- time_raster_sink_b_impl::pyqwidget()
- {
- return NULL;
- }
+void* time_raster_sink_b_impl::pyqwidget() { return NULL; }
#endif
- void
- time_raster_sink_b_impl::set_update_time(double t)
- {
- //convert update time to ticks
- gr::high_res_timer_type tps = gr::high_res_timer_tps();
- d_update_time = t * tps;
- d_main_gui->setUpdateTime(t);
- d_last_time = 0;
- }
-
- void
- time_raster_sink_b_impl::set_title(const std::string &title)
- {
- d_main_gui->setTitle(title.c_str());
- }
+void time_raster_sink_b_impl::set_update_time(double t)
+{
+ // convert update time to ticks
+ gr::high_res_timer_type tps = gr::high_res_timer_tps();
+ d_update_time = t * tps;
+ d_main_gui->setUpdateTime(t);
+ d_last_time = 0;
+}
+
+void time_raster_sink_b_impl::set_title(const std::string& title)
+{
+ d_main_gui->setTitle(title.c_str());
+}
+
+void time_raster_sink_b_impl::set_line_label(unsigned int which, const std::string& label)
+{
+ d_main_gui->setLineLabel(which, label.c_str());
+}
+
+void time_raster_sink_b_impl::set_line_color(unsigned int which, const std::string& color)
+{
+ d_main_gui->setLineColor(which, color.c_str());
+}
+
+void time_raster_sink_b_impl::set_line_width(unsigned int which, int width)
+{
+ d_main_gui->setLineWidth(which, width);
+}
+
+void time_raster_sink_b_impl::set_line_style(unsigned int which, Qt::PenStyle style)
+{
+ d_main_gui->setLineStyle(which, style);
+}
+
+void time_raster_sink_b_impl::set_line_marker(unsigned int which, QwtSymbol::Style marker)
+{
+ d_main_gui->setLineMarker(which, marker);
+}
+
+void time_raster_sink_b_impl::set_color_map(unsigned int which, const int color)
+{
+ d_main_gui->setColorMap(which, color);
+}
+
+void time_raster_sink_b_impl::set_line_alpha(unsigned int which, double alpha)
+{
+ d_main_gui->setAlpha(which, (int)(255.0 * alpha));
+}
+
+void time_raster_sink_b_impl::set_size(int width, int height)
+{
+ d_main_gui->resize(QSize(width, height));
+}
+
+void time_raster_sink_b_impl::set_samp_rate(const double samp_rate)
+{
+ d_samp_rate = samp_rate;
+ d_main_gui->setSampleRate(d_samp_rate);
+}
+
+void time_raster_sink_b_impl::set_num_rows(double rows) { d_main_gui->setNumRows(rows); }
+
+void time_raster_sink_b_impl::set_num_cols(double cols)
+{
+ if (d_cols != cols) {
+ gr::thread::scoped_lock lock(d_setlock);
- void
- time_raster_sink_b_impl::set_line_label(unsigned int which, const std::string &label)
- {
- d_main_gui->setLineLabel(which, label.c_str());
- }
+ d_qApplication->postEvent(d_main_gui, new TimeRasterSetSize(d_rows, cols));
- void
- time_raster_sink_b_impl::set_line_color(unsigned int which, const std::string &color)
- {
- d_main_gui->setLineColor(which, color.c_str());
- }
+ d_cols = cols;
+ d_icols = static_cast<int>(ceil(d_cols));
- void
- time_raster_sink_b_impl::set_line_width(unsigned int which, int width)
- {
- d_main_gui->setLineWidth(which, width);
+ volk_free(d_tmpflt);
+ d_tmpflt = (float*)volk_malloc(d_icols * sizeof(float), volk_get_alignment());
+ memset(d_tmpflt, 0, d_icols * sizeof(float));
+
+ for (int i = 0; i < d_nconnections + 1; i++) {
+ volk_free(d_residbufs[i]);
+ d_residbufs[i] =
+ (double*)volk_malloc(d_icols * sizeof(double), volk_get_alignment());
+ memset(d_residbufs[i], 0, d_icols * sizeof(double));
+ }
+ reset();
}
+}
- void
- time_raster_sink_b_impl::set_line_style(unsigned int which, Qt::PenStyle style)
- {
- d_main_gui->setLineStyle(which, style);
- }
+std::string time_raster_sink_b_impl::title() { return d_main_gui->title().toStdString(); }
- void
- time_raster_sink_b_impl::set_line_marker(unsigned int which, QwtSymbol::Style marker)
- {
- d_main_gui->setLineMarker(which, marker);
- }
+std::string time_raster_sink_b_impl::line_label(unsigned int which)
+{
+ return d_main_gui->lineLabel(which).toStdString();
+}
- void
- time_raster_sink_b_impl::set_color_map(unsigned int which, const int color)
- {
- d_main_gui->setColorMap(which, color);
- }
+std::string time_raster_sink_b_impl::line_color(unsigned int which)
+{
+ return d_main_gui->lineColor(which).toStdString();
+}
- void
- time_raster_sink_b_impl::set_line_alpha(unsigned int which, double alpha)
- {
- d_main_gui->setAlpha(which, (int)(255.0*alpha));
- }
+int time_raster_sink_b_impl::line_width(unsigned int which)
+{
+ return d_main_gui->lineWidth(which);
+}
- void
- time_raster_sink_b_impl::set_size(int width, int height)
- {
- d_main_gui->resize(QSize(width, height));
- }
+int time_raster_sink_b_impl::line_style(unsigned int which)
+{
+ return d_main_gui->lineStyle(which);
+}
- void
- time_raster_sink_b_impl::set_samp_rate(const double samp_rate)
- {
- d_samp_rate = samp_rate;
- d_main_gui->setSampleRate(d_samp_rate);
- }
+int time_raster_sink_b_impl::line_marker(unsigned int which)
+{
+ return d_main_gui->lineMarker(which);
+}
- void
- time_raster_sink_b_impl::set_num_rows(double rows)
- {
- d_main_gui->setNumRows(rows);
- }
+int time_raster_sink_b_impl::color_map(unsigned int which)
+{
+ return d_main_gui->getColorMap(which);
+}
- void
- time_raster_sink_b_impl::set_num_cols(double cols)
- {
- if(d_cols != cols) {
- gr::thread::scoped_lock lock(d_setlock);
+double time_raster_sink_b_impl::line_alpha(unsigned int which)
+{
+ return (double)(d_main_gui->markerAlpha(which)) / 255.0;
+}
- d_qApplication->postEvent(d_main_gui,
- new TimeRasterSetSize(d_rows, cols));
+double time_raster_sink_b_impl::num_rows() { return d_main_gui->numRows(); }
- d_cols = cols;
- d_icols = static_cast<int>(ceil(d_cols));
+double time_raster_sink_b_impl::num_cols() { return d_main_gui->numCols(); }
- volk_free(d_tmpflt);
- d_tmpflt = (float*)volk_malloc(d_icols*sizeof(float),
- volk_get_alignment());
- memset(d_tmpflt, 0, d_icols*sizeof(float));
-
- for(int i = 0; i < d_nconnections+1; i++) {
- volk_free(d_residbufs[i]);
- d_residbufs[i] = (double*)volk_malloc(d_icols*sizeof(double),
- volk_get_alignment());
- memset(d_residbufs[i], 0, d_icols*sizeof(double));
+void time_raster_sink_b_impl::set_multiplier(const std::vector<float>& mult)
+{
+ if (mult.size() == 0) {
+ for (int i = 0; i < d_nconnections + 1; i++) {
+ d_mult[i] = 1.0f;
}
- reset();
- }
- }
-
- std::string
- time_raster_sink_b_impl::title()
- {
- return d_main_gui->title().toStdString();
- }
-
- std::string
- time_raster_sink_b_impl::line_label(unsigned int which)
- {
- return d_main_gui->lineLabel(which).toStdString();
+ } else if (mult.size() == (size_t)d_nconnections) {
+ for (int i = 0; i < d_nconnections; i++) {
+ d_mult[i] = mult[i];
+ }
+ } else if (mult.size() == (size_t)d_nconnections + 1) {
+ for (int i = 0; i < d_nconnections + 1; i++) {
+ d_mult[i] = mult[i];
+ }
+ } else {
+ throw std::runtime_error(
+ "time_raster_sink_b_impl::set_multiplier incorrect dimensions.\n");
}
+}
- std::string
- time_raster_sink_b_impl::line_color(unsigned int which)
- {
- return d_main_gui->lineColor(which).toStdString();
+void time_raster_sink_b_impl::set_offset(const std::vector<float>& offset)
+{
+ if (offset.size() == 0) {
+ for (int i = 0; i < d_nconnections + 1; i++) {
+ d_offset[i] = 0.0f;
+ }
+ } else if (offset.size() == (size_t)d_nconnections) {
+ for (int i = 0; i < d_nconnections; i++) {
+ d_offset[i] = offset[i];
+ }
+ } else if (offset.size() == (size_t)d_nconnections + 1) {
+ for (int i = 0; i < d_nconnections + 1; i++) {
+ d_offset[i] = offset[i];
+ }
+ } else {
+ throw std::runtime_error(
+ "time_raster_sink_b_impl::set_offset incorrect dimensions.\n");
}
+}
- int
- time_raster_sink_b_impl::line_width(unsigned int which)
- {
- return d_main_gui->lineWidth(which);
- }
+void time_raster_sink_b_impl::set_intensity_range(float min, float max)
+{
+ d_main_gui->setIntensityRange(min, max);
+}
- int
- time_raster_sink_b_impl::line_style(unsigned int which)
- {
- return d_main_gui->lineStyle(which);
- }
+void time_raster_sink_b_impl::enable_menu(bool en) { d_main_gui->enableMenu(en); }
- int
- time_raster_sink_b_impl::line_marker(unsigned int which)
- {
- return d_main_gui->lineMarker(which);
- }
+void time_raster_sink_b_impl::enable_grid(bool en) { d_main_gui->setGrid(en); }
- int
- time_raster_sink_b_impl::color_map(unsigned int which)
- {
- return d_main_gui->getColorMap(which);
- }
+void time_raster_sink_b_impl::enable_axis_labels(bool en)
+{
+ d_main_gui->setAxisLabels(en);
+}
- double
- time_raster_sink_b_impl::line_alpha(unsigned int which)
- {
- return (double)(d_main_gui->markerAlpha(which))/255.0;
- }
+void time_raster_sink_b_impl::enable_autoscale(bool en) { d_main_gui->autoScale(en); }
- double
- time_raster_sink_b_impl::num_rows()
- {
- return d_main_gui->numRows();
- }
+void time_raster_sink_b_impl::reset() { d_index = 0; }
- double
- time_raster_sink_b_impl::num_cols()
- {
- return d_main_gui->numCols();
- }
+void time_raster_sink_b_impl::_ncols_resize()
+{
+ double cols = d_main_gui->numCols();
+ set_num_cols(cols);
+}
- void
- time_raster_sink_b_impl::set_multiplier(const std::vector<float> &mult)
- {
- if(mult.size() == 0) {
- for(int i = 0; i < d_nconnections+1; i++) {
- d_mult[i] = 1.0f;
- }
- }
- else if(mult.size() == (size_t)d_nconnections) {
- for(int i = 0; i < d_nconnections; i++) {
- d_mult[i] = mult[i];
- }
- }
- else if(mult.size() == (size_t)d_nconnections+1) {
- for(int i = 0; i < d_nconnections+1; i++) {
- d_mult[i] = mult[i];
- }
- }
- else {
- throw std::runtime_error("time_raster_sink_b_impl::set_multiplier incorrect dimensions.\n");
- }
- }
+int time_raster_sink_b_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ int n = 0, j = 0, idx = 0;
+ const int8_t* in = (const int8_t*)input_items[0];
- void
- time_raster_sink_b_impl::set_offset(const std::vector<float> &offset)
- {
- if(offset.size() == 0) {
- for(int i = 0; i < d_nconnections+1; i++) {
- d_offset[i] = 0.0f;
- }
- }
- else if(offset.size() == (size_t)d_nconnections) {
- for(int i = 0; i < d_nconnections; i++) {
- d_offset[i] = offset[i];
- }
- }
- else if(offset.size() == (size_t)d_nconnections+1) {
- for(int i = 0; i < d_nconnections+1; i++) {
- d_offset[i] = offset[i];
- }
- }
- else {
- throw std::runtime_error("time_raster_sink_b_impl::set_offset incorrect dimensions.\n");
- }
- }
+ _ncols_resize();
- void
- time_raster_sink_b_impl::set_intensity_range(float min, float max)
- {
- d_main_gui->setIntensityRange(min, max);
- }
+ for (int i = 0; i < noutput_items; i += d_icols) {
+ unsigned int datasize = noutput_items - i;
+ unsigned int resid = d_icols - d_index;
+ idx = 0;
- void
- time_raster_sink_b_impl::enable_menu(bool en)
- {
- d_main_gui->enableMenu(en);
- }
+ // If we have enough input for one full plot, do it
+ if (datasize >= resid) {
- void
- time_raster_sink_b_impl::enable_grid(bool en)
- {
- d_main_gui->setGrid(en);
- }
+ // Fill up residbufs with d_size number of items
+ for (n = 0; n < d_nconnections; n++) {
+ in = (const int8_t*)input_items[idx++];
+ volk_8i_s32f_convert_32f(d_tmpflt, &in[j], d_scale, resid);
- void
- time_raster_sink_b_impl::enable_axis_labels(bool en)
- {
- d_main_gui->setAxisLabels(en);
- }
+ // Scale and add offset
+ volk_32f_s32f_multiply_32f(d_tmpflt, d_tmpflt, d_mult[n], resid);
+ for (unsigned int s = 0; s < resid; s++)
+ d_tmpflt[s] = d_tmpflt[s] + d_offset[n];
- void
- time_raster_sink_b_impl::enable_autoscale(bool en)
- {
- d_main_gui->autoScale(en);
- }
+ volk_32f_convert_64f_u(&d_residbufs[n][d_index], d_tmpflt, resid);
+ }
- void
- time_raster_sink_b_impl::reset()
- {
- d_index = 0;
- }
+ if (gr::high_res_timer_now() - d_last_time > d_update_time) {
+ d_last_time = gr::high_res_timer_now();
+ d_qApplication->postEvent(
+ d_main_gui, new TimeRasterUpdateEvent(d_residbufs, d_icols));
+ }
- void
- time_raster_sink_b_impl::_ncols_resize()
- {
- double cols = d_main_gui->numCols();
- set_num_cols(cols);
+ d_index = 0;
+ j += resid;
+ }
+ // Otherwise, copy what we received into the residbufs for next time
+ // because we set the output_multiple, this should never need to be called
+ else {
+ for (n = 0; n < d_nconnections; n++) {
+ in = (const int8_t*)input_items[idx++];
+ volk_8i_s32f_convert_32f(d_tmpflt, &in[j], d_scale, datasize);
+
+ // Scale and add offset
+ volk_32f_s32f_multiply_32f(d_tmpflt, d_tmpflt, d_mult[n], datasize);
+ for (unsigned int s = 0; s < datasize; s++)
+ d_tmpflt[s] = d_tmpflt[s] + d_offset[n];
+
+ volk_32f_convert_64f(&d_residbufs[n][d_index], d_tmpflt, datasize);
+ }
+ d_index += datasize;
+ j += datasize;
+ }
}
- int
- time_raster_sink_b_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- int n=0, j=0, idx=0;
- const int8_t *in = (const int8_t*)input_items[0];
-
- _ncols_resize();
-
- for(int i = 0; i < noutput_items; i += d_icols) {
- unsigned int datasize = noutput_items - i;
- unsigned int resid = d_icols-d_index;
- idx = 0;
-
- // If we have enough input for one full plot, do it
- if(datasize >= resid) {
-
- // Fill up residbufs with d_size number of items
- for(n = 0; n < d_nconnections; n++) {
- in = (const int8_t*)input_items[idx++];
- volk_8i_s32f_convert_32f(d_tmpflt, &in[j],
- d_scale, resid);
-
- // Scale and add offset
- volk_32f_s32f_multiply_32f(d_tmpflt, d_tmpflt, d_mult[n], resid);
- for(unsigned int s = 0; s < resid; s++)
- d_tmpflt[s] = d_tmpflt[s] + d_offset[n];
-
- volk_32f_convert_64f_u(&d_residbufs[n][d_index],
- d_tmpflt, resid);
- }
-
- if(gr::high_res_timer_now() - d_last_time > d_update_time) {
- d_last_time = gr::high_res_timer_now();
- d_qApplication->postEvent(d_main_gui,
- new TimeRasterUpdateEvent(d_residbufs, d_icols));
- }
-
- d_index = 0;
- j += resid;
- }
- // Otherwise, copy what we received into the residbufs for next time
- // because we set the output_multiple, this should never need to be called
- else {
- for(n = 0; n < d_nconnections; n++) {
- in = (const int8_t*)input_items[idx++];
- volk_8i_s32f_convert_32f(d_tmpflt, &in[j],
- d_scale, datasize);
-
- // Scale and add offset
- volk_32f_s32f_multiply_32f(d_tmpflt, d_tmpflt, d_mult[n], datasize);
- for(unsigned int s = 0; s < datasize; s++)
- d_tmpflt[s] = d_tmpflt[s] + d_offset[n];
-
- volk_32f_convert_64f(&d_residbufs[n][d_index],
- d_tmpflt, datasize);
- }
- d_index += datasize;
- j += datasize;
- }
- }
-
- return j;
- }
+ return j;
+}
- void
- time_raster_sink_b_impl::handle_pdus(pmt::pmt_t msg)
- {
- size_t len;
- pmt::pmt_t dict, samples;
+void time_raster_sink_b_impl::handle_pdus(pmt::pmt_t msg)
+{
+ size_t len;
+ pmt::pmt_t dict, samples;
- // Test to make sure this is either a PDU or a uniform vector of
- // samples. Get the samples PMT and the dictionary if it's a PDU.
- // If not, we throw an error and exit.
- if(pmt::is_pair(msg)) {
+ // Test to make sure this is either a PDU or a uniform vector of
+ // samples. Get the samples PMT and the dictionary if it's a PDU.
+ // If not, we throw an error and exit.
+ if (pmt::is_pair(msg)) {
dict = pmt::car(msg);
samples = pmt::cdr(msg);
- }
- else if(pmt::is_uniform_vector(msg)) {
+ } else if (pmt::is_uniform_vector(msg)) {
samples = msg;
- }
- else {
+ } else {
throw std::runtime_error("time_sink_c: message must be either "
"a PDU or a uniform vector of samples.");
- }
+ }
- len = pmt::length(samples);
+ len = pmt::length(samples);
- const int8_t *in;
- if(pmt::is_s8vector(samples)) {
+ const int8_t* in;
+ if (pmt::is_s8vector(samples)) {
in = (const int8_t*)pmt::s8vector_elements(samples, len);
- }
- else if(pmt::is_u8vector(samples)) {
+ } else if (pmt::is_u8vector(samples)) {
in = (const int8_t*)pmt::u8vector_elements(samples, len);
- }
- else {
+ } else {
throw std::runtime_error("time_raster_sink_b: unknown data type "
"of samples; must be char ({u}int8_t).");
- }
+ }
- // Plot if we're past the last update time
- if(gr::high_res_timer_now() - d_last_time > d_update_time) {
+ // Plot if we're past the last update time
+ if (gr::high_res_timer_now() - d_last_time > d_update_time) {
d_last_time = gr::high_res_timer_now();
_ncols_resize();
@@ -552,28 +460,28 @@ namespace gr {
d_rows = ceil(static_cast<double>(len) / static_cast<double>(d_cols));
int irows = static_cast<int>(d_rows);
- d_qApplication->postEvent(d_main_gui,
- new TimeRasterSetSize(d_rows, d_cols));
+ d_qApplication->postEvent(d_main_gui, new TimeRasterSetSize(d_rows, d_cols));
int idx = 0;
- for(int r = 0; r < irows; r++) {
- // Scale and add offset
- int cpy_len = std::min(static_cast<size_t>(d_cols), len - idx);
- memset(d_residbufs[d_nconnections], 0, d_cols*sizeof(double));
- volk_8i_s32f_convert_32f(d_tmpflt, &in[idx], d_scale, cpy_len);
- volk_32f_s32f_multiply_32f(d_tmpflt, d_tmpflt, d_mult[d_nconnections], cpy_len);
- for(int c = 0; c < cpy_len; c++) {
- d_tmpflt[c] = d_tmpflt[c] + d_offset[d_nconnections];
- }
-
- volk_32f_convert_64f_u(d_residbufs[d_nconnections], d_tmpflt, cpy_len);
-
- d_qApplication->postEvent(d_main_gui,
- new TimeRasterUpdateEvent(d_residbufs, d_cols));
- idx += d_cols;
+ for (int r = 0; r < irows; r++) {
+ // Scale and add offset
+ int cpy_len = std::min(static_cast<size_t>(d_cols), len - idx);
+ memset(d_residbufs[d_nconnections], 0, d_cols * sizeof(double));
+ volk_8i_s32f_convert_32f(d_tmpflt, &in[idx], d_scale, cpy_len);
+ volk_32f_s32f_multiply_32f(
+ d_tmpflt, d_tmpflt, d_mult[d_nconnections], cpy_len);
+ for (int c = 0; c < cpy_len; c++) {
+ d_tmpflt[c] = d_tmpflt[c] + d_offset[d_nconnections];
+ }
+
+ volk_32f_convert_64f_u(d_residbufs[d_nconnections], d_tmpflt, cpy_len);
+
+ d_qApplication->postEvent(d_main_gui,
+ new TimeRasterUpdateEvent(d_residbufs, d_cols));
+ idx += d_cols;
}
- }
}
+}
- } /* namespace qtgui */
+} /* namespace qtgui */
} /* namespace gr */
diff --git a/gr-qtgui/lib/time_raster_sink_b_impl.h b/gr-qtgui/lib/time_raster_sink_b_impl.h
index 066f908e4f..71dda47b4d 100644
--- a/gr-qtgui/lib/time_raster_sink_b_impl.h
+++ b/gr-qtgui/lib/time_raster_sink_b_impl.h
@@ -31,107 +31,108 @@
#include <gnuradio/qtgui/timerasterdisplayform.h>
namespace gr {
- namespace qtgui {
+namespace qtgui {
- class QTGUI_API time_raster_sink_b_impl : public time_raster_sink_b
- {
- private:
- void initialize();
+class QTGUI_API time_raster_sink_b_impl : public time_raster_sink_b
+{
+private:
+ void initialize();
- std::string d_name;
- int d_nconnections;
+ std::string d_name;
+ int d_nconnections;
- int d_index;
- std::vector<double*> d_residbufs;
+ int d_index;
+ std::vector<double*> d_residbufs;
- float d_scale;
- float *d_tmpflt;
+ float d_scale;
+ float* d_tmpflt;
- int d_argc;
- char *d_argv;
- QWidget *d_parent;
- TimeRasterDisplayForm *d_main_gui;
+ int d_argc;
+ char* d_argv;
+ QWidget* d_parent;
+ TimeRasterDisplayForm* d_main_gui;
- int d_icols;
- double d_rows, d_cols;
- std::vector<float> d_mult;
- std::vector<float> d_offset;
- double d_samp_rate;
+ int d_icols;
+ double d_rows, d_cols;
+ std::vector<float> d_mult;
+ std::vector<float> d_offset;
+ double d_samp_rate;
- gr::high_res_timer_type d_update_time;
- gr::high_res_timer_type d_last_time;
+ gr::high_res_timer_type d_update_time;
+ gr::high_res_timer_type d_last_time;
- void _ncols_resize();
+ void _ncols_resize();
- // Handles message input port for displaying PDU samples.
- void handle_pdus(pmt::pmt_t msg);
+ // Handles message input port for displaying PDU samples.
+ void handle_pdus(pmt::pmt_t msg);
- public:
- time_raster_sink_b_impl(double samp_rate,
- double rows, double cols,
- const std::vector<float> &mult,
- const std::vector<float> &offset,
- const std::string &name,
- int nconnections,
- QWidget *parent=NULL);
- ~time_raster_sink_b_impl();
+public:
+ time_raster_sink_b_impl(double samp_rate,
+ double rows,
+ double cols,
+ const std::vector<float>& mult,
+ const std::vector<float>& offset,
+ const std::string& name,
+ int nconnections,
+ QWidget* parent = NULL);
+ ~time_raster_sink_b_impl();
- bool check_topology (int ninputs, int noutputs);
+ bool check_topology(int ninputs, int noutputs);
- void exec_();
- QWidget* qwidget();
+ void exec_();
+ QWidget* qwidget();
#ifdef ENABLE_PYTHON
- PyObject* pyqwidget();
+ PyObject* pyqwidget();
#else
- void* pyqwidget();
+ void* pyqwidget();
#endif
- void set_update_time(double t);
- void set_title(const std::string &title);
- void set_line_label(unsigned int which, const std::string &label);
- void set_line_color(unsigned int which, const std::string &color);
- void set_line_width(unsigned int which, int width);
- void set_line_style(unsigned int which, Qt::PenStyle style);
- void set_line_marker(unsigned int which, QwtSymbol::Style marker);
- void set_line_alpha(unsigned int which, double alpha);
- void set_color_map(unsigned int which, const int color);
-
- std::string title();
- std::string line_label(unsigned int which);
- std::string line_color(unsigned int which);
- int line_width(unsigned int which);
- int line_style(unsigned int which);
- int line_marker(unsigned int which);
- double line_alpha(unsigned int which);
- int color_map(unsigned int which);
-
- void set_size(int width, int height);
-
- void set_samp_rate(const double samp_rate);
- void set_num_rows(double rows);
- void set_num_cols(double cols);
-
- double num_rows();
- double num_cols();
-
- void set_multiplier(const std::vector<float> &mult);
- void set_offset(const std::vector<float> &offset);
-
- void set_intensity_range(float min, float max);
-
- void enable_menu(bool en);
- void enable_grid(bool en);
- void enable_autoscale(bool en);
- void enable_axis_labels(bool en);
- void reset();
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace qtgui */
+ void set_update_time(double t);
+ void set_title(const std::string& title);
+ void set_line_label(unsigned int which, const std::string& label);
+ void set_line_color(unsigned int which, const std::string& color);
+ void set_line_width(unsigned int which, int width);
+ void set_line_style(unsigned int which, Qt::PenStyle style);
+ void set_line_marker(unsigned int which, QwtSymbol::Style marker);
+ void set_line_alpha(unsigned int which, double alpha);
+ void set_color_map(unsigned int which, const int color);
+
+ std::string title();
+ std::string line_label(unsigned int which);
+ std::string line_color(unsigned int which);
+ int line_width(unsigned int which);
+ int line_style(unsigned int which);
+ int line_marker(unsigned int which);
+ double line_alpha(unsigned int which);
+ int color_map(unsigned int which);
+
+ void set_size(int width, int height);
+
+ void set_samp_rate(const double samp_rate);
+ void set_num_rows(double rows);
+ void set_num_cols(double cols);
+
+ double num_rows();
+ double num_cols();
+
+ void set_multiplier(const std::vector<float>& mult);
+ void set_offset(const std::vector<float>& offset);
+
+ void set_intensity_range(float min, float max);
+
+ void enable_menu(bool en);
+ void enable_grid(bool en);
+ void enable_autoscale(bool en);
+ void enable_axis_labels(bool en);
+ void reset();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
+
+} /* namespace qtgui */
} /* namespace gr */
#endif /* INCLUDED_QTGUI_TIME_RASTER_SINK_B_IMPL_H */
diff --git a/gr-qtgui/lib/time_raster_sink_f_impl.cc b/gr-qtgui/lib/time_raster_sink_f_impl.cc
index d2a2bdad02..05c37963b4 100644
--- a/gr-qtgui/lib/time_raster_sink_f_impl.cc
+++ b/gr-qtgui/lib/time_raster_sink_f_impl.cc
@@ -34,500 +34,416 @@
#include <string.h>
namespace gr {
- namespace qtgui {
-
- time_raster_sink_f::sptr
- time_raster_sink_f::make(double samp_rate,
- double rows, double cols,
- const std::vector<float> &mult,
- const std::vector<float> &offset,
- const std::string &name,
- int nconnections,
- QWidget *parent)
- {
- return gnuradio::get_initial_sptr
- (new time_raster_sink_f_impl(samp_rate,
- rows, cols,
- mult, offset,
- name,
- nconnections,
- parent));
- }
-
- time_raster_sink_f_impl::time_raster_sink_f_impl(double samp_rate,
- double rows, double cols,
- const std::vector<float> &mult,
- const std::vector<float> &offset,
- const std::string &name,
- int nconnections,
- QWidget *parent)
- : sync_block("time_raster_sink_f",
- io_signature::make(0, nconnections, sizeof(float)),
- io_signature::make(0, 0, 0)),
- d_name(name), d_nconnections(nconnections), d_parent(parent),
- d_rows(rows), d_cols(cols),
- d_mult(std::vector<float>(nconnections+1,1)),
- d_offset(std::vector<float>(nconnections+1,0)),
- d_samp_rate(samp_rate)
- {
- // Required now for Qt; argc must be greater than 0 and argv
- // must have at least one valid character. Must be valid through
- // life of the qApplication:
- // http://harmattan-dev.nokia.com/docs/library/html/qt4/qapplication.html
- d_argc = 1;
- d_argv = new char;
- d_argv[0] = '\0';
-
- d_main_gui = NULL;
-
- d_index = 0;
-
- // setup PDU handling input port
- message_port_register_in(pmt::mp("in"));
- set_msg_handler(pmt::mp("in"),
- boost::bind(&time_raster_sink_f_impl::handle_pdus, this, _1));
-
- d_icols = static_cast<int>(ceil(d_cols));
- d_tmpflt = (float*)volk_malloc(d_icols*sizeof(float),
- volk_get_alignment());
- memset(d_tmpflt, 0, d_icols*sizeof(float));
-
- // +1 for the PDU buffer
- for(int i = 0; i < d_nconnections+1; i++) {
- d_residbufs.push_back((double*)volk_malloc(d_icols*sizeof(double),
- volk_get_alignment()));
- memset(d_residbufs[i], 0, d_icols*sizeof(double));
- }
-
- set_multiplier(mult);
- set_offset(offset);
-
- initialize();
- }
-
- time_raster_sink_f_impl::~time_raster_sink_f_impl()
- {
- if(!d_main_gui->isClosed())
+namespace qtgui {
+
+time_raster_sink_f::sptr time_raster_sink_f::make(double samp_rate,
+ double rows,
+ double cols,
+ const std::vector<float>& mult,
+ const std::vector<float>& offset,
+ const std::string& name,
+ int nconnections,
+ QWidget* parent)
+{
+ return gnuradio::get_initial_sptr(new time_raster_sink_f_impl(
+ samp_rate, rows, cols, mult, offset, name, nconnections, parent));
+}
+
+time_raster_sink_f_impl::time_raster_sink_f_impl(double samp_rate,
+ double rows,
+ double cols,
+ const std::vector<float>& mult,
+ const std::vector<float>& offset,
+ const std::string& name,
+ int nconnections,
+ QWidget* parent)
+ : sync_block("time_raster_sink_f",
+ io_signature::make(0, nconnections, sizeof(float)),
+ io_signature::make(0, 0, 0)),
+ d_name(name),
+ d_nconnections(nconnections),
+ d_parent(parent),
+ d_rows(rows),
+ d_cols(cols),
+ d_mult(std::vector<float>(nconnections + 1, 1)),
+ d_offset(std::vector<float>(nconnections + 1, 0)),
+ d_samp_rate(samp_rate)
+{
+ // Required now for Qt; argc must be greater than 0 and argv
+ // must have at least one valid character. Must be valid through
+ // life of the qApplication:
+ // http://harmattan-dev.nokia.com/docs/library/html/qt4/qapplication.html
+ d_argc = 1;
+ d_argv = new char;
+ d_argv[0] = '\0';
+
+ d_main_gui = NULL;
+
+ d_index = 0;
+
+ // setup PDU handling input port
+ message_port_register_in(pmt::mp("in"));
+ set_msg_handler(pmt::mp("in"),
+ boost::bind(&time_raster_sink_f_impl::handle_pdus, this, _1));
+
+ d_icols = static_cast<int>(ceil(d_cols));
+ d_tmpflt = (float*)volk_malloc(d_icols * sizeof(float), volk_get_alignment());
+ memset(d_tmpflt, 0, d_icols * sizeof(float));
+
+ // +1 for the PDU buffer
+ for (int i = 0; i < d_nconnections + 1; i++) {
+ d_residbufs.push_back(
+ (double*)volk_malloc(d_icols * sizeof(double), volk_get_alignment()));
+ memset(d_residbufs[i], 0, d_icols * sizeof(double));
+ }
+
+ set_multiplier(mult);
+ set_offset(offset);
+
+ initialize();
+}
+
+time_raster_sink_f_impl::~time_raster_sink_f_impl()
+{
+ if (!d_main_gui->isClosed())
d_main_gui->close();
- volk_free(d_tmpflt);
- for(int i = 0; i < d_nconnections+1; i++) {
- volk_free(d_residbufs[i]);
- }
-
- delete d_argv;
+ volk_free(d_tmpflt);
+ for (int i = 0; i < d_nconnections + 1; i++) {
+ volk_free(d_residbufs[i]);
}
- bool
- time_raster_sink_f_impl::check_topology(int ninputs, int noutputs)
- {
- return ninputs == d_nconnections;
- }
+ delete d_argv;
+}
+
+bool time_raster_sink_f_impl::check_topology(int ninputs, int noutputs)
+{
+ return ninputs == d_nconnections;
+}
- void
- time_raster_sink_f_impl::initialize()
- {
- if(qApp != NULL) {
- d_qApplication = qApp;
- }
- else {
+void time_raster_sink_f_impl::initialize()
+{
+ if (qApp != NULL) {
+ d_qApplication = qApp;
+ } else {
#if QT_VERSION >= 0x040500 && QT_VERSION < 0x050000
std::string style = prefs::singleton()->get_string("qtgui", "style", "raster");
QApplication::setGraphicsSystem(QString(style.c_str()));
#endif
- d_qApplication = new QApplication(d_argc, &d_argv);
- }
-
- // If a style sheet is set in the prefs file, enable it here.
- check_set_qss(d_qApplication);
-
- // Create time raster plot; as a bit input, we expect to see 1's
- // and 0's from each stream, so we set the maximum intensity
- // (zmax) to the number of connections so after adding the
- // streams, the max will the the max of 1's from all streams.
- int numplots = (d_nconnections > 0) ? d_nconnections : 1;
- d_main_gui = new TimeRasterDisplayForm(numplots,
- d_samp_rate,
- d_rows, d_cols,
- 1, d_parent);
-
- if(d_name.size() > 0)
+ d_qApplication = new QApplication(d_argc, &d_argv);
+ }
+
+ // If a style sheet is set in the prefs file, enable it here.
+ check_set_qss(d_qApplication);
+
+ // Create time raster plot; as a bit input, we expect to see 1's
+ // and 0's from each stream, so we set the maximum intensity
+ // (zmax) to the number of connections so after adding the
+ // streams, the max will the the max of 1's from all streams.
+ int numplots = (d_nconnections > 0) ? d_nconnections : 1;
+ d_main_gui =
+ new TimeRasterDisplayForm(numplots, d_samp_rate, d_rows, d_cols, 1, d_parent);
+
+ if (d_name.size() > 0)
set_title(d_name);
- // initialize update time to 10 times a second
- set_update_time(0.1);
- }
+ // initialize update time to 10 times a second
+ set_update_time(0.1);
+}
- void
- time_raster_sink_f_impl::exec_()
- {
- d_qApplication->exec();
- }
+void time_raster_sink_f_impl::exec_() { d_qApplication->exec(); }
- QWidget*
- time_raster_sink_f_impl::qwidget()
- {
- return d_main_gui;
- }
+QWidget* time_raster_sink_f_impl::qwidget() { return d_main_gui; }
#ifdef ENABLE_PYTHON
- PyObject*
- time_raster_sink_f_impl::pyqwidget()
- {
- PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui);
- PyObject *retarg = Py_BuildValue("N", w);
- return retarg;
- }
+PyObject* time_raster_sink_f_impl::pyqwidget()
+{
+ PyObject* w = PyLong_FromVoidPtr((void*)d_main_gui);
+ PyObject* retarg = Py_BuildValue("N", w);
+ return retarg;
+}
#else
- void *
- time_raster_sink_f_impl::pyqwidget()
- {
- return NULL;
- }
+void* time_raster_sink_f_impl::pyqwidget() { return NULL; }
#endif
- void
- time_raster_sink_f_impl::set_update_time(double t)
- {
- //convert update time to ticks
- gr::high_res_timer_type tps = gr::high_res_timer_tps();
- d_update_time = t * tps;
- d_main_gui->setUpdateTime(t);
- d_last_time = 0;
- }
-
- void
- time_raster_sink_f_impl::set_title(const std::string &title)
- {
- d_main_gui->setTitle(title.c_str());
- }
+void time_raster_sink_f_impl::set_update_time(double t)
+{
+ // convert update time to ticks
+ gr::high_res_timer_type tps = gr::high_res_timer_tps();
+ d_update_time = t * tps;
+ d_main_gui->setUpdateTime(t);
+ d_last_time = 0;
+}
+
+void time_raster_sink_f_impl::set_title(const std::string& title)
+{
+ d_main_gui->setTitle(title.c_str());
+}
+
+void time_raster_sink_f_impl::set_line_label(unsigned int which, const std::string& label)
+{
+ d_main_gui->setLineLabel(which, label.c_str());
+}
+
+void time_raster_sink_f_impl::set_line_color(unsigned int which, const std::string& color)
+{
+ d_main_gui->setLineColor(which, color.c_str());
+}
+
+void time_raster_sink_f_impl::set_line_width(unsigned int which, int width)
+{
+ d_main_gui->setLineWidth(which, width);
+}
+
+void time_raster_sink_f_impl::set_line_style(unsigned int which, Qt::PenStyle style)
+{
+ d_main_gui->setLineStyle(which, style);
+}
+
+void time_raster_sink_f_impl::set_line_marker(unsigned int which, QwtSymbol::Style marker)
+{
+ d_main_gui->setLineMarker(which, marker);
+}
+
+void time_raster_sink_f_impl::set_color_map(unsigned int which, const int color)
+{
+ d_main_gui->setColorMap(which, color);
+}
+
+void time_raster_sink_f_impl::set_line_alpha(unsigned int which, double alpha)
+{
+ d_main_gui->setAlpha(which, (int)(255.0 * alpha));
+}
+
+void time_raster_sink_f_impl::set_size(int width, int height)
+{
+ d_main_gui->resize(QSize(width, height));
+}
+
+void time_raster_sink_f_impl::set_samp_rate(const double samp_rate)
+{
+ d_samp_rate = samp_rate;
+ d_main_gui->setSampleRate(d_samp_rate);
+}
+
+void time_raster_sink_f_impl::set_num_rows(double rows)
+{
+ gr::thread::scoped_lock lock(d_setlock);
+ d_rows = rows;
+ d_main_gui->setNumRows(rows);
+}
+
+void time_raster_sink_f_impl::set_num_cols(double cols)
+{
+ if (d_cols != cols) {
+ gr::thread::scoped_lock lock(d_setlock);
- void
- time_raster_sink_f_impl::set_line_label(unsigned int which, const std::string &label)
- {
- d_main_gui->setLineLabel(which, label.c_str());
- }
+ d_qApplication->postEvent(d_main_gui, new TimeRasterSetSize(d_rows, cols));
- void
- time_raster_sink_f_impl::set_line_color(unsigned int which, const std::string &color)
- {
- d_main_gui->setLineColor(which, color.c_str());
- }
+ d_cols = cols;
+ d_icols = static_cast<int>(ceil(d_cols));
- void
- time_raster_sink_f_impl::set_line_width(unsigned int which, int width)
- {
- d_main_gui->setLineWidth(which, width);
+ volk_free(d_tmpflt);
+ d_tmpflt = (float*)volk_malloc(d_icols * sizeof(float), volk_get_alignment());
+ memset(d_tmpflt, 0, d_icols * sizeof(float));
+
+ for (int i = 0; i < d_nconnections + 1; i++) {
+ volk_free(d_residbufs[i]);
+ d_residbufs[i] =
+ (double*)volk_malloc(d_icols * sizeof(double), volk_get_alignment());
+ memset(d_residbufs[i], 0, d_icols * sizeof(double));
+ }
+ reset();
}
+}
- void
- time_raster_sink_f_impl::set_line_style(unsigned int which, Qt::PenStyle style)
- {
- d_main_gui->setLineStyle(which, style);
- }
+std::string time_raster_sink_f_impl::title() { return d_main_gui->title().toStdString(); }
- void
- time_raster_sink_f_impl::set_line_marker(unsigned int which, QwtSymbol::Style marker)
- {
- d_main_gui->setLineMarker(which, marker);
- }
+std::string time_raster_sink_f_impl::line_label(unsigned int which)
+{
+ return d_main_gui->lineLabel(which).toStdString();
+}
- void
- time_raster_sink_f_impl::set_color_map(unsigned int which, const int color)
- {
- d_main_gui->setColorMap(which, color);
- }
+std::string time_raster_sink_f_impl::line_color(unsigned int which)
+{
+ return d_main_gui->lineColor(which).toStdString();
+}
- void
- time_raster_sink_f_impl::set_line_alpha(unsigned int which, double alpha)
- {
- d_main_gui->setAlpha(which, (int)(255.0*alpha));
- }
+int time_raster_sink_f_impl::line_width(unsigned int which)
+{
+ return d_main_gui->lineWidth(which);
+}
- void
- time_raster_sink_f_impl::set_size(int width, int height)
- {
- d_main_gui->resize(QSize(width, height));
- }
+int time_raster_sink_f_impl::line_style(unsigned int which)
+{
+ return d_main_gui->lineStyle(which);
+}
- void
- time_raster_sink_f_impl::set_samp_rate(const double samp_rate)
- {
- d_samp_rate = samp_rate;
- d_main_gui->setSampleRate(d_samp_rate);
- }
+int time_raster_sink_f_impl::line_marker(unsigned int which)
+{
+ return d_main_gui->lineMarker(which);
+}
- void
- time_raster_sink_f_impl::set_num_rows(double rows)
- {
- gr::thread::scoped_lock lock(d_setlock);
- d_rows = rows;
- d_main_gui->setNumRows(rows);
- }
+int time_raster_sink_f_impl::color_map(unsigned int which)
+{
+ return d_main_gui->getColorMap(which);
+}
- void
- time_raster_sink_f_impl::set_num_cols(double cols)
- {
- if(d_cols != cols) {
- gr::thread::scoped_lock lock(d_setlock);
+double time_raster_sink_f_impl::line_alpha(unsigned int which)
+{
+ return (double)(d_main_gui->markerAlpha(which)) / 255.0;
+}
- d_qApplication->postEvent(d_main_gui,
- new TimeRasterSetSize(d_rows, cols));
+double time_raster_sink_f_impl::num_rows() { return d_main_gui->numRows(); }
- d_cols = cols;
- d_icols = static_cast<int>(ceil(d_cols));
+double time_raster_sink_f_impl::num_cols() { return d_main_gui->numCols(); }
- volk_free(d_tmpflt);
- d_tmpflt = (float*)volk_malloc(d_icols*sizeof(float),
- volk_get_alignment());
- memset(d_tmpflt, 0, d_icols*sizeof(float));
-
- for(int i = 0; i < d_nconnections+1; i++) {
- volk_free(d_residbufs[i]);
- d_residbufs[i] = (double*)volk_malloc(d_icols*sizeof(double),
- volk_get_alignment());
- memset(d_residbufs[i], 0, d_icols*sizeof(double));
+void time_raster_sink_f_impl::set_multiplier(const std::vector<float>& mult)
+{
+ if (mult.size() == 0) {
+ for (int i = 0; i < d_nconnections; i++) {
+ d_mult[i] = 1.0f;
}
- reset();
- }
+ } else if (mult.size() == (size_t)d_nconnections) {
+ for (int i = 0; i < d_nconnections; i++) {
+ d_mult[i] = mult[i];
+ }
+ } else {
+ throw std::runtime_error(
+ "time_raster_sink_f_impl::set_multiplier incorrect dimensions.\n");
}
+}
- std::string
- time_raster_sink_f_impl::title()
- {
- return d_main_gui->title().toStdString();
+void time_raster_sink_f_impl::set_offset(const std::vector<float>& offset)
+{
+ if (offset.size() == 0) {
+ for (int i = 0; i < d_nconnections; i++) {
+ d_offset[i] = 0.0f;
+ }
+ } else if (offset.size() == (size_t)d_nconnections) {
+ for (int i = 0; i < d_nconnections; i++) {
+ d_offset[i] = offset[i];
+ }
+ } else {
+ throw std::runtime_error(
+ "time_raster_sink_f_impl::set_offset incorrect dimensions.\n");
}
+}
- std::string
- time_raster_sink_f_impl::line_label(unsigned int which)
- {
- return d_main_gui->lineLabel(which).toStdString();
- }
+void time_raster_sink_f_impl::set_intensity_range(float min, float max)
+{
+ d_main_gui->setIntensityRange(min, max);
+}
- std::string
- time_raster_sink_f_impl::line_color(unsigned int which)
- {
- return d_main_gui->lineColor(which).toStdString();
- }
+void time_raster_sink_f_impl::enable_menu(bool en) { d_main_gui->enableMenu(en); }
- int
- time_raster_sink_f_impl::line_width(unsigned int which)
- {
- return d_main_gui->lineWidth(which);
- }
+void time_raster_sink_f_impl::enable_grid(bool en) { d_main_gui->setGrid(en); }
- int
- time_raster_sink_f_impl::line_style(unsigned int which)
- {
- return d_main_gui->lineStyle(which);
- }
+void time_raster_sink_f_impl::enable_axis_labels(bool en)
+{
+ d_main_gui->setAxisLabels(en);
+}
- int
- time_raster_sink_f_impl::line_marker(unsigned int which)
- {
- return d_main_gui->lineMarker(which);
- }
+void time_raster_sink_f_impl::enable_autoscale(bool en) { d_main_gui->autoScale(en); }
- int
- time_raster_sink_f_impl::color_map(unsigned int which)
- {
- return d_main_gui->getColorMap(which);
- }
+void time_raster_sink_f_impl::reset() { d_index = 0; }
- double
- time_raster_sink_f_impl::line_alpha(unsigned int which)
- {
- return (double)(d_main_gui->markerAlpha(which))/255.0;
- }
+void time_raster_sink_f_impl::_ncols_resize()
+{
+ double cols = d_main_gui->numCols();
+ set_num_cols(cols);
+}
- double
- time_raster_sink_f_impl::num_rows()
- {
- return d_main_gui->numRows();
- }
+int time_raster_sink_f_impl::work(int noutput_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[0];
- double
- time_raster_sink_f_impl::num_cols()
- {
- return d_main_gui->numCols();
- }
-
- void
- time_raster_sink_f_impl::set_multiplier(const std::vector<float> &mult)
- {
- if(mult.size() == 0) {
- for(int i = 0; i < d_nconnections; i++) {
- d_mult[i] = 1.0f;
- }
- }
- else if(mult.size() == (size_t)d_nconnections) {
- for(int i = 0; i < d_nconnections; i++) {
- d_mult[i] = mult[i];
- }
- }
- else {
- throw std::runtime_error("time_raster_sink_f_impl::set_multiplier incorrect dimensions.\n");
- }
- }
-
- void
- time_raster_sink_f_impl::set_offset(const std::vector<float> &offset)
- {
- if(offset.size() == 0) {
- for(int i = 0; i < d_nconnections; i++) {
- d_offset[i] = 0.0f;
- }
- }
- else if(offset.size() == (size_t)d_nconnections) {
- for(int i = 0; i < d_nconnections; i++) {
- d_offset[i] = offset[i];
- }
- }
- else {
- throw std::runtime_error("time_raster_sink_f_impl::set_offset incorrect dimensions.\n");
- }
- }
+ _ncols_resize();
- void
- time_raster_sink_f_impl::set_intensity_range(float min, float max)
- {
- d_main_gui->setIntensityRange(min, max);
- }
+ for (int i = 0; i < noutput_items; i += d_icols) {
+ unsigned int datasize = noutput_items - i;
+ unsigned int resid = d_icols - d_index;
+ idx = 0;
- void
- time_raster_sink_f_impl::enable_menu(bool en)
- {
- d_main_gui->enableMenu(en);
- }
+ // If we have enough input for one full plot, do it
+ if (datasize >= resid) {
- void
- time_raster_sink_f_impl::enable_grid(bool en)
- {
- d_main_gui->setGrid(en);
- }
+ // Fill up residbufs with d_size number of items
+ for (n = 0; n < d_nconnections; n++) {
+ in = (const float*)input_items[idx++];
- void
- time_raster_sink_f_impl::enable_axis_labels(bool en)
- {
- d_main_gui->setAxisLabels(en);
- }
+ // Scale and add offset
+ volk_32f_s32f_multiply_32f(d_tmpflt, &in[j], d_mult[n], resid);
+ for (unsigned int s = 0; s < resid; s++)
+ d_tmpflt[s] = d_tmpflt[s] + d_offset[n];
- void
- time_raster_sink_f_impl::enable_autoscale(bool en)
- {
- d_main_gui->autoScale(en);
- }
+ volk_32f_convert_64f_u(&d_residbufs[n][d_index], d_tmpflt, resid);
+ }
- void
- time_raster_sink_f_impl::reset()
- {
- d_index = 0;
- }
+ // Update the plot if its time
+ if (gr::high_res_timer_now() - d_last_time > d_update_time) {
+ d_last_time = gr::high_res_timer_now();
+ d_qApplication->postEvent(d_main_gui,
+ new TimeRasterUpdateEvent(d_residbufs, d_cols));
+ }
- void
- time_raster_sink_f_impl::_ncols_resize()
- {
- double cols = d_main_gui->numCols();
- set_num_cols(cols);
+ d_index = 0;
+ j += resid;
+ }
+ // Otherwise, copy what we received into the residbufs for next time
+ // because we set the output_multiple, this should never need to be called
+ else {
+ for (n = 0; n < d_nconnections; n++) {
+ in = (const float*)input_items[idx++];
+
+ // Scale and add offset
+ volk_32f_s32f_multiply_32f(d_tmpflt, &in[j], d_mult[n], datasize);
+ for (unsigned int s = 0; s < datasize; s++)
+ d_tmpflt[s] = d_tmpflt[s] + d_offset[n];
+
+ volk_32f_convert_64f(&d_residbufs[n][d_index], d_tmpflt, datasize);
+ }
+ d_index += datasize;
+ j += datasize;
+ }
}
- int
- time_raster_sink_f_impl::work(int noutput_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[0];
-
- _ncols_resize();
-
- for(int i = 0; i < noutput_items; i += d_icols) {
- unsigned int datasize = noutput_items - i;
- unsigned int resid = d_icols-d_index;
- idx = 0;
-
- // If we have enough input for one full plot, do it
- if(datasize >= resid) {
-
- // Fill up residbufs with d_size number of items
- for(n = 0; n < d_nconnections; n++) {
- in = (const float*)input_items[idx++];
-
- // Scale and add offset
- volk_32f_s32f_multiply_32f(d_tmpflt, &in[j], d_mult[n], resid);
- for(unsigned int s = 0; s < resid; s++)
- d_tmpflt[s] = d_tmpflt[s] + d_offset[n];
-
- volk_32f_convert_64f_u(&d_residbufs[n][d_index],
- d_tmpflt, resid);
- }
-
- // Update the plot if its time
- if(gr::high_res_timer_now() - d_last_time > d_update_time) {
- d_last_time = gr::high_res_timer_now();
- d_qApplication->postEvent(d_main_gui,
- new TimeRasterUpdateEvent(d_residbufs, d_cols));
- }
-
- d_index = 0;
- j += resid;
- }
- // Otherwise, copy what we received into the residbufs for next time
- // because we set the output_multiple, this should never need to be called
- else {
- for(n = 0; n < d_nconnections; n++) {
- in = (const float*)input_items[idx++];
-
- // Scale and add offset
- volk_32f_s32f_multiply_32f(d_tmpflt, &in[j], d_mult[n], datasize);
- for(unsigned int s = 0; s < datasize; s++)
- d_tmpflt[s] = d_tmpflt[s] + d_offset[n];
-
- volk_32f_convert_64f(&d_residbufs[n][d_index],
- d_tmpflt, datasize);
- }
- d_index += datasize;
- j += datasize;
- }
- }
-
- return j;
- }
+ return j;
+}
- void
- time_raster_sink_f_impl::handle_pdus(pmt::pmt_t msg)
- {
- size_t len;
- pmt::pmt_t dict, samples;
+void time_raster_sink_f_impl::handle_pdus(pmt::pmt_t msg)
+{
+ size_t len;
+ pmt::pmt_t dict, samples;
- // Test to make sure this is either a PDU or a uniform vector of
- // samples. Get the samples PMT and the dictionary if it's a PDU.
- // If not, we throw an error and exit.
- if(pmt::is_pair(msg)) {
+ // Test to make sure this is either a PDU or a uniform vector of
+ // samples. Get the samples PMT and the dictionary if it's a PDU.
+ // If not, we throw an error and exit.
+ if (pmt::is_pair(msg)) {
dict = pmt::car(msg);
samples = pmt::cdr(msg);
- }
- else if(pmt::is_uniform_vector(msg)) {
+ } else if (pmt::is_uniform_vector(msg)) {
samples = msg;
- }
- else {
+ } else {
throw std::runtime_error("time_sink_c: message must be either "
"a PDU or a uniform vector of samples.");
- }
+ }
- len = pmt::length(samples);
+ len = pmt::length(samples);
- const float *in;
- if(pmt::is_f32vector(samples)) {
+ const float* in;
+ if (pmt::is_f32vector(samples)) {
in = (const float*)pmt::f32vector_elements(samples, len);
- }
- else {
+ } else {
throw std::runtime_error("time_raster_sink_f: unknown data type "
"of samples; must be float.");
- }
+ }
- // Plot if we're past the last update time
- if(gr::high_res_timer_now() - d_last_time > d_update_time) {
+ // Plot if we're past the last update time
+ if (gr::high_res_timer_now() - d_last_time > d_update_time) {
d_last_time = gr::high_res_timer_now();
_ncols_resize();
@@ -535,27 +451,27 @@ namespace gr {
d_rows = ceil(static_cast<double>(len) / static_cast<double>(d_cols));
int irows = static_cast<int>(d_rows);
- d_qApplication->postEvent(d_main_gui,
- new TimeRasterSetSize(d_rows, d_cols));
+ d_qApplication->postEvent(d_main_gui, new TimeRasterSetSize(d_rows, d_cols));
int idx = 0;
- for(int r = 0; r < irows; r++) {
- // Scale and add offset
- int cpy_len = std::min(static_cast<size_t>(d_cols), len - idx);
- memset(d_residbufs[d_nconnections], 0, d_cols*sizeof(double));
- volk_32f_s32f_multiply_32f(d_tmpflt, &in[idx], d_mult[d_nconnections], cpy_len);
- for(int c = 0; c < cpy_len; c++) {
- d_tmpflt[c] = d_tmpflt[c] + d_offset[d_nconnections];
- }
-
- volk_32f_convert_64f_u(d_residbufs[d_nconnections], d_tmpflt, cpy_len);
-
- d_qApplication->postEvent(d_main_gui,
- new TimeRasterUpdateEvent(d_residbufs, d_cols));
- idx += d_cols;
+ for (int r = 0; r < irows; r++) {
+ // Scale and add offset
+ int cpy_len = std::min(static_cast<size_t>(d_cols), len - idx);
+ memset(d_residbufs[d_nconnections], 0, d_cols * sizeof(double));
+ volk_32f_s32f_multiply_32f(
+ d_tmpflt, &in[idx], d_mult[d_nconnections], cpy_len);
+ for (int c = 0; c < cpy_len; c++) {
+ d_tmpflt[c] = d_tmpflt[c] + d_offset[d_nconnections];
+ }
+
+ volk_32f_convert_64f_u(d_residbufs[d_nconnections], d_tmpflt, cpy_len);
+
+ d_qApplication->postEvent(d_main_gui,
+ new TimeRasterUpdateEvent(d_residbufs, d_cols));
+ idx += d_cols;
}
- }
}
+}
- } /* namespace qtgui */
+} /* namespace qtgui */
} /* namespace gr */
diff --git a/gr-qtgui/lib/time_raster_sink_f_impl.h b/gr-qtgui/lib/time_raster_sink_f_impl.h
index 1e2777453a..b760907427 100644
--- a/gr-qtgui/lib/time_raster_sink_f_impl.h
+++ b/gr-qtgui/lib/time_raster_sink_f_impl.h
@@ -31,106 +31,107 @@
#include <gnuradio/qtgui/timerasterdisplayform.h>
namespace gr {
- namespace qtgui {
+namespace qtgui {
- class QTGUI_API time_raster_sink_f_impl : public time_raster_sink_f
- {
- private:
- void initialize();
+class QTGUI_API time_raster_sink_f_impl : public time_raster_sink_f
+{
+private:
+ void initialize();
- std::string d_name;
- int d_nconnections;
+ std::string d_name;
+ int d_nconnections;
- int d_index;
- std::vector<double*> d_residbufs;
+ int d_index;
+ std::vector<double*> d_residbufs;
- float *d_tmpflt;
+ float* d_tmpflt;
- int d_argc;
- char *d_argv;
- QWidget *d_parent;
- TimeRasterDisplayForm *d_main_gui;
+ int d_argc;
+ char* d_argv;
+ QWidget* d_parent;
+ TimeRasterDisplayForm* d_main_gui;
- int d_icols;
- double d_rows, d_cols;
- std::vector<float> d_mult;
- std::vector<float> d_offset;
- double d_samp_rate;
+ int d_icols;
+ double d_rows, d_cols;
+ std::vector<float> d_mult;
+ std::vector<float> d_offset;
+ double d_samp_rate;
- gr::high_res_timer_type d_update_time;
- gr::high_res_timer_type d_last_time;
+ gr::high_res_timer_type d_update_time;
+ gr::high_res_timer_type d_last_time;
- void _ncols_resize();
+ void _ncols_resize();
- // Handles message input port for displaying PDU samples.
- void handle_pdus(pmt::pmt_t msg);
+ // Handles message input port for displaying PDU samples.
+ void handle_pdus(pmt::pmt_t msg);
- public:
- time_raster_sink_f_impl(double samp_rate,
- double rows, double cols,
- const std::vector<float> &mult,
- const std::vector<float> &offset,
- const std::string &name,
- int nconnections,
- QWidget *parent=NULL);
- ~time_raster_sink_f_impl();
+public:
+ time_raster_sink_f_impl(double samp_rate,
+ double rows,
+ double cols,
+ const std::vector<float>& mult,
+ const std::vector<float>& offset,
+ const std::string& name,
+ int nconnections,
+ QWidget* parent = NULL);
+ ~time_raster_sink_f_impl();
- bool check_topology(int ninputs, int noutputs);
+ bool check_topology(int ninputs, int noutputs);
- void exec_();
- QWidget* qwidget();
+ void exec_();
+ QWidget* qwidget();
#ifdef ENABLE_PYTHON
- PyObject* pyqwidget();
+ PyObject* pyqwidget();
#else
- void* pyqwidget();
+ void* pyqwidget();
#endif
- void set_update_time(double t);
- void set_title(const std::string &title);
- void set_line_label(unsigned int which, const std::string &label);
- void set_line_color(unsigned int which, const std::string &color);
- void set_line_width(unsigned int which, int width);
- void set_line_style(unsigned int which, Qt::PenStyle style);
- void set_line_marker(unsigned int which, QwtSymbol::Style marker);
- void set_line_alpha(unsigned int which, double alpha);
- void set_color_map(unsigned int which, const int color);
-
- std::string title();
- std::string line_label(unsigned int which);
- std::string line_color(unsigned int which);
- int line_width(unsigned int which);
- int line_style(unsigned int which);
- int line_marker(unsigned int which);
- double line_alpha(unsigned int which);
- int color_map(unsigned int which);
-
- void set_size(int width, int height);
-
- void set_samp_rate(const double samp_rate);
- void set_num_rows(double rows);
- void set_num_cols(double cols);
-
- double num_rows();
- double num_cols();
-
- void set_multiplier(const std::vector<float> &mult);
- void set_offset(const std::vector<float> &offset);
-
- void set_intensity_range(float min, float max);
-
- void enable_menu(bool en);
- void enable_grid(bool en);
- void enable_autoscale(bool en);
- void enable_axis_labels(bool en);
- void reset();
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace qtgui */
+ void set_update_time(double t);
+ void set_title(const std::string& title);
+ void set_line_label(unsigned int which, const std::string& label);
+ void set_line_color(unsigned int which, const std::string& color);
+ void set_line_width(unsigned int which, int width);
+ void set_line_style(unsigned int which, Qt::PenStyle style);
+ void set_line_marker(unsigned int which, QwtSymbol::Style marker);
+ void set_line_alpha(unsigned int which, double alpha);
+ void set_color_map(unsigned int which, const int color);
+
+ std::string title();
+ std::string line_label(unsigned int which);
+ std::string line_color(unsigned int which);
+ int line_width(unsigned int which);
+ int line_style(unsigned int which);
+ int line_marker(unsigned int which);
+ double line_alpha(unsigned int which);
+ int color_map(unsigned int which);
+
+ void set_size(int width, int height);
+
+ void set_samp_rate(const double samp_rate);
+ void set_num_rows(double rows);
+ void set_num_cols(double cols);
+
+ double num_rows();
+ double num_cols();
+
+ void set_multiplier(const std::vector<float>& mult);
+ void set_offset(const std::vector<float>& offset);
+
+ void set_intensity_range(float min, float max);
+
+ void enable_menu(bool en);
+ void enable_grid(bool en);
+ void enable_autoscale(bool en);
+ void enable_axis_labels(bool en);
+ void reset();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
+
+} /* namespace qtgui */
} /* namespace gr */
#endif /* INCLUDED_QTGUI_TIME_RASTER_SINK_F_IMPL_H */
diff --git a/gr-qtgui/lib/time_sink_c_impl.cc b/gr-qtgui/lib/time_sink_c_impl.cc
index 31c17f3a9c..c885b7290e 100644
--- a/gr-qtgui/lib/time_sink_c_impl.cc
+++ b/gr-qtgui/lib/time_sink_c_impl.cc
@@ -36,543 +36,467 @@
#include <string.h>
namespace gr {
- namespace qtgui {
-
- time_sink_c::sptr
- time_sink_c::make(int size, double samp_rate,
- const std::string &name,
- unsigned int nconnections,
- QWidget *parent)
- {
- return gnuradio::get_initial_sptr
- (new time_sink_c_impl(size, samp_rate, name, nconnections, parent));
- }
-
- time_sink_c_impl::time_sink_c_impl(int size, double samp_rate,
- const std::string &name,
- unsigned int nconnections,
- QWidget *parent)
- : sync_block("time_sink_c",
- io_signature::make(0, nconnections, sizeof(gr_complex)),
- io_signature::make(0, 0, 0)),
- d_size(size), d_buffer_size(2*size), d_samp_rate(samp_rate), d_name(name),
- d_nconnections(2*nconnections),
- d_tag_key(pmt::mp("tags")),
- d_parent(parent)
- {
- if(nconnections > 12)
+namespace qtgui {
+
+time_sink_c::sptr time_sink_c::make(int size,
+ double samp_rate,
+ const std::string& name,
+ unsigned int nconnections,
+ QWidget* parent)
+{
+ return gnuradio::get_initial_sptr(
+ new time_sink_c_impl(size, samp_rate, name, nconnections, parent));
+}
+
+time_sink_c_impl::time_sink_c_impl(int size,
+ double samp_rate,
+ const std::string& name,
+ unsigned int nconnections,
+ QWidget* parent)
+ : sync_block("time_sink_c",
+ io_signature::make(0, nconnections, sizeof(gr_complex)),
+ io_signature::make(0, 0, 0)),
+ d_size(size),
+ d_buffer_size(2 * size),
+ d_samp_rate(samp_rate),
+ d_name(name),
+ d_nconnections(2 * nconnections),
+ d_tag_key(pmt::mp("tags")),
+ d_parent(parent)
+{
+ if (nconnections > 12)
throw std::runtime_error("time_sink_c only supports up to 12 inputs");
- // Required now for Qt; argc must be greater than 0 and argv
- // must have at least one valid character. Must be valid through
- // life of the qApplication:
- // http://harmattan-dev.nokia.com/docs/library/html/qt4/qapplication.html
- d_argc = 1;
- d_argv = new char;
- d_argv[0] = '\0';
-
- d_main_gui = NULL;
-
- // setup PDU handling input port
- message_port_register_in(pmt::mp("in"));
- set_msg_handler(pmt::mp("in"),
- boost::bind(&time_sink_c_impl::handle_pdus, this, _1));
-
- // +2 for the PDU message buffers
- for(unsigned int n = 0; n < d_nconnections+2; n++) {
- d_buffers.push_back((double*)volk_malloc(d_buffer_size*sizeof(double),
- volk_get_alignment()));
- memset(d_buffers[n], 0, d_buffer_size*sizeof(double));
- }
-
- // We don't use cbuffers with the PDU message handling capabilities.
- for(unsigned int n = 0; n < d_nconnections/2; n++) {
- d_cbuffers.push_back((gr_complex*)volk_malloc(d_buffer_size*sizeof(gr_complex),
+ // Required now for Qt; argc must be greater than 0 and argv
+ // must have at least one valid character. Must be valid through
+ // life of the qApplication:
+ // http://harmattan-dev.nokia.com/docs/library/html/qt4/qapplication.html
+ d_argc = 1;
+ d_argv = new char;
+ d_argv[0] = '\0';
+
+ d_main_gui = NULL;
+
+ // setup PDU handling input port
+ message_port_register_in(pmt::mp("in"));
+ set_msg_handler(pmt::mp("in"), boost::bind(&time_sink_c_impl::handle_pdus, this, _1));
+
+ // +2 for the PDU message buffers
+ for (unsigned int n = 0; n < d_nconnections + 2; n++) {
+ d_buffers.push_back(
+ (double*)volk_malloc(d_buffer_size * sizeof(double), volk_get_alignment()));
+ memset(d_buffers[n], 0, d_buffer_size * sizeof(double));
+ }
+
+ // We don't use cbuffers with the PDU message handling capabilities.
+ for (unsigned int n = 0; n < d_nconnections / 2; n++) {
+ d_cbuffers.push_back((gr_complex*)volk_malloc(d_buffer_size * sizeof(gr_complex),
volk_get_alignment()));
- memset(d_cbuffers[n], 0, d_buffer_size*sizeof(gr_complex));
- }
+ memset(d_cbuffers[n], 0, d_buffer_size * sizeof(gr_complex));
+ }
- // Set alignment properties for VOLK
- const int alignment_multiple =
- volk_get_alignment() / sizeof(gr_complex);
- set_alignment(std::max(1,alignment_multiple));
+ // Set alignment properties for VOLK
+ const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
+ set_alignment(std::max(1, alignment_multiple));
- d_tags = std::vector< std::vector<gr::tag_t> >(d_nconnections/2);
+ d_tags = std::vector<std::vector<gr::tag_t>>(d_nconnections / 2);
- initialize();
+ initialize();
- d_main_gui->setNPoints(d_size); // setup GUI box with size
- set_trigger_mode(TRIG_MODE_FREE, TRIG_SLOPE_POS, 0, 0, 0);
+ d_main_gui->setNPoints(d_size); // setup GUI box with size
+ set_trigger_mode(TRIG_MODE_FREE, TRIG_SLOPE_POS, 0, 0, 0);
- set_history(2); // so we can look ahead for the trigger slope
- declare_sample_delay(1); // delay the tags for a history of 2
- }
+ set_history(2); // so we can look ahead for the trigger slope
+ declare_sample_delay(1); // delay the tags for a history of 2
+}
- time_sink_c_impl::~time_sink_c_impl()
- {
- if(!d_main_gui->isClosed())
+time_sink_c_impl::~time_sink_c_impl()
+{
+ if (!d_main_gui->isClosed())
d_main_gui->close();
- // d_main_gui is a qwidget destroyed with its parent
- for(unsigned int n = 0; n < d_nconnections+2; n++) {
- volk_free(d_buffers[n]);
- }
- for(unsigned int n = 0; n < d_nconnections/2; n++) {
+ // d_main_gui is a qwidget destroyed with its parent
+ for (unsigned int n = 0; n < d_nconnections + 2; n++) {
+ volk_free(d_buffers[n]);
+ }
+ for (unsigned int n = 0; n < d_nconnections / 2; n++) {
volk_free(d_cbuffers[n]);
- }
-
- delete d_argv;
}
- bool
- time_sink_c_impl::check_topology(int ninputs, int noutputs)
- {
- return (unsigned int) (2*ninputs) == d_nconnections;
- }
+ delete d_argv;
+}
+
+bool time_sink_c_impl::check_topology(int ninputs, int noutputs)
+{
+ return (unsigned int)(2 * ninputs) == d_nconnections;
+}
- void
- time_sink_c_impl::initialize()
- {
- if(qApp != NULL) {
- d_qApplication = qApp;
- }
- else {
+void time_sink_c_impl::initialize()
+{
+ if (qApp != NULL) {
+ d_qApplication = qApp;
+ } else {
#if QT_VERSION >= 0x040500 && QT_VERSION < 0x050000
std::string style = prefs::singleton()->get_string("qtgui", "style", "raster");
QApplication::setGraphicsSystem(QString(style.c_str()));
#endif
- d_qApplication = new QApplication(d_argc, &d_argv);
- }
+ d_qApplication = new QApplication(d_argc, &d_argv);
+ }
- // If a style sheet is set in the prefs file, enable it here.
- check_set_qss(d_qApplication);
+ // If a style sheet is set in the prefs file, enable it here.
+ check_set_qss(d_qApplication);
- unsigned int numplots = (d_nconnections > 0) ? d_nconnections : 2;
- d_main_gui = new TimeDisplayForm(numplots, d_parent);
- d_main_gui->setNPoints(d_size);
- d_main_gui->setSampleRate(d_samp_rate);
+ unsigned int numplots = (d_nconnections > 0) ? d_nconnections : 2;
+ d_main_gui = new TimeDisplayForm(numplots, d_parent);
+ d_main_gui->setNPoints(d_size);
+ d_main_gui->setSampleRate(d_samp_rate);
- if(d_name.size() > 0)
+ if (d_name.size() > 0)
set_title(d_name);
- // initialize update time to 10 times a second
- set_update_time(0.1);
- }
+ // initialize update time to 10 times a second
+ set_update_time(0.1);
+}
- void
- time_sink_c_impl::exec_()
- {
- d_qApplication->exec();
- }
+void time_sink_c_impl::exec_() { d_qApplication->exec(); }
- QWidget*
- time_sink_c_impl::qwidget()
- {
- return d_main_gui;
- }
+QWidget* time_sink_c_impl::qwidget() { return d_main_gui; }
#ifdef ENABLE_PYTHON
- PyObject*
- time_sink_c_impl::pyqwidget()
- {
- PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui);
- PyObject *retarg = Py_BuildValue("N", w);
- return retarg;
- }
+PyObject* time_sink_c_impl::pyqwidget()
+{
+ PyObject* w = PyLong_FromVoidPtr((void*)d_main_gui);
+ PyObject* retarg = Py_BuildValue("N", w);
+ return retarg;
+}
#else
- void *
- time_sink_c_impl::pyqwidget()
- {
- return NULL;
- }
+void* time_sink_c_impl::pyqwidget() { return NULL; }
#endif
- void
- time_sink_c_impl::set_y_axis(double min, double max)
- {
- d_main_gui->setYaxis(min, max);
- }
-
- void
- time_sink_c_impl::set_y_label(const std::string &label,
- const std::string &unit)
- {
- d_main_gui->setYLabel(label, unit);
- }
-
- void
- time_sink_c_impl::set_update_time(double t)
- {
- //convert update time to ticks
- gr::high_res_timer_type tps = gr::high_res_timer_tps();
- d_update_time = t * tps;
- d_main_gui->setUpdateTime(t);
- d_last_time = 0;
- }
-
- void
- time_sink_c_impl::set_title(const std::string &title)
- {
- d_main_gui->setTitle(title.c_str());
- }
-
- void
- time_sink_c_impl::set_line_label(unsigned int which, const std::string &label)
- {
- d_main_gui->setLineLabel(which, label.c_str());
- }
-
- void
- time_sink_c_impl::set_line_color(unsigned int which, const std::string &color)
- {
- d_main_gui->setLineColor(which, color.c_str());
- }
-
- void
- time_sink_c_impl::set_line_width(unsigned int which, int width)
- {
- d_main_gui->setLineWidth(which, width);
- }
-
- void
- time_sink_c_impl::set_line_style(unsigned int which, int style)
- {
- d_main_gui->setLineStyle(which, (Qt::PenStyle)style);
- }
-
- void
- time_sink_c_impl::set_line_marker(unsigned int which, int marker)
- {
- d_main_gui->setLineMarker(which, (QwtSymbol::Style)marker);
- }
-
- void
- time_sink_c_impl::set_line_alpha(unsigned int which, double alpha)
- {
- d_main_gui->setMarkerAlpha(which, (int)(255.0*alpha));
- }
-
- void
- time_sink_c_impl::set_trigger_mode(trigger_mode mode,
- trigger_slope slope,
- float level,
- float delay, int channel,
- const std::string &tag_key)
- {
- gr::thread::scoped_lock lock(d_setlock);
-
- d_trigger_mode = mode;
- d_trigger_slope = slope;
- d_trigger_level = level;
- d_trigger_delay = static_cast<int>(delay*d_samp_rate);
- d_trigger_channel = channel;
- d_trigger_tag_key = pmt::intern(tag_key);
- d_triggered = false;
- d_trigger_count = 0;
-
- if((d_trigger_delay < 0) || (d_trigger_delay >= d_size)) {
- GR_LOG_WARN(d_logger, boost::format("Trigger delay (%1%) outside of display range (0:%2%).") \
- % (d_trigger_delay/d_samp_rate) % ((d_size-1)/d_samp_rate));
- d_trigger_delay = std::max(0, std::min(d_size-1, d_trigger_delay));
- delay = d_trigger_delay/d_samp_rate;
- }
-
- d_main_gui->setTriggerMode(d_trigger_mode);
- d_main_gui->setTriggerSlope(d_trigger_slope);
- d_main_gui->setTriggerLevel(d_trigger_level);
- d_main_gui->setTriggerDelay(delay);
- d_main_gui->setTriggerChannel(d_trigger_channel);
- d_main_gui->setTriggerTagKey(tag_key);
-
- _reset();
- }
-
- void
- time_sink_c_impl::set_size(int width, int height)
- {
- d_main_gui->resize(QSize(width, height));
- }
-
- std::string
- time_sink_c_impl::title()
- {
- return d_main_gui->title().toStdString();
- }
-
- std::string
- time_sink_c_impl::line_label(unsigned int which)
- {
- return d_main_gui->lineLabel(which).toStdString();
- }
-
- std::string
- time_sink_c_impl::line_color(unsigned int which)
- {
- return d_main_gui->lineColor(which).toStdString();
- }
-
- int
- time_sink_c_impl::line_width(unsigned int which)
- {
- return d_main_gui->lineWidth(which);
- }
-
- int
- time_sink_c_impl::line_style(unsigned int which)
- {
- return d_main_gui->lineStyle(which);
- }
-
- int
- time_sink_c_impl::line_marker(unsigned int which)
- {
- return d_main_gui->lineMarker(which);
- }
-
- double
- time_sink_c_impl::line_alpha(unsigned int which)
- {
- return (double)(d_main_gui->markerAlpha(which))/255.0;
- }
-
- void
- time_sink_c_impl::set_nsamps(const int newsize)
- {
- if(newsize != d_size) {
+void time_sink_c_impl::set_y_axis(double min, double max)
+{
+ d_main_gui->setYaxis(min, max);
+}
+
+void time_sink_c_impl::set_y_label(const std::string& label, const std::string& unit)
+{
+ d_main_gui->setYLabel(label, unit);
+}
+
+void time_sink_c_impl::set_update_time(double t)
+{
+ // convert update time to ticks
+ gr::high_res_timer_type tps = gr::high_res_timer_tps();
+ d_update_time = t * tps;
+ d_main_gui->setUpdateTime(t);
+ d_last_time = 0;
+}
+
+void time_sink_c_impl::set_title(const std::string& title)
+{
+ d_main_gui->setTitle(title.c_str());
+}
+
+void time_sink_c_impl::set_line_label(unsigned int which, const std::string& label)
+{
+ d_main_gui->setLineLabel(which, label.c_str());
+}
+
+void time_sink_c_impl::set_line_color(unsigned int which, const std::string& color)
+{
+ d_main_gui->setLineColor(which, color.c_str());
+}
+
+void time_sink_c_impl::set_line_width(unsigned int which, int width)
+{
+ d_main_gui->setLineWidth(which, width);
+}
+
+void time_sink_c_impl::set_line_style(unsigned int which, int style)
+{
+ d_main_gui->setLineStyle(which, (Qt::PenStyle)style);
+}
+
+void time_sink_c_impl::set_line_marker(unsigned int which, int marker)
+{
+ d_main_gui->setLineMarker(which, (QwtSymbol::Style)marker);
+}
+
+void time_sink_c_impl::set_line_alpha(unsigned int which, double alpha)
+{
+ d_main_gui->setMarkerAlpha(which, (int)(255.0 * alpha));
+}
+
+void time_sink_c_impl::set_trigger_mode(trigger_mode mode,
+ trigger_slope slope,
+ float level,
+ float delay,
+ int channel,
+ const std::string& tag_key)
+{
+ gr::thread::scoped_lock lock(d_setlock);
+
+ d_trigger_mode = mode;
+ d_trigger_slope = slope;
+ d_trigger_level = level;
+ d_trigger_delay = static_cast<int>(delay * d_samp_rate);
+ d_trigger_channel = channel;
+ d_trigger_tag_key = pmt::intern(tag_key);
+ d_triggered = false;
+ d_trigger_count = 0;
+
+ if ((d_trigger_delay < 0) || (d_trigger_delay >= d_size)) {
+ GR_LOG_WARN(
+ d_logger,
+ boost::format("Trigger delay (%1%) outside of display range (0:%2%).") %
+ (d_trigger_delay / d_samp_rate) % ((d_size - 1) / d_samp_rate));
+ d_trigger_delay = std::max(0, std::min(d_size - 1, d_trigger_delay));
+ delay = d_trigger_delay / d_samp_rate;
+ }
+
+ d_main_gui->setTriggerMode(d_trigger_mode);
+ d_main_gui->setTriggerSlope(d_trigger_slope);
+ d_main_gui->setTriggerLevel(d_trigger_level);
+ d_main_gui->setTriggerDelay(delay);
+ d_main_gui->setTriggerChannel(d_trigger_channel);
+ d_main_gui->setTriggerTagKey(tag_key);
+
+ _reset();
+}
+
+void time_sink_c_impl::set_size(int width, int height)
+{
+ d_main_gui->resize(QSize(width, height));
+}
+
+std::string time_sink_c_impl::title() { return d_main_gui->title().toStdString(); }
+
+std::string time_sink_c_impl::line_label(unsigned int which)
+{
+ return d_main_gui->lineLabel(which).toStdString();
+}
+
+std::string time_sink_c_impl::line_color(unsigned int which)
+{
+ return d_main_gui->lineColor(which).toStdString();
+}
+
+int time_sink_c_impl::line_width(unsigned int which)
+{
+ return d_main_gui->lineWidth(which);
+}
+
+int time_sink_c_impl::line_style(unsigned int which)
+{
+ return d_main_gui->lineStyle(which);
+}
+
+int time_sink_c_impl::line_marker(unsigned int which)
+{
+ return d_main_gui->lineMarker(which);
+}
+
+double time_sink_c_impl::line_alpha(unsigned int which)
+{
+ return (double)(d_main_gui->markerAlpha(which)) / 255.0;
+}
+
+void time_sink_c_impl::set_nsamps(const int newsize)
+{
+ if (newsize != d_size) {
gr::thread::scoped_lock lock(d_setlock);
- // Set new size and reset buffer index
- // (throws away any currently held data, but who cares?)
- d_size = newsize;
- d_buffer_size = 2*d_size;
-
- // Resize buffers and replace data
- for(unsigned int n = 0; n < d_nconnections+2; n++) {
- volk_free(d_buffers[n]);
- d_buffers[n] = (double*)volk_malloc(d_buffer_size*sizeof(double),
- volk_get_alignment());
- memset(d_buffers[n], 0, d_buffer_size*sizeof(double));
- }
-
- for(unsigned int n = 0; n < d_nconnections/2; n++) {
- volk_free(d_cbuffers[n]);
- d_cbuffers[n] = (gr_complex*)volk_malloc(d_buffer_size*sizeof(gr_complex),
- volk_get_alignment());
- memset(d_cbuffers[n], 0, d_buffer_size*sizeof(gr_complex));
- }
+ // Set new size and reset buffer index
+ // (throws away any currently held data, but who cares?)
+ d_size = newsize;
+ d_buffer_size = 2 * d_size;
+
+ // Resize buffers and replace data
+ for (unsigned int n = 0; n < d_nconnections + 2; n++) {
+ volk_free(d_buffers[n]);
+ d_buffers[n] = (double*)volk_malloc(d_buffer_size * sizeof(double),
+ volk_get_alignment());
+ memset(d_buffers[n], 0, d_buffer_size * sizeof(double));
+ }
+
+ for (unsigned int n = 0; n < d_nconnections / 2; n++) {
+ volk_free(d_cbuffers[n]);
+ d_cbuffers[n] = (gr_complex*)volk_malloc(d_buffer_size * sizeof(gr_complex),
+ volk_get_alignment());
+ memset(d_cbuffers[n], 0, d_buffer_size * sizeof(gr_complex));
+ }
// If delay was set beyond the new boundary, pull it back.
- if(d_trigger_delay >= d_size) {
- GR_LOG_WARN(d_logger, boost::format("Trigger delay (%1%) outside of display range (0:%2%). Moving to 50%% point.") \
- % (d_trigger_delay/d_samp_rate) % ((d_size-1)/d_samp_rate));
- d_trigger_delay = d_size/2;
- d_main_gui->setTriggerDelay(d_trigger_delay/d_samp_rate);
+ if (d_trigger_delay >= d_size) {
+ GR_LOG_WARN(d_logger,
+ boost::format("Trigger delay (%1%) outside of display range "
+ "(0:%2%). Moving to 50%% point.") %
+ (d_trigger_delay / d_samp_rate) %
+ ((d_size - 1) / d_samp_rate));
+ d_trigger_delay = d_size / 2;
+ d_main_gui->setTriggerDelay(d_trigger_delay / d_samp_rate);
}
- d_main_gui->setNPoints(d_size);
+ d_main_gui->setNPoints(d_size);
_reset();
- }
}
+}
- void
- time_sink_c_impl::set_samp_rate(const double samp_rate)
- {
- gr::thread::scoped_lock lock(d_setlock);
- d_samp_rate = samp_rate;
- d_main_gui->setSampleRate(d_samp_rate);
- }
+void time_sink_c_impl::set_samp_rate(const double samp_rate)
+{
+ gr::thread::scoped_lock lock(d_setlock);
+ d_samp_rate = samp_rate;
+ d_main_gui->setSampleRate(d_samp_rate);
+}
- int
- time_sink_c_impl::nsamps() const
- {
- return d_size;
- }
+int time_sink_c_impl::nsamps() const { return d_size; }
- void
- time_sink_c_impl::enable_menu(bool en)
- {
- d_main_gui->enableMenu(en);
- }
+void time_sink_c_impl::enable_menu(bool en) { d_main_gui->enableMenu(en); }
- void
- time_sink_c_impl::enable_grid(bool en)
- {
- d_main_gui->setGrid(en);
- }
+void time_sink_c_impl::enable_grid(bool en) { d_main_gui->setGrid(en); }
- void
- time_sink_c_impl::enable_autoscale(bool en)
- {
- d_main_gui->autoScale(en);
- }
+void time_sink_c_impl::enable_autoscale(bool en) { d_main_gui->autoScale(en); }
- void
- time_sink_c_impl::enable_stem_plot(bool en)
- {
- d_main_gui->setStem(en);
- }
+void time_sink_c_impl::enable_stem_plot(bool en) { d_main_gui->setStem(en); }
- void
- time_sink_c_impl::enable_semilogx(bool en)
- {
- d_main_gui->setSemilogx(en);
- }
+void time_sink_c_impl::enable_semilogx(bool en) { d_main_gui->setSemilogx(en); }
- void
- time_sink_c_impl::enable_semilogy(bool en)
- {
- d_main_gui->setSemilogy(en);
- }
+void time_sink_c_impl::enable_semilogy(bool en) { d_main_gui->setSemilogy(en); }
- void
- time_sink_c_impl::enable_control_panel(bool en)
- {
- if(en)
+void time_sink_c_impl::enable_control_panel(bool en)
+{
+ if (en)
d_main_gui->setupControlPanel();
- else
+ else
d_main_gui->teardownControlPanel();
- }
-
- void
- time_sink_c_impl::enable_tags(unsigned int which, bool en)
- {
- d_main_gui->setTagMenu(which, en);
- }
-
- void
- time_sink_c_impl::enable_tags(bool en)
- {
- for(unsigned int n = 0; n < d_nconnections; ++n) {
- d_main_gui->setTagMenu(n, en);
- }
- }
-
- void
- time_sink_c_impl::enable_axis_labels(bool en)
- {
- d_main_gui->setAxisLabels(en);
- }
-
- void
- time_sink_c_impl::disable_legend()
- {
- d_main_gui->disableLegend();
- }
-
- void
- time_sink_c_impl::reset()
- {
- gr::thread::scoped_lock lock(d_setlock);
- _reset();
- }
-
- void
- time_sink_c_impl::_reset()
- {
- unsigned int n;
- if(d_trigger_delay) {
- for(n = 0; n < d_nconnections/2; n++) {
- // Move the tail of the buffers to the front. This section
- // represents data that might have to be plotted again if a
- // trigger occurs and we have a trigger delay set. The tail
- // section is between (d_end-d_trigger_delay) and d_end.
- memmove(d_cbuffers[n], &d_cbuffers[n][d_end-d_trigger_delay],
- d_trigger_delay*sizeof(gr_complex));
-
- // Also move the offsets of any tags that occur in the tail
- // section so they would be plotted again, too.
- std::vector<gr::tag_t> tmp_tags;
- for(size_t t = 0; t < d_tags[n].size(); t++) {
- if(d_tags[n][t].offset > (uint64_t)(d_size - d_trigger_delay)) {
- d_tags[n][t].offset = d_tags[n][t].offset - (d_size - d_trigger_delay);
- tmp_tags.push_back(d_tags[n][t]);
+}
+
+void time_sink_c_impl::enable_tags(unsigned int which, bool en)
+{
+ d_main_gui->setTagMenu(which, en);
+}
+
+void time_sink_c_impl::enable_tags(bool en)
+{
+ for (unsigned int n = 0; n < d_nconnections; ++n) {
+ d_main_gui->setTagMenu(n, en);
+ }
+}
+
+void time_sink_c_impl::enable_axis_labels(bool en) { d_main_gui->setAxisLabels(en); }
+
+void time_sink_c_impl::disable_legend() { d_main_gui->disableLegend(); }
+
+void time_sink_c_impl::reset()
+{
+ gr::thread::scoped_lock lock(d_setlock);
+ _reset();
+}
+
+void time_sink_c_impl::_reset()
+{
+ unsigned int n;
+ if (d_trigger_delay) {
+ for (n = 0; n < d_nconnections / 2; n++) {
+ // Move the tail of the buffers to the front. This section
+ // represents data that might have to be plotted again if a
+ // trigger occurs and we have a trigger delay set. The tail
+ // section is between (d_end-d_trigger_delay) and d_end.
+ memmove(d_cbuffers[n],
+ &d_cbuffers[n][d_end - d_trigger_delay],
+ d_trigger_delay * sizeof(gr_complex));
+
+ // Also move the offsets of any tags that occur in the tail
+ // section so they would be plotted again, too.
+ std::vector<gr::tag_t> tmp_tags;
+ for (size_t t = 0; t < d_tags[n].size(); t++) {
+ if (d_tags[n][t].offset > (uint64_t)(d_size - d_trigger_delay)) {
+ d_tags[n][t].offset =
+ d_tags[n][t].offset - (d_size - d_trigger_delay);
+ tmp_tags.push_back(d_tags[n][t]);
+ }
}
- }
- d_tags[n] = tmp_tags;
+ d_tags[n] = tmp_tags;
}
- }
- // Otherwise, just clear the local list of tags.
- else {
- for(n = 0; n < d_nconnections/2; n++) {
- d_tags[n].clear();
+ }
+ // Otherwise, just clear the local list of tags.
+ else {
+ for (n = 0; n < d_nconnections / 2; n++) {
+ d_tags[n].clear();
}
- }
+ }
- // Reset the start and end indices.
- d_start = 0;
- d_end = d_size;
+ // Reset the start and end indices.
+ d_start = 0;
+ d_end = d_size;
- // Reset the trigger. If in free running mode, ignore the
- // trigger delay and always set trigger to true.
- if(d_trigger_mode == TRIG_MODE_FREE) {
+ // Reset the trigger. If in free running mode, ignore the
+ // trigger delay and always set trigger to true.
+ if (d_trigger_mode == TRIG_MODE_FREE) {
d_index = 0;
d_triggered = true;
- }
- else {
+ } else {
d_index = d_trigger_delay;
d_triggered = false;
- }
}
+}
- void
- time_sink_c_impl::_npoints_resize()
- {
- int newsize = d_main_gui->getNPoints();
- set_nsamps(newsize);
- }
+void time_sink_c_impl::_npoints_resize()
+{
+ int newsize = d_main_gui->getNPoints();
+ set_nsamps(newsize);
+}
- void
- time_sink_c_impl::_adjust_tags(int adj)
- {
- for(size_t n = 0; n < d_tags.size(); n++) {
- for(size_t t = 0; t < d_tags[n].size(); t++) {
- d_tags[n][t].offset += adj;
+void time_sink_c_impl::_adjust_tags(int adj)
+{
+ for (size_t n = 0; n < d_tags.size(); n++) {
+ for (size_t t = 0; t < d_tags[n].size(); t++) {
+ d_tags[n][t].offset += adj;
}
- }
}
+}
- void
- time_sink_c_impl::_gui_update_trigger()
- {
- d_trigger_mode = d_main_gui->getTriggerMode();
- d_trigger_slope = d_main_gui->getTriggerSlope();
- d_trigger_level = d_main_gui->getTriggerLevel();
- d_trigger_channel = d_main_gui->getTriggerChannel();
- d_trigger_count = 0;
+void time_sink_c_impl::_gui_update_trigger()
+{
+ d_trigger_mode = d_main_gui->getTriggerMode();
+ d_trigger_slope = d_main_gui->getTriggerSlope();
+ d_trigger_level = d_main_gui->getTriggerLevel();
+ d_trigger_channel = d_main_gui->getTriggerChannel();
+ d_trigger_count = 0;
- float delayf = d_main_gui->getTriggerDelay();
- int delay = static_cast<int>(delayf*d_samp_rate);
+ float delayf = d_main_gui->getTriggerDelay();
+ int delay = static_cast<int>(delayf * d_samp_rate);
- if(delay != d_trigger_delay) {
+ if (delay != d_trigger_delay) {
// We restrict the delay to be within the window of time being
// plotted.
- if((delay < 0) || (delay >= d_size)) {
- GR_LOG_WARN(d_logger, boost::format("Trigger delay (%1%) outside of display range (0:%2%).") \
- % (delay/d_samp_rate) % ((d_size-1)/d_samp_rate));
- delay = std::max(0, std::min(d_size-1, delay));
- delayf = delay/d_samp_rate;
+ if ((delay < 0) || (delay >= d_size)) {
+ GR_LOG_WARN(
+ d_logger,
+ boost::format("Trigger delay (%1%) outside of display range (0:%2%).") %
+ (delay / d_samp_rate) % ((d_size - 1) / d_samp_rate));
+ delay = std::max(0, std::min(d_size - 1, delay));
+ delayf = delay / d_samp_rate;
}
d_trigger_delay = delay;
d_main_gui->setTriggerDelay(delayf);
_reset();
- }
-
- std::string tagkey = d_main_gui->getTriggerTagKey();
- d_trigger_tag_key = pmt::intern(tagkey);
}
- void
- time_sink_c_impl::_test_trigger_tags(int nitems)
- {
- int trigger_index;
-
- uint64_t nr = nitems_read(d_trigger_channel/2);
- std::vector<gr::tag_t> tags;
- get_tags_in_range(tags, d_trigger_channel/2,
- nr, nr + nitems + 1,
- d_trigger_tag_key);
- if(tags.size() > 0) {
+ std::string tagkey = d_main_gui->getTriggerTagKey();
+ d_trigger_tag_key = pmt::intern(tagkey);
+}
+
+void time_sink_c_impl::_test_trigger_tags(int nitems)
+{
+ int trigger_index;
+
+ uint64_t nr = nitems_read(d_trigger_channel / 2);
+ std::vector<gr::tag_t> tags;
+ get_tags_in_range(
+ tags, d_trigger_channel / 2, nr, nr + nitems + 1, d_trigger_tag_key);
+ if (tags.size() > 0) {
trigger_index = tags[0].offset - nr;
int start = d_index + trigger_index - d_trigger_delay - 1;
if (start >= 0) {
@@ -582,196 +506,190 @@ namespace gr {
d_trigger_count = 0;
_adjust_tags(-d_start);
}
- }
}
+}
- void
- time_sink_c_impl::_test_trigger_norm(int nitems, gr_vector_const_void_star inputs)
- {
- int trigger_index;
- const gr_complex *in = (const gr_complex*)inputs[d_trigger_channel/2];
- for(trigger_index = 0; trigger_index < nitems - 1; trigger_index++) {
+void time_sink_c_impl::_test_trigger_norm(int nitems, gr_vector_const_void_star inputs)
+{
+ int trigger_index;
+ const gr_complex* in = (const gr_complex*)inputs[d_trigger_channel / 2];
+ for (trigger_index = 0; trigger_index < nitems - 1; trigger_index++) {
d_trigger_count++;
// Test if trigger has occurred based on the input stream,
// channel number, and slope direction
- if(_test_trigger_slope(&in[trigger_index])) {
- d_triggered = true;
- d_start = d_index + trigger_index - d_trigger_delay;
- d_end = d_start + d_size;
- d_trigger_count = 0;
- _adjust_tags(-d_start);
- break;
+ if (_test_trigger_slope(&in[trigger_index])) {
+ d_triggered = true;
+ d_start = d_index + trigger_index - d_trigger_delay;
+ d_end = d_start + d_size;
+ d_trigger_count = 0;
+ _adjust_tags(-d_start);
+ break;
}
- }
+ }
- // If using auto trigger mode, trigger periodically even
- // without a trigger event.
- if((d_trigger_mode == TRIG_MODE_AUTO) && (d_trigger_count > d_size)) {
+ // If using auto trigger mode, trigger periodically even
+ // without a trigger event.
+ if ((d_trigger_mode == TRIG_MODE_AUTO) && (d_trigger_count > d_size)) {
d_triggered = true;
d_trigger_count = 0;
- }
}
+}
- bool
- time_sink_c_impl::_test_trigger_slope(const gr_complex *in) const
- {
- float x0, x1;
- if(d_trigger_channel % 2 == 0) {
+bool time_sink_c_impl::_test_trigger_slope(const gr_complex* in) const
+{
+ float x0, x1;
+ if (d_trigger_channel % 2 == 0) {
x0 = in[0].real();
x1 = in[1].real();
- }
- else {
+ } else {
x0 = in[0].imag();
x1 = in[1].imag();
- }
+ }
- if(d_trigger_slope == TRIG_SLOPE_POS)
+ if (d_trigger_slope == TRIG_SLOPE_POS)
return ((x0 <= d_trigger_level) && (x1 > d_trigger_level));
- else
+ else
return ((x0 >= d_trigger_level) && (x1 < d_trigger_level));
- }
+}
- int
- time_sink_c_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- unsigned int n=0;
- const gr_complex *in;
+int time_sink_c_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ unsigned int n = 0;
+ const gr_complex* in;
- _npoints_resize();
- _gui_update_trigger();
+ _npoints_resize();
+ _gui_update_trigger();
- gr::thread::scoped_lock lock(d_setlock);
+ gr::thread::scoped_lock lock(d_setlock);
- int nfill = d_end - d_index; // how much room left in buffers
- int nitems = std::min(noutput_items, nfill); // num items we can put in buffers
+ int nfill = d_end - d_index; // how much room left in buffers
+ int nitems = std::min(noutput_items, nfill); // num items we can put in buffers
- // If auto, normal, or tag trigger, look for the trigger
- if((d_trigger_mode != TRIG_MODE_FREE) && !d_triggered) {
+ // If auto, normal, or tag trigger, look for the trigger
+ if ((d_trigger_mode != TRIG_MODE_FREE) && !d_triggered) {
// trigger off a tag key (first one found)
- if(d_trigger_mode == TRIG_MODE_TAG) {
- _test_trigger_tags(nitems);
+ if (d_trigger_mode == TRIG_MODE_TAG) {
+ _test_trigger_tags(nitems);
}
// Normal or Auto trigger
else {
- _test_trigger_norm(nitems, input_items);
+ _test_trigger_norm(nitems, input_items);
}
- }
+ }
- // Copy data into the buffers.
- for(n = 0; n < d_nconnections/2; n++) {
+ // Copy data into the buffers.
+ for (n = 0; n < d_nconnections / 2; n++) {
in = (const gr_complex*)input_items[n];
- memcpy(&d_cbuffers[n][d_index], &in[1], nitems*sizeof(gr_complex));
+ memcpy(&d_cbuffers[n][d_index], &in[1], nitems * sizeof(gr_complex));
uint64_t nr = nitems_read(n);
std::vector<gr::tag_t> tags;
get_tags_in_range(tags, n, nr, nr + nitems);
- for(size_t t = 0; t < tags.size(); t++) {
- tags[t].offset = tags[t].offset - nr + (d_index-d_start-1);
+ for (size_t t = 0; t < tags.size(); t++) {
+ tags[t].offset = tags[t].offset - nr + (d_index - d_start - 1);
}
d_tags[n].insert(d_tags[n].end(), tags.begin(), tags.end());
- }
- d_index += nitems;
+ }
+ d_index += nitems;
- // If we've have a trigger and a full d_size of items in the buffers, plot.
- if((d_triggered) && (d_index == d_end)) {
+ // If we've have a trigger and a full d_size of items in the buffers, plot.
+ if ((d_triggered) && (d_index == d_end)) {
// Copy data to be plotted to start of buffers.
- for(n = 0; n < d_nconnections/2; n++) {
- volk_32fc_deinterleave_64f_x2(d_buffers[2*n+0], d_buffers[2*n+1],
- &d_cbuffers[n][d_start], d_size);
+ for (n = 0; n < d_nconnections / 2; n++) {
+ volk_32fc_deinterleave_64f_x2(d_buffers[2 * n + 0],
+ d_buffers[2 * n + 1],
+ &d_cbuffers[n][d_start],
+ d_size);
}
// Plot if we are able to update
- if(gr::high_res_timer_now() - d_last_time > d_update_time) {
- d_last_time = gr::high_res_timer_now();
- d_qApplication->postEvent(d_main_gui,
- new TimeUpdateEvent(d_buffers, d_size, d_tags));
+ if (gr::high_res_timer_now() - d_last_time > d_update_time) {
+ d_last_time = gr::high_res_timer_now();
+ d_qApplication->postEvent(d_main_gui,
+ new TimeUpdateEvent(d_buffers, d_size, d_tags));
}
// We've plotting, so reset the state
_reset();
- }
+ }
- // If we've filled up the buffers but haven't triggered, reset.
- if(d_index == d_end) {
+ // If we've filled up the buffers but haven't triggered, reset.
+ if (d_index == d_end) {
_reset();
- }
-
- return nitems;
}
- void
- time_sink_c_impl::handle_pdus(pmt::pmt_t msg)
- {
- size_t len;
- pmt::pmt_t dict, samples;
- std::vector< std::vector<gr::tag_t> > t(1);
-
- // Test to make sure this is either a PDU or a uniform vector of
- // samples. Get the samples PMT and the dictionary if it's a PDU.
- // If not, we throw an error and exit.
- if(pmt::is_pair(msg)) {
+ return nitems;
+}
+
+void time_sink_c_impl::handle_pdus(pmt::pmt_t msg)
+{
+ size_t len;
+ pmt::pmt_t dict, samples;
+ std::vector<std::vector<gr::tag_t>> t(1);
+
+ // Test to make sure this is either a PDU or a uniform vector of
+ // samples. Get the samples PMT and the dictionary if it's a PDU.
+ // If not, we throw an error and exit.
+ if (pmt::is_pair(msg)) {
dict = pmt::car(msg);
samples = pmt::cdr(msg);
- }
- else if(pmt::is_uniform_vector(msg)) {
+ } else if (pmt::is_uniform_vector(msg)) {
samples = msg;
- }
- else {
+ } else {
throw std::runtime_error("time_sink_c: message must be either "
"a PDU or a uniform vector of samples.");
- }
+ }
- // add tag info if it is present in metadata
- if(pmt::is_dict(dict)){
- if(pmt::dict_has_key(dict, d_tag_key)){
+ // add tag info if it is present in metadata
+ if (pmt::is_dict(dict)) {
+ if (pmt::dict_has_key(dict, d_tag_key)) {
d_tags.clear();
pmt::pmt_t tags = pmt::dict_ref(dict, d_tag_key, pmt::PMT_NIL);
int len = pmt::length(tags);
- for(int i=0; i<len; i++){
+ for (int i = 0; i < len; i++) {
// get tag info from list
pmt::pmt_t tup = pmt::vector_ref(tags, i);
- int tagval = pmt::to_long(pmt::tuple_ref(tup,0));
- pmt::pmt_t k = pmt::tuple_ref(tup,1);
- pmt::pmt_t v = pmt::tuple_ref(tup,2);
+ int tagval = pmt::to_long(pmt::tuple_ref(tup, 0));
+ pmt::pmt_t k = pmt::tuple_ref(tup, 1);
+ pmt::pmt_t v = pmt::tuple_ref(tup, 2);
// add the tag
- t[0].push_back( gr::tag_t() );
- t[0][t[0].size()-1].offset = tagval;
- t[0][t[0].size()-1].key = k;
- t[0][t[0].size()-1].value = v;
- t[0][t[0].size()-1].srcid = pmt::PMT_NIL;
- }
+ t[0].push_back(gr::tag_t());
+ t[0][t[0].size() - 1].offset = tagval;
+ t[0][t[0].size() - 1].key = k;
+ t[0][t[0].size() - 1].value = v;
+ t[0][t[0].size() - 1].srcid = pmt::PMT_NIL;
}
}
+ }
- len = pmt::length(samples);
+ len = pmt::length(samples);
- const gr_complex *in;
- if(pmt::is_c32vector(samples)) {
+ const gr_complex* in;
+ if (pmt::is_c32vector(samples)) {
in = (const gr_complex*)pmt::c32vector_elements(samples, len);
- }
- else {
+ } else {
throw std::runtime_error("time_sink_c: unknown data type "
"of samples; must be complex.");
- }
+ }
- // Plot if we're past the last update time
- if(gr::high_res_timer_now() - d_last_time > d_update_time) {
+ // Plot if we're past the last update time
+ if (gr::high_res_timer_now() - d_last_time > d_update_time) {
d_last_time = gr::high_res_timer_now();
set_nsamps(len);
- volk_32fc_deinterleave_64f_x2(d_buffers[2*d_nconnections+0],
- d_buffers[2*d_nconnections+1],
- in, len);
+ volk_32fc_deinterleave_64f_x2(d_buffers[2 * d_nconnections + 0],
+ d_buffers[2 * d_nconnections + 1],
+ in,
+ len);
- d_qApplication->postEvent(d_main_gui,
- new TimeUpdateEvent(d_buffers, len, t));
- }
+ d_qApplication->postEvent(d_main_gui, new TimeUpdateEvent(d_buffers, len, t));
}
+}
- } /* namespace qtgui */
+} /* namespace qtgui */
} /* namespace gr */
diff --git a/gr-qtgui/lib/time_sink_c_impl.h b/gr-qtgui/lib/time_sink_c_impl.h
index 5c75ca5308..d927e4a973 100644
--- a/gr-qtgui/lib/time_sink_c_impl.h
+++ b/gr-qtgui/lib/time_sink_c_impl.h
@@ -29,122 +29,125 @@
#include <gnuradio/high_res_timer.h>
namespace gr {
- namespace qtgui {
-
- class QTGUI_API time_sink_c_impl : public time_sink_c
- {
- private:
- void initialize();
-
- int d_size, d_buffer_size;
- double d_samp_rate;
- std::string d_name;
- unsigned int d_nconnections;
-
- const pmt::pmt_t d_tag_key;
-
- int d_index, d_start, d_end;
- std::vector<gr_complex*> d_cbuffers;
- std::vector<double*> d_buffers;
- std::vector< std::vector<gr::tag_t> > d_tags;
-
- int d_argc;
- char *d_argv;
- QWidget *d_parent;
- TimeDisplayForm *d_main_gui;
-
- gr::high_res_timer_type d_update_time;
- gr::high_res_timer_type d_last_time;
-
- // Members used for triggering scope
- trigger_mode d_trigger_mode;
- trigger_slope d_trigger_slope;
- float d_trigger_level;
- int d_trigger_channel;
- int d_trigger_delay;
- pmt::pmt_t d_trigger_tag_key;
- bool d_triggered;
- int d_trigger_count;
- int d_initial_delay; // used for limiting d_trigger_delay
-
- void _reset();
- void _npoints_resize();
- void _adjust_tags(int adj);
- void _gui_update_trigger();
- void _test_trigger_tags(int nitems);
- void _test_trigger_norm(int nitems, gr_vector_const_void_star inputs);
- bool _test_trigger_slope(const gr_complex *in) const;
-
- // Handles message input port for displaying PDU samples.
- void handle_pdus(pmt::pmt_t msg);
-
- public:
- time_sink_c_impl(int size, double samp_rate,
- const std::string &name,
- unsigned int nconnections,
- QWidget *parent=NULL);
- ~time_sink_c_impl();
-
- bool check_topology(int ninputs, int noutputs);
-
- void exec_();
- QWidget* qwidget();
+namespace qtgui {
+
+class QTGUI_API time_sink_c_impl : public time_sink_c
+{
+private:
+ void initialize();
+
+ int d_size, d_buffer_size;
+ double d_samp_rate;
+ std::string d_name;
+ unsigned int d_nconnections;
+
+ const pmt::pmt_t d_tag_key;
+
+ int d_index, d_start, d_end;
+ std::vector<gr_complex*> d_cbuffers;
+ std::vector<double*> d_buffers;
+ std::vector<std::vector<gr::tag_t>> d_tags;
+
+ int d_argc;
+ char* d_argv;
+ QWidget* d_parent;
+ TimeDisplayForm* d_main_gui;
+
+ gr::high_res_timer_type d_update_time;
+ gr::high_res_timer_type d_last_time;
+
+ // Members used for triggering scope
+ trigger_mode d_trigger_mode;
+ trigger_slope d_trigger_slope;
+ float d_trigger_level;
+ int d_trigger_channel;
+ int d_trigger_delay;
+ pmt::pmt_t d_trigger_tag_key;
+ bool d_triggered;
+ int d_trigger_count;
+ int d_initial_delay; // used for limiting d_trigger_delay
+
+ void _reset();
+ void _npoints_resize();
+ void _adjust_tags(int adj);
+ void _gui_update_trigger();
+ void _test_trigger_tags(int nitems);
+ void _test_trigger_norm(int nitems, gr_vector_const_void_star inputs);
+ bool _test_trigger_slope(const gr_complex* in) const;
+
+ // Handles message input port for displaying PDU samples.
+ void handle_pdus(pmt::pmt_t msg);
+
+public:
+ time_sink_c_impl(int size,
+ double samp_rate,
+ const std::string& name,
+ unsigned int nconnections,
+ QWidget* parent = NULL);
+ ~time_sink_c_impl();
+
+ bool check_topology(int ninputs, int noutputs);
+
+ void exec_();
+ QWidget* qwidget();
#ifdef ENABLE_PYTHON
- PyObject* pyqwidget();
+ PyObject* pyqwidget();
#else
- void* pyqwidget();
+ void* pyqwidget();
#endif
- void set_y_axis(double min, double max);
- void set_y_label(const std::string &label,
- const std::string &unit="");
- void set_update_time(double t);
- void set_title(const std::string &title);
- void set_line_label(unsigned int which, const std::string &label);
- void set_line_color(unsigned int which, const std::string &color);
- void set_line_width(unsigned int which, int width);
- void set_line_style(unsigned int which, int style);
- void set_line_marker(unsigned int which, int marker);
- void set_nsamps(const int size);
- void set_samp_rate(const double samp_rate);
- void set_line_alpha(unsigned int which, double alpha);
- void set_trigger_mode(trigger_mode mode, trigger_slope slope,
- float level, float delay, int channel,
- const std::string &tag_key="");
-
- std::string title();
- std::string line_label(unsigned int which);
- std::string line_color(unsigned int which);
- int line_width(unsigned int which);
- int line_style(unsigned int which);
- int line_marker(unsigned int which);
- double line_alpha(unsigned int which);
-
- void set_size(int width, int height);
-
- int nsamps() const;
-
- void enable_menu(bool en);
- void enable_grid(bool en);
- void enable_autoscale(bool en);
- void enable_stem_plot(bool en);
- void enable_semilogx(bool en);
- void enable_semilogy(bool en);
- void enable_control_panel(bool en);
- void enable_tags(unsigned int which, bool en);
- void enable_tags(bool en);
- void enable_axis_labels(bool en);
- void disable_legend();
-
- void reset();
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace qtgui */
+ void set_y_axis(double min, double max);
+ void set_y_label(const std::string& label, const std::string& unit = "");
+ void set_update_time(double t);
+ void set_title(const std::string& title);
+ void set_line_label(unsigned int which, const std::string& label);
+ void set_line_color(unsigned int which, const std::string& color);
+ void set_line_width(unsigned int which, int width);
+ void set_line_style(unsigned int which, int style);
+ void set_line_marker(unsigned int which, int marker);
+ void set_nsamps(const int size);
+ void set_samp_rate(const double samp_rate);
+ void set_line_alpha(unsigned int which, double alpha);
+ void set_trigger_mode(trigger_mode mode,
+ trigger_slope slope,
+ float level,
+ float delay,
+ int channel,
+ const std::string& tag_key = "");
+
+ std::string title();
+ std::string line_label(unsigned int which);
+ std::string line_color(unsigned int which);
+ int line_width(unsigned int which);
+ int line_style(unsigned int which);
+ int line_marker(unsigned int which);
+ double line_alpha(unsigned int which);
+
+ void set_size(int width, int height);
+
+ int nsamps() const;
+
+ void enable_menu(bool en);
+ void enable_grid(bool en);
+ void enable_autoscale(bool en);
+ void enable_stem_plot(bool en);
+ void enable_semilogx(bool en);
+ void enable_semilogy(bool en);
+ void enable_control_panel(bool en);
+ void enable_tags(unsigned int which, bool en);
+ void enable_tags(bool en);
+ void enable_axis_labels(bool en);
+ void disable_legend();
+
+ void reset();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
+
+} /* namespace qtgui */
} /* namespace gr */
#endif /* INCLUDED_QTGUI_TIME_SINK_C_IMPL_H */
diff --git a/gr-qtgui/lib/time_sink_f_impl.cc b/gr-qtgui/lib/time_sink_f_impl.cc
index 4fbd0705f7..07bacc5581 100644
--- a/gr-qtgui/lib/time_sink_f_impl.cc
+++ b/gr-qtgui/lib/time_sink_f_impl.cc
@@ -38,534 +38,458 @@
#include <string.h>
namespace gr {
- namespace qtgui {
-
- time_sink_f::sptr
- time_sink_f::make(int size, double samp_rate,
- const std::string &name,
- unsigned int nconnections,
- QWidget *parent)
- {
- return gnuradio::get_initial_sptr
- (new time_sink_f_impl(size, samp_rate, name, nconnections, parent));
- }
-
- time_sink_f_impl::time_sink_f_impl(int size, double samp_rate,
- const std::string &name,
- unsigned int nconnections,
- QWidget *parent)
- : sync_block("time_sink_f",
- io_signature::make(0, nconnections, sizeof(float)),
- io_signature::make(0, 0, 0)),
- d_size(size), d_buffer_size(2*size), d_samp_rate(samp_rate), d_name(name),
- d_nconnections(nconnections), d_parent(parent)
- {
- if(nconnections > 24)
+namespace qtgui {
+
+time_sink_f::sptr time_sink_f::make(int size,
+ double samp_rate,
+ const std::string& name,
+ unsigned int nconnections,
+ QWidget* parent)
+{
+ return gnuradio::get_initial_sptr(
+ new time_sink_f_impl(size, samp_rate, name, nconnections, parent));
+}
+
+time_sink_f_impl::time_sink_f_impl(int size,
+ double samp_rate,
+ const std::string& name,
+ unsigned int nconnections,
+ QWidget* parent)
+ : sync_block("time_sink_f",
+ io_signature::make(0, nconnections, sizeof(float)),
+ io_signature::make(0, 0, 0)),
+ d_size(size),
+ d_buffer_size(2 * size),
+ d_samp_rate(samp_rate),
+ d_name(name),
+ d_nconnections(nconnections),
+ d_parent(parent)
+{
+ if (nconnections > 24)
throw std::runtime_error("time_sink_f only supports up to 24 inputs");
- // Required now for Qt; argc must be greater than 0 and argv
- // must have at least one valid character. Must be valid through
- // life of the qApplication:
- // http://harmattan-dev.nokia.com/docs/library/html/qt4/qapplication.html
- d_argc = 1;
- d_argv = new char;
- d_argv[0] = '\0';
+ // Required now for Qt; argc must be greater than 0 and argv
+ // must have at least one valid character. Must be valid through
+ // life of the qApplication:
+ // http://harmattan-dev.nokia.com/docs/library/html/qt4/qapplication.html
+ d_argc = 1;
+ d_argv = new char;
+ d_argv[0] = '\0';
- d_main_gui = NULL;
+ d_main_gui = NULL;
- // setup PDU handling input port
- message_port_register_in(pmt::mp("in"));
- set_msg_handler(pmt::mp("in"),
- boost::bind(&time_sink_f_impl::handle_pdus, this, _1));
+ // setup PDU handling input port
+ message_port_register_in(pmt::mp("in"));
+ set_msg_handler(pmt::mp("in"), boost::bind(&time_sink_f_impl::handle_pdus, this, _1));
- // +1 for the PDU buffer
- for(unsigned int n = 0; n < d_nconnections+1; n++) {
- d_buffers.push_back((double*)volk_malloc(d_buffer_size*sizeof(double),
- volk_get_alignment()));
- memset(d_buffers[n], 0, d_buffer_size*sizeof(double));
+ // +1 for the PDU buffer
+ for (unsigned int n = 0; n < d_nconnections + 1; n++) {
+ d_buffers.push_back(
+ (double*)volk_malloc(d_buffer_size * sizeof(double), volk_get_alignment()));
+ memset(d_buffers[n], 0, d_buffer_size * sizeof(double));
- d_fbuffers.push_back((float*)volk_malloc(d_buffer_size*sizeof(float),
- volk_get_alignment()));
- memset(d_fbuffers[n], 0, d_buffer_size*sizeof(float));
- }
+ d_fbuffers.push_back(
+ (float*)volk_malloc(d_buffer_size * sizeof(float), volk_get_alignment()));
+ memset(d_fbuffers[n], 0, d_buffer_size * sizeof(float));
+ }
- // Set alignment properties for VOLK
- const int alignment_multiple =
- volk_get_alignment() / sizeof(float);
- set_alignment(std::max(1,alignment_multiple));
+ // Set alignment properties for VOLK
+ const int alignment_multiple = volk_get_alignment() / sizeof(float);
+ set_alignment(std::max(1, alignment_multiple));
- d_tags = std::vector< std::vector<gr::tag_t> >(d_nconnections);
+ d_tags = std::vector<std::vector<gr::tag_t>>(d_nconnections);
- initialize();
+ initialize();
- d_main_gui->setNPoints(d_size); // setup GUI box with size
- set_trigger_mode(TRIG_MODE_FREE, TRIG_SLOPE_POS, 0, 0, 0);
+ d_main_gui->setNPoints(d_size); // setup GUI box with size
+ set_trigger_mode(TRIG_MODE_FREE, TRIG_SLOPE_POS, 0, 0, 0);
- set_history(2); // so we can look ahead for the trigger slope
- declare_sample_delay(1); // delay the tags for a history of 2
- }
+ set_history(2); // so we can look ahead for the trigger slope
+ declare_sample_delay(1); // delay the tags for a history of 2
+}
- time_sink_f_impl::~time_sink_f_impl()
- {
- if(!d_main_gui->isClosed())
+time_sink_f_impl::~time_sink_f_impl()
+{
+ if (!d_main_gui->isClosed())
d_main_gui->close();
- // d_main_gui is a qwidget destroyed with its parent
- for(unsigned int n = 0; n < d_nconnections+1; n++) {
- volk_free(d_buffers[n]);
- volk_free(d_fbuffers[n]);
- }
-
- delete d_argv;
+ // d_main_gui is a qwidget destroyed with its parent
+ for (unsigned int n = 0; n < d_nconnections + 1; n++) {
+ volk_free(d_buffers[n]);
+ volk_free(d_fbuffers[n]);
}
- bool
- time_sink_f_impl::check_topology(int ninputs, int noutputs)
- {
- return (unsigned int)(ninputs) == d_nconnections;
- }
+ delete d_argv;
+}
- void
- time_sink_f_impl::initialize()
- {
- if(qApp != NULL) {
- d_qApplication = qApp;
- }
- else {
+bool time_sink_f_impl::check_topology(int ninputs, int noutputs)
+{
+ return (unsigned int)(ninputs) == d_nconnections;
+}
+
+void time_sink_f_impl::initialize()
+{
+ if (qApp != NULL) {
+ d_qApplication = qApp;
+ } else {
#if QT_VERSION >= 0x040500 && QT_VERSION < 0x050000
std::string style = prefs::singleton()->get_string("qtgui", "style", "raster");
QApplication::setGraphicsSystem(QString(style.c_str()));
#endif
- d_qApplication = new QApplication(d_argc, &d_argv);
- }
+ d_qApplication = new QApplication(d_argc, &d_argv);
+ }
- // If a style sheet is set in the prefs file, enable it here.
- check_set_qss(d_qApplication);
+ // If a style sheet is set in the prefs file, enable it here.
+ check_set_qss(d_qApplication);
- unsigned int numplots = (d_nconnections > 0) ? d_nconnections : 1;
- d_main_gui = new TimeDisplayForm(numplots, d_parent);
- d_main_gui->setNPoints(d_size);
- d_main_gui->setSampleRate(d_samp_rate);
+ unsigned int numplots = (d_nconnections > 0) ? d_nconnections : 1;
+ d_main_gui = new TimeDisplayForm(numplots, d_parent);
+ d_main_gui->setNPoints(d_size);
+ d_main_gui->setSampleRate(d_samp_rate);
- if(d_name.size() > 0)
+ if (d_name.size() > 0)
set_title(d_name);
- // initialize update time to 10 times a second
- set_update_time(0.1);
- }
+ // initialize update time to 10 times a second
+ set_update_time(0.1);
+}
- void
- time_sink_f_impl::exec_()
- {
- d_qApplication->exec();
- }
+void time_sink_f_impl::exec_() { d_qApplication->exec(); }
- QWidget*
- time_sink_f_impl::qwidget()
- {
- return d_main_gui;
- }
+QWidget* time_sink_f_impl::qwidget() { return d_main_gui; }
#ifdef ENABLE_PYTHON
- PyObject*
- time_sink_f_impl::pyqwidget()
- {
- PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui);
- PyObject *retarg = Py_BuildValue("N", w);
- return retarg;
- }
+PyObject* time_sink_f_impl::pyqwidget()
+{
+ PyObject* w = PyLong_FromVoidPtr((void*)d_main_gui);
+ PyObject* retarg = Py_BuildValue("N", w);
+ return retarg;
+}
#else
- void *
- time_sink_f_impl::pyqwidget()
- {
- return NULL;
- }
+void* time_sink_f_impl::pyqwidget() { return NULL; }
#endif
- void
- time_sink_f_impl::set_y_axis(double min, double max)
- {
- d_main_gui->setYaxis(min, max);
- }
-
- void
- time_sink_f_impl::set_y_label(const std::string &label,
- const std::string &unit)
- {
- d_main_gui->setYLabel(label, unit);
- }
-
- void
- time_sink_f_impl::set_update_time(double t)
- {
- //convert update time to ticks
- gr::high_res_timer_type tps = gr::high_res_timer_tps();
- d_update_time = t * tps;
- d_main_gui->setUpdateTime(t);
- d_last_time = 0;
- }
-
- void
- time_sink_f_impl::set_title(const std::string &title)
- {
- d_main_gui->setTitle(title.c_str());
- }
-
- void
- time_sink_f_impl::set_line_label(unsigned int which, const std::string &label)
- {
- d_main_gui->setLineLabel(which, label.c_str());
- }
-
- void
- time_sink_f_impl::set_line_color(unsigned int which, const std::string &color)
- {
- d_main_gui->setLineColor(which, color.c_str());
- }
-
- void
- time_sink_f_impl::set_line_width(unsigned int which, int width)
- {
- d_main_gui->setLineWidth(which, width);
- }
-
- void
- time_sink_f_impl::set_line_style(unsigned int which, int style)
- {
- d_main_gui->setLineStyle(which, (Qt::PenStyle)style);
- }
-
- void
- time_sink_f_impl::set_line_marker(unsigned int which, int marker)
- {
- d_main_gui->setLineMarker(which, (QwtSymbol::Style)marker);
- }
-
- void
- time_sink_f_impl::set_line_alpha(unsigned int which, double alpha)
- {
- d_main_gui->setMarkerAlpha(which, (int)(255.0*alpha));
- }
-
- void
- time_sink_f_impl::set_trigger_mode(trigger_mode mode,
- trigger_slope slope,
- float level,
- float delay, int channel,
- const std::string &tag_key)
- {
- gr::thread::scoped_lock lock(d_setlock);
-
- d_trigger_mode = mode;
- d_trigger_slope = slope;
- d_trigger_level = level;
- d_trigger_delay = static_cast<int>(delay*d_samp_rate);
- d_trigger_channel = channel;
- d_trigger_tag_key = pmt::intern(tag_key);
- d_triggered = false;
- d_trigger_count = 0;
-
- if((d_trigger_delay < 0) || (d_trigger_delay >= d_size)) {
- GR_LOG_WARN(d_logger, boost::format("Trigger delay (%1%) outside of display range (0:%2%).") \
- % (d_trigger_delay/d_samp_rate) % ((d_size-1)/d_samp_rate));
- d_trigger_delay = std::max(0, std::min(d_size-1, d_trigger_delay));
- delay = d_trigger_delay/d_samp_rate;
- }
-
- d_main_gui->setTriggerMode(d_trigger_mode);
- d_main_gui->setTriggerSlope(d_trigger_slope);
- d_main_gui->setTriggerLevel(d_trigger_level);
- d_main_gui->setTriggerDelay(delay);
- d_main_gui->setTriggerChannel(d_trigger_channel);
- d_main_gui->setTriggerTagKey(tag_key);
-
- _reset();
- }
-
- void
- time_sink_f_impl::set_size(int width, int height)
- {
- d_main_gui->resize(QSize(width, height));
- }
-
- std::string
- time_sink_f_impl::title()
- {
- return d_main_gui->title().toStdString();
- }
-
- std::string
- time_sink_f_impl::line_label(unsigned int which)
- {
- return d_main_gui->lineLabel(which).toStdString();
- }
-
- std::string
- time_sink_f_impl::line_color(unsigned int which)
- {
- return d_main_gui->lineColor(which).toStdString();
- }
-
- int
- time_sink_f_impl::line_width(unsigned int which)
- {
- return d_main_gui->lineWidth(which);
- }
-
- int
- time_sink_f_impl::line_style(unsigned int which)
- {
- return d_main_gui->lineStyle(which);
- }
-
- int
- time_sink_f_impl::line_marker(unsigned int which)
- {
- return d_main_gui->lineMarker(which);
- }
-
- double
- time_sink_f_impl::line_alpha(unsigned int which)
- {
- return (double)(d_main_gui->markerAlpha(which))/255.0;
- }
-
- void
- time_sink_f_impl::set_nsamps(const int newsize)
- {
- if(newsize != d_size) {
+void time_sink_f_impl::set_y_axis(double min, double max)
+{
+ d_main_gui->setYaxis(min, max);
+}
+
+void time_sink_f_impl::set_y_label(const std::string& label, const std::string& unit)
+{
+ d_main_gui->setYLabel(label, unit);
+}
+
+void time_sink_f_impl::set_update_time(double t)
+{
+ // convert update time to ticks
+ gr::high_res_timer_type tps = gr::high_res_timer_tps();
+ d_update_time = t * tps;
+ d_main_gui->setUpdateTime(t);
+ d_last_time = 0;
+}
+
+void time_sink_f_impl::set_title(const std::string& title)
+{
+ d_main_gui->setTitle(title.c_str());
+}
+
+void time_sink_f_impl::set_line_label(unsigned int which, const std::string& label)
+{
+ d_main_gui->setLineLabel(which, label.c_str());
+}
+
+void time_sink_f_impl::set_line_color(unsigned int which, const std::string& color)
+{
+ d_main_gui->setLineColor(which, color.c_str());
+}
+
+void time_sink_f_impl::set_line_width(unsigned int which, int width)
+{
+ d_main_gui->setLineWidth(which, width);
+}
+
+void time_sink_f_impl::set_line_style(unsigned int which, int style)
+{
+ d_main_gui->setLineStyle(which, (Qt::PenStyle)style);
+}
+
+void time_sink_f_impl::set_line_marker(unsigned int which, int marker)
+{
+ d_main_gui->setLineMarker(which, (QwtSymbol::Style)marker);
+}
+
+void time_sink_f_impl::set_line_alpha(unsigned int which, double alpha)
+{
+ d_main_gui->setMarkerAlpha(which, (int)(255.0 * alpha));
+}
+
+void time_sink_f_impl::set_trigger_mode(trigger_mode mode,
+ trigger_slope slope,
+ float level,
+ float delay,
+ int channel,
+ const std::string& tag_key)
+{
+ gr::thread::scoped_lock lock(d_setlock);
+
+ d_trigger_mode = mode;
+ d_trigger_slope = slope;
+ d_trigger_level = level;
+ d_trigger_delay = static_cast<int>(delay * d_samp_rate);
+ d_trigger_channel = channel;
+ d_trigger_tag_key = pmt::intern(tag_key);
+ d_triggered = false;
+ d_trigger_count = 0;
+
+ if ((d_trigger_delay < 0) || (d_trigger_delay >= d_size)) {
+ GR_LOG_WARN(
+ d_logger,
+ boost::format("Trigger delay (%1%) outside of display range (0:%2%).") %
+ (d_trigger_delay / d_samp_rate) % ((d_size - 1) / d_samp_rate));
+ d_trigger_delay = std::max(0, std::min(d_size - 1, d_trigger_delay));
+ delay = d_trigger_delay / d_samp_rate;
+ }
+
+ d_main_gui->setTriggerMode(d_trigger_mode);
+ d_main_gui->setTriggerSlope(d_trigger_slope);
+ d_main_gui->setTriggerLevel(d_trigger_level);
+ d_main_gui->setTriggerDelay(delay);
+ d_main_gui->setTriggerChannel(d_trigger_channel);
+ d_main_gui->setTriggerTagKey(tag_key);
+
+ _reset();
+}
+
+void time_sink_f_impl::set_size(int width, int height)
+{
+ d_main_gui->resize(QSize(width, height));
+}
+
+std::string time_sink_f_impl::title() { return d_main_gui->title().toStdString(); }
+
+std::string time_sink_f_impl::line_label(unsigned int which)
+{
+ return d_main_gui->lineLabel(which).toStdString();
+}
+
+std::string time_sink_f_impl::line_color(unsigned int which)
+{
+ return d_main_gui->lineColor(which).toStdString();
+}
+
+int time_sink_f_impl::line_width(unsigned int which)
+{
+ return d_main_gui->lineWidth(which);
+}
+
+int time_sink_f_impl::line_style(unsigned int which)
+{
+ return d_main_gui->lineStyle(which);
+}
+
+int time_sink_f_impl::line_marker(unsigned int which)
+{
+ return d_main_gui->lineMarker(which);
+}
+
+double time_sink_f_impl::line_alpha(unsigned int which)
+{
+ return (double)(d_main_gui->markerAlpha(which)) / 255.0;
+}
+
+void time_sink_f_impl::set_nsamps(const int newsize)
+{
+ if (newsize != d_size) {
gr::thread::scoped_lock lock(d_setlock);
- // Set new size and reset buffer index
- // (throws away any currently held data, but who cares?)
- d_size = newsize;
- d_buffer_size = 2*d_size;
-
- // Resize buffers and replace data
- for(unsigned int n = 0; n < d_nconnections+1; n++) {
- volk_free(d_buffers[n]);
- d_buffers[n] = (double*)volk_malloc(d_buffer_size*sizeof(double),
- volk_get_alignment());
- memset(d_buffers[n], 0, d_buffer_size*sizeof(double));
-
- volk_free(d_fbuffers[n]);
- d_fbuffers[n] = (float*)volk_malloc(d_buffer_size*sizeof(float),
- volk_get_alignment());
- memset(d_fbuffers[n], 0, d_buffer_size*sizeof(float));
- }
+ // Set new size and reset buffer index
+ // (throws away any currently held data, but who cares?)
+ d_size = newsize;
+ d_buffer_size = 2 * d_size;
+
+ // Resize buffers and replace data
+ for (unsigned int n = 0; n < d_nconnections + 1; n++) {
+ volk_free(d_buffers[n]);
+ d_buffers[n] = (double*)volk_malloc(d_buffer_size * sizeof(double),
+ volk_get_alignment());
+ memset(d_buffers[n], 0, d_buffer_size * sizeof(double));
+
+ volk_free(d_fbuffers[n]);
+ d_fbuffers[n] =
+ (float*)volk_malloc(d_buffer_size * sizeof(float), volk_get_alignment());
+ memset(d_fbuffers[n], 0, d_buffer_size * sizeof(float));
+ }
// If delay was set beyond the new boundary, pull it back.
- if(d_trigger_delay >= d_size) {
- GR_LOG_WARN(d_logger, boost::format("Trigger delay (%1%) outside of display range (0:%2%). Moving to 50%% point.") \
- % (d_trigger_delay/d_samp_rate) % ((d_size-1)/d_samp_rate));
- d_trigger_delay = d_size-1;
- d_main_gui->setTriggerDelay(d_trigger_delay/d_samp_rate);
+ if (d_trigger_delay >= d_size) {
+ GR_LOG_WARN(d_logger,
+ boost::format("Trigger delay (%1%) outside of display range "
+ "(0:%2%). Moving to 50%% point.") %
+ (d_trigger_delay / d_samp_rate) %
+ ((d_size - 1) / d_samp_rate));
+ d_trigger_delay = d_size - 1;
+ d_main_gui->setTriggerDelay(d_trigger_delay / d_samp_rate);
}
- d_main_gui->setNPoints(d_size);
+ d_main_gui->setNPoints(d_size);
_reset();
- }
}
+}
- void
- time_sink_f_impl::set_samp_rate(const double samp_rate)
- {
- gr::thread::scoped_lock lock(d_setlock);
- d_samp_rate = samp_rate;
- d_main_gui->setSampleRate(d_samp_rate);
- }
+void time_sink_f_impl::set_samp_rate(const double samp_rate)
+{
+ gr::thread::scoped_lock lock(d_setlock);
+ d_samp_rate = samp_rate;
+ d_main_gui->setSampleRate(d_samp_rate);
+}
- int
- time_sink_f_impl::nsamps() const
- {
- return d_size;
- }
+int time_sink_f_impl::nsamps() const { return d_size; }
- void
- time_sink_f_impl::enable_stem_plot(bool en)
- {
- d_main_gui->setStem(en);
- }
+void time_sink_f_impl::enable_stem_plot(bool en) { d_main_gui->setStem(en); }
- void
- time_sink_f_impl::enable_menu(bool en)
- {
- d_main_gui->enableMenu(en);
- }
+void time_sink_f_impl::enable_menu(bool en) { d_main_gui->enableMenu(en); }
- void
- time_sink_f_impl::enable_grid(bool en)
- {
- d_main_gui->setGrid(en);
- }
+void time_sink_f_impl::enable_grid(bool en) { d_main_gui->setGrid(en); }
- void
- time_sink_f_impl::enable_autoscale(bool en)
- {
- d_main_gui->autoScale(en);
- }
+void time_sink_f_impl::enable_autoscale(bool en) { d_main_gui->autoScale(en); }
- void
- time_sink_f_impl::enable_semilogx(bool en)
- {
- d_main_gui->setSemilogx(en);
- }
+void time_sink_f_impl::enable_semilogx(bool en) { d_main_gui->setSemilogx(en); }
- void
- time_sink_f_impl::enable_semilogy(bool en)
- {
- d_main_gui->setSemilogy(en);
- }
+void time_sink_f_impl::enable_semilogy(bool en) { d_main_gui->setSemilogy(en); }
- void
- time_sink_f_impl::enable_control_panel(bool en)
- {
- if(en)
+void time_sink_f_impl::enable_control_panel(bool en)
+{
+ if (en)
d_main_gui->setupControlPanel();
- else
+ else
d_main_gui->teardownControlPanel();
- }
-
- void
- time_sink_f_impl::enable_tags(unsigned int which, bool en)
- {
- d_main_gui->setTagMenu(which, en);
- }
-
- void
- time_sink_f_impl::enable_tags(bool en)
- {
- for(unsigned int n = 0; n < d_nconnections; ++n) {
- d_main_gui->setTagMenu(n, en);
+}
+
+void time_sink_f_impl::enable_tags(unsigned int which, bool en)
+{
+ d_main_gui->setTagMenu(which, en);
+}
+
+void time_sink_f_impl::enable_tags(bool en)
+{
+ for (unsigned int n = 0; n < d_nconnections; ++n) {
+ d_main_gui->setTagMenu(n, en);
+ }
+}
+
+void time_sink_f_impl::enable_axis_labels(bool en) { d_main_gui->setAxisLabels(en); }
+
+void time_sink_f_impl::disable_legend() { d_main_gui->disableLegend(); }
+
+void time_sink_f_impl::reset()
+{
+ gr::thread::scoped_lock lock(d_setlock);
+ _reset();
+}
+
+void time_sink_f_impl::_reset()
+{
+ unsigned int n;
+ if (d_trigger_delay) {
+ for (n = 0; n < d_nconnections; n++) {
+ // Move the tail of the buffers to the front. This section
+ // represents data that might have to be plotted again if a
+ // trigger occurs and we have a trigger delay set. The tail
+ // section is between (d_end-d_trigger_delay) and d_end.
+ memmove(d_fbuffers[n],
+ &d_fbuffers[n][d_end - d_trigger_delay],
+ d_trigger_delay * sizeof(float));
+
+ // Also move the offsets of any tags that occur in the tail
+ // section so they would be plotted again, too.
+ std::vector<gr::tag_t> tmp_tags;
+ for (size_t t = 0; t < d_tags[n].size(); t++) {
+ if (d_tags[n][t].offset > (uint64_t)(d_size - d_trigger_delay)) {
+ d_tags[n][t].offset =
+ d_tags[n][t].offset - (d_size - d_trigger_delay);
+ tmp_tags.push_back(d_tags[n][t]);
+ }
}
- }
-
- void
- time_sink_f_impl::enable_axis_labels(bool en)
- {
- d_main_gui->setAxisLabels(en);
- }
-
- void
- time_sink_f_impl::disable_legend()
- {
- d_main_gui->disableLegend();
- }
-
- void
- time_sink_f_impl::reset()
- {
- gr::thread::scoped_lock lock(d_setlock);
- _reset();
- }
-
- void
- time_sink_f_impl::_reset()
- {
- unsigned int n;
- if(d_trigger_delay) {
- for(n = 0; n < d_nconnections; n++) {
- // Move the tail of the buffers to the front. This section
- // represents data that might have to be plotted again if a
- // trigger occurs and we have a trigger delay set. The tail
- // section is between (d_end-d_trigger_delay) and d_end.
- memmove(d_fbuffers[n], &d_fbuffers[n][d_end-d_trigger_delay],
- d_trigger_delay*sizeof(float));
-
- // Also move the offsets of any tags that occur in the tail
- // section so they would be plotted again, too.
- std::vector<gr::tag_t> tmp_tags;
- for(size_t t = 0; t < d_tags[n].size(); t++) {
- if(d_tags[n][t].offset > (uint64_t)(d_size - d_trigger_delay)) {
- d_tags[n][t].offset = d_tags[n][t].offset - (d_size - d_trigger_delay);
- tmp_tags.push_back(d_tags[n][t]);
- }
- }
- d_tags[n] = tmp_tags;
+ d_tags[n] = tmp_tags;
}
- }
- // Otherwise, just clear the local list of tags.
- else {
- for(n = 0; n < d_nconnections; n++) {
- d_tags[n].clear();
+ }
+ // Otherwise, just clear the local list of tags.
+ else {
+ for (n = 0; n < d_nconnections; n++) {
+ d_tags[n].clear();
}
- }
+ }
- // Reset the start and end indices.
- d_start = 0;
- d_end = d_size;
+ // Reset the start and end indices.
+ d_start = 0;
+ d_end = d_size;
- // Reset the trigger. If in free running mode, ignore the
- // trigger delay and always set trigger to true.
- if(d_trigger_mode == TRIG_MODE_FREE) {
+ // Reset the trigger. If in free running mode, ignore the
+ // trigger delay and always set trigger to true.
+ if (d_trigger_mode == TRIG_MODE_FREE) {
d_index = 0;
d_triggered = true;
- }
- else {
+ } else {
d_index = d_trigger_delay;
d_triggered = false;
- }
}
+}
- void
- time_sink_f_impl::_npoints_resize()
- {
- int newsize = d_main_gui->getNPoints();
- set_nsamps(newsize);
- }
+void time_sink_f_impl::_npoints_resize()
+{
+ int newsize = d_main_gui->getNPoints();
+ set_nsamps(newsize);
+}
- void
- time_sink_f_impl::_adjust_tags(int adj)
- {
- for(size_t n = 0; n < d_tags.size(); n++) {
- for(size_t t = 0; t < d_tags[n].size(); t++) {
- d_tags[n][t].offset += adj;
+void time_sink_f_impl::_adjust_tags(int adj)
+{
+ for (size_t n = 0; n < d_tags.size(); n++) {
+ for (size_t t = 0; t < d_tags[n].size(); t++) {
+ d_tags[n][t].offset += adj;
}
- }
}
+}
- void
- time_sink_f_impl::_gui_update_trigger()
- {
- d_trigger_mode = d_main_gui->getTriggerMode();
- d_trigger_slope = d_main_gui->getTriggerSlope();
- d_trigger_level = d_main_gui->getTriggerLevel();
- d_trigger_channel = d_main_gui->getTriggerChannel();
- d_trigger_count = 0;
+void time_sink_f_impl::_gui_update_trigger()
+{
+ d_trigger_mode = d_main_gui->getTriggerMode();
+ d_trigger_slope = d_main_gui->getTriggerSlope();
+ d_trigger_level = d_main_gui->getTriggerLevel();
+ d_trigger_channel = d_main_gui->getTriggerChannel();
+ d_trigger_count = 0;
- float delayf = d_main_gui->getTriggerDelay();
- int delay = static_cast<int>(delayf*d_samp_rate);
+ float delayf = d_main_gui->getTriggerDelay();
+ int delay = static_cast<int>(delayf * d_samp_rate);
- if(delay != d_trigger_delay) {
+ if (delay != d_trigger_delay) {
// We restrict the delay to be within the window of time being
// plotted.
- if((delay < 0) || (delay >= d_size)) {
- GR_LOG_WARN(d_logger, boost::format("Trigger delay (%1%) outside of display range (0:%2%).") \
- % (delay/d_samp_rate) % ((d_size-1)/d_samp_rate));
- delay = std::max(0, std::min(d_size-1, delay));
- delayf = delay/d_samp_rate;
+ if ((delay < 0) || (delay >= d_size)) {
+ GR_LOG_WARN(
+ d_logger,
+ boost::format("Trigger delay (%1%) outside of display range (0:%2%).") %
+ (delay / d_samp_rate) % ((d_size - 1) / d_samp_rate));
+ delay = std::max(0, std::min(d_size - 1, delay));
+ delayf = delay / d_samp_rate;
}
d_trigger_delay = delay;
d_main_gui->setTriggerDelay(delayf);
_reset();
- }
-
- std::string tagkey = d_main_gui->getTriggerTagKey();
- d_trigger_tag_key = pmt::intern(tagkey);
}
- void
- time_sink_f_impl::_test_trigger_tags(int nitems)
- {
- int trigger_index;
-
- uint64_t nr = nitems_read(d_trigger_channel);
- std::vector<gr::tag_t> tags;
- get_tags_in_range(tags, d_trigger_channel,
- nr, nr + nitems + 1,
- d_trigger_tag_key);
- if(tags.size() > 0) {
+ std::string tagkey = d_main_gui->getTriggerTagKey();
+ d_trigger_tag_key = pmt::intern(tagkey);
+}
+
+void time_sink_f_impl::_test_trigger_tags(int nitems)
+{
+ int trigger_index;
+
+ uint64_t nr = nitems_read(d_trigger_channel);
+ std::vector<gr::tag_t> tags;
+ get_tags_in_range(tags, d_trigger_channel, nr, nr + nitems + 1, d_trigger_tag_key);
+ if (tags.size() > 0) {
trigger_index = tags[0].offset - nr;
int start = d_index + trigger_index - d_trigger_delay - 1;
if (start >= 0) {
@@ -575,168 +499,160 @@ namespace gr {
d_trigger_count = 0;
_adjust_tags(-d_start);
}
- }
}
+}
- void
- time_sink_f_impl::_test_trigger_norm(int nitems, gr_vector_const_void_star inputs)
- {
- int trigger_index;
- const float *in = (const float*)inputs[d_trigger_channel];
- for(trigger_index = 0; trigger_index < nitems; trigger_index++) {
+void time_sink_f_impl::_test_trigger_norm(int nitems, gr_vector_const_void_star inputs)
+{
+ int trigger_index;
+ const float* in = (const float*)inputs[d_trigger_channel];
+ for (trigger_index = 0; trigger_index < nitems; trigger_index++) {
d_trigger_count++;
// Test if trigger has occurred based on the input stream,
// channel number, and slope direction
- if(_test_trigger_slope(&in[trigger_index])) {
- d_triggered = true;
- d_start = d_index + trigger_index - d_trigger_delay;
- d_end = d_start + d_size;
- d_trigger_count = 0;
- _adjust_tags(-d_start);
- break;
+ if (_test_trigger_slope(&in[trigger_index])) {
+ d_triggered = true;
+ d_start = d_index + trigger_index - d_trigger_delay;
+ d_end = d_start + d_size;
+ d_trigger_count = 0;
+ _adjust_tags(-d_start);
+ break;
}
- }
+ }
- // If using auto trigger mode, trigger periodically even
- // without a trigger event.
- if((d_trigger_mode == TRIG_MODE_AUTO) && (d_trigger_count > d_size)) {
+ // If using auto trigger mode, trigger periodically even
+ // without a trigger event.
+ if ((d_trigger_mode == TRIG_MODE_AUTO) && (d_trigger_count > d_size)) {
d_triggered = true;
d_trigger_count = 0;
- }
}
+}
- bool
- time_sink_f_impl::_test_trigger_slope(const float *in) const
- {
- float x0, x1;
- x0 = in[0];
- x1 = in[1];
+bool time_sink_f_impl::_test_trigger_slope(const float* in) const
+{
+ float x0, x1;
+ x0 = in[0];
+ x1 = in[1];
- if(d_trigger_slope == TRIG_SLOPE_POS)
+ if (d_trigger_slope == TRIG_SLOPE_POS)
return ((x0 <= d_trigger_level) && (x1 > d_trigger_level));
- else
+ else
return ((x0 >= d_trigger_level) && (x1 < d_trigger_level));
- }
+}
- int
- time_sink_f_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- unsigned int n=0, idx=0;
- const float *in;
+int time_sink_f_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ unsigned int n = 0, idx = 0;
+ const float* in;
- _npoints_resize();
- _gui_update_trigger();
+ _npoints_resize();
+ _gui_update_trigger();
- gr::thread::scoped_lock lock(d_setlock);
+ gr::thread::scoped_lock lock(d_setlock);
- int nfill = d_end - d_index; // how much room left in buffers
- int nitems = std::min(noutput_items, nfill); // num items we can put in buffers
+ int nfill = d_end - d_index; // how much room left in buffers
+ int nitems = std::min(noutput_items, nfill); // num items we can put in buffers
- // If auto, normal, or tag trigger, look for the trigger
- if((d_trigger_mode != TRIG_MODE_FREE) && !d_triggered) {
+ // If auto, normal, or tag trigger, look for the trigger
+ if ((d_trigger_mode != TRIG_MODE_FREE) && !d_triggered) {
// trigger off a tag key (first one found)
- if(d_trigger_mode == TRIG_MODE_TAG) {
- _test_trigger_tags(nitems);
+ if (d_trigger_mode == TRIG_MODE_TAG) {
+ _test_trigger_tags(nitems);
}
// Normal or Auto trigger
else {
- _test_trigger_norm(nitems, input_items);
+ _test_trigger_norm(nitems, input_items);
}
- }
+ }
- // Copy data into the buffers.
- for(n = 0; n < d_nconnections; n++) {
+ // Copy data into the buffers.
+ for (n = 0; n < d_nconnections; n++) {
in = (const float*)input_items[idx];
- memcpy(&d_fbuffers[n][d_index], &in[1], nitems*sizeof(float));
- //volk_32f_convert_64f(&d_buffers[n][d_index],
+ memcpy(&d_fbuffers[n][d_index], &in[1], nitems * sizeof(float));
+ // volk_32f_convert_64f(&d_buffers[n][d_index],
// &in[1], nitems);
uint64_t nr = nitems_read(idx);
std::vector<gr::tag_t> tags;
get_tags_in_range(tags, idx, nr, nr + nitems);
- for(size_t t = 0; t < tags.size(); t++) {
- tags[t].offset = tags[t].offset - nr + (d_index-d_start-1);
+ for (size_t t = 0; t < tags.size(); t++) {
+ tags[t].offset = tags[t].offset - nr + (d_index - d_start - 1);
}
d_tags[idx].insert(d_tags[idx].end(), tags.begin(), tags.end());
idx++;
- }
- d_index += nitems;
+ }
+ d_index += nitems;
- // If we've have a trigger and a full d_size of items in the buffers, plot.
- if((d_triggered) && (d_index == d_end)) {
+ // If we've have a trigger and a full d_size of items in the buffers, plot.
+ if ((d_triggered) && (d_index == d_end)) {
// Copy data to be plotted to start of buffers.
- for(n = 0; n < d_nconnections; n++) {
- //memmove(d_buffers[n], &d_buffers[n][d_start], d_size*sizeof(double));
- volk_32f_convert_64f(d_buffers[n], &d_fbuffers[n][d_start], d_size);
+ for (n = 0; n < d_nconnections; n++) {
+ // memmove(d_buffers[n], &d_buffers[n][d_start], d_size*sizeof(double));
+ volk_32f_convert_64f(d_buffers[n], &d_fbuffers[n][d_start], d_size);
}
// Plot if we are able to update
- if(gr::high_res_timer_now() - d_last_time > d_update_time) {
- d_last_time = gr::high_res_timer_now();
- d_qApplication->postEvent(d_main_gui,
- new TimeUpdateEvent(d_buffers, d_size, d_tags));
+ if (gr::high_res_timer_now() - d_last_time > d_update_time) {
+ d_last_time = gr::high_res_timer_now();
+ d_qApplication->postEvent(d_main_gui,
+ new TimeUpdateEvent(d_buffers, d_size, d_tags));
}
// We've plotting, so reset the state
_reset();
- }
+ }
- // If we've filled up the buffers but haven't triggered, reset.
- if(d_index == d_end) {
+ // If we've filled up the buffers but haven't triggered, reset.
+ if (d_index == d_end) {
_reset();
- }
-
- return nitems;
}
- void
- time_sink_f_impl::handle_pdus(pmt::pmt_t msg)
- {
- size_t len;
- pmt::pmt_t dict, samples;
+ return nitems;
+}
+
+void time_sink_f_impl::handle_pdus(pmt::pmt_t msg)
+{
+ size_t len;
+ pmt::pmt_t dict, samples;
- // Test to make sure this is either a PDU or a uniform vector of
- // samples. Get the samples PMT and the dictionary if it's a PDU.
- // If not, we throw an error and exit.
- if(pmt::is_pair(msg)) {
+ // Test to make sure this is either a PDU or a uniform vector of
+ // samples. Get the samples PMT and the dictionary if it's a PDU.
+ // If not, we throw an error and exit.
+ if (pmt::is_pair(msg)) {
dict = pmt::car(msg);
samples = pmt::cdr(msg);
- }
- else if(pmt::is_uniform_vector(msg)) {
+ } else if (pmt::is_uniform_vector(msg)) {
samples = msg;
- }
- else {
+ } else {
throw std::runtime_error("time_sink_c: message must be either "
"a PDU or a uniform vector of samples.");
- }
+ }
- len = pmt::length(samples);
+ len = pmt::length(samples);
- const float *in;
- if(pmt::is_f32vector(samples)) {
+ const float* in;
+ if (pmt::is_f32vector(samples)) {
in = (const float*)pmt::f32vector_elements(samples, len);
- }
- else {
+ } else {
throw std::runtime_error("time_sink_f: unknown data type "
- "of samples; must be float.");
- }
+ "of samples; must be float.");
+ }
- // Plot if we're past the last update time
- if(gr::high_res_timer_now() - d_last_time > d_update_time) {
+ // Plot if we're past the last update time
+ if (gr::high_res_timer_now() - d_last_time > d_update_time) {
d_last_time = gr::high_res_timer_now();
set_nsamps(len);
volk_32f_convert_64f(d_buffers[d_nconnections], in, len);
- std::vector< std::vector<gr::tag_t> > t;
- d_qApplication->postEvent(d_main_gui,
- new TimeUpdateEvent(d_buffers, len, t));
- }
+ std::vector<std::vector<gr::tag_t>> t;
+ d_qApplication->postEvent(d_main_gui, new TimeUpdateEvent(d_buffers, len, t));
}
+}
- } /* namespace qtgui */
+} /* namespace qtgui */
} /* namespace gr */
diff --git a/gr-qtgui/lib/time_sink_f_impl.h b/gr-qtgui/lib/time_sink_f_impl.h
index 2cac336ed0..1f608657a2 100644
--- a/gr-qtgui/lib/time_sink_f_impl.h
+++ b/gr-qtgui/lib/time_sink_f_impl.h
@@ -29,120 +29,123 @@
#include <gnuradio/high_res_timer.h>
namespace gr {
- namespace qtgui {
-
- class QTGUI_API time_sink_f_impl : public time_sink_f
- {
- private:
- void initialize();
-
- int d_size, d_buffer_size;
- double d_samp_rate;
- std::string d_name;
- unsigned int d_nconnections;
-
- int d_index, d_start, d_end;
- std::vector<float*> d_fbuffers;
- std::vector<double*> d_buffers;
- std::vector< std::vector<gr::tag_t> > d_tags;
-
- int d_argc;
- char *d_argv;
- QWidget *d_parent;
- TimeDisplayForm *d_main_gui;
-
- gr::high_res_timer_type d_update_time;
- gr::high_res_timer_type d_last_time;
-
- // Members used for triggering scope
- trigger_mode d_trigger_mode;
- trigger_slope d_trigger_slope;
- float d_trigger_level;
- int d_trigger_channel;
- int d_trigger_delay;
- pmt::pmt_t d_trigger_tag_key;
- bool d_triggered;
- int d_trigger_count;
- int d_initial_delay; // used for limiting d_trigger_delay
-
- void _reset();
- void _npoints_resize();
- void _adjust_tags(int adj);
- void _gui_update_trigger();
- void _test_trigger_tags(int nitems);
- void _test_trigger_norm(int nitems, gr_vector_const_void_star inputs);
- bool _test_trigger_slope(const float *in) const;
-
- // Handles message input port for displaying PDU samples.
- void handle_pdus(pmt::pmt_t msg);
-
- public:
- time_sink_f_impl(int size, double samp_rate,
- const std::string &name,
- unsigned int nconnections,
- QWidget *parent=NULL);
- ~time_sink_f_impl();
-
- bool check_topology(int ninputs, int noutputs);
-
- void exec_();
- QWidget* qwidget();
+namespace qtgui {
+
+class QTGUI_API time_sink_f_impl : public time_sink_f
+{
+private:
+ void initialize();
+
+ int d_size, d_buffer_size;
+ double d_samp_rate;
+ std::string d_name;
+ unsigned int d_nconnections;
+
+ int d_index, d_start, d_end;
+ std::vector<float*> d_fbuffers;
+ std::vector<double*> d_buffers;
+ std::vector<std::vector<gr::tag_t>> d_tags;
+
+ int d_argc;
+ char* d_argv;
+ QWidget* d_parent;
+ TimeDisplayForm* d_main_gui;
+
+ gr::high_res_timer_type d_update_time;
+ gr::high_res_timer_type d_last_time;
+
+ // Members used for triggering scope
+ trigger_mode d_trigger_mode;
+ trigger_slope d_trigger_slope;
+ float d_trigger_level;
+ int d_trigger_channel;
+ int d_trigger_delay;
+ pmt::pmt_t d_trigger_tag_key;
+ bool d_triggered;
+ int d_trigger_count;
+ int d_initial_delay; // used for limiting d_trigger_delay
+
+ void _reset();
+ void _npoints_resize();
+ void _adjust_tags(int adj);
+ void _gui_update_trigger();
+ void _test_trigger_tags(int nitems);
+ void _test_trigger_norm(int nitems, gr_vector_const_void_star inputs);
+ bool _test_trigger_slope(const float* in) const;
+
+ // Handles message input port for displaying PDU samples.
+ void handle_pdus(pmt::pmt_t msg);
+
+public:
+ time_sink_f_impl(int size,
+ double samp_rate,
+ const std::string& name,
+ unsigned int nconnections,
+ QWidget* parent = NULL);
+ ~time_sink_f_impl();
+
+ bool check_topology(int ninputs, int noutputs);
+
+ void exec_();
+ QWidget* qwidget();
#ifdef ENABLE_PYTHON
- PyObject* pyqwidget();
+ PyObject* pyqwidget();
#else
- void* pyqwidget();
+ void* pyqwidget();
#endif
- void set_y_axis(double min, double max);
- void set_y_label(const std::string &label,
- const std::string &unit="");
- void set_update_time(double t);
- void set_title(const std::string &title);
- void set_line_label(unsigned int which, const std::string &label);
- void set_line_color(unsigned int which, const std::string &color);
- void set_line_width(unsigned int which, int width);
- void set_line_style(unsigned int which, int style);
- void set_line_marker(unsigned int which, int marker);
- void set_nsamps(const int size);
- void set_samp_rate(const double samp_rate);
- void set_line_alpha(unsigned int which, double alpha);
- void set_trigger_mode(trigger_mode mode, trigger_slope slope,
- float level, float delay, int channel,
- const std::string &tag_key="");
-
- std::string title();
- std::string line_label(unsigned int which);
- std::string line_color(unsigned int which);
- int line_width(unsigned int which);
- int line_style(unsigned int which);
- int line_marker(unsigned int which);
- double line_alpha(unsigned int which);
-
- void set_size(int width, int height);
-
- int nsamps() const;
-
- void enable_menu(bool en);
- void enable_grid(bool en);
- void enable_autoscale(bool en);
- void enable_stem_plot(bool en);
- void enable_semilogx(bool en);
- void enable_semilogy(bool en);
- void enable_control_panel(bool en);
- void enable_tags(unsigned int which, bool en);
- void enable_tags(bool en);
- void enable_axis_labels(bool en);
- void disable_legend();
-
- void reset();
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace qtgui */
+ void set_y_axis(double min, double max);
+ void set_y_label(const std::string& label, const std::string& unit = "");
+ void set_update_time(double t);
+ void set_title(const std::string& title);
+ void set_line_label(unsigned int which, const std::string& label);
+ void set_line_color(unsigned int which, const std::string& color);
+ void set_line_width(unsigned int which, int width);
+ void set_line_style(unsigned int which, int style);
+ void set_line_marker(unsigned int which, int marker);
+ void set_nsamps(const int size);
+ void set_samp_rate(const double samp_rate);
+ void set_line_alpha(unsigned int which, double alpha);
+ void set_trigger_mode(trigger_mode mode,
+ trigger_slope slope,
+ float level,
+ float delay,
+ int channel,
+ const std::string& tag_key = "");
+
+ std::string title();
+ std::string line_label(unsigned int which);
+ std::string line_color(unsigned int which);
+ int line_width(unsigned int which);
+ int line_style(unsigned int which);
+ int line_marker(unsigned int which);
+ double line_alpha(unsigned int which);
+
+ void set_size(int width, int height);
+
+ int nsamps() const;
+
+ void enable_menu(bool en);
+ void enable_grid(bool en);
+ void enable_autoscale(bool en);
+ void enable_stem_plot(bool en);
+ void enable_semilogx(bool en);
+ void enable_semilogy(bool en);
+ void enable_control_panel(bool en);
+ void enable_tags(unsigned int which, bool en);
+ void enable_tags(bool en);
+ void enable_axis_labels(bool en);
+ void disable_legend();
+
+ void reset();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
+
+} /* namespace qtgui */
} /* namespace gr */
#endif /* INCLUDED_QTGUI_TIME_SINK_F_IMPL_H */
diff --git a/gr-qtgui/lib/timecontrolpanel.cc b/gr-qtgui/lib/timecontrolpanel.cc
index 95d2cb7a1c..3ea70bc3ee 100644
--- a/gr-qtgui/lib/timecontrolpanel.cc
+++ b/gr-qtgui/lib/timecontrolpanel.cc
@@ -22,194 +22,181 @@
#include <gnuradio/qtgui/timecontrolpanel.h>
-TimeControlPanel::TimeControlPanel(TimeDisplayForm *form)
- : QVBoxLayout(),
- d_parent(form)
+TimeControlPanel::TimeControlPanel(TimeDisplayForm* form) : QVBoxLayout(), d_parent(form)
{
- // Set up the box for axes items
- d_axes_box = new QGroupBox("Axes");
- d_axes_layout = new QVBoxLayout;
- d_autoscale_check = new QCheckBox("Autoscale");
- d_grid_check = new QCheckBox("Grid");
- d_axislabels_check = new QCheckBox("Axis Labels");
- d_axislabels_check->setChecked(true);
-
- d_yoff_layout = new QHBoxLayout;
- d_yoff_label = new QLabel("Y Offset:");
- d_yoff_plus = new QPushButton("+");
- d_yoff_minus = new QPushButton("-");
- d_yoff_plus->setMaximumWidth(30);
- d_yoff_minus->setMaximumWidth(30);
- d_yoff_layout->addWidget(d_yoff_label);
- d_yoff_layout->addWidget(d_yoff_plus);
- d_yoff_layout->addWidget(d_yoff_minus);
-
- d_yrange_layout = new QHBoxLayout;
- d_yrange_label = new QLabel("Y Range:");
- d_yrange_plus = new QPushButton("+");
- d_yrange_minus = new QPushButton("-");
- d_yrange_plus->setMaximumWidth(30);
- d_yrange_minus->setMaximumWidth(30);
- d_yrange_layout->addWidget(d_yrange_label);
- d_yrange_layout->addWidget(d_yrange_plus);
- d_yrange_layout->addWidget(d_yrange_minus);
-
- d_xmax_layout = new QHBoxLayout;
- d_xmax_label = new QLabel("X Max:");
- d_xmax_plus = new QPushButton("+");
- d_xmax_minus = new QPushButton("-");
- d_xmax_plus->setMaximumWidth(30);
- d_xmax_minus->setMaximumWidth(30);
- d_xmax_layout->addWidget(d_xmax_label);
- d_xmax_layout->addWidget(d_xmax_plus);
- d_xmax_layout->addWidget(d_xmax_minus);
-
-
- // Set up the box for trigger items
- d_trigger_box = new QGroupBox("Trigger");
- d_trigger_layout = new QVBoxLayout;
- d_trigger_mode_combo = new QComboBox();
- d_trigger_mode_combo->addItem("Free");
- d_trigger_mode_combo->addItem("Auto");
- d_trigger_mode_combo->addItem("Normal");
- d_trigger_mode_combo->addItem("Tag");
-
- d_trigger_slope_combo = new QComboBox();
- d_trigger_slope_combo->addItem("Positive");
- d_trigger_slope_combo->addItem("Negative");
-
- d_trigger_level_layout = new QHBoxLayout;
- d_trigger_level_label = new QLabel("Level:");
- d_trigger_level_plus = new QPushButton("+");
- d_trigger_level_minus = new QPushButton("-");
- d_trigger_level_plus->setMaximumWidth(30);
- d_trigger_level_minus->setMaximumWidth(30);
- d_trigger_level_layout->addWidget(d_trigger_level_label);
- d_trigger_level_layout->addWidget(d_trigger_level_plus);
- d_trigger_level_layout->addWidget(d_trigger_level_minus);
-
- d_trigger_delay_layout = new QHBoxLayout;
- d_trigger_delay_label = new QLabel("Delay:");
- d_trigger_delay_plus = new QPushButton("+");
- d_trigger_delay_minus = new QPushButton("-");
- d_trigger_delay_plus->setMaximumWidth(30);
- d_trigger_delay_minus->setMaximumWidth(30);
- d_trigger_delay_layout->addWidget(d_trigger_delay_label);
- d_trigger_delay_layout->addWidget(d_trigger_delay_plus);
- d_trigger_delay_layout->addWidget(d_trigger_delay_minus);
-
- // Set up the box for other items
- d_extras_box = new QGroupBox("Extras");
- d_extras_layout = new QVBoxLayout;
- d_autoscale_button = new QPushButton("Autoscale");
- d_stop_button = new QPushButton("Stop");
- d_stop_button->setCheckable(true);
-
- // Set up the boxes into the layout
- d_axes_layout->addWidget(d_autoscale_check);
- d_axes_layout->addWidget(d_grid_check);
- d_axes_layout->addWidget(d_axislabels_check);
- d_axes_layout->addLayout(d_yoff_layout);
- d_axes_layout->addLayout(d_yrange_layout);
- d_axes_layout->addLayout(d_xmax_layout);
- d_axes_box->setLayout(d_axes_layout);
-
- d_trigger_layout->addWidget(d_trigger_mode_combo);
- d_trigger_layout->addWidget(d_trigger_slope_combo);
- d_trigger_layout->addLayout(d_trigger_level_layout);
- d_trigger_layout->addLayout(d_trigger_delay_layout);
- d_trigger_box->setLayout(d_trigger_layout);
-
- d_extras_layout->addWidget(d_autoscale_button);
- d_extras_layout->addWidget(d_stop_button);
- d_extras_box->setLayout(d_extras_layout);
-
- addWidget(d_axes_box);
- addWidget(d_trigger_box);
- addWidget(d_extras_box);
- addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum,
- QSizePolicy::Expanding));
-
- // Connect up the control signals/slots
- connect(d_autoscale_check, SIGNAL(clicked(bool)),
- d_parent, SLOT(autoScale(bool)));
- connect(d_grid_check, SIGNAL(clicked(bool)),
- d_parent, SLOT(setGrid(bool)));
- connect(d_axislabels_check, SIGNAL(clicked(bool)),
- d_parent, SLOT(setAxisLabels(bool)));
- connect(d_yoff_plus, SIGNAL(pressed(void)),
- d_parent, SLOT(notifyYAxisPlus(void)));
- connect(d_yoff_minus, SIGNAL(pressed(void)),
- d_parent, SLOT(notifyYAxisMinus(void)));
-
- connect(d_yrange_plus, SIGNAL(pressed(void)),
- d_parent, SLOT(notifyYRangePlus(void)));
- connect(d_yrange_minus, SIGNAL(pressed(void)),
- d_parent, SLOT(notifyYRangeMinus(void)));
-
- connect(d_xmax_plus, SIGNAL(pressed(void)),
- d_parent, SLOT(notifyXAxisPlus(void)));
- connect(d_xmax_minus, SIGNAL(pressed(void)),
- d_parent, SLOT(notifyXAxisMinus(void)));
- connect(d_trigger_mode_combo, SIGNAL(currentIndexChanged(const QString&)),
- d_parent, SLOT(notifyTriggerMode(const QString&)));
- connect(d_trigger_slope_combo, SIGNAL(currentIndexChanged(const QString&)),
- d_parent, SLOT(notifyTriggerSlope(const QString&)));
- connect(d_trigger_level_plus, SIGNAL(pressed(void)),
- d_parent, SLOT(notifyTriggerLevelPlus()));
- connect(d_trigger_level_minus, SIGNAL(pressed(void)),
- d_parent, SLOT(notifyTriggerLevelMinus()));
- connect(d_trigger_delay_plus, SIGNAL(pressed(void)),
- d_parent, SLOT(notifyTriggerDelayPlus()));
- connect(d_trigger_delay_minus, SIGNAL(pressed(void)),
- d_parent, SLOT(notifyTriggerDelayMinus()));
-
- connect(d_autoscale_button, SIGNAL(pressed(void)),
- d_parent, SLOT(autoScaleShot(void)));
- connect(d_stop_button, SIGNAL(pressed(void)),
- d_parent, SLOT(setStop(void)));
- connect(this, SIGNAL(signalToggleStopButton(void)),
- d_stop_button, SLOT(toggle(void)));
+ // Set up the box for axes items
+ d_axes_box = new QGroupBox("Axes");
+ d_axes_layout = new QVBoxLayout;
+ d_autoscale_check = new QCheckBox("Autoscale");
+ d_grid_check = new QCheckBox("Grid");
+ d_axislabels_check = new QCheckBox("Axis Labels");
+ d_axislabels_check->setChecked(true);
+
+ d_yoff_layout = new QHBoxLayout;
+ d_yoff_label = new QLabel("Y Offset:");
+ d_yoff_plus = new QPushButton("+");
+ d_yoff_minus = new QPushButton("-");
+ d_yoff_plus->setMaximumWidth(30);
+ d_yoff_minus->setMaximumWidth(30);
+ d_yoff_layout->addWidget(d_yoff_label);
+ d_yoff_layout->addWidget(d_yoff_plus);
+ d_yoff_layout->addWidget(d_yoff_minus);
+
+ d_yrange_layout = new QHBoxLayout;
+ d_yrange_label = new QLabel("Y Range:");
+ d_yrange_plus = new QPushButton("+");
+ d_yrange_minus = new QPushButton("-");
+ d_yrange_plus->setMaximumWidth(30);
+ d_yrange_minus->setMaximumWidth(30);
+ d_yrange_layout->addWidget(d_yrange_label);
+ d_yrange_layout->addWidget(d_yrange_plus);
+ d_yrange_layout->addWidget(d_yrange_minus);
+
+ d_xmax_layout = new QHBoxLayout;
+ d_xmax_label = new QLabel("X Max:");
+ d_xmax_plus = new QPushButton("+");
+ d_xmax_minus = new QPushButton("-");
+ d_xmax_plus->setMaximumWidth(30);
+ d_xmax_minus->setMaximumWidth(30);
+ d_xmax_layout->addWidget(d_xmax_label);
+ d_xmax_layout->addWidget(d_xmax_plus);
+ d_xmax_layout->addWidget(d_xmax_minus);
+
+
+ // Set up the box for trigger items
+ d_trigger_box = new QGroupBox("Trigger");
+ d_trigger_layout = new QVBoxLayout;
+ d_trigger_mode_combo = new QComboBox();
+ d_trigger_mode_combo->addItem("Free");
+ d_trigger_mode_combo->addItem("Auto");
+ d_trigger_mode_combo->addItem("Normal");
+ d_trigger_mode_combo->addItem("Tag");
+
+ d_trigger_slope_combo = new QComboBox();
+ d_trigger_slope_combo->addItem("Positive");
+ d_trigger_slope_combo->addItem("Negative");
+
+ d_trigger_level_layout = new QHBoxLayout;
+ d_trigger_level_label = new QLabel("Level:");
+ d_trigger_level_plus = new QPushButton("+");
+ d_trigger_level_minus = new QPushButton("-");
+ d_trigger_level_plus->setMaximumWidth(30);
+ d_trigger_level_minus->setMaximumWidth(30);
+ d_trigger_level_layout->addWidget(d_trigger_level_label);
+ d_trigger_level_layout->addWidget(d_trigger_level_plus);
+ d_trigger_level_layout->addWidget(d_trigger_level_minus);
+
+ d_trigger_delay_layout = new QHBoxLayout;
+ d_trigger_delay_label = new QLabel("Delay:");
+ d_trigger_delay_plus = new QPushButton("+");
+ d_trigger_delay_minus = new QPushButton("-");
+ d_trigger_delay_plus->setMaximumWidth(30);
+ d_trigger_delay_minus->setMaximumWidth(30);
+ d_trigger_delay_layout->addWidget(d_trigger_delay_label);
+ d_trigger_delay_layout->addWidget(d_trigger_delay_plus);
+ d_trigger_delay_layout->addWidget(d_trigger_delay_minus);
+
+ // Set up the box for other items
+ d_extras_box = new QGroupBox("Extras");
+ d_extras_layout = new QVBoxLayout;
+ d_autoscale_button = new QPushButton("Autoscale");
+ d_stop_button = new QPushButton("Stop");
+ d_stop_button->setCheckable(true);
+
+ // Set up the boxes into the layout
+ d_axes_layout->addWidget(d_autoscale_check);
+ d_axes_layout->addWidget(d_grid_check);
+ d_axes_layout->addWidget(d_axislabels_check);
+ d_axes_layout->addLayout(d_yoff_layout);
+ d_axes_layout->addLayout(d_yrange_layout);
+ d_axes_layout->addLayout(d_xmax_layout);
+ d_axes_box->setLayout(d_axes_layout);
+
+ d_trigger_layout->addWidget(d_trigger_mode_combo);
+ d_trigger_layout->addWidget(d_trigger_slope_combo);
+ d_trigger_layout->addLayout(d_trigger_level_layout);
+ d_trigger_layout->addLayout(d_trigger_delay_layout);
+ d_trigger_box->setLayout(d_trigger_layout);
+
+ d_extras_layout->addWidget(d_autoscale_button);
+ d_extras_layout->addWidget(d_stop_button);
+ d_extras_box->setLayout(d_extras_layout);
+
+ addWidget(d_axes_box);
+ addWidget(d_trigger_box);
+ addWidget(d_extras_box);
+ addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding));
+
+ // Connect up the control signals/slots
+ connect(d_autoscale_check, SIGNAL(clicked(bool)), d_parent, SLOT(autoScale(bool)));
+ connect(d_grid_check, SIGNAL(clicked(bool)), d_parent, SLOT(setGrid(bool)));
+ connect(
+ d_axislabels_check, SIGNAL(clicked(bool)), d_parent, SLOT(setAxisLabels(bool)));
+ connect(d_yoff_plus, SIGNAL(pressed(void)), d_parent, SLOT(notifyYAxisPlus(void)));
+ connect(d_yoff_minus, SIGNAL(pressed(void)), d_parent, SLOT(notifyYAxisMinus(void)));
+
+ connect(d_yrange_plus, SIGNAL(pressed(void)), d_parent, SLOT(notifyYRangePlus(void)));
+ connect(
+ d_yrange_minus, SIGNAL(pressed(void)), d_parent, SLOT(notifyYRangeMinus(void)));
+
+ connect(d_xmax_plus, SIGNAL(pressed(void)), d_parent, SLOT(notifyXAxisPlus(void)));
+ connect(d_xmax_minus, SIGNAL(pressed(void)), d_parent, SLOT(notifyXAxisMinus(void)));
+ connect(d_trigger_mode_combo,
+ SIGNAL(currentIndexChanged(const QString&)),
+ d_parent,
+ SLOT(notifyTriggerMode(const QString&)));
+ connect(d_trigger_slope_combo,
+ SIGNAL(currentIndexChanged(const QString&)),
+ d_parent,
+ SLOT(notifyTriggerSlope(const QString&)));
+ connect(d_trigger_level_plus,
+ SIGNAL(pressed(void)),
+ d_parent,
+ SLOT(notifyTriggerLevelPlus()));
+ connect(d_trigger_level_minus,
+ SIGNAL(pressed(void)),
+ d_parent,
+ SLOT(notifyTriggerLevelMinus()));
+ connect(d_trigger_delay_plus,
+ SIGNAL(pressed(void)),
+ d_parent,
+ SLOT(notifyTriggerDelayPlus()));
+ connect(d_trigger_delay_minus,
+ SIGNAL(pressed(void)),
+ d_parent,
+ SLOT(notifyTriggerDelayMinus()));
+
+ connect(
+ d_autoscale_button, SIGNAL(pressed(void)), d_parent, SLOT(autoScaleShot(void)));
+ connect(d_stop_button, SIGNAL(pressed(void)), d_parent, SLOT(setStop(void)));
+ connect(
+ this, SIGNAL(signalToggleStopButton(void)), d_stop_button, SLOT(toggle(void)));
}
TimeControlPanel::~TimeControlPanel()
{
- removeWidget(d_axes_box);
- removeWidget(d_trigger_box);
- removeWidget(d_extras_box);
- delete d_axes_box;
- delete d_trigger_box;
- delete d_extras_box;
-
- // All other children of the boxes are automatically deleted.
+ removeWidget(d_axes_box);
+ removeWidget(d_trigger_box);
+ removeWidget(d_extras_box);
+ delete d_axes_box;
+ delete d_trigger_box;
+ delete d_extras_box;
+
+ // All other children of the boxes are automatically deleted.
}
-void
-TimeControlPanel::toggleAutoScale(bool en)
-{
- d_autoscale_check->setChecked(en);
-}
+void TimeControlPanel::toggleAutoScale(bool en) { d_autoscale_check->setChecked(en); }
-void
-TimeControlPanel::toggleGrid(bool en)
-{
- d_grid_check->setChecked(en);
-}
+void TimeControlPanel::toggleGrid(bool en) { d_grid_check->setChecked(en); }
-void
-TimeControlPanel::toggleTriggerMode(gr::qtgui::trigger_mode mode)
+void TimeControlPanel::toggleTriggerMode(gr::qtgui::trigger_mode mode)
{
- d_trigger_mode_combo->setCurrentIndex(static_cast<int>(mode));
+ d_trigger_mode_combo->setCurrentIndex(static_cast<int>(mode));
}
-void
-TimeControlPanel::toggleTriggerSlope(gr::qtgui::trigger_slope slope)
+void TimeControlPanel::toggleTriggerSlope(gr::qtgui::trigger_slope slope)
{
- d_trigger_slope_combo->setCurrentIndex(static_cast<int>(slope));
+ d_trigger_slope_combo->setCurrentIndex(static_cast<int>(slope));
}
-void
-TimeControlPanel::toggleStopButton()
-{
- emit signalToggleStopButton();
-}
+void TimeControlPanel::toggleStopButton() { emit signalToggleStopButton(); }
diff --git a/gr-qtgui/lib/timedisplayform.cc b/gr-qtgui/lib/timedisplayform.cc
index 50b73980fe..6380153395 100644
--- a/gr-qtgui/lib/timedisplayform.cc
+++ b/gr-qtgui/lib/timedisplayform.cc
@@ -32,332 +32,315 @@
TimeDisplayForm::TimeDisplayForm(int nplots, QWidget* parent)
- : DisplayForm(nplots, parent)
-{
- d_stem = false;
- d_semilogx = false;
- d_semilogy = false;
- d_current_units = 1;
-
- d_trig_mode = gr::qtgui::TRIG_MODE_FREE;
- d_trig_slope = gr::qtgui::TRIG_SLOPE_POS;
- d_trig_level = 0;
- d_trig_delay = 0;
- d_trig_channel = 0;
- d_trig_tag_key = "";
-
- d_int_validator = new QIntValidator(this);
- d_int_validator->setBottom(0);
-
- d_layout = new QGridLayout(this);
- d_display_plot = new TimeDomainDisplayPlot(nplots, this);
-
- d_controlpanel = NULL;
-
- // Setup the layout of the display
- d_layout->addWidget(d_display_plot, 0, 0);
-
- d_layout->setColumnStretch(0, 1);
- setLayout(d_layout);
-
- d_nptsmenu = new NPointsMenu(this);
- d_menu->addAction(d_nptsmenu);
- connect(d_nptsmenu, SIGNAL(whichTrigger(int)),
- this, SLOT(setNPoints(const int)));
- connect(this, SIGNAL(signalNPoints(const int)),
- d_nptsmenu, SLOT(setDiagText(const int)));
-
- d_stemmenu = new QAction("Stem Plot", this);
- d_stemmenu->setCheckable(true);
- d_menu->addAction(d_stemmenu);
- connect(d_stemmenu, SIGNAL(triggered(bool)),
- this, SLOT(setStem(bool)));
-
- d_semilogxmenu = new QAction("Semilog X", this);
- d_semilogxmenu->setCheckable(true);
- d_menu->addAction(d_semilogxmenu);
- connect(d_semilogxmenu, SIGNAL(triggered(bool)),
- this, SLOT(setSemilogx(bool)));
-
- d_semilogymenu = new QAction("Semilog Y", this);
- d_semilogymenu->setCheckable(true);
- d_menu->addAction(d_semilogymenu);
- connect(d_semilogymenu, SIGNAL(triggered(bool)),
- this, SLOT(setSemilogy(bool)));
-
- for(unsigned int i = 0; i < d_nplots; ++i) {
- d_tagsmenu.push_back(new QAction("Show Tag Makers", this));
- d_tagsmenu[i]->setCheckable(true);
- d_tagsmenu[i]->setChecked(true);
- connect(d_tagsmenu[i], SIGNAL(triggered(bool)),
- this, SLOT(tagMenuSlot(bool)));
- d_lines_menu[i]->addAction(d_tagsmenu[i]);
- }
-
- // Set up the trigger menu
- d_triggermenu = new QMenu("Trigger", this);
- d_tr_mode_menu = new TriggerModeMenu(this);
- d_tr_slope_menu = new TriggerSlopeMenu(this);
- d_tr_level_act = new PopupMenu("Level", this);
- d_tr_delay_act = new PopupMenu("Delay", this);
- d_tr_channel_menu = new TriggerChannelMenu(nplots, this);
- d_tr_tag_key_act = new PopupMenu("Tag Key", this);
- d_triggermenu->addMenu(d_tr_mode_menu);
- d_triggermenu->addMenu(d_tr_slope_menu);
- d_triggermenu->addAction(d_tr_level_act);
- d_triggermenu->addAction(d_tr_delay_act);
- d_triggermenu->addMenu(d_tr_channel_menu);
- d_triggermenu->addAction(d_tr_tag_key_act);
- d_menu->addMenu(d_triggermenu);
-
- d_controlpanelmenu = new QAction("Control Panel", this);
- d_controlpanelmenu->setCheckable(true);
- d_menu->addAction(d_controlpanelmenu);
- connect(d_controlpanelmenu, SIGNAL(triggered(bool)),
- this, SLOT(setupControlPanel(bool)));
-
- setTriggerMode(gr::qtgui::TRIG_MODE_FREE);
- setTriggerSlope(gr::qtgui::TRIG_SLOPE_POS);
-
- connect(d_tr_mode_menu, SIGNAL(whichTrigger(gr::qtgui::trigger_mode)),
- this, SLOT(setTriggerMode(gr::qtgui::trigger_mode)));
- // updates trigger state by calling set level or set tag key.
- connect(d_tr_mode_menu, SIGNAL(whichTrigger(gr::qtgui::trigger_mode)),
- this, SLOT(updateTrigger(gr::qtgui::trigger_mode)));
-
- connect(d_tr_slope_menu, SIGNAL(whichTrigger(gr::qtgui::trigger_slope)),
- this, SLOT(setTriggerSlope(gr::qtgui::trigger_slope)));
-
- setTriggerLevel(0);
- connect(d_tr_level_act, SIGNAL(whichTrigger(QString)),
- this, SLOT(setTriggerLevel(QString)));
- connect(this, SIGNAL(signalTriggerLevel(float)),
- this, SLOT(setTriggerLevel(float)));
-
- setTriggerDelay(0);
- connect(d_tr_delay_act, SIGNAL(whichTrigger(QString)),
- this, SLOT(setTriggerDelay(QString)));
- connect(this, SIGNAL(signalTriggerDelay(float)),
- this, SLOT(setTriggerDelay(float)));
-
- setTriggerChannel(0);
- connect(d_tr_channel_menu, SIGNAL(whichTrigger(int)),
- this, SLOT(setTriggerChannel(int)));
-
- setTriggerTagKey(std::string(""));
- connect(d_tr_tag_key_act, SIGNAL(whichTrigger(QString)),
- this, SLOT(setTriggerTagKey(QString)));
-
- Reset();
-
- connect(d_display_plot, SIGNAL(plotPointSelected(const QPointF)),
- this, SLOT(onPlotPointSelected(const QPointF)));
-
- connect(this, SIGNAL(signalReplot()),
- getPlot(), SLOT(replot()));
+ : DisplayForm(nplots, parent)
+{
+ d_stem = false;
+ d_semilogx = false;
+ d_semilogy = false;
+ d_current_units = 1;
+
+ d_trig_mode = gr::qtgui::TRIG_MODE_FREE;
+ d_trig_slope = gr::qtgui::TRIG_SLOPE_POS;
+ d_trig_level = 0;
+ d_trig_delay = 0;
+ d_trig_channel = 0;
+ d_trig_tag_key = "";
+
+ d_int_validator = new QIntValidator(this);
+ d_int_validator->setBottom(0);
+
+ d_layout = new QGridLayout(this);
+ d_display_plot = new TimeDomainDisplayPlot(nplots, this);
+
+ d_controlpanel = NULL;
+
+ // Setup the layout of the display
+ d_layout->addWidget(d_display_plot, 0, 0);
+
+ d_layout->setColumnStretch(0, 1);
+ setLayout(d_layout);
+
+ d_nptsmenu = new NPointsMenu(this);
+ d_menu->addAction(d_nptsmenu);
+ connect(d_nptsmenu, SIGNAL(whichTrigger(int)), this, SLOT(setNPoints(const int)));
+ connect(
+ this, SIGNAL(signalNPoints(const int)), d_nptsmenu, SLOT(setDiagText(const int)));
+
+ d_stemmenu = new QAction("Stem Plot", this);
+ d_stemmenu->setCheckable(true);
+ d_menu->addAction(d_stemmenu);
+ connect(d_stemmenu, SIGNAL(triggered(bool)), this, SLOT(setStem(bool)));
+
+ d_semilogxmenu = new QAction("Semilog X", this);
+ d_semilogxmenu->setCheckable(true);
+ d_menu->addAction(d_semilogxmenu);
+ connect(d_semilogxmenu, SIGNAL(triggered(bool)), this, SLOT(setSemilogx(bool)));
+
+ d_semilogymenu = new QAction("Semilog Y", this);
+ d_semilogymenu->setCheckable(true);
+ d_menu->addAction(d_semilogymenu);
+ connect(d_semilogymenu, SIGNAL(triggered(bool)), this, SLOT(setSemilogy(bool)));
+
+ for (unsigned int i = 0; i < d_nplots; ++i) {
+ d_tagsmenu.push_back(new QAction("Show Tag Makers", this));
+ d_tagsmenu[i]->setCheckable(true);
+ d_tagsmenu[i]->setChecked(true);
+ connect(d_tagsmenu[i], SIGNAL(triggered(bool)), this, SLOT(tagMenuSlot(bool)));
+ d_lines_menu[i]->addAction(d_tagsmenu[i]);
+ }
+
+ // Set up the trigger menu
+ d_triggermenu = new QMenu("Trigger", this);
+ d_tr_mode_menu = new TriggerModeMenu(this);
+ d_tr_slope_menu = new TriggerSlopeMenu(this);
+ d_tr_level_act = new PopupMenu("Level", this);
+ d_tr_delay_act = new PopupMenu("Delay", this);
+ d_tr_channel_menu = new TriggerChannelMenu(nplots, this);
+ d_tr_tag_key_act = new PopupMenu("Tag Key", this);
+ d_triggermenu->addMenu(d_tr_mode_menu);
+ d_triggermenu->addMenu(d_tr_slope_menu);
+ d_triggermenu->addAction(d_tr_level_act);
+ d_triggermenu->addAction(d_tr_delay_act);
+ d_triggermenu->addMenu(d_tr_channel_menu);
+ d_triggermenu->addAction(d_tr_tag_key_act);
+ d_menu->addMenu(d_triggermenu);
+
+ d_controlpanelmenu = new QAction("Control Panel", this);
+ d_controlpanelmenu->setCheckable(true);
+ d_menu->addAction(d_controlpanelmenu);
+ connect(
+ d_controlpanelmenu, SIGNAL(triggered(bool)), this, SLOT(setupControlPanel(bool)));
+
+ setTriggerMode(gr::qtgui::TRIG_MODE_FREE);
+ setTriggerSlope(gr::qtgui::TRIG_SLOPE_POS);
+
+ connect(d_tr_mode_menu,
+ SIGNAL(whichTrigger(gr::qtgui::trigger_mode)),
+ this,
+ SLOT(setTriggerMode(gr::qtgui::trigger_mode)));
+ // updates trigger state by calling set level or set tag key.
+ connect(d_tr_mode_menu,
+ SIGNAL(whichTrigger(gr::qtgui::trigger_mode)),
+ this,
+ SLOT(updateTrigger(gr::qtgui::trigger_mode)));
+
+ connect(d_tr_slope_menu,
+ SIGNAL(whichTrigger(gr::qtgui::trigger_slope)),
+ this,
+ SLOT(setTriggerSlope(gr::qtgui::trigger_slope)));
+
+ setTriggerLevel(0);
+ connect(d_tr_level_act,
+ SIGNAL(whichTrigger(QString)),
+ this,
+ SLOT(setTriggerLevel(QString)));
+ connect(this, SIGNAL(signalTriggerLevel(float)), this, SLOT(setTriggerLevel(float)));
+
+ setTriggerDelay(0);
+ connect(d_tr_delay_act,
+ SIGNAL(whichTrigger(QString)),
+ this,
+ SLOT(setTriggerDelay(QString)));
+ connect(this, SIGNAL(signalTriggerDelay(float)), this, SLOT(setTriggerDelay(float)));
+
+ setTriggerChannel(0);
+ connect(
+ d_tr_channel_menu, SIGNAL(whichTrigger(int)), this, SLOT(setTriggerChannel(int)));
+
+ setTriggerTagKey(std::string(""));
+ connect(d_tr_tag_key_act,
+ SIGNAL(whichTrigger(QString)),
+ this,
+ SLOT(setTriggerTagKey(QString)));
+
+ Reset();
+
+ connect(d_display_plot,
+ SIGNAL(plotPointSelected(const QPointF)),
+ this,
+ SLOT(onPlotPointSelected(const QPointF)));
+
+ connect(this, SIGNAL(signalReplot()), getPlot(), SLOT(replot()));
}
TimeDisplayForm::~TimeDisplayForm()
{
- // Qt deletes children when parent is deleted
+ // Qt deletes children when parent is deleted
- // Don't worry about deleting Display Plots - they are deleted when parents are deleted
- delete d_int_validator;
+ // Don't worry about deleting Display Plots - they are deleted when parents are
+ // deleted
+ delete d_int_validator;
- teardownControlPanel();
+ teardownControlPanel();
}
-void
-TimeDisplayForm::setupControlPanel(bool en)
+void TimeDisplayForm::setupControlPanel(bool en)
{
- if(en) {
- setupControlPanel();
- }
- else {
- teardownControlPanel();
- }
+ if (en) {
+ setupControlPanel();
+ } else {
+ teardownControlPanel();
+ }
}
-void
-TimeDisplayForm::setupControlPanel()
+void TimeDisplayForm::setupControlPanel()
{
- if(d_controlpanel)
- delete d_controlpanel;
+ if (d_controlpanel)
+ delete d_controlpanel;
- // Create the control panel layout
- d_controlpanel = new TimeControlPanel(this);
+ // Create the control panel layout
+ d_controlpanel = new TimeControlPanel(this);
- // Connect action items in menu to controlpanel widgets
- connect(d_autoscale_act, SIGNAL(triggered(bool)),
- d_controlpanel, SLOT(toggleAutoScale(bool)));
- connect(d_grid_act, SIGNAL(triggered(bool)),
- d_controlpanel, SLOT(toggleGrid(bool)));
- connect(d_tr_mode_menu, SIGNAL(whichTrigger(gr::qtgui::trigger_mode)),
- d_controlpanel, SLOT(toggleTriggerMode(gr::qtgui::trigger_mode)));
- connect(this, SIGNAL(signalTriggerMode(gr::qtgui::trigger_mode)),
- d_controlpanel, SLOT(toggleTriggerMode(gr::qtgui::trigger_mode)));
- connect(d_tr_slope_menu, SIGNAL(whichTrigger(gr::qtgui::trigger_slope)),
- d_controlpanel, SLOT(toggleTriggerSlope(gr::qtgui::trigger_slope)));
- connect(this, SIGNAL(signalTriggerSlope(gr::qtgui::trigger_slope)),
- d_controlpanel, SLOT(toggleTriggerSlope(gr::qtgui::trigger_slope)));
- connect(d_stop_act, SIGNAL(triggered()),
- d_controlpanel, SLOT(toggleStopButton()));
- d_layout->addLayout(d_controlpanel, 0, 1);
+ // Connect action items in menu to controlpanel widgets
+ connect(d_autoscale_act,
+ SIGNAL(triggered(bool)),
+ d_controlpanel,
+ SLOT(toggleAutoScale(bool)));
+ connect(d_grid_act, SIGNAL(triggered(bool)), d_controlpanel, SLOT(toggleGrid(bool)));
+ connect(d_tr_mode_menu,
+ SIGNAL(whichTrigger(gr::qtgui::trigger_mode)),
+ d_controlpanel,
+ SLOT(toggleTriggerMode(gr::qtgui::trigger_mode)));
+ connect(this,
+ SIGNAL(signalTriggerMode(gr::qtgui::trigger_mode)),
+ d_controlpanel,
+ SLOT(toggleTriggerMode(gr::qtgui::trigger_mode)));
+ connect(d_tr_slope_menu,
+ SIGNAL(whichTrigger(gr::qtgui::trigger_slope)),
+ d_controlpanel,
+ SLOT(toggleTriggerSlope(gr::qtgui::trigger_slope)));
+ connect(this,
+ SIGNAL(signalTriggerSlope(gr::qtgui::trigger_slope)),
+ d_controlpanel,
+ SLOT(toggleTriggerSlope(gr::qtgui::trigger_slope)));
+ connect(d_stop_act, SIGNAL(triggered()), d_controlpanel, SLOT(toggleStopButton()));
+ d_layout->addLayout(d_controlpanel, 0, 1);
- d_controlpanel->toggleAutoScale(d_autoscale_act->isChecked());
- d_controlpanel->toggleGrid(d_grid_act->isChecked());
- d_controlpanel->toggleTriggerMode(getTriggerMode());
- d_controlpanel->toggleTriggerSlope(getTriggerSlope());
+ d_controlpanel->toggleAutoScale(d_autoscale_act->isChecked());
+ d_controlpanel->toggleGrid(d_grid_act->isChecked());
+ d_controlpanel->toggleTriggerMode(getTriggerMode());
+ d_controlpanel->toggleTriggerSlope(getTriggerSlope());
- d_controlpanelmenu->setChecked(true);
+ d_controlpanelmenu->setChecked(true);
}
-void
-TimeDisplayForm::teardownControlPanel()
+void TimeDisplayForm::teardownControlPanel()
{
- if(d_controlpanel) {
- d_layout->removeItem(d_controlpanel);
- delete d_controlpanel;
- d_controlpanel = NULL;
- }
- d_controlpanelmenu->setChecked(false);
+ if (d_controlpanel) {
+ d_layout->removeItem(d_controlpanel);
+ delete d_controlpanel;
+ d_controlpanel = NULL;
+ }
+ d_controlpanelmenu->setChecked(false);
}
-TimeDomainDisplayPlot*
-TimeDisplayForm::getPlot()
+TimeDomainDisplayPlot* TimeDisplayForm::getPlot()
{
- return ((TimeDomainDisplayPlot*)d_display_plot);
+ return ((TimeDomainDisplayPlot*)d_display_plot);
}
-void
-TimeDisplayForm::newData(const QEvent* updateEvent)
+void TimeDisplayForm::newData(const QEvent* updateEvent)
{
- TimeUpdateEvent *tevent = (TimeUpdateEvent*)updateEvent;
- const std::vector<double*> dataPoints = tevent->getTimeDomainPoints();
- const uint64_t numDataPoints = tevent->getNumTimeDomainDataPoints();
- const std::vector< std::vector<gr::tag_t> > tags = tevent->getTags();
+ TimeUpdateEvent* tevent = (TimeUpdateEvent*)updateEvent;
+ const std::vector<double*> dataPoints = tevent->getTimeDomainPoints();
+ const uint64_t numDataPoints = tevent->getNumTimeDomainDataPoints();
+ const std::vector<std::vector<gr::tag_t>> tags = tevent->getTags();
- getPlot()->plotNewData(dataPoints,
- numDataPoints,
- d_update_time,
- tags);
+ getPlot()->plotNewData(dataPoints, numDataPoints, d_update_time, tags);
}
-void
-TimeDisplayForm::customEvent(QEvent * e)
+void TimeDisplayForm::customEvent(QEvent* e)
{
- if(e->type() == TimeUpdateEvent::Type()) {
- newData(e);
- }
+ if (e->type() == TimeUpdateEvent::Type()) {
+ newData(e);
+ }
}
-void
-TimeDisplayForm::setSampleRate(const QString &samprate)
+void TimeDisplayForm::setSampleRate(const QString& samprate)
{
- setSampleRate(samprate.toDouble());
+ setSampleRate(samprate.toDouble());
}
-void
-TimeDisplayForm::setSampleRate(const double samprate)
+void TimeDisplayForm::setSampleRate(const double samprate)
{
- if(samprate > 0) {
- std::string strtime[4] = {"sec", "ms", "us", "ns"};
- double units10 = floor(log10(samprate));
- double units3 = std::max(floor(units10 / 3.0), 0.0);
- double units = pow(10, (units10-fmod(units10, 3.0)));
- int iunit = static_cast<int>(units3);
+ if (samprate > 0) {
+ std::string strtime[4] = { "sec", "ms", "us", "ns" };
+ double units10 = floor(log10(samprate));
+ double units3 = std::max(floor(units10 / 3.0), 0.0);
+ double units = pow(10, (units10 - fmod(units10, 3.0)));
+ int iunit = static_cast<int>(units3);
- d_current_units = units;
+ d_current_units = units;
- getPlot()->setSampleRate(samprate, units, strtime[iunit]);
- }
- else {
- throw std::runtime_error("TimeDisplayForm: samprate must be > 0.\n");
- }
+ getPlot()->setSampleRate(samprate, units, strtime[iunit]);
+ } else {
+ throw std::runtime_error("TimeDisplayForm: samprate must be > 0.\n");
+ }
}
-void
-TimeDisplayForm::setYaxis(double min, double max)
-{
- getPlot()->setYaxis(min, max);
-}
+void TimeDisplayForm::setYaxis(double min, double max) { getPlot()->setYaxis(min, max); }
-void
-TimeDisplayForm::setYLabel(const std::string &label,
- const std::string &unit)
+void TimeDisplayForm::setYLabel(const std::string& label, const std::string& unit)
{
- getPlot()->setYLabel(label, unit);
+ getPlot()->setYLabel(label, unit);
}
-int
-TimeDisplayForm::getNPoints() const
-{
- return d_npoints;
-}
+int TimeDisplayForm::getNPoints() const { return d_npoints; }
-void
-TimeDisplayForm::setNPoints(const int npoints)
+void TimeDisplayForm::setNPoints(const int npoints)
{
- d_npoints = npoints;
- emit signalNPoints(npoints);
+ d_npoints = npoints;
+ emit signalNPoints(npoints);
}
-void
-TimeDisplayForm::setStem(bool en)
+void TimeDisplayForm::setStem(bool en)
{
- d_stem = en;
- d_stemmenu->setChecked(en);
- getPlot()->stemPlot(d_stem);
- emit signalReplot();
+ d_stem = en;
+ d_stemmenu->setChecked(en);
+ getPlot()->stemPlot(d_stem);
+ emit signalReplot();
}
-void
-TimeDisplayForm::autoScale(bool en)
+void TimeDisplayForm::autoScale(bool en)
{
- d_autoscale_state = en;
- d_autoscale_act->setChecked(en);
- getPlot()->setAutoScale(d_autoscale_state);
- emit signalReplot();
+ d_autoscale_state = en;
+ d_autoscale_act->setChecked(en);
+ getPlot()->setAutoScale(d_autoscale_state);
+ emit signalReplot();
}
-void
-TimeDisplayForm::autoScaleShot()
+void TimeDisplayForm::autoScaleShot()
{
- getPlot()->setAutoScaleShot();
- emit signalReplot();
+ getPlot()->setAutoScaleShot();
+ emit signalReplot();
}
-void
-TimeDisplayForm::setSemilogx(bool en)
+void TimeDisplayForm::setSemilogx(bool en)
{
- d_semilogx = en;
- d_semilogxmenu->setChecked(en);
- getPlot()->setSemilogx(d_semilogx);
-
+ d_semilogx = en;
+ d_semilogxmenu->setChecked(en);
+ getPlot()->setSemilogx(d_semilogx);
}
-void
-TimeDisplayForm::setSemilogy(bool en)
+void TimeDisplayForm::setSemilogy(bool en)
{
- d_semilogy = en;
- d_semilogymenu->setChecked(en);
- getPlot()->setSemilogy(d_semilogy);
- emit signalReplot();
+ d_semilogy = en;
+ d_semilogymenu->setChecked(en);
+ getPlot()->setSemilogy(d_semilogy);
+ emit signalReplot();
}
-void
-TimeDisplayForm::setTagMenu(unsigned int which, bool en)
+void TimeDisplayForm::setTagMenu(unsigned int which, bool en)
{
- getPlot()->enableTagMarker(which, en);
- d_tagsmenu[which]->setChecked(en);
+ getPlot()->enableTagMarker(which, en);
+ d_tagsmenu[which]->setChecked(en);
}
-void
-TimeDisplayForm::tagMenuSlot(bool en)
+void TimeDisplayForm::tagMenuSlot(bool en)
{
- for(size_t i = 0; i < d_tagsmenu.size(); i++) {
- getPlot()->enableTagMarker(i, d_tagsmenu[i]->isChecked());
- }
+ for (size_t i = 0; i < d_tagsmenu.size(); i++) {
+ getPlot()->enableTagMarker(i, d_tagsmenu[i]->isChecked());
+ }
}
@@ -365,357 +348,309 @@ TimeDisplayForm::tagMenuSlot(bool en)
* TRIGGER METHODS
*******************************************************************/
-void
-TimeDisplayForm::setTriggerMode(gr::qtgui::trigger_mode mode)
+void TimeDisplayForm::setTriggerMode(gr::qtgui::trigger_mode mode)
{
- d_trig_mode = mode;
- d_tr_mode_menu->getAction(mode)->setChecked(true);
+ d_trig_mode = mode;
+ d_tr_mode_menu->getAction(mode)->setChecked(true);
- if((d_trig_mode == gr::qtgui::TRIG_MODE_AUTO) || (d_trig_mode == gr::qtgui::TRIG_MODE_NORM)) {
- getPlot()->attachTriggerLines(true);
- }
- else {
- getPlot()->attachTriggerLines(false);
- }
+ if ((d_trig_mode == gr::qtgui::TRIG_MODE_AUTO) ||
+ (d_trig_mode == gr::qtgui::TRIG_MODE_NORM)) {
+ getPlot()->attachTriggerLines(true);
+ } else {
+ getPlot()->attachTriggerLines(false);
+ }
- emit signalReplot();
- emit signalTriggerMode(mode);
+ emit signalReplot();
+ emit signalTriggerMode(mode);
}
-void
-TimeDisplayForm::updateTrigger(gr::qtgui::trigger_mode mode)
+void TimeDisplayForm::updateTrigger(gr::qtgui::trigger_mode mode)
{
- // If auto or normal mode, popup trigger level box to set
- if((d_trig_mode == gr::qtgui::TRIG_MODE_AUTO) || (d_trig_mode == gr::qtgui::TRIG_MODE_NORM)) {
- d_tr_level_act->activate(QAction::Trigger);
- getPlot()->attachTriggerLines(true);
- }
- else {
- getPlot()->attachTriggerLines(false);
- }
+ // If auto or normal mode, popup trigger level box to set
+ if ((d_trig_mode == gr::qtgui::TRIG_MODE_AUTO) ||
+ (d_trig_mode == gr::qtgui::TRIG_MODE_NORM)) {
+ d_tr_level_act->activate(QAction::Trigger);
+ getPlot()->attachTriggerLines(true);
+ } else {
+ getPlot()->attachTriggerLines(false);
+ }
- // if tag mode, popup tag key box to set
- if((d_trig_tag_key == "") && (d_trig_mode == gr::qtgui::TRIG_MODE_TAG))
- d_tr_tag_key_act->activate(QAction::Trigger);
+ // if tag mode, popup tag key box to set
+ if ((d_trig_tag_key == "") && (d_trig_mode == gr::qtgui::TRIG_MODE_TAG))
+ d_tr_tag_key_act->activate(QAction::Trigger);
- emit signalReplot();
- emit signalTriggerMode(mode);
+ emit signalReplot();
+ emit signalTriggerMode(mode);
}
-gr::qtgui::trigger_mode
-TimeDisplayForm::getTriggerMode() const
-{
- return d_trig_mode;
-}
+gr::qtgui::trigger_mode TimeDisplayForm::getTriggerMode() const { return d_trig_mode; }
-void
-TimeDisplayForm::setTriggerSlope(gr::qtgui::trigger_slope slope)
+void TimeDisplayForm::setTriggerSlope(gr::qtgui::trigger_slope slope)
{
- d_trig_slope = slope;
- d_tr_slope_menu->getAction(slope)->setChecked(true);
+ d_trig_slope = slope;
+ d_tr_slope_menu->getAction(slope)->setChecked(true);
- emit signalReplot();
- emit signalTriggerSlope(slope);
+ emit signalReplot();
+ emit signalTriggerSlope(slope);
}
-gr::qtgui::trigger_slope
-TimeDisplayForm::getTriggerSlope() const
-{
- return d_trig_slope;
-}
+gr::qtgui::trigger_slope TimeDisplayForm::getTriggerSlope() const { return d_trig_slope; }
-void
-TimeDisplayForm::setTriggerLevel(QString s)
+void TimeDisplayForm::setTriggerLevel(QString s)
{
- d_trig_level = s.toFloat();
+ d_trig_level = s.toFloat();
- if((d_trig_mode == gr::qtgui::TRIG_MODE_AUTO) || (d_trig_mode == gr::qtgui::TRIG_MODE_NORM)) {
- getPlot()->setTriggerLines(d_trig_delay*d_current_units, d_trig_level);
- }
+ if ((d_trig_mode == gr::qtgui::TRIG_MODE_AUTO) ||
+ (d_trig_mode == gr::qtgui::TRIG_MODE_NORM)) {
+ getPlot()->setTriggerLines(d_trig_delay * d_current_units, d_trig_level);
+ }
- emit signalReplot();
+ emit signalReplot();
}
-void
-TimeDisplayForm::setTriggerLevel(float level)
+void TimeDisplayForm::setTriggerLevel(float level)
{
- d_trig_level = level;
- d_tr_level_act->setText(QString().setNum(d_trig_level));
+ d_trig_level = level;
+ d_tr_level_act->setText(QString().setNum(d_trig_level));
- if((d_trig_mode == gr::qtgui::TRIG_MODE_AUTO) || (d_trig_mode == gr::qtgui::TRIG_MODE_NORM)) {
- getPlot()->setTriggerLines(d_trig_delay*d_current_units, d_trig_level);
- }
+ if ((d_trig_mode == gr::qtgui::TRIG_MODE_AUTO) ||
+ (d_trig_mode == gr::qtgui::TRIG_MODE_NORM)) {
+ getPlot()->setTriggerLines(d_trig_delay * d_current_units, d_trig_level);
+ }
- emit signalReplot();
+ emit signalReplot();
}
-float
-TimeDisplayForm::getTriggerLevel() const
-{
- return d_trig_level;
-}
+float TimeDisplayForm::getTriggerLevel() const { return d_trig_level; }
-void
-TimeDisplayForm::setTriggerDelay(QString s)
+void TimeDisplayForm::setTriggerDelay(QString s)
{
- d_trig_delay = s.toFloat();
+ d_trig_delay = s.toFloat();
- if((d_trig_mode == gr::qtgui::TRIG_MODE_AUTO) || (d_trig_mode == gr::qtgui::TRIG_MODE_NORM)) {
- getPlot()->setTriggerLines(d_trig_delay*d_current_units, d_trig_level);
- }
+ if ((d_trig_mode == gr::qtgui::TRIG_MODE_AUTO) ||
+ (d_trig_mode == gr::qtgui::TRIG_MODE_NORM)) {
+ getPlot()->setTriggerLines(d_trig_delay * d_current_units, d_trig_level);
+ }
- emit signalReplot();
+ emit signalReplot();
}
-void
-TimeDisplayForm::setTriggerDelay(float delay)
+void TimeDisplayForm::setTriggerDelay(float delay)
{
- d_trig_delay = delay;
- d_tr_delay_act->setText(QString().setNum(d_trig_delay));
+ d_trig_delay = delay;
+ d_tr_delay_act->setText(QString().setNum(d_trig_delay));
- if((d_trig_mode == gr::qtgui::TRIG_MODE_AUTO) || (d_trig_mode == gr::qtgui::TRIG_MODE_NORM)) {
- getPlot()->setTriggerLines(d_trig_delay*d_current_units, d_trig_level);
- }
+ if ((d_trig_mode == gr::qtgui::TRIG_MODE_AUTO) ||
+ (d_trig_mode == gr::qtgui::TRIG_MODE_NORM)) {
+ getPlot()->setTriggerLines(d_trig_delay * d_current_units, d_trig_level);
+ }
- emit signalReplot();
+ emit signalReplot();
}
-float
-TimeDisplayForm::getTriggerDelay() const
-{
- return d_trig_delay;
-}
+float TimeDisplayForm::getTriggerDelay() const { return d_trig_delay; }
-void
-TimeDisplayForm::setTriggerChannel(int channel)
+void TimeDisplayForm::setTriggerChannel(int channel)
{
- d_trig_channel = channel;
- d_tr_channel_menu->getAction(d_trig_channel)->setChecked(true);
+ d_trig_channel = channel;
+ d_tr_channel_menu->getAction(d_trig_channel)->setChecked(true);
- emit signalReplot();
+ emit signalReplot();
}
-int
-TimeDisplayForm::getTriggerChannel() const
-{
- return d_trig_channel;
-}
+int TimeDisplayForm::getTriggerChannel() const { return d_trig_channel; }
-void
-TimeDisplayForm::setTriggerTagKey(QString s)
+void TimeDisplayForm::setTriggerTagKey(QString s)
{
- d_trig_tag_key = s.toStdString();
+ d_trig_tag_key = s.toStdString();
- emit signalReplot();
+ emit signalReplot();
}
-void
-TimeDisplayForm::setTriggerTagKey(const std::string &key)
+void TimeDisplayForm::setTriggerTagKey(const std::string& key)
{
- d_trig_tag_key = key;
- d_tr_tag_key_act->setText(QString().fromStdString(d_trig_tag_key));
+ d_trig_tag_key = key;
+ d_tr_tag_key_act->setText(QString().fromStdString(d_trig_tag_key));
- emit signalReplot();
-}
-
-std::string
-TimeDisplayForm::getTriggerTagKey() const
-{
- return d_trig_tag_key;
+ emit signalReplot();
}
+std::string TimeDisplayForm::getTriggerTagKey() const { return d_trig_tag_key; }
/********************************************************************
* Notification messages from the control panel
*******************************************************************/
-void
-TimeDisplayForm::notifyYAxisPlus()
+void TimeDisplayForm::notifyYAxisPlus()
{
#if QWT_VERSION < 0x060100
- QwtScaleDiv *ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
- double range = ax->upperBound() - ax->lowerBound();
- double step = range/20.0;
- getPlot()->setYaxis(ax->lowerBound()+step, ax->upperBound()+step);
+ QwtScaleDiv* ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
+ double range = ax->upperBound() - ax->lowerBound();
+ double step = range / 20.0;
+ getPlot()->setYaxis(ax->lowerBound() + step, ax->upperBound() + step);
#else
- QwtScaleDiv ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
- double range = ax.upperBound() - ax.lowerBound();
- double step = range/20.0;
- getPlot()->setYaxis(ax.lowerBound()+step, ax.upperBound()+step);
+ QwtScaleDiv ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
+ double range = ax.upperBound() - ax.lowerBound();
+ double step = range / 20.0;
+ getPlot()->setYaxis(ax.lowerBound() + step, ax.upperBound() + step);
#endif
}
-void
-TimeDisplayForm::notifyYAxisMinus()
+void TimeDisplayForm::notifyYAxisMinus()
{
#if QWT_VERSION < 0x060100
- QwtScaleDiv *ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
- double range = ax->upperBound() - ax->lowerBound();
- double step = range/20.0;
- getPlot()->setYaxis(ax->lowerBound()-step, ax->upperBound()-step);
+ QwtScaleDiv* ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
+ double range = ax->upperBound() - ax->lowerBound();
+ double step = range / 20.0;
+ getPlot()->setYaxis(ax->lowerBound() - step, ax->upperBound() - step);
#else
- QwtScaleDiv ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
- double range = ax.upperBound() - ax.lowerBound();
- double step = range/20.0;
- getPlot()->setYaxis(ax.lowerBound()-step, ax.upperBound()-step);
+ QwtScaleDiv ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
+ double range = ax.upperBound() - ax.lowerBound();
+ double step = range / 20.0;
+ getPlot()->setYaxis(ax.lowerBound() - step, ax.upperBound() - step);
#endif
}
-void
-TimeDisplayForm::notifyYRangePlus()
+void TimeDisplayForm::notifyYRangePlus()
{
#if QWT_VERSION < 0x060100
- QwtScaleDiv *ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
- double range = ax->upperBound() - ax->lowerBound();
- double step = range/20.0;
- getPlot()->setYaxis(ax->lowerBound()-step, ax->upperBound()+step);
+ QwtScaleDiv* ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
+ double range = ax->upperBound() - ax->lowerBound();
+ double step = range / 20.0;
+ getPlot()->setYaxis(ax->lowerBound() - step, ax->upperBound() + step);
#else
- QwtScaleDiv ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
- double range = ax.upperBound() - ax.lowerBound();
- double step = range/20.0;
- getPlot()->setYaxis(ax.lowerBound()-step, ax.upperBound()+step);
+ QwtScaleDiv ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
+ double range = ax.upperBound() - ax.lowerBound();
+ double step = range / 20.0;
+ getPlot()->setYaxis(ax.lowerBound() - step, ax.upperBound() + step);
#endif
}
-void
-TimeDisplayForm::notifyYRangeMinus()
+void TimeDisplayForm::notifyYRangeMinus()
{
#if QWT_VERSION < 0x060100
- QwtScaleDiv *ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
- double range = ax->upperBound() - ax->lowerBound();
- double step = range/20.0;
- getPlot()->setYaxis(ax->lowerBound()+step, ax->upperBound()-step);
+ QwtScaleDiv* ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
+ double range = ax->upperBound() - ax->lowerBound();
+ double step = range / 20.0;
+ getPlot()->setYaxis(ax->lowerBound() + step, ax->upperBound() - step);
#else
- QwtScaleDiv ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
- double range = ax.upperBound() - ax.lowerBound();
- double step = range/20.0;
- getPlot()->setYaxis(ax.lowerBound()+step, ax.upperBound()-step);
+ QwtScaleDiv ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
+ double range = ax.upperBound() - ax.lowerBound();
+ double step = range / 20.0;
+ getPlot()->setYaxis(ax.lowerBound() + step, ax.upperBound() - step);
#endif
}
-void
-TimeDisplayForm::notifyXAxisPlus()
+void TimeDisplayForm::notifyXAxisPlus()
{
- // increase by 10%
- setNPoints(static_cast<int>(1.1*getNPoints()));
+ // increase by 10%
+ setNPoints(static_cast<int>(1.1 * getNPoints()));
}
-void
-TimeDisplayForm::notifyXAxisMinus()
+void TimeDisplayForm::notifyXAxisMinus()
{
- // decrease by 10%
- setNPoints(static_cast<int>(0.9*getNPoints()));
+ // decrease by 10%
+ setNPoints(static_cast<int>(0.9 * getNPoints()));
}
+void TimeDisplayForm::notifyTriggerMode(const QString& mode)
+{
+ if (mode == "Free") {
+ setTriggerMode(gr::qtgui::TRIG_MODE_FREE);
+ } else if (mode == "Auto") {
+ setTriggerMode(gr::qtgui::TRIG_MODE_AUTO);
+ } else if (mode == "Normal") {
+ setTriggerMode(gr::qtgui::TRIG_MODE_NORM);
+ } else if (mode == "Tag") {
+ setTriggerMode(gr::qtgui::TRIG_MODE_TAG);
+ updateTrigger(gr::qtgui::TRIG_MODE_TAG);
+ }
+}
-void
-TimeDisplayForm::notifyTriggerMode(const QString &mode)
+void TimeDisplayForm::notifyTriggerSlope(const QString& slope)
{
- if(mode == "Free") {
- setTriggerMode(gr::qtgui::TRIG_MODE_FREE);
- }
- else if(mode == "Auto") {
- setTriggerMode(gr::qtgui::TRIG_MODE_AUTO);
- }
- else if(mode == "Normal") {
- setTriggerMode(gr::qtgui::TRIG_MODE_NORM);
- }
- else if(mode == "Tag") {
- setTriggerMode(gr::qtgui::TRIG_MODE_TAG);
- updateTrigger(gr::qtgui::TRIG_MODE_TAG);
- }
-}
-
-void
-TimeDisplayForm::notifyTriggerSlope(const QString &slope)
-{
- if(slope == "Positive") {
- setTriggerSlope(gr::qtgui::TRIG_SLOPE_POS);
- }
- else if(slope == "Negative") {
- setTriggerSlope(gr::qtgui::TRIG_SLOPE_NEG);
- }
+ if (slope == "Positive") {
+ setTriggerSlope(gr::qtgui::TRIG_SLOPE_POS);
+ } else if (slope == "Negative") {
+ setTriggerSlope(gr::qtgui::TRIG_SLOPE_NEG);
+ }
}
-void
-TimeDisplayForm::notifyTriggerLevelPlus()
+void TimeDisplayForm::notifyTriggerLevelPlus()
{
#if QWT_VERSION < 0x060100
- QwtScaleDiv *ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
- double range = ax->upperBound() - ax->lowerBound();
+ QwtScaleDiv* ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
+ double range = ax->upperBound() - ax->lowerBound();
#else
- QwtScaleDiv ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
- double range = ax.upperBound() - ax.lowerBound();
+ QwtScaleDiv ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
+ double range = ax.upperBound() - ax.lowerBound();
#endif
- double step = range/20.0;
- emit signalTriggerLevel(getTriggerLevel() + step);
+ double step = range / 20.0;
+ emit signalTriggerLevel(getTriggerLevel() + step);
}
-void
-TimeDisplayForm::notifyTriggerLevelMinus()
+void TimeDisplayForm::notifyTriggerLevelMinus()
{
#if QWT_VERSION < 0x060100
- QwtScaleDiv *ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
- double range = ax->upperBound() - ax->lowerBound();
+ QwtScaleDiv* ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
+ double range = ax->upperBound() - ax->lowerBound();
#else
- QwtScaleDiv ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
- double range = ax.upperBound() - ax.lowerBound();
+ QwtScaleDiv ax = getPlot()->axisScaleDiv(QwtPlot::yLeft);
+ double range = ax.upperBound() - ax.lowerBound();
#endif
- double step = range/20.0;
- emit signalTriggerLevel(getTriggerLevel() - step);
+ double step = range / 20.0;
+ emit signalTriggerLevel(getTriggerLevel() - step);
}
-void
-TimeDisplayForm::notifyTriggerDelayPlus()
+void TimeDisplayForm::notifyTriggerDelayPlus()
{
#if QWT_VERSION < 0x060100
- QwtScaleDiv *ax = getPlot()->axisScaleDiv(QwtPlot::xBottom);
- double range = ax->upperBound() - ax->lowerBound();
+ QwtScaleDiv* ax = getPlot()->axisScaleDiv(QwtPlot::xBottom);
+ double range = ax->upperBound() - ax->lowerBound();
#else
- QwtScaleDiv ax = getPlot()->axisScaleDiv(QwtPlot::xBottom);
- double range = ax.upperBound() - ax.lowerBound();
+ QwtScaleDiv ax = getPlot()->axisScaleDiv(QwtPlot::xBottom);
+ double range = ax.upperBound() - ax.lowerBound();
#endif
- double step = range/20.0;
- double trig = getTriggerDelay() + step / d_current_units;
- emit signalTriggerDelay(trig);
+ double step = range / 20.0;
+ double trig = getTriggerDelay() + step / d_current_units;
+ emit signalTriggerDelay(trig);
}
-void
-TimeDisplayForm::notifyTriggerDelayMinus()
+void TimeDisplayForm::notifyTriggerDelayMinus()
{
#if QWT_VERSION < 0x060100
- QwtScaleDiv *ax = getPlot()->axisScaleDiv(QwtPlot::xBottom);
- double range = ax->upperBound() - ax->lowerBound();
+ QwtScaleDiv* ax = getPlot()->axisScaleDiv(QwtPlot::xBottom);
+ double range = ax->upperBound() - ax->lowerBound();
#else
- QwtScaleDiv ax = getPlot()->axisScaleDiv(QwtPlot::xBottom);
- double range = ax.upperBound() - ax.lowerBound();
+ QwtScaleDiv ax = getPlot()->axisScaleDiv(QwtPlot::xBottom);
+ double range = ax.upperBound() - ax.lowerBound();
#endif
- double step = range/20.0;
- double trig = getTriggerDelay() - step / d_current_units;
- if(trig < 0)
- trig = 0;
- emit signalTriggerDelay(trig);
+ double step = range / 20.0;
+ double trig = getTriggerDelay() - step / d_current_units;
+ if (trig < 0)
+ trig = 0;
+ emit signalTriggerDelay(trig);
}
diff --git a/gr-qtgui/lib/timerasterdisplayform.cc b/gr-qtgui/lib/timerasterdisplayform.cc
index aedf3b70f1..eec013b7a7 100644
--- a/gr-qtgui/lib/timerasterdisplayform.cc
+++ b/gr-qtgui/lib/timerasterdisplayform.cc
@@ -28,264 +28,245 @@
#include <cmath>
#include <iostream>
-TimeRasterDisplayForm::TimeRasterDisplayForm(int nplots,
- double samp_rate,
- double rows, double cols,
- double zmax,
- QWidget* parent)
- : DisplayForm(nplots, parent)
+TimeRasterDisplayForm::TimeRasterDisplayForm(
+ int nplots, double samp_rate, double rows, double cols, double zmax, QWidget* parent)
+ : DisplayForm(nplots, parent)
{
#if QWT_VERSION < 0x060000
- std::cerr << "Warning: QWT5 has been found which has serious performance issues with raster plots."
- << std::endl << " Consider updating to QWT version 6 to use the time raster GUIs."
- << std::endl << std::endl;
+ std::cerr
+ << "Warning: QWT5 has been found which has serious performance issues with "
+ "raster plots."
+ << std::endl
+ << " Consider updating to QWT version 6 to use the time raster GUIs."
+ << std::endl
+ << std::endl;
#endif
- d_layout = new QGridLayout(this);
- d_display_plot = new TimeRasterDisplayPlot(nplots, samp_rate, rows, cols, this);
- d_layout->addWidget(d_display_plot, 0, 0);
- setLayout(d_layout);
-
- d_min_val = 10;
- d_max_val = -10;
-
- // We don't use the normal menus that are part of the displayform.
- // Clear them out to get rid of their resources.
- for(int i = 0; i < nplots; i++) {
- d_lines_menu[i]->clear();
- }
- d_line_title_act.clear();
- d_line_color_menu.clear();
- d_line_width_menu.clear();
- d_line_style_menu.clear();
- d_line_marker_menu.clear();
- d_marker_alpha_menu.clear();
-
- // Now create our own menus
- for(int i = 0; i < nplots; i++) {
- d_line_title_act.push_back(new LineTitleAction(i, this));
- connect(d_line_title_act[i], SIGNAL(whichTrigger(unsigned int, const QString&)),
- this, SLOT(setLineLabel(unsigned int, const QString&)));
- d_lines_menu[i]->addAction(d_line_title_act[i]);
-
- ColorMapMenu *colormap = new ColorMapMenu(i, this);
- connect(colormap, SIGNAL(whichTrigger(unsigned int, const int, const QColor&, const QColor&)),
- this, SLOT(setColorMap(unsigned int, const int, const QColor&, const QColor&)));
- d_lines_menu[i]->addMenu(colormap);
-
- d_marker_alpha_menu.push_back(new MarkerAlphaMenu(i, this));
- connect(d_marker_alpha_menu[i], SIGNAL(whichTrigger(unsigned int, unsigned int)),
- this, SLOT(setAlpha(unsigned int, unsigned int)));
- d_lines_menu[i]->addMenu(d_marker_alpha_menu[i]);
- }
-
- // One scales once when clicked, so no on/off toggling
- d_autoscale_act->setText(tr("Auto Scale"));
- d_autoscale_act->setCheckable(false);
-
- PopupMenu *colsmenu = new PopupMenu("Num. Columns", this);
- d_menu->addAction(colsmenu);
- connect(colsmenu, SIGNAL(whichTrigger(QString)),
- this, SLOT(setNumCols(QString)));
-
- PopupMenu *rowsmenu = new PopupMenu("Num. Rows", this);
- d_menu->addAction(rowsmenu);
- connect(rowsmenu, SIGNAL(whichTrigger(QString)),
- this, SLOT(setNumRows(QString)));
-
- PopupMenu *maxintmenu = new PopupMenu("Int. Max", this);
- d_menu->addAction(maxintmenu);
- connect(maxintmenu, SIGNAL(whichTrigger(QString)),
- this, SLOT(setMaxIntensity(QString)));
-
- PopupMenu *minintmenu = new PopupMenu("Int. Min", this);
- d_menu->addAction(minintmenu);
- connect(minintmenu, SIGNAL(whichTrigger(QString)),
- this, SLOT(setMinIntensity(QString)));
-
- getPlot()->setIntensityRange(0, zmax);
-
- Reset();
-
- connect(d_display_plot, SIGNAL(plotPointSelected(const QPointF)),
- this, SLOT(onPlotPointSelected(const QPointF)));
+ d_layout = new QGridLayout(this);
+ d_display_plot = new TimeRasterDisplayPlot(nplots, samp_rate, rows, cols, this);
+ d_layout->addWidget(d_display_plot, 0, 0);
+ setLayout(d_layout);
+
+ d_min_val = 10;
+ d_max_val = -10;
+
+ // We don't use the normal menus that are part of the displayform.
+ // Clear them out to get rid of their resources.
+ for (int i = 0; i < nplots; i++) {
+ d_lines_menu[i]->clear();
+ }
+ d_line_title_act.clear();
+ d_line_color_menu.clear();
+ d_line_width_menu.clear();
+ d_line_style_menu.clear();
+ d_line_marker_menu.clear();
+ d_marker_alpha_menu.clear();
+
+ // Now create our own menus
+ for (int i = 0; i < nplots; i++) {
+ d_line_title_act.push_back(new LineTitleAction(i, this));
+ connect(d_line_title_act[i],
+ SIGNAL(whichTrigger(unsigned int, const QString&)),
+ this,
+ SLOT(setLineLabel(unsigned int, const QString&)));
+ d_lines_menu[i]->addAction(d_line_title_act[i]);
+
+ ColorMapMenu* colormap = new ColorMapMenu(i, this);
+ connect(
+ colormap,
+ SIGNAL(whichTrigger(unsigned int, const int, const QColor&, const QColor&)),
+ this,
+ SLOT(setColorMap(unsigned int, const int, const QColor&, const QColor&)));
+ d_lines_menu[i]->addMenu(colormap);
+
+ d_marker_alpha_menu.push_back(new MarkerAlphaMenu(i, this));
+ connect(d_marker_alpha_menu[i],
+ SIGNAL(whichTrigger(unsigned int, unsigned int)),
+ this,
+ SLOT(setAlpha(unsigned int, unsigned int)));
+ d_lines_menu[i]->addMenu(d_marker_alpha_menu[i]);
+ }
+
+ // One scales once when clicked, so no on/off toggling
+ d_autoscale_act->setText(tr("Auto Scale"));
+ d_autoscale_act->setCheckable(false);
+
+ PopupMenu* colsmenu = new PopupMenu("Num. Columns", this);
+ d_menu->addAction(colsmenu);
+ connect(colsmenu, SIGNAL(whichTrigger(QString)), this, SLOT(setNumCols(QString)));
+
+ PopupMenu* rowsmenu = new PopupMenu("Num. Rows", this);
+ d_menu->addAction(rowsmenu);
+ connect(rowsmenu, SIGNAL(whichTrigger(QString)), this, SLOT(setNumRows(QString)));
+
+ PopupMenu* maxintmenu = new PopupMenu("Int. Max", this);
+ d_menu->addAction(maxintmenu);
+ connect(
+ maxintmenu, SIGNAL(whichTrigger(QString)), this, SLOT(setMaxIntensity(QString)));
+
+ PopupMenu* minintmenu = new PopupMenu("Int. Min", this);
+ d_menu->addAction(minintmenu);
+ connect(
+ minintmenu, SIGNAL(whichTrigger(QString)), this, SLOT(setMinIntensity(QString)));
+
+ getPlot()->setIntensityRange(0, zmax);
+
+ Reset();
+
+ connect(d_display_plot,
+ SIGNAL(plotPointSelected(const QPointF)),
+ this,
+ SLOT(onPlotPointSelected(const QPointF)));
}
TimeRasterDisplayForm::~TimeRasterDisplayForm()
{
- // Don't worry about deleting Display Plots - they are deleted when
- // parents are deleted
+ // Don't worry about deleting Display Plots - they are deleted when
+ // parents are deleted
}
-TimeRasterDisplayPlot*
-TimeRasterDisplayForm::getPlot()
+TimeRasterDisplayPlot* TimeRasterDisplayForm::getPlot()
{
- return ((TimeRasterDisplayPlot*)d_display_plot);
+ return ((TimeRasterDisplayPlot*)d_display_plot);
}
-double
-TimeRasterDisplayForm::numRows()
-{
- return getPlot()->numRows();
-}
+double TimeRasterDisplayForm::numRows() { return getPlot()->numRows(); }
-double
-TimeRasterDisplayForm::numCols()
-{
- return getPlot()->numCols();
-}
+double TimeRasterDisplayForm::numCols() { return getPlot()->numCols(); }
-int
-TimeRasterDisplayForm::getColorMap(unsigned int which)
+int TimeRasterDisplayForm::getColorMap(unsigned int which)
{
- return getPlot()->getIntensityColorMapType(which);
+ return getPlot()->getIntensityColorMapType(which);
}
-int
-TimeRasterDisplayForm::getAlpha(unsigned int which)
+int TimeRasterDisplayForm::getAlpha(unsigned int which)
{
- return getPlot()->getAlpha(which);
+ return getPlot()->getAlpha(which);
}
-double
-TimeRasterDisplayForm::getMinIntensity(unsigned int which)
+double TimeRasterDisplayForm::getMinIntensity(unsigned int which)
{
- return getPlot()->getMinIntensity(which);
+ return getPlot()->getMinIntensity(which);
}
-double
-TimeRasterDisplayForm::getMaxIntensity(unsigned int which)
+double TimeRasterDisplayForm::getMaxIntensity(unsigned int which)
{
- return getPlot()->getMaxIntensity(which);
+ return getPlot()->getMaxIntensity(which);
}
-void
-TimeRasterDisplayForm::newData(const QEvent *updateEvent)
+void TimeRasterDisplayForm::newData(const QEvent* updateEvent)
{
- TimeRasterUpdateEvent *event = (TimeRasterUpdateEvent*)updateEvent;
- const std::vector<double*> dataPoints = event->getPoints();
- const uint64_t numDataPoints = event->getNumDataPoints();
-
- for(size_t i=0; i < dataPoints.size(); i++) {
- double *min_val = std::min_element(&dataPoints[i][0], &dataPoints[i][numDataPoints-1]);
- double *max_val = std::max_element(&dataPoints[i][0], &dataPoints[i][numDataPoints-1]);
- if(*min_val < d_min_val)
- d_min_val = *min_val;
- if(*max_val > d_max_val)
- d_max_val = *max_val;
- }
-
- getPlot()->plotNewData(dataPoints, numDataPoints);
+ TimeRasterUpdateEvent* event = (TimeRasterUpdateEvent*)updateEvent;
+ const std::vector<double*> dataPoints = event->getPoints();
+ const uint64_t numDataPoints = event->getNumDataPoints();
+
+ for (size_t i = 0; i < dataPoints.size(); i++) {
+ double* min_val =
+ std::min_element(&dataPoints[i][0], &dataPoints[i][numDataPoints - 1]);
+ double* max_val =
+ std::max_element(&dataPoints[i][0], &dataPoints[i][numDataPoints - 1]);
+ if (*min_val < d_min_val)
+ d_min_val = *min_val;
+ if (*max_val > d_max_val)
+ d_max_val = *max_val;
+ }
+
+ getPlot()->plotNewData(dataPoints, numDataPoints);
}
-void
-TimeRasterDisplayForm::customEvent( QEvent * e)
+void TimeRasterDisplayForm::customEvent(QEvent* e)
{
- if(e->type() == TimeRasterUpdateEvent::Type()) {
- newData(e);
- }
- else if(e->type() == TimeRasterSetSize::Type()) {
- double r = ((TimeRasterSetSize*)e)->nRows();
- double c = ((TimeRasterSetSize*)e)->nCols();
- getPlot()->setNumRows(r);
- getPlot()->setNumCols(c);
- getPlot()->replot();
- }
+ if (e->type() == TimeRasterUpdateEvent::Type()) {
+ newData(e);
+ } else if (e->type() == TimeRasterSetSize::Type()) {
+ double r = ((TimeRasterSetSize*)e)->nRows();
+ double c = ((TimeRasterSetSize*)e)->nCols();
+ getPlot()->setNumRows(r);
+ getPlot()->setNumCols(c);
+ getPlot()->replot();
+ }
}
-void
-TimeRasterDisplayForm::setNumRows(double rows)
+void TimeRasterDisplayForm::setNumRows(double rows)
{
- getPlot()->setNumRows(rows);
- getPlot()->replot();
+ getPlot()->setNumRows(rows);
+ getPlot()->replot();
}
-void
-TimeRasterDisplayForm::setNumRows(QString rows)
+void TimeRasterDisplayForm::setNumRows(QString rows)
{
- getPlot()->setNumRows(rows.toDouble());
- getPlot()->replot();
+ getPlot()->setNumRows(rows.toDouble());
+ getPlot()->replot();
}
-void
-TimeRasterDisplayForm::setNumCols(double cols)
+void TimeRasterDisplayForm::setNumCols(double cols)
{
- getPlot()->setNumCols(cols);
- getPlot()->replot();
+ getPlot()->setNumCols(cols);
+ getPlot()->replot();
}
-void
-TimeRasterDisplayForm::setNumCols(QString cols)
+void TimeRasterDisplayForm::setNumCols(QString cols)
{
- getPlot()->setNumCols(cols.toDouble());
- getPlot()->replot();
+ getPlot()->setNumCols(cols.toDouble());
+ getPlot()->replot();
}
-void
-TimeRasterDisplayForm::setSampleRate(const double rate)
+void TimeRasterDisplayForm::setSampleRate(const double rate)
{
- getPlot()->setSampleRate(rate);
- getPlot()->replot();
+ getPlot()->setSampleRate(rate);
+ getPlot()->replot();
}
-void
-TimeRasterDisplayForm::setSampleRate(const QString &rate)
+void TimeRasterDisplayForm::setSampleRate(const QString& rate)
{
- getPlot()->setSampleRate(rate.toDouble());
- getPlot()->replot();
+ getPlot()->setSampleRate(rate.toDouble());
+ getPlot()->replot();
}
-void
-TimeRasterDisplayForm::setColorMap(unsigned int which,
- const int newType,
- const QColor lowColor,
- const QColor highColor)
+void TimeRasterDisplayForm::setColorMap(unsigned int which,
+ const int newType,
+ const QColor lowColor,
+ const QColor highColor)
{
- getPlot()->setIntensityColorMapType(which, newType,
- lowColor, highColor);
- getPlot()->replot();
+ getPlot()->setIntensityColorMapType(which, newType, lowColor, highColor);
+ getPlot()->replot();
}
-void
-TimeRasterDisplayForm::setAlpha(unsigned int which, unsigned int alpha)
+void TimeRasterDisplayForm::setAlpha(unsigned int which, unsigned int alpha)
{
- getPlot()->setAlpha(which, alpha);
- getPlot()->replot();
+ getPlot()->setAlpha(which, alpha);
+ getPlot()->replot();
}
-void
-TimeRasterDisplayForm::setIntensityRange(const double minIntensity,
- const double maxIntensity)
+void TimeRasterDisplayForm::setIntensityRange(const double minIntensity,
+ const double maxIntensity)
{
- // reset max and min values
- d_min_val = 10;
- d_max_val = -10;
-
- d_cur_min_val = minIntensity;
- d_cur_max_val = maxIntensity;
- getPlot()->setIntensityRange(minIntensity, maxIntensity);
- getPlot()->replot();
+ // reset max and min values
+ d_min_val = 10;
+ d_max_val = -10;
+
+ d_cur_min_val = minIntensity;
+ d_cur_max_val = maxIntensity;
+ getPlot()->setIntensityRange(minIntensity, maxIntensity);
+ getPlot()->replot();
}
-void
-TimeRasterDisplayForm::setMaxIntensity(const QString &m)
+void TimeRasterDisplayForm::setMaxIntensity(const QString& m)
{
- double new_max = m.toDouble();
- if(new_max > d_cur_min_val)
- setIntensityRange(d_cur_min_val, new_max);
+ double new_max = m.toDouble();
+ if (new_max > d_cur_min_val)
+ setIntensityRange(d_cur_min_val, new_max);
}
-void
-TimeRasterDisplayForm::setMinIntensity(const QString &m)
+void TimeRasterDisplayForm::setMinIntensity(const QString& m)
{
- double new_min = m.toDouble();
- if(new_min < d_cur_max_val)
- setIntensityRange(new_min, d_cur_max_val);
+ double new_min = m.toDouble();
+ if (new_min < d_cur_max_val)
+ setIntensityRange(new_min, d_cur_max_val);
}
-void
-TimeRasterDisplayForm::autoScale(bool en)
+void TimeRasterDisplayForm::autoScale(bool en)
{
- setIntensityRange(d_min_val, d_max_val);
+ setIntensityRange(d_min_val, d_max_val);
}
diff --git a/gr-qtgui/lib/vector_sink_f_impl.cc b/gr-qtgui/lib/vector_sink_f_impl.cc
index b1789354b0..92963b4a64 100644
--- a/gr-qtgui/lib/vector_sink_f_impl.cc
+++ b/gr-qtgui/lib/vector_sink_f_impl.cc
@@ -35,403 +35,310 @@
#include <string.h>
namespace gr {
- namespace qtgui {
-
- static const std::string MSG_PORT_OUT_XVAL = "xval";
-
- vector_sink_f::sptr
- vector_sink_f::make(
- unsigned int vlen,
- double x_start,
- double x_step,
- const std::string &x_axis_label,
- const std::string &y_axis_label,
- const std::string &name,
- int nconnections,
- QWidget *parent
- ) {
- return gnuradio::get_initial_sptr (
- new vector_sink_f_impl(
- vlen,
- x_start,
- x_step,
- x_axis_label,
- y_axis_label,
- name,
- nconnections,
- parent
- )
- );
- }
-
- vector_sink_f_impl::vector_sink_f_impl(
- unsigned int vlen,
- double x_start,
- double x_step,
- const std::string &x_axis_label,
- const std::string &y_axis_label,
- const std::string &name,
- int nconnections,
- QWidget *parent
- ) : sync_block("vector_sink_f",
- io_signature::make(1, -1, sizeof(float) * vlen),
- io_signature::make(0, 0, 0)),
- d_vlen(vlen),
- d_vecavg(1.0),
- d_name(name),
- d_nconnections(nconnections),
- d_port(pmt::mp(MSG_PORT_OUT_XVAL)),
- d_msg(pmt::mp("x")),
- d_parent(parent)
- {
- // Required now for Qt; argc must be greater than 0 and argv
- // must have at least one valid character. Must be valid through
- // life of the qApplication:
- // http://harmattan-dev.nokia.com/docs/library/html/qt4/qapplication.html
- d_argc = 1;
- d_argv = new char;
- d_argv[0] = '\0';
-
- // setup output message port to post frequency when display is
- // double-clicked
- message_port_register_out(d_port);
-
- d_main_gui = NULL;
-
- for(int i = 0; i < d_nconnections; i++) {
- d_magbufs.push_back((double*)volk_malloc(d_vlen*sizeof(double), volk_get_alignment()));
- memset(d_magbufs[i], 0, d_vlen*sizeof(double));
- }
-
- initialize(
- name,
- x_axis_label,
- y_axis_label,
- x_start,
- x_step
- );
- }
-
- vector_sink_f_impl::~vector_sink_f_impl()
- {
- if (!d_main_gui->isClosed()) {
+namespace qtgui {
+
+static const std::string MSG_PORT_OUT_XVAL = "xval";
+
+vector_sink_f::sptr vector_sink_f::make(unsigned int vlen,
+ double x_start,
+ double x_step,
+ const std::string& x_axis_label,
+ const std::string& y_axis_label,
+ const std::string& name,
+ int nconnections,
+ QWidget* parent)
+{
+ return gnuradio::get_initial_sptr(new vector_sink_f_impl(
+ vlen, x_start, x_step, x_axis_label, y_axis_label, name, nconnections, parent));
+}
+
+vector_sink_f_impl::vector_sink_f_impl(unsigned int vlen,
+ double x_start,
+ double x_step,
+ const std::string& x_axis_label,
+ const std::string& y_axis_label,
+ const std::string& name,
+ int nconnections,
+ QWidget* parent)
+ : sync_block("vector_sink_f",
+ io_signature::make(1, -1, sizeof(float) * vlen),
+ io_signature::make(0, 0, 0)),
+ d_vlen(vlen),
+ d_vecavg(1.0),
+ d_name(name),
+ d_nconnections(nconnections),
+ d_port(pmt::mp(MSG_PORT_OUT_XVAL)),
+ d_msg(pmt::mp("x")),
+ d_parent(parent)
+{
+ // Required now for Qt; argc must be greater than 0 and argv
+ // must have at least one valid character. Must be valid through
+ // life of the qApplication:
+ // http://harmattan-dev.nokia.com/docs/library/html/qt4/qapplication.html
+ d_argc = 1;
+ d_argv = new char;
+ d_argv[0] = '\0';
+
+ // setup output message port to post frequency when display is
+ // double-clicked
+ message_port_register_out(d_port);
+
+ d_main_gui = NULL;
+
+ for (int i = 0; i < d_nconnections; i++) {
+ d_magbufs.push_back(
+ (double*)volk_malloc(d_vlen * sizeof(double), volk_get_alignment()));
+ memset(d_magbufs[i], 0, d_vlen * sizeof(double));
+ }
+
+ initialize(name, x_axis_label, y_axis_label, x_start, x_step);
+}
+
+vector_sink_f_impl::~vector_sink_f_impl()
+{
+ if (!d_main_gui->isClosed()) {
d_main_gui->close();
- }
+ }
- for(int i = 0; i < d_nconnections; i++) {
+ for (int i = 0; i < d_nconnections; i++) {
volk_free(d_magbufs[i]);
- }
-
- delete d_argv;
}
- bool
- vector_sink_f_impl::check_topology(int ninputs, int noutputs)
- {
- return ninputs == d_nconnections;
- }
+ delete d_argv;
+}
- void
- vector_sink_f_impl::initialize(
- const std::string &name,
- const std::string &x_axis_label,
- const std::string &y_axis_label,
- double x_start,
- double x_step
- ) {
- if(qApp != NULL) {
+bool vector_sink_f_impl::check_topology(int ninputs, int noutputs)
+{
+ return ninputs == d_nconnections;
+}
+
+void vector_sink_f_impl::initialize(const std::string& name,
+ const std::string& x_axis_label,
+ const std::string& y_axis_label,
+ double x_start,
+ double x_step)
+{
+ if (qApp != NULL) {
d_qApplication = qApp;
- }
- else {
+ } else {
#if QT_VERSION >= 0x040500 && QT_VERSION < 0x050000
std::string style = prefs::singleton()->get_string("qtgui", "style", "raster");
QApplication::setGraphicsSystem(QString(style.c_str()));
#endif
d_qApplication = new QApplication(d_argc, &d_argv);
- }
+ }
- // If a style sheet is set in the prefs file, enable it here.
- check_set_qss(d_qApplication);
+ // If a style sheet is set in the prefs file, enable it here.
+ check_set_qss(d_qApplication);
- d_main_gui = new VectorDisplayForm(d_nconnections, d_parent);
- d_main_gui->setVecSize(d_vlen);
- set_x_axis(x_start, x_step);
+ d_main_gui = new VectorDisplayForm(d_nconnections, d_parent);
+ d_main_gui->setVecSize(d_vlen);
+ set_x_axis(x_start, x_step);
- if(! name.empty())
+ if (!name.empty())
set_title(name);
- set_x_axis_label(x_axis_label);
- set_y_axis_label(y_axis_label);
+ set_x_axis_label(x_axis_label);
+ set_y_axis_label(y_axis_label);
- // initialize update time to 10 times a second
- set_update_time(0.1);
- }
+ // initialize update time to 10 times a second
+ set_update_time(0.1);
+}
- void
- vector_sink_f_impl::exec_()
- {
- d_qApplication->exec();
- }
+void vector_sink_f_impl::exec_() { d_qApplication->exec(); }
- QWidget*
- vector_sink_f_impl::qwidget()
- {
- return d_main_gui;
- }
+QWidget* vector_sink_f_impl::qwidget() { return d_main_gui; }
#ifdef ENABLE_PYTHON
- PyObject*
- vector_sink_f_impl::pyqwidget()
- {
- PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui);
- PyObject *retarg = Py_BuildValue("N", w);
- return retarg;
- }
+PyObject* vector_sink_f_impl::pyqwidget()
+{
+ PyObject* w = PyLong_FromVoidPtr((void*)d_main_gui);
+ PyObject* retarg = Py_BuildValue("N", w);
+ return retarg;
+}
#else
- void *
- vector_sink_f_impl::pyqwidget()
- {
- return NULL;
- }
+void* vector_sink_f_impl::pyqwidget() { return NULL; }
#endif
- unsigned int
- vector_sink_f_impl::vlen() const
- {
- return d_vlen;
- }
+unsigned int vector_sink_f_impl::vlen() const { return d_vlen; }
- void
- vector_sink_f_impl::set_vec_average(const float avg)
- {
- if (avg < 0 || avg > 1.0) {
- GR_LOG_ALERT(d_logger, "Invalid average value received in set_vec_average(), must be within [0, 1].");
+void vector_sink_f_impl::set_vec_average(const float avg)
+{
+ if (avg < 0 || avg > 1.0) {
+ GR_LOG_ALERT(d_logger,
+ "Invalid average value received in set_vec_average(), must be "
+ "within [0, 1].");
return;
- }
- d_main_gui->setVecAverage(avg);
- d_vecavg = avg;
- }
-
- float
- vector_sink_f_impl::vec_average() const
- {
- return d_vecavg;
- }
-
- void
- vector_sink_f_impl::set_x_axis(const double start, const double step)
- {
- d_main_gui->setXaxis(start, step);
- }
-
- void
- vector_sink_f_impl::set_y_axis(double min, double max)
- {
- d_main_gui->setYaxis(min, max);
- }
-
- void
- vector_sink_f_impl::set_ref_level(double ref_level)
- {
- d_main_gui->setRefLevel(ref_level);
- }
-
- void
- vector_sink_f_impl::set_x_axis_label(const std::string &label)
- {
- d_main_gui->setXAxisLabel(label.c_str());
- }
-
- void
- vector_sink_f_impl::set_y_axis_label(const std::string &label)
- {
- d_main_gui->setYAxisLabel(label.c_str());
- }
-
- void
- vector_sink_f_impl::set_x_axis_units(const std::string &units)
- {
- d_main_gui->getPlot()->setXAxisUnit(units.c_str());
- }
-
- void
- vector_sink_f_impl::set_y_axis_units(const std::string &units)
- {
- d_main_gui->getPlot()->setYAxisUnit(units.c_str());
- }
-
- void
- vector_sink_f_impl::set_update_time(double t)
- {
- //convert update time to ticks
- gr::high_res_timer_type tps = gr::high_res_timer_tps();
- d_update_time = t * tps;
- d_main_gui->setUpdateTime(t);
- d_last_time = 0;
- }
-
- void
- vector_sink_f_impl::set_title(const std::string &title)
- {
- d_main_gui->setTitle(title.c_str());
- }
-
- void
- vector_sink_f_impl::set_line_label(unsigned int which, const std::string &label)
- {
- d_main_gui->setLineLabel(which, label.c_str());
- }
-
- void
- vector_sink_f_impl::set_line_color(unsigned int which, const std::string &color)
- {
- d_main_gui->setLineColor(which, color.c_str());
- }
-
- void
- vector_sink_f_impl::set_line_width(unsigned int which, int width)
- {
- d_main_gui->setLineWidth(which, width);
}
-
- void
- vector_sink_f_impl::set_line_style(unsigned int which, int style)
- {
- d_main_gui->setLineStyle(which, (Qt::PenStyle)style);
- }
-
- void
- vector_sink_f_impl::set_line_marker(unsigned int which, int marker)
- {
- d_main_gui->setLineMarker(which, (QwtSymbol::Style)marker);
- }
-
- void
- vector_sink_f_impl::set_line_alpha(unsigned int which, double alpha)
- {
- d_main_gui->setMarkerAlpha(which, (int)(255.0*alpha));
- }
-
- void
- vector_sink_f_impl::set_size(int width, int height)
- {
- d_main_gui->resize(QSize(width, height));
- }
-
- std::string
- vector_sink_f_impl::title()
- {
- return d_main_gui->title().toStdString();
- }
-
- std::string
- vector_sink_f_impl::line_label(unsigned int which)
- {
- return d_main_gui->lineLabel(which).toStdString();
- }
-
- std::string
- vector_sink_f_impl::line_color(unsigned int which)
- {
- return d_main_gui->lineColor(which).toStdString();
- }
-
- int
- vector_sink_f_impl::line_width(unsigned int which)
- {
- return d_main_gui->lineWidth(which);
- }
-
- int
- vector_sink_f_impl::line_style(unsigned int which)
- {
- return d_main_gui->lineStyle(which);
- }
-
- int
- vector_sink_f_impl::line_marker(unsigned int which)
- {
- return d_main_gui->lineMarker(which);
- }
-
- double
- vector_sink_f_impl::line_alpha(unsigned int which)
- {
- return (double)(d_main_gui->markerAlpha(which))/255.0;
- }
-
- void
- vector_sink_f_impl::enable_menu(bool en)
- {
- d_main_gui->enableMenu(en);
- }
-
- void
- vector_sink_f_impl::enable_grid(bool en)
- {
- d_main_gui->setGrid(en);
- }
-
- void
- vector_sink_f_impl::enable_autoscale(bool en)
- {
- d_main_gui->autoScale(en);
- }
-
- void
- vector_sink_f_impl::clear_max_hold()
- {
- d_main_gui->clearMaxHold();
- }
-
- void
- vector_sink_f_impl::clear_min_hold()
- {
- d_main_gui->clearMinHold();
- }
-
- void
- vector_sink_f_impl::reset()
- {
- // nop
- }
-
- void
- vector_sink_f_impl::check_clicked()
- {
- if(d_main_gui->checkClicked()) {
+ d_main_gui->setVecAverage(avg);
+ d_vecavg = avg;
+}
+
+float vector_sink_f_impl::vec_average() const { return d_vecavg; }
+
+void vector_sink_f_impl::set_x_axis(const double start, const double step)
+{
+ d_main_gui->setXaxis(start, step);
+}
+
+void vector_sink_f_impl::set_y_axis(double min, double max)
+{
+ d_main_gui->setYaxis(min, max);
+}
+
+void vector_sink_f_impl::set_ref_level(double ref_level)
+{
+ d_main_gui->setRefLevel(ref_level);
+}
+
+void vector_sink_f_impl::set_x_axis_label(const std::string& label)
+{
+ d_main_gui->setXAxisLabel(label.c_str());
+}
+
+void vector_sink_f_impl::set_y_axis_label(const std::string& label)
+{
+ d_main_gui->setYAxisLabel(label.c_str());
+}
+
+void vector_sink_f_impl::set_x_axis_units(const std::string& units)
+{
+ d_main_gui->getPlot()->setXAxisUnit(units.c_str());
+}
+
+void vector_sink_f_impl::set_y_axis_units(const std::string& units)
+{
+ d_main_gui->getPlot()->setYAxisUnit(units.c_str());
+}
+
+void vector_sink_f_impl::set_update_time(double t)
+{
+ // convert update time to ticks
+ gr::high_res_timer_type tps = gr::high_res_timer_tps();
+ d_update_time = t * tps;
+ d_main_gui->setUpdateTime(t);
+ d_last_time = 0;
+}
+
+void vector_sink_f_impl::set_title(const std::string& title)
+{
+ d_main_gui->setTitle(title.c_str());
+}
+
+void vector_sink_f_impl::set_line_label(unsigned int which, const std::string& label)
+{
+ d_main_gui->setLineLabel(which, label.c_str());
+}
+
+void vector_sink_f_impl::set_line_color(unsigned int which, const std::string& color)
+{
+ d_main_gui->setLineColor(which, color.c_str());
+}
+
+void vector_sink_f_impl::set_line_width(unsigned int which, int width)
+{
+ d_main_gui->setLineWidth(which, width);
+}
+
+void vector_sink_f_impl::set_line_style(unsigned int which, int style)
+{
+ d_main_gui->setLineStyle(which, (Qt::PenStyle)style);
+}
+
+void vector_sink_f_impl::set_line_marker(unsigned int which, int marker)
+{
+ d_main_gui->setLineMarker(which, (QwtSymbol::Style)marker);
+}
+
+void vector_sink_f_impl::set_line_alpha(unsigned int which, double alpha)
+{
+ d_main_gui->setMarkerAlpha(which, (int)(255.0 * alpha));
+}
+
+void vector_sink_f_impl::set_size(int width, int height)
+{
+ d_main_gui->resize(QSize(width, height));
+}
+
+std::string vector_sink_f_impl::title() { return d_main_gui->title().toStdString(); }
+
+std::string vector_sink_f_impl::line_label(unsigned int which)
+{
+ return d_main_gui->lineLabel(which).toStdString();
+}
+
+std::string vector_sink_f_impl::line_color(unsigned int which)
+{
+ return d_main_gui->lineColor(which).toStdString();
+}
+
+int vector_sink_f_impl::line_width(unsigned int which)
+{
+ return d_main_gui->lineWidth(which);
+}
+
+int vector_sink_f_impl::line_style(unsigned int which)
+{
+ return d_main_gui->lineStyle(which);
+}
+
+int vector_sink_f_impl::line_marker(unsigned int which)
+{
+ return d_main_gui->lineMarker(which);
+}
+
+double vector_sink_f_impl::line_alpha(unsigned int which)
+{
+ return (double)(d_main_gui->markerAlpha(which)) / 255.0;
+}
+
+void vector_sink_f_impl::enable_menu(bool en) { d_main_gui->enableMenu(en); }
+
+void vector_sink_f_impl::enable_grid(bool en) { d_main_gui->setGrid(en); }
+
+void vector_sink_f_impl::enable_autoscale(bool en) { d_main_gui->autoScale(en); }
+
+void vector_sink_f_impl::clear_max_hold() { d_main_gui->clearMaxHold(); }
+
+void vector_sink_f_impl::clear_min_hold() { d_main_gui->clearMinHold(); }
+
+void vector_sink_f_impl::reset()
+{
+ // nop
+}
+
+void vector_sink_f_impl::check_clicked()
+{
+ if (d_main_gui->checkClicked()) {
double xval = d_main_gui->getClickedXVal();
- message_port_pub(
- d_port,
- pmt::cons(d_msg, pmt::from_double(xval))
- );
- }
- }
-
- int
- vector_sink_f_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items
- ) {
- const float *in = (const float*) input_items[0];
-
- // See if we generate a message
- check_clicked();
-
- for(int i = 0; i < noutput_items; i++) {
- if(gr::high_res_timer_now() - d_last_time > d_update_time) {
- for(int n = 0; n < d_nconnections; n++) {
- in = ((const float*)input_items[n]) + d_vlen;
- for(unsigned int x = 0; x < d_vlen; x++) {
- d_magbufs[n][x] = (double)((1.0-d_vecavg)*d_magbufs[n][x] + (d_vecavg)*in[x]);
- }
+ message_port_pub(d_port, pmt::cons(d_msg, pmt::from_double(xval)));
+ }
+}
+
+int vector_sink_f_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ const float* in = (const float*)input_items[0];
+
+ // See if we generate a message
+ check_clicked();
+
+ for (int i = 0; i < noutput_items; i++) {
+ if (gr::high_res_timer_now() - d_last_time > d_update_time) {
+ for (int n = 0; n < d_nconnections; n++) {
+ in = ((const float*)input_items[n]) + d_vlen;
+ for (unsigned int x = 0; x < d_vlen; x++) {
+ d_magbufs[n][x] =
+ (double)((1.0 - d_vecavg) * d_magbufs[n][x] + (d_vecavg)*in[x]);
+ }
}
d_last_time = gr::high_res_timer_now();
d_qApplication->postEvent(d_main_gui, new FreqUpdateEvent(d_magbufs, d_vlen));
- }
}
+ }
- return noutput_items;
- }
+ return noutput_items;
+}
- } /* namespace qtgui */
+} /* namespace qtgui */
} /* namespace gr */
diff --git a/gr-qtgui/lib/vector_sink_f_impl.h b/gr-qtgui/lib/vector_sink_f_impl.h
index c7f635358e..f590941e6e 100644
--- a/gr-qtgui/lib/vector_sink_f_impl.h
+++ b/gr-qtgui/lib/vector_sink_f_impl.h
@@ -29,117 +29,113 @@
#include <gnuradio/qtgui/vectordisplayform.h>
namespace gr {
- namespace qtgui {
+namespace qtgui {
- class QTGUI_API vector_sink_f_impl : public vector_sink_f
- {
- private:
- void initialize(
- const std::string &name,
- const std::string &x_axis_label,
- const std::string &y_axis_label,
- double x_start,
- double x_step
- );
+class QTGUI_API vector_sink_f_impl : public vector_sink_f
+{
+private:
+ void initialize(const std::string& name,
+ const std::string& x_axis_label,
+ const std::string& y_axis_label,
+ double x_start,
+ double x_step);
- const unsigned int d_vlen; //!< Vector length at input
- float d_vecavg;
+ const unsigned int d_vlen; //!< Vector length at input
+ float d_vecavg;
- std::string d_name; //!< Initial title of the plot
- int d_nconnections; //!< Number of connected streaming ports on input
+ std::string d_name; //!< Initial title of the plot
+ int d_nconnections; //!< Number of connected streaming ports on input
- const pmt::pmt_t d_port;
- const pmt::pmt_t d_msg; //< Key of outgoing messages
+ const pmt::pmt_t d_port;
+ const pmt::pmt_t d_msg; //< Key of outgoing messages
- std::vector<double*> d_magbufs;
+ std::vector<double*> d_magbufs;
- int d_argc;
- char *d_argv;
- QWidget *d_parent;
- VectorDisplayForm *d_main_gui;
+ int d_argc;
+ char* d_argv;
+ QWidget* d_parent;
+ VectorDisplayForm* d_main_gui;
- gr::high_res_timer_type d_update_time;
- gr::high_res_timer_type d_last_time;
+ gr::high_res_timer_type d_update_time;
+ gr::high_res_timer_type d_last_time;
- // TODO remove this?
- void check_clicked();
+ // TODO remove this?
+ void check_clicked();
- // Handles message input port for setting new center frequency.
- // The message is a PMT pair (intern('freq'), double(frequency)).
- void handle_set_freq(pmt::pmt_t msg);
+ // Handles message input port for setting new center frequency.
+ // The message is a PMT pair (intern('freq'), double(frequency)).
+ void handle_set_freq(pmt::pmt_t msg);
- public:
- vector_sink_f_impl(
- unsigned int vlen,
- double x_start,
- double x_step,
- const std::string &x_axis_label,
- const std::string &y_axis_label,
- const std::string &name,
- int nconnections,
- QWidget *parent=NULL
- );
- ~vector_sink_f_impl();
+public:
+ vector_sink_f_impl(unsigned int vlen,
+ double x_start,
+ double x_step,
+ const std::string& x_axis_label,
+ const std::string& y_axis_label,
+ const std::string& name,
+ int nconnections,
+ QWidget* parent = NULL);
+ ~vector_sink_f_impl();
- bool check_topology(int ninputs, int noutputs);
+ bool check_topology(int ninputs, int noutputs);
- void exec_();
- QWidget* qwidget();
+ void exec_();
+ QWidget* qwidget();
#ifdef ENABLE_PYTHON
- PyObject* pyqwidget();
+ PyObject* pyqwidget();
#else
- void* pyqwidget();
+ void* pyqwidget();
#endif
- unsigned int vlen() const;
- void set_vec_average(const float avg);
- float vec_average() const;
-
- void set_frequency_range(const double centerfreq, const double bandwidth);
- void set_x_axis(const double start, const double step);
- void set_y_axis(double min, double max);
- void set_ref_level(double ref_level);
-
- void set_x_axis_label(const std::string &label);
- void set_y_axis_label(const std::string &label);
-
- void set_x_axis_units(const std::string &units);
- void set_y_axis_units(const std::string &units);
-
- void set_update_time(double t);
- void set_title(const std::string &title);
- void set_line_label(unsigned int which, const std::string &label);
- void set_line_color(unsigned int which, const std::string &color);
- void set_line_width(unsigned int which, int width);
- void set_line_style(unsigned int which, int style);
- void set_line_marker(unsigned int which, int marker);
- void set_line_alpha(unsigned int which, double alpha);
-
- std::string title();
- std::string line_label(unsigned int which);
- std::string line_color(unsigned int which);
- int line_width(unsigned int which);
- int line_style(unsigned int which);
- int line_marker(unsigned int which);
- double line_alpha(unsigned int which);
-
- void set_size(int width, int height);
-
- void enable_menu(bool en);
- void enable_grid(bool en);
- void enable_autoscale(bool en);
- void clear_max_hold();
- void clear_min_hold();
- void reset();
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace qtgui */
+ unsigned int vlen() const;
+ void set_vec_average(const float avg);
+ float vec_average() const;
+
+ void set_frequency_range(const double centerfreq, const double bandwidth);
+ void set_x_axis(const double start, const double step);
+ void set_y_axis(double min, double max);
+ void set_ref_level(double ref_level);
+
+ void set_x_axis_label(const std::string& label);
+ void set_y_axis_label(const std::string& label);
+
+ void set_x_axis_units(const std::string& units);
+ void set_y_axis_units(const std::string& units);
+
+ void set_update_time(double t);
+ void set_title(const std::string& title);
+ void set_line_label(unsigned int which, const std::string& label);
+ void set_line_color(unsigned int which, const std::string& color);
+ void set_line_width(unsigned int which, int width);
+ void set_line_style(unsigned int which, int style);
+ void set_line_marker(unsigned int which, int marker);
+ void set_line_alpha(unsigned int which, double alpha);
+
+ std::string title();
+ std::string line_label(unsigned int which);
+ std::string line_color(unsigned int which);
+ int line_width(unsigned int which);
+ int line_style(unsigned int which);
+ int line_marker(unsigned int which);
+ double line_alpha(unsigned int which);
+
+ void set_size(int width, int height);
+
+ void enable_menu(bool en);
+ void enable_grid(bool en);
+ void enable_autoscale(bool en);
+ void clear_max_hold();
+ void clear_min_hold();
+ void reset();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
+
+} /* namespace qtgui */
} /* namespace gr */
#endif /* INCLUDED_QTGUI_VECTOR_SINK_F_IMPL_H */
diff --git a/gr-qtgui/lib/vectordisplayform.cc b/gr-qtgui/lib/vectordisplayform.cc
index d1a5882d3e..d2ed550012 100644
--- a/gr-qtgui/lib/vectordisplayform.cc
+++ b/gr-qtgui/lib/vectordisplayform.cc
@@ -28,210 +28,168 @@
#include <iostream>
VectorDisplayForm::VectorDisplayForm(int nplots, QWidget* parent)
- : DisplayForm(nplots, parent)
+ : DisplayForm(nplots, parent)
{
- d_int_validator = new QIntValidator(this);
- d_int_validator->setBottom(0);
+ d_int_validator = new QIntValidator(this);
+ d_int_validator->setBottom(0);
- d_layout = new QGridLayout(this);
- d_display_plot = new VectorDisplayPlot(nplots, this);
- d_layout->addWidget(d_display_plot, 0, 0);
- setLayout(d_layout);
+ d_layout = new QGridLayout(this);
+ d_display_plot = new VectorDisplayPlot(nplots, this);
+ d_layout->addWidget(d_display_plot, 0, 0);
+ setLayout(d_layout);
- d_num_real_data_points = 1024;
- d_vecsize = 1024;
- d_vecavg = 1.0;
- d_ref_level = 0.0;
- d_clicked = false;
- d_clicked_x_level = 0;
+ d_num_real_data_points = 1024;
+ d_vecsize = 1024;
+ d_vecavg = 1.0;
+ d_ref_level = 0.0;
+ d_clicked = false;
+ d_clicked_x_level = 0;
- d_avgmenu = new AverageMenu("Average", this);
- d_menu->addMenu(d_avgmenu);
- connect(d_avgmenu, SIGNAL(whichTrigger(float)),
- this, SLOT(setVecAverage(const float)));
+ d_avgmenu = new AverageMenu("Average", this);
+ d_menu->addMenu(d_avgmenu);
+ connect(
+ d_avgmenu, SIGNAL(whichTrigger(float)), this, SLOT(setVecAverage(const float)));
- PopupMenu *maxymenu = new PopupMenu("Y Max", this);
- d_menu->addAction(maxymenu);
- connect(maxymenu, SIGNAL(whichTrigger(QString)),
- this, SLOT(setYMax(QString)));
+ PopupMenu* maxymenu = new PopupMenu("Y Max", this);
+ d_menu->addAction(maxymenu);
+ connect(maxymenu, SIGNAL(whichTrigger(QString)), this, SLOT(setYMax(QString)));
- PopupMenu *minymenu = new PopupMenu("Y Min", this);
- d_menu->addAction(minymenu);
- connect(minymenu, SIGNAL(whichTrigger(QString)),
- this, SLOT(setYMin(QString)));
+ PopupMenu* minymenu = new PopupMenu("Y Min", this);
+ d_menu->addAction(minymenu);
+ connect(minymenu, SIGNAL(whichTrigger(QString)), this, SLOT(setYMin(QString)));
- d_clearmax_act = new QAction("Clear Max", this);
- d_menu->addAction(d_clearmax_act);
- connect(d_clearmax_act, SIGNAL(triggered()),
- this, SLOT(clearMaxHold()));
- d_clearmin_act = new QAction("Clear Min", this);
- d_menu->addAction(d_clearmin_act);
- connect(d_clearmin_act, SIGNAL(triggered()),
- this, SLOT(clearMinHold()));
+ d_clearmax_act = new QAction("Clear Max", this);
+ d_menu->addAction(d_clearmax_act);
+ connect(d_clearmax_act, SIGNAL(triggered()), this, SLOT(clearMaxHold()));
+ d_clearmin_act = new QAction("Clear Min", this);
+ d_menu->addAction(d_clearmin_act);
+ connect(d_clearmin_act, SIGNAL(triggered()), this, SLOT(clearMinHold()));
- Reset();
+ Reset();
- connect(d_display_plot, SIGNAL(plotPointSelected(const QPointF)),
- this, SLOT(onPlotPointSelected(const QPointF)));
+ connect(d_display_plot,
+ SIGNAL(plotPointSelected(const QPointF)),
+ this,
+ SLOT(onPlotPointSelected(const QPointF)));
}
VectorDisplayForm::~VectorDisplayForm()
{
- // Qt deletes children when parent is deleted
+ // Qt deletes children when parent is deleted
- // Don't worry about deleting Display Plots - they are deleted when parents are deleted
- delete d_int_validator;
+ // Don't worry about deleting Display Plots - they are deleted when parents are
+ // deleted
+ delete d_int_validator;
}
-VectorDisplayPlot*
-VectorDisplayForm::getPlot()
+VectorDisplayPlot* VectorDisplayForm::getPlot()
{
- return ((VectorDisplayPlot*)d_display_plot);
+ return ((VectorDisplayPlot*)d_display_plot);
}
-void
-VectorDisplayForm::newData(const QEvent *updateEvent)
+void VectorDisplayForm::newData(const QEvent* updateEvent)
{
- FreqUpdateEvent *fevent = (FreqUpdateEvent*)updateEvent;
- const std::vector<double*> dataPoints = fevent->getPoints();
- const uint64_t numDataPoints = fevent->getNumDataPoints();
+ FreqUpdateEvent* fevent = (FreqUpdateEvent*)updateEvent;
+ const std::vector<double*> dataPoints = fevent->getPoints();
+ const uint64_t numDataPoints = fevent->getNumDataPoints();
- getPlot()->plotNewData(
- dataPoints,
- numDataPoints,
- d_ref_level,
- d_update_time
- );
+ getPlot()->plotNewData(dataPoints, numDataPoints, d_ref_level, d_update_time);
}
-void
-VectorDisplayForm::customEvent( QEvent * e)
+void VectorDisplayForm::customEvent(QEvent* e)
{
- // We just re-use FreqUpdateEvent as long as that works
- if(e->type() == FreqUpdateEvent::Type()) {
- newData(e);
- }
+ // We just re-use FreqUpdateEvent as long as that works
+ if (e->type() == FreqUpdateEvent::Type()) {
+ newData(e);
+ }
}
-int
-VectorDisplayForm::getVecSize() const
-{
- return d_vecsize;
-}
+int VectorDisplayForm::getVecSize() const { return d_vecsize; }
-float
-VectorDisplayForm::getVecAverage() const
-{
- return d_vecavg;
-}
+float VectorDisplayForm::getVecAverage() const { return d_vecavg; }
-void VectorDisplayForm::setXAxisLabel(const QString &label)
+void VectorDisplayForm::setXAxisLabel(const QString& label)
{
- getPlot()->setXAxisLabel(label);
+ getPlot()->setXAxisLabel(label);
}
-void VectorDisplayForm::setYAxisLabel(const QString &label)
+void VectorDisplayForm::setYAxisLabel(const QString& label)
{
- getPlot()->setYAxisLabel(label);
+ getPlot()->setYAxisLabel(label);
}
-void VectorDisplayForm::setRefLevel(double refLevel)
-{
- d_ref_level = refLevel;
-}
+void VectorDisplayForm::setRefLevel(double refLevel) { d_ref_level = refLevel; }
-void
-VectorDisplayForm::setVecSize(const int newsize)
+void VectorDisplayForm::setVecSize(const int newsize)
{
- d_vecsize = newsize;
- getPlot()->replot();
+ d_vecsize = newsize;
+ getPlot()->replot();
}
-void
-VectorDisplayForm::setVecAverage(const float newavg)
+void VectorDisplayForm::setVecAverage(const float newavg)
{
- d_vecavg = newavg;
- d_avgmenu->getActionFromAvg(newavg)->setChecked(true);
- getPlot()->replot();
+ d_vecavg = newavg;
+ d_avgmenu->getActionFromAvg(newavg)->setChecked(true);
+ getPlot()->replot();
}
void VectorDisplayForm::setXaxis(double start, double step)
{
- getPlot()->setXAxisValues(start, step);
+ getPlot()->setXAxisValues(start, step);
}
-void
-VectorDisplayForm::setYaxis(double min, double max)
+void VectorDisplayForm::setYaxis(double min, double max)
{
- getPlot()->setYaxis(min, max);
+ getPlot()->setYaxis(min, max);
}
-void
-VectorDisplayForm::setYMax(const QString &m)
+void VectorDisplayForm::setYMax(const QString& m)
{
- double new_max = m.toDouble();
- double cur_ymin = getPlot()->getYMin();
- if(new_max > cur_ymin)
- setYaxis(cur_ymin, new_max);
+ double new_max = m.toDouble();
+ double cur_ymin = getPlot()->getYMin();
+ if (new_max > cur_ymin)
+ setYaxis(cur_ymin, new_max);
}
-void
-VectorDisplayForm::setYMin(const QString &m)
+void VectorDisplayForm::setYMin(const QString& m)
{
- double new_min = m.toDouble();
- double cur_ymax = getPlot()->getYMax();
- if(new_min < cur_ymax)
- setYaxis(new_min, cur_ymax);
+ double new_min = m.toDouble();
+ double cur_ymax = getPlot()->getYMax();
+ if (new_min < cur_ymax)
+ setYaxis(new_min, cur_ymax);
}
-void
-VectorDisplayForm::autoScale(bool en)
+void VectorDisplayForm::autoScale(bool en)
{
- if(en) {
- d_autoscale_state = true;
- }
- else {
- d_autoscale_state = false;
- }
+ if (en) {
+ d_autoscale_state = true;
+ } else {
+ d_autoscale_state = false;
+ }
- d_autoscale_act->setChecked(en);
- getPlot()->setAutoScale(d_autoscale_state);
- getPlot()->replot();
+ d_autoscale_act->setChecked(en);
+ getPlot()->setAutoScale(d_autoscale_state);
+ getPlot()->replot();
}
-void
-VectorDisplayForm::clearMaxHold()
-{
- getPlot()->clearMaxData();
-}
+void VectorDisplayForm::clearMaxHold() { getPlot()->clearMaxData(); }
-void
-VectorDisplayForm::clearMinHold()
-{
- getPlot()->clearMinData();
-}
+void VectorDisplayForm::clearMinHold() { getPlot()->clearMinData(); }
-void
-VectorDisplayForm::onPlotPointSelected(const QPointF p)
+void VectorDisplayForm::onPlotPointSelected(const QPointF p)
{
- d_clicked = true;
- d_clicked_x_level = p.x();
+ d_clicked = true;
+ d_clicked_x_level = p.x();
}
-bool
-VectorDisplayForm::checkClicked()
+bool VectorDisplayForm::checkClicked()
{
- if(d_clicked) {
- d_clicked = false;
- return true;
- }
- else {
- return false;
- }
+ if (d_clicked) {
+ d_clicked = false;
+ return true;
+ } else {
+ return false;
+ }
}
-float
-VectorDisplayForm::getClickedXVal() const
-{
- return d_clicked_x_level;
-}
+float VectorDisplayForm::getClickedXVal() const { return d_clicked_x_level; }
diff --git a/gr-qtgui/lib/waterfallGlobalData.cc b/gr-qtgui/lib/waterfallGlobalData.cc
index 09d8b7efd2..3f370c1952 100644
--- a/gr-qtgui/lib/waterfallGlobalData.cc
+++ b/gr-qtgui/lib/waterfallGlobalData.cc
@@ -28,141 +28,135 @@
#include <cstdio>
WaterfallData::WaterfallData(const double minimumFrequency,
- const double maximumFrequency,
- const uint64_t fftPoints,
- const unsigned int historyExtent)
+ const double maximumFrequency,
+ const uint64_t fftPoints,
+ const unsigned int historyExtent)
#if QWT_VERSION < 0x060000
- : QwtRasterData(QwtDoubleRect(minimumFrequency /* X START */, 0 /* Y START */,
- maximumFrequency - minimumFrequency /* WIDTH */,
- static_cast<double>(historyExtent)/* HEIGHT */))
+ : QwtRasterData(QwtDoubleRect(minimumFrequency /* X START */,
+ 0 /* Y START */,
+ maximumFrequency - minimumFrequency /* WIDTH */,
+ static_cast<double>(historyExtent) /* HEIGHT */))
#else
: QwtRasterData()
#endif
{
- _intensityRange = QwtDoubleInterval(-200.0, 0.0);
+ _intensityRange = QwtDoubleInterval(-200.0, 0.0);
- _fftPoints = fftPoints;
- _historyLength = historyExtent;
+ _fftPoints = fftPoints;
+ _historyLength = historyExtent;
- _spectrumData = new double[_fftPoints * _historyLength];
+ _spectrumData = new double[_fftPoints * _historyLength];
#if QWT_VERSION >= 0x060000
- setInterval(Qt::XAxis, QwtInterval(minimumFrequency, maximumFrequency));
- setInterval(Qt::YAxis, QwtInterval(0, historyExtent));
- setInterval(Qt::ZAxis, QwtInterval(-200, 0.0));
+ setInterval(Qt::XAxis, QwtInterval(minimumFrequency, maximumFrequency));
+ setInterval(Qt::YAxis, QwtInterval(0, historyExtent));
+ setInterval(Qt::ZAxis, QwtInterval(-200, 0.0));
#endif
- reset();
+ reset();
}
-WaterfallData::~WaterfallData()
-{
- delete[] _spectrumData;
-}
+WaterfallData::~WaterfallData() { delete[] _spectrumData; }
void WaterfallData::reset()
{
- memset(_spectrumData, 0x0, _fftPoints*_historyLength*sizeof(double));
+ memset(_spectrumData, 0x0, _fftPoints * _historyLength * sizeof(double));
- _numLinesToUpdate = -1;
+ _numLinesToUpdate = -1;
}
void WaterfallData::copy(const WaterfallData* rhs)
{
#if QWT_VERSION < 0x060000
- if((_fftPoints != rhs->getNumFFTPoints()) ||
- (boundingRect() != rhs->boundingRect()) ){
- _fftPoints = rhs->getNumFFTPoints();
- setBoundingRect(rhs->boundingRect());
- delete[] _spectrumData;
- _spectrumData = new double[_fftPoints * _historyLength];
- }
+ if ((_fftPoints != rhs->getNumFFTPoints()) ||
+ (boundingRect() != rhs->boundingRect())) {
+ _fftPoints = rhs->getNumFFTPoints();
+ setBoundingRect(rhs->boundingRect());
+ delete[] _spectrumData;
+ _spectrumData = new double[_fftPoints * _historyLength];
+ }
#else
- if(_fftPoints != rhs->getNumFFTPoints()) {
- _fftPoints = rhs->getNumFFTPoints();
- delete[] _spectrumData;
- _spectrumData = new double[_fftPoints * _historyLength];
- }
+ if (_fftPoints != rhs->getNumFFTPoints()) {
+ _fftPoints = rhs->getNumFFTPoints();
+ delete[] _spectrumData;
+ _spectrumData = new double[_fftPoints * _historyLength];
+ }
#endif
- reset();
- setSpectrumDataBuffer(rhs->getSpectrumDataBuffer());
- setNumLinesToUpdate(rhs->getNumLinesToUpdate());
+ reset();
+ setSpectrumDataBuffer(rhs->getSpectrumDataBuffer());
+ setNumLinesToUpdate(rhs->getNumLinesToUpdate());
#if QWT_VERSION < 0x060000
- setRange(rhs->range());
+ setRange(rhs->range());
#else
- setInterval(Qt::XAxis, rhs->interval(Qt::XAxis));
- setInterval(Qt::YAxis, rhs->interval(Qt::YAxis));
- setInterval(Qt::ZAxis, rhs->interval(Qt::ZAxis));
+ setInterval(Qt::XAxis, rhs->interval(Qt::XAxis));
+ setInterval(Qt::YAxis, rhs->interval(Qt::YAxis));
+ setInterval(Qt::ZAxis, rhs->interval(Qt::ZAxis));
#endif
}
void WaterfallData::resizeData(const double startFreq,
- const double stopFreq,
- const uint64_t fftPoints,
+ const double stopFreq,
+ const uint64_t fftPoints,
const int history)
{
- if(history > 0) {
- _historyLength = history;
- }
+ if (history > 0) {
+ _historyLength = history;
+ }
#if QWT_VERSION < 0x060000
- if((fftPoints != getNumFFTPoints()) ||
- (boundingRect().width() != (stopFreq - startFreq)) ||
- (boundingRect().left() != startFreq)){
-
- setBoundingRect(QwtDoubleRect(startFreq, 0,
- stopFreq-startFreq,
- static_cast<double>(_historyLength)));
- _fftPoints = fftPoints;
- delete[] _spectrumData;
- _spectrumData = new double[_fftPoints * _historyLength];
- }
+ if ((fftPoints != getNumFFTPoints()) ||
+ (boundingRect().width() != (stopFreq - startFreq)) ||
+ (boundingRect().left() != startFreq)) {
+
+ setBoundingRect(QwtDoubleRect(
+ startFreq, 0, stopFreq - startFreq, static_cast<double>(_historyLength)));
+ _fftPoints = fftPoints;
+ delete[] _spectrumData;
+ _spectrumData = new double[_fftPoints * _historyLength];
+ }
#else
- if((fftPoints != getNumFFTPoints()) ||
- (interval(Qt::XAxis).width() != (stopFreq - startFreq)) ||
- (interval(Qt::XAxis).minValue() != startFreq)){
+ if ((fftPoints != getNumFFTPoints()) ||
+ (interval(Qt::XAxis).width() != (stopFreq - startFreq)) ||
+ (interval(Qt::XAxis).minValue() != startFreq)) {
- setInterval(Qt::XAxis, QwtInterval(startFreq, stopFreq));
- setInterval(Qt::YAxis, QwtInterval(0, _historyLength));
+ setInterval(Qt::XAxis, QwtInterval(startFreq, stopFreq));
+ setInterval(Qt::YAxis, QwtInterval(0, _historyLength));
- _fftPoints = fftPoints;
- delete[] _spectrumData;
- _spectrumData = new double[_fftPoints * _historyLength];
- }
+ _fftPoints = fftPoints;
+ delete[] _spectrumData;
+ _spectrumData = new double[_fftPoints * _historyLength];
+ }
#endif
- reset();
+ reset();
}
-QwtRasterData *WaterfallData::copy() const
+QwtRasterData* WaterfallData::copy() const
{
#if QWT_VERSION < 0x060000
- WaterfallData* returnData = new WaterfallData(boundingRect().left(),
- boundingRect().right(),
- _fftPoints, _historyLength);
+ WaterfallData* returnData = new WaterfallData(
+ boundingRect().left(), boundingRect().right(), _fftPoints, _historyLength);
#else
- WaterfallData* returnData = new WaterfallData(interval(Qt::XAxis).minValue(),
- interval(Qt::XAxis).maxValue(),
- _fftPoints, _historyLength);
+ WaterfallData* returnData = new WaterfallData(interval(Qt::XAxis).minValue(),
+ interval(Qt::XAxis).maxValue(),
+ _fftPoints,
+ _historyLength);
#endif
- returnData->copy(this);
- return returnData;
+ returnData->copy(this);
+ return returnData;
}
#if QWT_VERSION < 0x060000
-QwtDoubleInterval WaterfallData::range() const
-{
- return _intensityRange;
-}
+QwtDoubleInterval WaterfallData::range() const { return _intensityRange; }
void WaterfallData::setRange(const QwtDoubleInterval& newRange)
{
- _intensityRange = newRange;
+ _intensityRange = newRange;
}
#endif
@@ -170,90 +164,84 @@ void WaterfallData::setRange(const QwtDoubleInterval& newRange)
double WaterfallData::value(double x, double y) const
{
- double returnValue = 0.0;
+ double returnValue = 0.0;
#if QWT_VERSION < 0x060000
- const unsigned int intY = static_cast<unsigned int>((1.0 - (y/boundingRect().height())) *
- static_cast<double>(_historyLength-1));
- const unsigned int intX = static_cast<unsigned int>((((x - boundingRect().left()) / boundingRect().width()) *
- static_cast<double>(_fftPoints-1)) + 0.5);
+ const unsigned int intY = static_cast<unsigned int>(
+ (1.0 - (y / boundingRect().height())) * static_cast<double>(_historyLength - 1));
+ const unsigned int intX = static_cast<unsigned int>(
+ (((x - boundingRect().left()) / boundingRect().width()) *
+ static_cast<double>(_fftPoints - 1)) +
+ 0.5);
#else
- double height = interval(Qt::YAxis).maxValue();
- double left = interval(Qt::XAxis).minValue();
- double right = interval(Qt::XAxis).maxValue();
- double ylen = static_cast<double>(_historyLength-1);
- double xlen = static_cast<double>(_fftPoints-1);
- const unsigned int intY = static_cast<unsigned int>((1.0 - y/height) * ylen);
- const unsigned int intX = static_cast<unsigned int>((((x - left) / (right-left)) * xlen) + 0.5);
+ double height = interval(Qt::YAxis).maxValue();
+ double left = interval(Qt::XAxis).minValue();
+ double right = interval(Qt::XAxis).maxValue();
+ double ylen = static_cast<double>(_historyLength - 1);
+ double xlen = static_cast<double>(_fftPoints - 1);
+ const unsigned int intY = static_cast<unsigned int>((1.0 - y / height) * ylen);
+ const unsigned int intX =
+ static_cast<unsigned int>((((x - left) / (right - left)) * xlen) + 0.5);
#endif
- const int location = (intY * _fftPoints) + intX;
- if((location > -1) && (location < static_cast<int64_t>(_fftPoints * _historyLength))){
- returnValue = _spectrumData[location];
- }
+ const int location = (intY * _fftPoints) + intX;
+ if ((location > -1) &&
+ (location < static_cast<int64_t>(_fftPoints * _historyLength))) {
+ returnValue = _spectrumData[location];
+ }
- return returnValue;
+ return returnValue;
}
-uint64_t WaterfallData::getNumFFTPoints() const
-{
- return _fftPoints;
-}
+uint64_t WaterfallData::getNumFFTPoints() const { return _fftPoints; }
void WaterfallData::addFFTData(const double* fftData,
- const uint64_t fftDataSize,
- const int droppedFrames){
- if(fftDataSize == _fftPoints){
- int64_t heightOffset = _historyLength - 1 - droppedFrames;
- uint64_t drawingDroppedFrames = droppedFrames;
-
- // Any valid data rolled off the display so just fill in zeros and write new data
- if(heightOffset < 0){
- heightOffset = 0;
- drawingDroppedFrames = static_cast<uint64_t>(_historyLength-1);
- }
-
- // Copy the old data over if any available
- if(heightOffset > 0){
- memmove( _spectrumData, &_spectrumData[(drawingDroppedFrames+1) * _fftPoints],
- heightOffset * _fftPoints * sizeof(double)) ;
- }
-
- if(drawingDroppedFrames > 0){
- // Fill in zeros data for dropped data
- memset(&_spectrumData[heightOffset * _fftPoints], 0x00,
- static_cast<int64_t>(drawingDroppedFrames) * _fftPoints * sizeof(double));
+ const uint64_t fftDataSize,
+ const int droppedFrames)
+{
+ if (fftDataSize == _fftPoints) {
+ int64_t heightOffset = _historyLength - 1 - droppedFrames;
+ uint64_t drawingDroppedFrames = droppedFrames;
+
+ // Any valid data rolled off the display so just fill in zeros and write new data
+ if (heightOffset < 0) {
+ heightOffset = 0;
+ drawingDroppedFrames = static_cast<uint64_t>(_historyLength - 1);
+ }
+
+ // Copy the old data over if any available
+ if (heightOffset > 0) {
+ memmove(_spectrumData,
+ &_spectrumData[(drawingDroppedFrames + 1) * _fftPoints],
+ heightOffset * _fftPoints * sizeof(double));
+ }
+
+ if (drawingDroppedFrames > 0) {
+ // Fill in zeros data for dropped data
+ memset(&_spectrumData[heightOffset * _fftPoints],
+ 0x00,
+ static_cast<int64_t>(drawingDroppedFrames) * _fftPoints *
+ sizeof(double));
+ }
+
+ // add the new buffer
+ memcpy(&_spectrumData[(_historyLength - 1) * _fftPoints],
+ fftData,
+ _fftPoints * sizeof(double));
}
-
- // add the new buffer
- memcpy(&_spectrumData[(_historyLength - 1) * _fftPoints], fftData,
- _fftPoints*sizeof(double));
- }
}
-double* WaterfallData::getSpectrumDataBuffer() const
-{
- return _spectrumData;
-}
+double* WaterfallData::getSpectrumDataBuffer() const { return _spectrumData; }
void WaterfallData::setSpectrumDataBuffer(const double* newData)
{
- memcpy(_spectrumData, newData, _fftPoints * _historyLength * sizeof(double));
+ memcpy(_spectrumData, newData, _fftPoints * _historyLength * sizeof(double));
}
-int WaterfallData::getNumLinesToUpdate() const
-{
- return _numLinesToUpdate;
-}
+int WaterfallData::getNumLinesToUpdate() const { return _numLinesToUpdate; }
-void WaterfallData::setNumLinesToUpdate(const int newNum)
-{
- _numLinesToUpdate = newNum;
-}
+void WaterfallData::setNumLinesToUpdate(const int newNum) { _numLinesToUpdate = newNum; }
-void WaterfallData::incrementNumLinesToUpdate()
-{
- _numLinesToUpdate++;
-}
+void WaterfallData::incrementNumLinesToUpdate() { _numLinesToUpdate++; }
#endif /* WATERFALL_GLOBAL_DATA_CPP */
diff --git a/gr-qtgui/lib/waterfall_sink_c_impl.cc b/gr-qtgui/lib/waterfall_sink_c_impl.cc
index eac4badce5..b2f5751eab 100644
--- a/gr-qtgui/lib/waterfall_sink_c_impl.cc
+++ b/gr-qtgui/lib/waterfall_sink_c_impl.cc
@@ -36,424 +36,343 @@
#include <string.h>
namespace gr {
- namespace qtgui {
-
- waterfall_sink_c::sptr
- waterfall_sink_c::make(int fftsize, int wintype,
- double fc, double bw,
- const std::string &name,
- int nconnections,
- QWidget *parent)
- {
- return gnuradio::get_initial_sptr
- (new waterfall_sink_c_impl(fftsize, wintype,
- fc, bw, name,
- nconnections,
- parent));
- }
-
- waterfall_sink_c_impl::waterfall_sink_c_impl(int fftsize, int wintype,
- double fc, double bw,
- const std::string &name,
- int nconnections,
- QWidget *parent)
- : sync_block("waterfall_sink_c",
- io_signature::make(0, nconnections, sizeof(gr_complex)),
- io_signature::make(0, 0, 0)),
- d_fftsize(fftsize),
- d_fft_shift(fftsize),
- d_fftavg(1.0),
- d_wintype((filter::firdes::win_type)(wintype)),
- d_center_freq(fc),
- d_bandwidth(bw),
- d_name(name),
- d_nconnections(nconnections),
- d_nrows(200),
- d_port(pmt::mp("freq")),
- d_port_bw(pmt::mp("bw")),
- d_parent(parent)
- {
- // Required now for Qt; argc must be greater than 0 and argv
- // must have at least one valid character. Must be valid through
- // life of the qApplication:
- // http://harmattan-dev.nokia.com/docs/library/html/qt4/qapplication.html
- d_argc = 1;
- d_argv = new char;
- d_argv[0] = '\0';
-
- d_main_gui = NULL;
-
- // Perform fftshift operation;
- // this is usually desired when plotting
- d_shift = true;
-
- d_fft = new fft::fft_complex(d_fftsize, true);
- d_fbuf = (float*)volk_malloc(d_fftsize*sizeof(float),
- volk_get_alignment());
- memset(d_fbuf, 0, d_fftsize*sizeof(float));
-
- d_index = 0;
- // save the last "connection" for the PDU memory
- for(int i = 0; i < d_nconnections; i++) {
- d_residbufs.push_back((gr_complex*)volk_malloc(d_fftsize*sizeof(gr_complex),
+namespace qtgui {
+
+waterfall_sink_c::sptr waterfall_sink_c::make(int fftsize,
+ int wintype,
+ double fc,
+ double bw,
+ const std::string& name,
+ int nconnections,
+ QWidget* parent)
+{
+ return gnuradio::get_initial_sptr(
+ new waterfall_sink_c_impl(fftsize, wintype, fc, bw, name, nconnections, parent));
+}
+
+waterfall_sink_c_impl::waterfall_sink_c_impl(int fftsize,
+ int wintype,
+ double fc,
+ double bw,
+ const std::string& name,
+ int nconnections,
+ QWidget* parent)
+ : sync_block("waterfall_sink_c",
+ io_signature::make(0, nconnections, sizeof(gr_complex)),
+ io_signature::make(0, 0, 0)),
+ d_fftsize(fftsize),
+ d_fft_shift(fftsize),
+ d_fftavg(1.0),
+ d_wintype((filter::firdes::win_type)(wintype)),
+ d_center_freq(fc),
+ d_bandwidth(bw),
+ d_name(name),
+ d_nconnections(nconnections),
+ d_nrows(200),
+ d_port(pmt::mp("freq")),
+ d_port_bw(pmt::mp("bw")),
+ d_parent(parent)
+{
+ // Required now for Qt; argc must be greater than 0 and argv
+ // must have at least one valid character. Must be valid through
+ // life of the qApplication:
+ // http://harmattan-dev.nokia.com/docs/library/html/qt4/qapplication.html
+ d_argc = 1;
+ d_argv = new char;
+ d_argv[0] = '\0';
+
+ d_main_gui = NULL;
+
+ // Perform fftshift operation;
+ // this is usually desired when plotting
+ d_shift = true;
+
+ d_fft = new fft::fft_complex(d_fftsize, true);
+ d_fbuf = (float*)volk_malloc(d_fftsize * sizeof(float), volk_get_alignment());
+ memset(d_fbuf, 0, d_fftsize * sizeof(float));
+
+ d_index = 0;
+ // save the last "connection" for the PDU memory
+ for (int i = 0; i < d_nconnections; i++) {
+ d_residbufs.push_back((gr_complex*)volk_malloc(d_fftsize * sizeof(gr_complex),
volk_get_alignment()));
- d_magbufs.push_back((double*)volk_malloc(d_fftsize*sizeof(double),
- volk_get_alignment()));
- memset(d_residbufs[i], 0, d_fftsize*sizeof(gr_complex));
- memset(d_magbufs[i], 0, d_fftsize*sizeof(double));
- }
-
- d_residbufs.push_back((gr_complex*)volk_malloc(d_fftsize*sizeof(gr_complex),
- volk_get_alignment()));
- d_pdu_magbuf = (double*)volk_malloc(d_fftsize*sizeof(double)*d_nrows,
- volk_get_alignment());
- d_magbufs.push_back(d_pdu_magbuf);
- memset(d_pdu_magbuf, 0, d_fftsize*sizeof(double)*d_nrows);
- memset(d_residbufs[d_nconnections], 0, d_fftsize*sizeof(gr_complex));
-
- buildwindow();
-
- initialize();
-
- // setup bw input port
- message_port_register_in(d_port_bw);
- set_msg_handler(d_port_bw,
- boost::bind(&waterfall_sink_c_impl::handle_set_bw, this, _1));
-
- // setup output message port to post frequency when display is
- // double-clicked
- message_port_register_out(d_port);
- message_port_register_in(d_port);
- set_msg_handler(d_port,
- boost::bind(&waterfall_sink_c_impl::handle_set_freq, this, _1));
-
- // setup PDU handling input port
- message_port_register_in(pmt::mp("in"));
- set_msg_handler(pmt::mp("in"),
- boost::bind(&waterfall_sink_c_impl::handle_pdus, this, _1));
- }
-
- waterfall_sink_c_impl::~waterfall_sink_c_impl()
- {
- if(!d_main_gui->isClosed())
+ d_magbufs.push_back(
+ (double*)volk_malloc(d_fftsize * sizeof(double), volk_get_alignment()));
+ memset(d_residbufs[i], 0, d_fftsize * sizeof(gr_complex));
+ memset(d_magbufs[i], 0, d_fftsize * sizeof(double));
+ }
+
+ d_residbufs.push_back(
+ (gr_complex*)volk_malloc(d_fftsize * sizeof(gr_complex), volk_get_alignment()));
+ d_pdu_magbuf =
+ (double*)volk_malloc(d_fftsize * sizeof(double) * d_nrows, volk_get_alignment());
+ d_magbufs.push_back(d_pdu_magbuf);
+ memset(d_pdu_magbuf, 0, d_fftsize * sizeof(double) * d_nrows);
+ memset(d_residbufs[d_nconnections], 0, d_fftsize * sizeof(gr_complex));
+
+ buildwindow();
+
+ initialize();
+
+ // setup bw input port
+ message_port_register_in(d_port_bw);
+ set_msg_handler(d_port_bw,
+ boost::bind(&waterfall_sink_c_impl::handle_set_bw, this, _1));
+
+ // setup output message port to post frequency when display is
+ // double-clicked
+ message_port_register_out(d_port);
+ message_port_register_in(d_port);
+ set_msg_handler(d_port,
+ boost::bind(&waterfall_sink_c_impl::handle_set_freq, this, _1));
+
+ // setup PDU handling input port
+ message_port_register_in(pmt::mp("in"));
+ set_msg_handler(pmt::mp("in"),
+ boost::bind(&waterfall_sink_c_impl::handle_pdus, this, _1));
+}
+
+waterfall_sink_c_impl::~waterfall_sink_c_impl()
+{
+ if (!d_main_gui->isClosed())
d_main_gui->close();
- for(int i = 0; i < (int)d_residbufs.size(); i++) {
+ for (int i = 0; i < (int)d_residbufs.size(); i++) {
volk_free(d_residbufs[i]);
volk_free(d_magbufs[i]);
- }
- delete d_fft;
- volk_free(d_fbuf);
-
- delete d_argv;
}
+ delete d_fft;
+ volk_free(d_fbuf);
- bool
- waterfall_sink_c_impl::check_topology(int ninputs, int noutputs)
- {
- return ninputs == d_nconnections;
- }
+ delete d_argv;
+}
- void
- waterfall_sink_c_impl::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_fftsize, 8191);
- }
+bool waterfall_sink_c_impl::check_topology(int ninputs, int noutputs)
+{
+ return ninputs == d_nconnections;
+}
+
+void waterfall_sink_c_impl::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_fftsize, 8191);
}
+}
- void
- waterfall_sink_c_impl::initialize()
- {
- if(qApp != NULL) {
- d_qApplication = qApp;
- }
- else {
+void waterfall_sink_c_impl::initialize()
+{
+ if (qApp != NULL) {
+ d_qApplication = qApp;
+ } else {
#if QT_VERSION >= 0x040500 && QT_VERSION < 0x050000
std::string style = prefs::singleton()->get_string("qtgui", "style", "raster");
QApplication::setGraphicsSystem(QString(style.c_str()));
#endif
- d_qApplication = new QApplication(d_argc, &d_argv);
- }
+ d_qApplication = new QApplication(d_argc, &d_argv);
+ }
- // If a style sheet is set in the prefs file, enable it here.
- check_set_qss(d_qApplication);
+ // If a style sheet is set in the prefs file, enable it here.
+ check_set_qss(d_qApplication);
- int numplots = (d_nconnections > 0) ? d_nconnections : 1;
- d_main_gui = new WaterfallDisplayForm(numplots, d_parent);
- set_fft_window(d_wintype);
- set_fft_size(d_fftsize);
- set_frequency_range(d_center_freq, d_bandwidth);
+ int numplots = (d_nconnections > 0) ? d_nconnections : 1;
+ d_main_gui = new WaterfallDisplayForm(numplots, d_parent);
+ set_fft_window(d_wintype);
+ set_fft_size(d_fftsize);
+ set_frequency_range(d_center_freq, d_bandwidth);
- if(d_name.size() > 0)
+ if (d_name.size() > 0)
set_title(d_name);
- // initialize update time to 10 times a second
- set_update_time(0.1);
- }
+ // initialize update time to 10 times a second
+ set_update_time(0.1);
+}
- void
- waterfall_sink_c_impl::exec_()
- {
- d_qApplication->exec();
- }
+void waterfall_sink_c_impl::exec_() { d_qApplication->exec(); }
- QWidget*
- waterfall_sink_c_impl::qwidget()
- {
- return d_main_gui;
- }
+QWidget* waterfall_sink_c_impl::qwidget() { return d_main_gui; }
#ifdef ENABLE_PYTHON
- PyObject*
- waterfall_sink_c_impl::pyqwidget()
- {
- PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui);
- PyObject *retarg = Py_BuildValue("N", w);
- return retarg;
- }
+PyObject* waterfall_sink_c_impl::pyqwidget()
+{
+ PyObject* w = PyLong_FromVoidPtr((void*)d_main_gui);
+ PyObject* retarg = Py_BuildValue("N", w);
+ return retarg;
+}
#else
- void *
- waterfall_sink_c_impl::pyqwidget()
- {
- return NULL;
- }
+void* waterfall_sink_c_impl::pyqwidget() { return NULL; }
#endif
- void
- waterfall_sink_c_impl::clear_data()
- {
- d_main_gui->clearData();
- }
-
- void
- waterfall_sink_c_impl::set_fft_size(const int fftsize)
- {
- d_main_gui->setFFTSize(fftsize);
- }
-
- int
- waterfall_sink_c_impl::fft_size() const
- {
- return d_fftsize;
- }
-
- void
- waterfall_sink_c_impl::set_fft_average(const float fftavg)
- {
- d_main_gui->setFFTAverage(fftavg);
- }
-
- float
- waterfall_sink_c_impl::fft_average() const
- {
- return d_fftavg;
- }
-
- void
- waterfall_sink_c_impl::set_fft_window(const filter::firdes::win_type win)
- {
- d_main_gui->setFFTWindowType(win);
- }
-
- filter::firdes::win_type
- waterfall_sink_c_impl::fft_window()
- {
- return d_wintype;
- }
-
- void
- waterfall_sink_c_impl::set_frequency_range(const double centerfreq,
- const double bandwidth)
- {
- d_center_freq = centerfreq;
- d_bandwidth = bandwidth;
- d_main_gui->setFrequencyRange(d_center_freq, d_bandwidth);
- }
-
- void
- waterfall_sink_c_impl::set_intensity_range(const double min,
- const double max)
- {
- d_main_gui->setIntensityRange(min, max);
- }
-
- void
- waterfall_sink_c_impl::set_update_time(double t)
- {
- //convert update time to ticks
- gr::high_res_timer_type tps = gr::high_res_timer_tps();
- d_update_time = t * tps;
- d_main_gui->setUpdateTime(t);
- d_last_time = 0;
- }
-
- void
- waterfall_sink_c_impl::set_title(const std::string &title)
- {
- d_main_gui->setTitle(title.c_str());
- }
-
- void
- waterfall_sink_c_impl::set_time_title(const std::string &title)
- {
- d_main_gui->setTimeTitle(title);
- }
-
- void
- waterfall_sink_c_impl::set_line_label(unsigned int which, const std::string &label)
- {
- d_main_gui->setLineLabel(which, label.c_str());
- }
-
- void
- waterfall_sink_c_impl::set_color_map(unsigned int which, const int color)
- {
- d_main_gui->setColorMap(which, color);
- }
+void waterfall_sink_c_impl::clear_data() { d_main_gui->clearData(); }
+
+void waterfall_sink_c_impl::set_fft_size(const int fftsize)
+{
+ d_main_gui->setFFTSize(fftsize);
+}
+
+int waterfall_sink_c_impl::fft_size() const { return d_fftsize; }
+
+void waterfall_sink_c_impl::set_fft_average(const float fftavg)
+{
+ d_main_gui->setFFTAverage(fftavg);
+}
- void
- waterfall_sink_c_impl::set_line_alpha(unsigned int which, double alpha)
- {
- d_main_gui->setAlpha(which, (int)(255.0*alpha));
- }
+float waterfall_sink_c_impl::fft_average() const { return d_fftavg; }
+
+void waterfall_sink_c_impl::set_fft_window(const filter::firdes::win_type win)
+{
+ d_main_gui->setFFTWindowType(win);
+}
- void
- waterfall_sink_c_impl::set_size(int width, int height)
- {
- d_main_gui->resize(QSize(width, height));
- }
+filter::firdes::win_type waterfall_sink_c_impl::fft_window() { return d_wintype; }
- std::string
- waterfall_sink_c_impl::title()
- {
- return d_main_gui->title().toStdString();
- }
+void waterfall_sink_c_impl::set_frequency_range(const double centerfreq,
+ const double bandwidth)
+{
+ d_center_freq = centerfreq;
+ d_bandwidth = bandwidth;
+ d_main_gui->setFrequencyRange(d_center_freq, d_bandwidth);
+}
- std::string
- waterfall_sink_c_impl::line_label(unsigned int which)
- {
- return d_main_gui->lineLabel(which).toStdString();
- }
+void waterfall_sink_c_impl::set_intensity_range(const double min, const double max)
+{
+ d_main_gui->setIntensityRange(min, max);
+}
- int
- waterfall_sink_c_impl::color_map(unsigned int which)
- {
- return d_main_gui->getColorMap(which);
- }
+void waterfall_sink_c_impl::set_update_time(double t)
+{
+ // convert update time to ticks
+ gr::high_res_timer_type tps = gr::high_res_timer_tps();
+ d_update_time = t * tps;
+ d_main_gui->setUpdateTime(t);
+ d_last_time = 0;
+}
- double
- waterfall_sink_c_impl::line_alpha(unsigned int which)
- {
- return (double)(d_main_gui->markerAlpha(which))/255.0;
- }
+void waterfall_sink_c_impl::set_title(const std::string& title)
+{
+ d_main_gui->setTitle(title.c_str());
+}
- void
- waterfall_sink_c_impl::auto_scale()
- {
- d_main_gui->autoScale();
- }
+void waterfall_sink_c_impl::set_time_title(const std::string& title)
+{
+ d_main_gui->setTimeTitle(title);
+}
- double
- waterfall_sink_c_impl::min_intensity(unsigned int which)
- {
- return d_main_gui->getMinIntensity(which);
- }
+void waterfall_sink_c_impl::set_line_label(unsigned int which, const std::string& label)
+{
+ d_main_gui->setLineLabel(which, label.c_str());
+}
- double
- waterfall_sink_c_impl::max_intensity(unsigned int which)
- {
- return d_main_gui->getMaxIntensity(which);
- }
+void waterfall_sink_c_impl::set_color_map(unsigned int which, const int color)
+{
+ d_main_gui->setColorMap(which, color);
+}
- void
- waterfall_sink_c_impl::enable_menu(bool en)
- {
- d_main_gui->enableMenu(en);
- }
+void waterfall_sink_c_impl::set_line_alpha(unsigned int which, double alpha)
+{
+ d_main_gui->setAlpha(which, (int)(255.0 * alpha));
+}
- void
- waterfall_sink_c_impl::enable_grid(bool en)
- {
- d_main_gui->setGrid(en);
- }
+void waterfall_sink_c_impl::set_size(int width, int height)
+{
+ d_main_gui->resize(QSize(width, height));
+}
- void
- waterfall_sink_c_impl::enable_axis_labels(bool en)
- {
- d_main_gui->setAxisLabels(en);
- }
+std::string waterfall_sink_c_impl::title() { return d_main_gui->title().toStdString(); }
- void
- waterfall_sink_c_impl::disable_legend()
- {
- d_main_gui->disableLegend();
- }
+std::string waterfall_sink_c_impl::line_label(unsigned int which)
+{
+ return d_main_gui->lineLabel(which).toStdString();
+}
- void
- waterfall_sink_c_impl::fft(float *data_out, const gr_complex *data_in, int size)
- {
- if(d_window.size()) {
- volk_32fc_32f_multiply_32fc(d_fft->get_inbuf(), data_in,
- &d_window.front(), size);
- }
- else {
- memcpy(d_fft->get_inbuf(), data_in, sizeof(gr_complex)*size);
- }
+int waterfall_sink_c_impl::color_map(unsigned int which)
+{
+ return d_main_gui->getColorMap(which);
+}
- d_fft->execute(); // compute the fft
+double waterfall_sink_c_impl::line_alpha(unsigned int which)
+{
+ return (double)(d_main_gui->markerAlpha(which)) / 255.0;
+}
- volk_32fc_s32f_x2_power_spectral_density_32f(data_out, d_fft->get_outbuf(),
- size, 1.0, size);
+void waterfall_sink_c_impl::auto_scale() { d_main_gui->autoScale(); }
- d_fft_shift.shift(data_out, size);
- }
+double waterfall_sink_c_impl::min_intensity(unsigned int which)
+{
+ return d_main_gui->getMinIntensity(which);
+}
- void
- waterfall_sink_c_impl::windowreset()
- {
- gr::thread::scoped_lock lock(d_setlock);
+double waterfall_sink_c_impl::max_intensity(unsigned int which)
+{
+ return d_main_gui->getMaxIntensity(which);
+}
+
+void waterfall_sink_c_impl::enable_menu(bool en) { d_main_gui->enableMenu(en); }
- filter::firdes::win_type newwintype;
- newwintype = d_main_gui->getFFTWindowType();
- if(d_wintype != newwintype) {
+void waterfall_sink_c_impl::enable_grid(bool en) { d_main_gui->setGrid(en); }
+
+void waterfall_sink_c_impl::enable_axis_labels(bool en) { d_main_gui->setAxisLabels(en); }
+
+void waterfall_sink_c_impl::disable_legend() { d_main_gui->disableLegend(); }
+
+void waterfall_sink_c_impl::fft(float* data_out, const gr_complex* data_in, int size)
+{
+ if (d_window.size()) {
+ volk_32fc_32f_multiply_32fc(d_fft->get_inbuf(), data_in, &d_window.front(), size);
+ } else {
+ memcpy(d_fft->get_inbuf(), data_in, sizeof(gr_complex) * size);
+ }
+
+ d_fft->execute(); // compute the fft
+
+ volk_32fc_s32f_x2_power_spectral_density_32f(
+ data_out, d_fft->get_outbuf(), size, 1.0, size);
+
+ d_fft_shift.shift(data_out, size);
+}
+
+void waterfall_sink_c_impl::windowreset()
+{
+ gr::thread::scoped_lock lock(d_setlock);
+
+ filter::firdes::win_type newwintype;
+ newwintype = d_main_gui->getFFTWindowType();
+ if (d_wintype != newwintype) {
d_wintype = newwintype;
buildwindow();
- }
}
+}
- void
- waterfall_sink_c_impl::buildwindow()
- {
- d_window.clear();
- if(d_wintype != filter::firdes::WIN_NONE) {
- d_window = filter::firdes::window(d_wintype, d_fftsize, 6.76);
- }
+void waterfall_sink_c_impl::buildwindow()
+{
+ d_window.clear();
+ if (d_wintype != filter::firdes::WIN_NONE) {
+ d_window = filter::firdes::window(d_wintype, d_fftsize, 6.76);
}
+}
- void
- waterfall_sink_c_impl::fftresize()
- {
- gr::thread::scoped_lock lock(d_setlock);
+void waterfall_sink_c_impl::fftresize()
+{
+ gr::thread::scoped_lock lock(d_setlock);
- int newfftsize = d_main_gui->getFFTSize();
- d_fftavg = d_main_gui->getFFTAverage();
+ int newfftsize = d_main_gui->getFFTSize();
+ d_fftavg = d_main_gui->getFFTAverage();
- if(newfftsize != d_fftsize) {
+ if (newfftsize != d_fftsize) {
// Resize residbuf and replace data
- for(int i = 0; i < d_nconnections; i++) {
- volk_free(d_residbufs[i]);
- volk_free(d_magbufs[i]);
+ for (int i = 0; i < d_nconnections; i++) {
+ volk_free(d_residbufs[i]);
+ volk_free(d_magbufs[i]);
- d_residbufs[i] = (gr_complex*)volk_malloc(newfftsize*sizeof(gr_complex),
- volk_get_alignment());
- d_magbufs[i] = (double*)volk_malloc(newfftsize*sizeof(double),
- volk_get_alignment());
+ d_residbufs[i] = (gr_complex*)volk_malloc(newfftsize * sizeof(gr_complex),
+ volk_get_alignment());
+ d_magbufs[i] =
+ (double*)volk_malloc(newfftsize * sizeof(double), volk_get_alignment());
- memset(d_residbufs[i], 0, newfftsize*sizeof(gr_complex));
- memset(d_magbufs[i], 0, newfftsize*sizeof(double));
+ memset(d_residbufs[i], 0, newfftsize * sizeof(gr_complex));
+ memset(d_magbufs[i], 0, newfftsize * sizeof(double));
}
// Handle the PDU buffers separately because of the different
@@ -461,13 +380,13 @@ namespace gr {
volk_free(d_residbufs[d_nconnections]);
volk_free(d_pdu_magbuf);
- d_residbufs[d_nconnections] = (gr_complex*)volk_malloc(newfftsize*sizeof(gr_complex),
- volk_get_alignment());
- d_pdu_magbuf = (double*)volk_malloc(newfftsize*sizeof(double)*d_nrows,
+ d_residbufs[d_nconnections] = (gr_complex*)volk_malloc(
+ newfftsize * sizeof(gr_complex), volk_get_alignment());
+ d_pdu_magbuf = (double*)volk_malloc(newfftsize * sizeof(double) * d_nrows,
volk_get_alignment());
d_magbufs[d_nconnections] = d_pdu_magbuf;
- memset(d_residbufs[d_nconnections], 0, newfftsize*sizeof(gr_complex));
- memset(d_pdu_magbuf, 0, newfftsize*sizeof(double)*d_nrows);
+ memset(d_residbufs[d_nconnections], 0, newfftsize * sizeof(gr_complex));
+ memset(d_pdu_magbuf, 0, newfftsize * sizeof(double) * d_nrows);
// Set new fft size and reset buffer index
// (throws away any currently held data, but who cares?)
@@ -481,157 +400,142 @@ namespace gr {
delete d_fft;
d_fft = new fft::fft_complex(d_fftsize, true);
- d_fft_shift.resize(d_fftsize);
+ d_fft_shift.resize(d_fftsize);
volk_free(d_fbuf);
- d_fbuf = (float*)volk_malloc(d_fftsize*sizeof(float),
- volk_get_alignment());
- memset(d_fbuf, 0, d_fftsize*sizeof(float));
+ d_fbuf = (float*)volk_malloc(d_fftsize * sizeof(float), volk_get_alignment());
+ memset(d_fbuf, 0, d_fftsize * sizeof(float));
d_last_time = 0;
- }
}
+}
- void
- waterfall_sink_c_impl::check_clicked()
- {
- if(d_main_gui->checkClicked()) {
+void waterfall_sink_c_impl::check_clicked()
+{
+ if (d_main_gui->checkClicked()) {
double freq = d_main_gui->getClickedFreq();
- message_port_pub(d_port,
- pmt::cons(d_port,
- pmt::from_double(freq)));
- }
+ message_port_pub(d_port, pmt::cons(d_port, pmt::from_double(freq)));
}
+}
- void
- waterfall_sink_c_impl::handle_set_freq(pmt::pmt_t msg)
- {
- if(pmt::is_pair(msg)) {
+void waterfall_sink_c_impl::handle_set_freq(pmt::pmt_t msg)
+{
+ if (pmt::is_pair(msg)) {
pmt::pmt_t x = pmt::cdr(msg);
- if(pmt::is_real(x)) {
- d_center_freq = pmt::to_double(x);
- d_qApplication->postEvent(d_main_gui,
- new SetFreqEvent(d_center_freq, d_bandwidth));
+ if (pmt::is_real(x)) {
+ d_center_freq = pmt::to_double(x);
+ d_qApplication->postEvent(d_main_gui,
+ new SetFreqEvent(d_center_freq, d_bandwidth));
}
- }
}
+}
- void
- waterfall_sink_c_impl::handle_set_bw(pmt::pmt_t msg)
- {
- if(pmt::is_pair(msg)) {
+void waterfall_sink_c_impl::handle_set_bw(pmt::pmt_t msg)
+{
+ if (pmt::is_pair(msg)) {
pmt::pmt_t x = pmt::cdr(msg);
- if(pmt::is_real(x)) {
- d_bandwidth = pmt::to_double(x);
- d_qApplication->postEvent(d_main_gui,
- new SetFreqEvent(d_center_freq, d_bandwidth));
+ if (pmt::is_real(x)) {
+ d_bandwidth = pmt::to_double(x);
+ d_qApplication->postEvent(d_main_gui,
+ new SetFreqEvent(d_center_freq, d_bandwidth));
}
- }
}
+}
+
+void waterfall_sink_c_impl::set_time_per_fft(double t) { d_main_gui->setTimePerFFT(t); }
+
+int waterfall_sink_c_impl::work(int noutput_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];
+
+ // Update the FFT size from the application
+ fftresize();
+ windowreset();
+ check_clicked();
+
+ for (int i = 0; i < noutput_items; i += d_fftsize) {
+ unsigned int datasize = noutput_items - i;
+ unsigned int resid = d_fftsize - d_index;
+
+ // If we have enough input for one full FFT, do it
+ if (datasize >= resid) {
+
+ if (gr::high_res_timer_now() - d_last_time > d_update_time) {
+ for (int n = 0; n < d_nconnections; n++) {
+ // Fill up residbuf with d_fftsize number of items
+ in = (const gr_complex*)input_items[n];
+ memcpy(d_residbufs[n] + d_index, &in[j], sizeof(gr_complex) * resid);
+
+ fft(d_fbuf, d_residbufs[n], d_fftsize);
+ for (int x = 0; x < d_fftsize; x++) {
+ d_magbufs[n][x] = (double)((1.0 - d_fftavg) * d_magbufs[n][x] +
+ (d_fftavg)*d_fbuf[x]);
+ }
+ // volk_32f_convert_64f(d_magbufs[n], d_fbuf, d_fftsize);
+ }
+
+ d_last_time = gr::high_res_timer_now();
+ d_qApplication->postEvent(
+ d_main_gui,
+ new WaterfallUpdateEvent(d_magbufs, d_fftsize, d_last_time));
+ }
- void
- waterfall_sink_c_impl::set_time_per_fft(double t)
- {
- d_main_gui->setTimePerFFT(t);
+ d_index = 0;
+ j += resid;
+ }
+ // Otherwise, copy what we received into the residbuf for next time
+ else {
+ for (int n = 0; n < d_nconnections; n++) {
+ in = (const gr_complex*)input_items[n];
+ memcpy(d_residbufs[n] + d_index, &in[j], sizeof(gr_complex) * datasize);
+ }
+ d_index += datasize;
+ j += datasize;
+ }
}
- int
- waterfall_sink_c_impl::work(int noutput_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];
-
- // Update the FFT size from the application
- fftresize();
- windowreset();
- check_clicked();
-
- for(int i=0; i < noutput_items; i+=d_fftsize) {
- unsigned int datasize = noutput_items - i;
- unsigned int resid = d_fftsize-d_index;
-
- // If we have enough input for one full FFT, do it
- if(datasize >= resid) {
-
- if(gr::high_res_timer_now() - d_last_time > d_update_time) {
- for(int n = 0; n < d_nconnections; n++) {
- // Fill up residbuf with d_fftsize number of items
- in = (const gr_complex*)input_items[n];
- memcpy(d_residbufs[n]+d_index, &in[j], sizeof(gr_complex)*resid);
-
- fft(d_fbuf, d_residbufs[n], d_fftsize);
- for(int x = 0; x < d_fftsize; x++) {
- d_magbufs[n][x] = (double)((1.0-d_fftavg)*d_magbufs[n][x] + (d_fftavg)*d_fbuf[x]);
- }
- //volk_32f_convert_64f(d_magbufs[n], d_fbuf, d_fftsize);
- }
+ return j;
+}
- d_last_time = gr::high_res_timer_now();
- d_qApplication->postEvent(d_main_gui,
- new WaterfallUpdateEvent(d_magbufs,
- d_fftsize,
- d_last_time));
- }
-
- d_index = 0;
- j += resid;
- }
- // Otherwise, copy what we received into the residbuf for next time
- else {
- for(int n = 0; n < d_nconnections; n++) {
- in = (const gr_complex*)input_items[n];
- memcpy(d_residbufs[n]+d_index, &in[j], sizeof(gr_complex)*datasize);
- }
- d_index += datasize;
- j += datasize;
- }
- }
-
- return j;
- }
+void waterfall_sink_c_impl::handle_pdus(pmt::pmt_t msg)
+{
+ size_t len;
+ size_t start = 0;
+ pmt::pmt_t dict, samples;
- void
- waterfall_sink_c_impl::handle_pdus(pmt::pmt_t msg)
- {
- size_t len;
- size_t start = 0;
- pmt::pmt_t dict, samples;
-
- // Test to make sure this is either a PDU or a uniform vector of
- // samples. Get the samples PMT and the dictionary if it's a PDU.
- // If not, we throw an error and exit.
- if(pmt::is_pair(msg)) {
+ // Test to make sure this is either a PDU or a uniform vector of
+ // samples. Get the samples PMT and the dictionary if it's a PDU.
+ // If not, we throw an error and exit.
+ if (pmt::is_pair(msg)) {
dict = pmt::car(msg);
samples = pmt::cdr(msg);
pmt::pmt_t start_key = pmt::string_to_symbol("start");
- if(pmt::dict_has_key(dict, start_key)) {
- start = pmt::to_uint64(pmt::dict_ref(dict, start_key, pmt::PMT_NIL));
+ if (pmt::dict_has_key(dict, start_key)) {
+ start = pmt::to_uint64(pmt::dict_ref(dict, start_key, pmt::PMT_NIL));
}
- }
- else if(pmt::is_uniform_vector(msg)) {
+ } else if (pmt::is_uniform_vector(msg)) {
samples = msg;
- }
- else {
+ } else {
throw std::runtime_error("time_sink_c: message must be either "
"a PDU or a uniform vector of samples.");
- }
+ }
- len = pmt::length(samples);
+ len = pmt::length(samples);
- const gr_complex *in;
- if(pmt::is_c32vector(samples)) {
+ const gr_complex* in;
+ if (pmt::is_c32vector(samples)) {
in = (const gr_complex*)pmt::c32vector_elements(samples, len);
- }
- else {
+ } else {
throw std::runtime_error("waterfall_sink_c: unknown data type "
"of samples; must be complex.");
- }
+ }
- // Plot if we're past the last update time
- if(gr::high_res_timer_now() - d_last_time > d_update_time) {
+ // Plot if we're past the last update time
+ if (gr::high_res_timer_now() - d_last_time > d_update_time) {
d_last_time = gr::high_res_timer_now();
// Update the FFT size from the application
@@ -639,11 +543,12 @@ namespace gr {
windowreset();
check_clicked();
- gr::high_res_timer_type ref_start = (uint64_t)start * (double)(1.0/d_bandwidth) * 1000000;
+ gr::high_res_timer_type ref_start =
+ (uint64_t)start * (double)(1.0 / d_bandwidth) * 1000000;
- int stride = std::max(0, (int)(len - d_fftsize)/(int)(d_nrows));
+ int stride = std::max(0, (int)(len - d_fftsize) / (int)(d_nrows));
- set_time_per_fft(1.0/d_bandwidth * stride);
+ set_time_per_fft(1.0 / d_bandwidth * stride);
std::ostringstream title("");
title << "Time (+" << (uint64_t)ref_start << "us)";
set_time_title(title.str());
@@ -651,34 +556,33 @@ namespace gr {
int j = 0;
size_t min = 0;
size_t max = std::min(d_fftsize, static_cast<int>(len));
- for(size_t i=0; j < d_nrows; i+=stride) {
- // Clear residbufs if len < d_fftsize
- memset(d_residbufs[d_nconnections], 0x00, sizeof(gr_complex)*d_fftsize);
-
- // Copy in as much of the input samples as we can
- memcpy(d_residbufs[d_nconnections], &in[min], sizeof(gr_complex)*(max-min));
-
- // Apply the window and FFT; copy data into the PDU
- // magnitude buffer.
- fft(d_fbuf, d_residbufs[d_nconnections], d_fftsize);
- for(int x = 0; x < d_fftsize; x++) {
- d_pdu_magbuf[j * d_fftsize + x] = (double)d_fbuf[x];
- }
-
- // Increment our indices; set max up to the number of
- // samples in the input PDU.
- min += stride;
- max = std::min(max + stride, len);
- j++;
+ for (size_t i = 0; j < d_nrows; i += stride) {
+ // Clear residbufs if len < d_fftsize
+ memset(d_residbufs[d_nconnections], 0x00, sizeof(gr_complex) * d_fftsize);
+
+ // Copy in as much of the input samples as we can
+ memcpy(
+ d_residbufs[d_nconnections], &in[min], sizeof(gr_complex) * (max - min));
+
+ // Apply the window and FFT; copy data into the PDU
+ // magnitude buffer.
+ fft(d_fbuf, d_residbufs[d_nconnections], d_fftsize);
+ for (int x = 0; x < d_fftsize; x++) {
+ d_pdu_magbuf[j * d_fftsize + x] = (double)d_fbuf[x];
+ }
+
+ // Increment our indices; set max up to the number of
+ // samples in the input PDU.
+ min += stride;
+ max = std::min(max + stride, len);
+ j++;
}
- //update gui per-pdu
- d_qApplication->postEvent(d_main_gui,
- new WaterfallUpdateEvent(d_magbufs,
- d_fftsize*d_nrows,
- 0));
- }
+ // update gui per-pdu
+ d_qApplication->postEvent(
+ d_main_gui, new WaterfallUpdateEvent(d_magbufs, d_fftsize * d_nrows, 0));
}
+}
- } /* namespace qtgui */
+} /* namespace qtgui */
} /* namespace gr */
diff --git a/gr-qtgui/lib/waterfall_sink_c_impl.h b/gr-qtgui/lib/waterfall_sink_c_impl.h
index 6eba6f8ede..41fdf86e48 100644
--- a/gr-qtgui/lib/waterfall_sink_c_impl.h
+++ b/gr-qtgui/lib/waterfall_sink_c_impl.h
@@ -32,124 +32,126 @@
#include <gnuradio/qtgui/waterfalldisplayform.h>
namespace gr {
- namespace qtgui {
-
- class QTGUI_API waterfall_sink_c_impl : public waterfall_sink_c
- {
- private:
- void forecast(int noutput_items, gr_vector_int &ninput_items_required);
-
- void initialize();
-
- int d_fftsize;
- fft::fft_shift<float> d_fft_shift;
- float d_fftavg;
- filter::firdes::win_type d_wintype;
- std::vector<float> d_window;
- double d_center_freq;
- double d_bandwidth;
- std::string d_name;
- int d_nconnections;
- int d_nrows;
-
- const pmt::pmt_t d_port;
- const pmt::pmt_t d_port_bw;
-
- bool d_shift;
- fft::fft_complex *d_fft;
-
- int d_index;
- std::vector<gr_complex*> d_residbufs;
- std::vector<double*> d_magbufs;
- double* d_pdu_magbuf;
- float *d_fbuf;
-
- int d_argc;
- char *d_argv;
- QWidget *d_parent;
- WaterfallDisplayForm *d_main_gui;
-
- gr::high_res_timer_type d_update_time;
- gr::high_res_timer_type d_last_time;
-
- void windowreset();
- void buildwindow();
- void fftresize();
- void check_clicked();
- void fft(float *data_out, const gr_complex *data_in, int size);
-
- // Handles message input port for setting new bandwidth
- // The message is a PMT pair (intern('bw'), double(bw))
- void handle_set_bw(pmt::pmt_t msg);
-
- // Handles message input port for setting new center frequency.
- // The message is a PMT pair (intern('freq'), double(frequency)).
- void handle_set_freq(pmt::pmt_t msg);
-
- // Handles message input port for displaying PDU samples.
- void handle_pdus(pmt::pmt_t msg);
-
- public:
- waterfall_sink_c_impl(int size, int wintype,
- double fc, double bw,
- const std::string &name,
- int nconnections,
- QWidget *parent=NULL);
- ~waterfall_sink_c_impl();
-
- bool check_topology(int ninputs, int noutputs);
-
- void exec_();
- QWidget* qwidget();
+namespace qtgui {
+
+class QTGUI_API waterfall_sink_c_impl : public waterfall_sink_c
+{
+private:
+ void forecast(int noutput_items, gr_vector_int& ninput_items_required);
+
+ void initialize();
+
+ int d_fftsize;
+ fft::fft_shift<float> d_fft_shift;
+ float d_fftavg;
+ filter::firdes::win_type d_wintype;
+ std::vector<float> d_window;
+ double d_center_freq;
+ double d_bandwidth;
+ std::string d_name;
+ int d_nconnections;
+ int d_nrows;
+
+ const pmt::pmt_t d_port;
+ const pmt::pmt_t d_port_bw;
+
+ bool d_shift;
+ fft::fft_complex* d_fft;
+
+ int d_index;
+ std::vector<gr_complex*> d_residbufs;
+ std::vector<double*> d_magbufs;
+ double* d_pdu_magbuf;
+ float* d_fbuf;
+
+ int d_argc;
+ char* d_argv;
+ QWidget* d_parent;
+ WaterfallDisplayForm* d_main_gui;
+
+ gr::high_res_timer_type d_update_time;
+ gr::high_res_timer_type d_last_time;
+
+ void windowreset();
+ void buildwindow();
+ void fftresize();
+ void check_clicked();
+ void fft(float* data_out, const gr_complex* data_in, int size);
+
+ // Handles message input port for setting new bandwidth
+ // The message is a PMT pair (intern('bw'), double(bw))
+ void handle_set_bw(pmt::pmt_t msg);
+
+ // Handles message input port for setting new center frequency.
+ // The message is a PMT pair (intern('freq'), double(frequency)).
+ void handle_set_freq(pmt::pmt_t msg);
+
+ // Handles message input port for displaying PDU samples.
+ void handle_pdus(pmt::pmt_t msg);
+
+public:
+ waterfall_sink_c_impl(int size,
+ int wintype,
+ double fc,
+ double bw,
+ const std::string& name,
+ int nconnections,
+ QWidget* parent = NULL);
+ ~waterfall_sink_c_impl();
+
+ bool check_topology(int ninputs, int noutputs);
+
+ void exec_();
+ QWidget* qwidget();
#ifdef ENABLE_PYTHON
- PyObject* pyqwidget();
+ PyObject* pyqwidget();
#else
- void* pyqwidget();
+ void* pyqwidget();
#endif
- void clear_data();
+ void clear_data();
- void set_fft_size(const int fftsize);
- int fft_size() const;
- void set_fft_average(const float fftavg);
- float fft_average() const;
- void set_fft_window(const gr::filter::firdes::win_type win);
- gr::filter::firdes::win_type fft_window();
+ void set_fft_size(const int fftsize);
+ int fft_size() const;
+ void set_fft_average(const float fftavg);
+ float fft_average() const;
+ void set_fft_window(const gr::filter::firdes::win_type win);
+ gr::filter::firdes::win_type fft_window();
- void set_frequency_range(const double centerfreq, const double bandwidth);
- void set_intensity_range(const double min, const double max);
+ void set_frequency_range(const double centerfreq, const double bandwidth);
+ void set_intensity_range(const double min, const double max);
- void set_update_time(double t);
- void set_time_per_fft(double t);
- void set_title(const std::string &title);
- void set_time_title(const std::string &title);
- void set_line_label(unsigned int which, const std::string &label);
- void set_line_alpha(unsigned int which, double alpha);
- void set_color_map(unsigned int which, const int color);
+ void set_update_time(double t);
+ void set_time_per_fft(double t);
+ void set_title(const std::string& title);
+ void set_time_title(const std::string& title);
+ void set_line_label(unsigned int which, const std::string& label);
+ void set_line_alpha(unsigned int which, double alpha);
+ void set_color_map(unsigned int which, const int color);
- std::string title();
- std::string line_label(unsigned int which);
- double line_alpha(unsigned int which);
- int color_map(unsigned int which);
+ std::string title();
+ std::string line_label(unsigned int which);
+ double line_alpha(unsigned int which);
+ int color_map(unsigned int which);
- void set_size(int width, int height);
+ void set_size(int width, int height);
- void auto_scale();
- double min_intensity(unsigned int which);
- double max_intensity(unsigned int which);
+ void auto_scale();
+ double min_intensity(unsigned int which);
+ double max_intensity(unsigned int which);
- void enable_menu(bool en);
- void enable_grid(bool en);
- void disable_legend();
- void enable_axis_labels(bool en);
+ void enable_menu(bool en);
+ void enable_grid(bool en);
+ void disable_legend();
+ void enable_axis_labels(bool en);
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
- } /* namespace qtgui */
+} /* namespace qtgui */
} /* namespace gr */
#endif /* INCLUDED_QTGUI_WATERFALL_SINK_C_IMPL_H */
diff --git a/gr-qtgui/lib/waterfall_sink_f_impl.cc b/gr-qtgui/lib/waterfall_sink_f_impl.cc
index ad466b7c17..e523ac328e 100644
--- a/gr-qtgui/lib/waterfall_sink_f_impl.cc
+++ b/gr-qtgui/lib/waterfall_sink_f_impl.cc
@@ -35,607 +35,514 @@
#include <iostream>
namespace gr {
- namespace qtgui {
-
- waterfall_sink_f::sptr
- waterfall_sink_f::make(int fftsize, int wintype,
- double fc, double bw,
- const std::string &name,
- int nconnections,
- QWidget *parent)
- {
- return gnuradio::get_initial_sptr
- (new waterfall_sink_f_impl(fftsize, wintype,
- fc, bw, name,
- nconnections,
- parent));
- }
-
- waterfall_sink_f_impl::waterfall_sink_f_impl(int fftsize, int wintype,
- double fc, double bw,
- const std::string &name,
- int nconnections,
- QWidget *parent)
- : sync_block("waterfall_sink_f",
- io_signature::make(0, nconnections, sizeof(float)),
- io_signature::make(0, 0, 0)),
- d_fftsize(fftsize),
- d_fft_shift(fftsize),
- d_fftavg(1.0),
- d_wintype((filter::firdes::win_type)(wintype)),
- d_center_freq(fc), d_bandwidth(bw), d_name(name),
- d_nconnections(nconnections), d_nrows(200),
- d_port(pmt::mp("freq")),
- d_port_bw(pmt::mp("bw")),
- d_parent(parent)
- {
- // Required now for Qt; argc must be greater than 0 and argv
- // must have at least one valid character. Must be valid through
- // life of the qApplication:
- // http://harmattan-dev.nokia.com/docs/library/html/qt4/qapplication.html
- d_argc = 1;
- d_argv = new char;
- d_argv[0] = '\0';
-
- d_main_gui = NULL;
-
- // Perform fftshift operation;
- // this is usually desired when plotting
- d_shift = true;
-
- d_fft = new fft::fft_complex(d_fftsize, true);
- d_fbuf = (float*)volk_malloc(d_fftsize*sizeof(float),
- volk_get_alignment());
- memset(d_fbuf, 0, d_fftsize*sizeof(float));
-
- d_index = 0;
- // save the last "connection" for the PDU memory
- for(int i = 0; i < d_nconnections; i++) {
- d_residbufs.push_back((float*)volk_malloc(d_fftsize*sizeof(float),
- volk_get_alignment()));
- d_magbufs.push_back((double*)volk_malloc(d_fftsize*sizeof(double),
- volk_get_alignment()));
- memset(d_residbufs[i], 0, d_fftsize*sizeof(float));
- memset(d_magbufs[i], 0, d_fftsize*sizeof(double));
- }
-
- d_residbufs.push_back((float*)volk_malloc(d_fftsize*sizeof(float),
- volk_get_alignment()));
- d_pdu_magbuf = (double*)volk_malloc(d_fftsize*sizeof(double)*d_nrows,
- volk_get_alignment());
- d_magbufs.push_back(d_pdu_magbuf);
- memset(d_pdu_magbuf, 0, d_fftsize*sizeof(double)*d_nrows);
- memset(d_residbufs[d_nconnections], 0, d_fftsize*sizeof(float));
-
- buildwindow();
-
- initialize();
-
- // setup bw input port
- message_port_register_in(d_port_bw);
- set_msg_handler(d_port_bw,
- boost::bind(&waterfall_sink_f_impl::handle_set_bw, this, _1));
-
- // setup output message port to post frequency when display is
- // double-clicked
- message_port_register_out(d_port);
- message_port_register_in(d_port);
- set_msg_handler(d_port,
- boost::bind(&waterfall_sink_f_impl::handle_set_freq, this, _1));
-
- // setup PDU handling input port
- message_port_register_in(pmt::mp("in"));
- set_msg_handler(pmt::mp("in"),
- boost::bind(&waterfall_sink_f_impl::handle_pdus, this, _1));
- }
-
- waterfall_sink_f_impl::~waterfall_sink_f_impl()
- {
- if(!d_main_gui->isClosed())
+namespace qtgui {
+
+waterfall_sink_f::sptr waterfall_sink_f::make(int fftsize,
+ int wintype,
+ double fc,
+ double bw,
+ const std::string& name,
+ int nconnections,
+ QWidget* parent)
+{
+ return gnuradio::get_initial_sptr(
+ new waterfall_sink_f_impl(fftsize, wintype, fc, bw, name, nconnections, parent));
+}
+
+waterfall_sink_f_impl::waterfall_sink_f_impl(int fftsize,
+ int wintype,
+ double fc,
+ double bw,
+ const std::string& name,
+ int nconnections,
+ QWidget* parent)
+ : sync_block("waterfall_sink_f",
+ io_signature::make(0, nconnections, sizeof(float)),
+ io_signature::make(0, 0, 0)),
+ d_fftsize(fftsize),
+ d_fft_shift(fftsize),
+ d_fftavg(1.0),
+ d_wintype((filter::firdes::win_type)(wintype)),
+ d_center_freq(fc),
+ d_bandwidth(bw),
+ d_name(name),
+ d_nconnections(nconnections),
+ d_nrows(200),
+ d_port(pmt::mp("freq")),
+ d_port_bw(pmt::mp("bw")),
+ d_parent(parent)
+{
+ // Required now for Qt; argc must be greater than 0 and argv
+ // must have at least one valid character. Must be valid through
+ // life of the qApplication:
+ // http://harmattan-dev.nokia.com/docs/library/html/qt4/qapplication.html
+ d_argc = 1;
+ d_argv = new char;
+ d_argv[0] = '\0';
+
+ d_main_gui = NULL;
+
+ // Perform fftshift operation;
+ // this is usually desired when plotting
+ d_shift = true;
+
+ d_fft = new fft::fft_complex(d_fftsize, true);
+ d_fbuf = (float*)volk_malloc(d_fftsize * sizeof(float), volk_get_alignment());
+ memset(d_fbuf, 0, d_fftsize * sizeof(float));
+
+ d_index = 0;
+ // save the last "connection" for the PDU memory
+ for (int i = 0; i < d_nconnections; i++) {
+ d_residbufs.push_back(
+ (float*)volk_malloc(d_fftsize * sizeof(float), volk_get_alignment()));
+ d_magbufs.push_back(
+ (double*)volk_malloc(d_fftsize * sizeof(double), volk_get_alignment()));
+ memset(d_residbufs[i], 0, d_fftsize * sizeof(float));
+ memset(d_magbufs[i], 0, d_fftsize * sizeof(double));
+ }
+
+ d_residbufs.push_back(
+ (float*)volk_malloc(d_fftsize * sizeof(float), volk_get_alignment()));
+ d_pdu_magbuf =
+ (double*)volk_malloc(d_fftsize * sizeof(double) * d_nrows, volk_get_alignment());
+ d_magbufs.push_back(d_pdu_magbuf);
+ memset(d_pdu_magbuf, 0, d_fftsize * sizeof(double) * d_nrows);
+ memset(d_residbufs[d_nconnections], 0, d_fftsize * sizeof(float));
+
+ buildwindow();
+
+ initialize();
+
+ // setup bw input port
+ message_port_register_in(d_port_bw);
+ set_msg_handler(d_port_bw,
+ boost::bind(&waterfall_sink_f_impl::handle_set_bw, this, _1));
+
+ // setup output message port to post frequency when display is
+ // double-clicked
+ message_port_register_out(d_port);
+ message_port_register_in(d_port);
+ set_msg_handler(d_port,
+ boost::bind(&waterfall_sink_f_impl::handle_set_freq, this, _1));
+
+ // setup PDU handling input port
+ message_port_register_in(pmt::mp("in"));
+ set_msg_handler(pmt::mp("in"),
+ boost::bind(&waterfall_sink_f_impl::handle_pdus, this, _1));
+}
+
+waterfall_sink_f_impl::~waterfall_sink_f_impl()
+{
+ if (!d_main_gui->isClosed())
d_main_gui->close();
- for(int i = 0; i < (int)d_residbufs.size(); i++) {
- volk_free(d_residbufs[i]);
- volk_free(d_magbufs[i]);
- }
- delete d_fft;
- volk_free(d_fbuf);
-
- delete d_argv;
+ for (int i = 0; i < (int)d_residbufs.size(); i++) {
+ volk_free(d_residbufs[i]);
+ volk_free(d_magbufs[i]);
}
+ delete d_fft;
+ volk_free(d_fbuf);
- bool
- waterfall_sink_f_impl::check_topology(int ninputs, int noutputs)
- {
- return ninputs == d_nconnections;
- }
+ delete d_argv;
+}
+
+bool waterfall_sink_f_impl::check_topology(int ninputs, int noutputs)
+{
+ return ninputs == d_nconnections;
+}
- void
- waterfall_sink_f_impl::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_fftsize, 8191);
- }
+void waterfall_sink_f_impl::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_fftsize, 8191);
}
+}
- void
- waterfall_sink_f_impl::initialize()
- {
- if(qApp != NULL) {
- d_qApplication = qApp;
- }
- else {
+void waterfall_sink_f_impl::initialize()
+{
+ if (qApp != NULL) {
+ d_qApplication = qApp;
+ } else {
#if QT_VERSION >= 0x040500 && QT_VERSION < 0x050000
std::string style = prefs::singleton()->get_string("qtgui", "style", "raster");
QApplication::setGraphicsSystem(QString(style.c_str()));
#endif
- d_qApplication = new QApplication(d_argc, &d_argv);
- }
+ d_qApplication = new QApplication(d_argc, &d_argv);
+ }
- // If a style sheet is set in the prefs file, enable it here.
- check_set_qss(d_qApplication);
+ // If a style sheet is set in the prefs file, enable it here.
+ check_set_qss(d_qApplication);
- int numplots = (d_nconnections > 0) ? d_nconnections : 1;
- d_main_gui = new WaterfallDisplayForm(numplots, d_parent);
- set_fft_window(d_wintype);
- set_fft_size(d_fftsize);
- set_frequency_range(d_center_freq, d_bandwidth);
+ int numplots = (d_nconnections > 0) ? d_nconnections : 1;
+ d_main_gui = new WaterfallDisplayForm(numplots, d_parent);
+ set_fft_window(d_wintype);
+ set_fft_size(d_fftsize);
+ set_frequency_range(d_center_freq, d_bandwidth);
- if(d_name.size() > 0)
+ if (d_name.size() > 0)
set_title(d_name);
- // initialize update time to 10 times a second
- set_update_time(0.1);
- }
+ // initialize update time to 10 times a second
+ set_update_time(0.1);
+}
- void
- waterfall_sink_f_impl::exec_()
- {
- d_qApplication->exec();
- }
+void waterfall_sink_f_impl::exec_() { d_qApplication->exec(); }
- QWidget*
- waterfall_sink_f_impl::qwidget()
- {
- return d_main_gui;
- }
+QWidget* waterfall_sink_f_impl::qwidget() { return d_main_gui; }
#ifdef ENABLE_PYTHON
- PyObject*
- waterfall_sink_f_impl::pyqwidget()
- {
- PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui);
- PyObject *retarg = Py_BuildValue("N", w);
- return retarg;
- }
+PyObject* waterfall_sink_f_impl::pyqwidget()
+{
+ PyObject* w = PyLong_FromVoidPtr((void*)d_main_gui);
+ PyObject* retarg = Py_BuildValue("N", w);
+ return retarg;
+}
#else
- void *
- waterfall_sink_f_impl::pyqwidget()
- {
- return NULL;
- }
+void* waterfall_sink_f_impl::pyqwidget() { return NULL; }
#endif
- void
- waterfall_sink_f_impl::clear_data()
- {
- d_main_gui->clearData();
- }
+void waterfall_sink_f_impl::clear_data() { d_main_gui->clearData(); }
+
+void waterfall_sink_f_impl::set_fft_size(const int fftsize)
+{
+ d_main_gui->setFFTSize(fftsize);
+}
+
+int waterfall_sink_f_impl::fft_size() const { return d_fftsize; }
+
+void waterfall_sink_f_impl::set_fft_average(const float fftavg)
+{
+ d_main_gui->setFFTAverage(fftavg);
+}
+
+float waterfall_sink_f_impl::fft_average() const { return d_fftavg; }
+
+void waterfall_sink_f_impl::set_fft_window(const filter::firdes::win_type win)
+{
+ d_main_gui->setFFTWindowType(win);
+}
+
+filter::firdes::win_type waterfall_sink_f_impl::fft_window() { return d_wintype; }
+
+void waterfall_sink_f_impl::set_frequency_range(const double centerfreq,
+ const double bandwidth)
+{
+ d_center_freq = centerfreq;
+ d_bandwidth = bandwidth;
+ d_main_gui->setFrequencyRange(d_center_freq, d_bandwidth);
+}
- void
- waterfall_sink_f_impl::set_fft_size(const int fftsize)
- {
- d_main_gui->setFFTSize(fftsize);
- }
+void waterfall_sink_f_impl::set_intensity_range(const double min, const double max)
+{
+ d_main_gui->setIntensityRange(min, max);
+}
- int
- waterfall_sink_f_impl::fft_size() const
- {
- return d_fftsize;
- }
+void waterfall_sink_f_impl::set_update_time(double t)
+{
+ // convert update time to ticks
+ gr::high_res_timer_type tps = gr::high_res_timer_tps();
+ d_update_time = t * tps;
+ d_main_gui->setUpdateTime(t);
+ d_last_time = 0;
+}
- void
- waterfall_sink_f_impl::set_fft_average(const float fftavg)
- {
- d_main_gui->setFFTAverage(fftavg);
- }
+void waterfall_sink_f_impl::set_title(const std::string& title)
+{
+ d_main_gui->setTitle(title.c_str());
+}
- float
- waterfall_sink_f_impl::fft_average() const
- {
- return d_fftavg;
- }
+void waterfall_sink_f_impl::set_time_title(const std::string& title)
+{
+ d_main_gui->setTimeTitle(title);
+}
- void
- waterfall_sink_f_impl::set_fft_window(const filter::firdes::win_type win)
- {
- d_main_gui->setFFTWindowType(win);
- }
+void waterfall_sink_f_impl::set_line_label(unsigned int which, const std::string& label)
+{
+ d_main_gui->setLineLabel(which, label.c_str());
+}
- filter::firdes::win_type
- waterfall_sink_f_impl::fft_window()
- {
- return d_wintype;
- }
+void waterfall_sink_f_impl::set_color_map(unsigned int which, const int color)
+{
+ d_main_gui->setColorMap(which, color);
+}
- void
- waterfall_sink_f_impl::set_frequency_range(const double centerfreq,
- const double bandwidth)
- {
- d_center_freq = centerfreq;
- d_bandwidth = bandwidth;
- d_main_gui->setFrequencyRange(d_center_freq, d_bandwidth);
- }
+void waterfall_sink_f_impl::set_line_alpha(unsigned int which, double alpha)
+{
+ d_main_gui->setAlpha(which, (int)(255.0 * alpha));
+}
- void
- waterfall_sink_f_impl::set_intensity_range(const double min,
- const double max)
- {
- d_main_gui->setIntensityRange(min, max);
- }
+void waterfall_sink_f_impl::set_size(int width, int height)
+{
+ d_main_gui->resize(QSize(width, height));
+}
- void
- waterfall_sink_f_impl::set_update_time(double t)
- {
- //convert update time to ticks
- gr::high_res_timer_type tps = gr::high_res_timer_tps();
- d_update_time = t * tps;
- d_main_gui->setUpdateTime(t);
- d_last_time = 0;
- }
+void waterfall_sink_f_impl::set_plot_pos_half(bool half)
+{
+ d_main_gui->setPlotPosHalf(half);
+}
- void
- waterfall_sink_f_impl::set_title(const std::string &title)
- {
- d_main_gui->setTitle(title.c_str());
- }
+std::string waterfall_sink_f_impl::title() { return d_main_gui->title().toStdString(); }
- void
- waterfall_sink_f_impl::set_time_title(const std::string &title)
- {
- d_main_gui->setTimeTitle(title);
- }
+std::string waterfall_sink_f_impl::line_label(unsigned int which)
+{
+ return d_main_gui->lineLabel(which).toStdString();
+}
- void
- waterfall_sink_f_impl::set_line_label(unsigned int which, const std::string &label)
- {
- d_main_gui->setLineLabel(which, label.c_str());
- }
+int waterfall_sink_f_impl::color_map(unsigned int which)
+{
+ return d_main_gui->getColorMap(which);
+}
- void
- waterfall_sink_f_impl::set_color_map(unsigned int which, const int color)
- {
- d_main_gui->setColorMap(which, color);
- }
+double waterfall_sink_f_impl::line_alpha(unsigned int which)
+{
+ return (double)(d_main_gui->getAlpha(which)) / 255.0;
+}
- void
- waterfall_sink_f_impl::set_line_alpha(unsigned int which, double alpha)
- {
- d_main_gui->setAlpha(which, (int)(255.0*alpha));
- }
+void waterfall_sink_f_impl::auto_scale() { d_main_gui->autoScale(); }
- void
- waterfall_sink_f_impl::set_size(int width, int height)
- {
- d_main_gui->resize(QSize(width, height));
- }
+double waterfall_sink_f_impl::min_intensity(unsigned int which)
+{
+ return d_main_gui->getMinIntensity(which);
+}
+
+double waterfall_sink_f_impl::max_intensity(unsigned int which)
+{
+ return d_main_gui->getMaxIntensity(which);
+}
- void
- waterfall_sink_f_impl::set_plot_pos_half(bool half)
- {
- d_main_gui->setPlotPosHalf(half);
- }
+void waterfall_sink_f_impl::enable_menu(bool en) { d_main_gui->enableMenu(en); }
+
+void waterfall_sink_f_impl::enable_grid(bool en) { d_main_gui->setGrid(en); }
- std::string
- waterfall_sink_f_impl::title()
- {
- return d_main_gui->title().toStdString();
- }
+void waterfall_sink_f_impl::enable_axis_labels(bool en) { d_main_gui->setAxisLabels(en); }
+
+void waterfall_sink_f_impl::disable_legend() { d_main_gui->disableLegend(); }
+
+void waterfall_sink_f_impl::fft(float* data_out, const float* data_in, int size)
+{
+ // float to complex conversion
+ gr_complex* dst = d_fft->get_inbuf();
+ for (int i = 0; i < size; i++)
+ dst[i] = data_in[i];
+
+ if (d_window.size()) {
+ volk_32fc_32f_multiply_32fc(d_fft->get_inbuf(), dst, &d_window.front(), size);
+ }
+
+ d_fft->execute(); // compute the fft
- std::string
- waterfall_sink_f_impl::line_label(unsigned int which)
- {
- return d_main_gui->lineLabel(which).toStdString();
- }
+ volk_32fc_s32f_x2_power_spectral_density_32f(
+ data_out, d_fft->get_outbuf(), size, 1.0, size);
- int
- waterfall_sink_f_impl::color_map(unsigned int which)
- {
- return d_main_gui->getColorMap(which);
- }
+ d_fft_shift.shift(data_out, size);
+}
- double
- waterfall_sink_f_impl::line_alpha(unsigned int which)
- {
- return (double)(d_main_gui->getAlpha(which))/255.0;
- }
+void waterfall_sink_f_impl::windowreset()
+{
+ gr::thread::scoped_lock lock(d_setlock);
- void
- waterfall_sink_f_impl::auto_scale()
- {
- d_main_gui->autoScale();
- }
-
- double
- waterfall_sink_f_impl::min_intensity(unsigned int which)
- {
- return d_main_gui->getMinIntensity(which);
- }
-
- double
- waterfall_sink_f_impl::max_intensity(unsigned int which)
- {
- return d_main_gui->getMaxIntensity(which);
- }
-
- void
- waterfall_sink_f_impl::enable_menu(bool en)
- {
- d_main_gui->enableMenu(en);
- }
-
- void
- waterfall_sink_f_impl::enable_grid(bool en)
- {
- d_main_gui->setGrid(en);
- }
-
- void
- waterfall_sink_f_impl::enable_axis_labels(bool en)
- {
- d_main_gui->setAxisLabels(en);
- }
-
- void
- waterfall_sink_f_impl::disable_legend()
- {
- d_main_gui->disableLegend();
- }
-
- void
- waterfall_sink_f_impl::fft(float *data_out, const float *data_in, int size)
- {
- // float to complex conversion
- gr_complex *dst = d_fft->get_inbuf();
- for (int i = 0; i < size; i++)
- dst[i] = data_in[i];
-
- if(d_window.size()) {
- volk_32fc_32f_multiply_32fc(d_fft->get_inbuf(), dst,
- &d_window.front(), size);
- }
-
- d_fft->execute(); // compute the fft
-
- volk_32fc_s32f_x2_power_spectral_density_32f(data_out, d_fft->get_outbuf(),
- size, 1.0, size);
-
- d_fft_shift.shift(data_out, size);
- }
-
- void
- waterfall_sink_f_impl::windowreset()
- {
- gr::thread::scoped_lock lock(d_setlock);
-
- filter::firdes::win_type newwintype;
- newwintype = d_main_gui->getFFTWindowType();
- if(d_wintype != newwintype) {
+ filter::firdes::win_type newwintype;
+ newwintype = d_main_gui->getFFTWindowType();
+ if (d_wintype != newwintype) {
d_wintype = newwintype;
buildwindow();
- }
}
+}
- void
- waterfall_sink_f_impl::buildwindow()
- {
- d_window.clear();
- if(d_wintype != filter::firdes::WIN_NONE) {
- d_window = filter::firdes::window(d_wintype, d_fftsize, 6.76);
- }
+void waterfall_sink_f_impl::buildwindow()
+{
+ d_window.clear();
+ if (d_wintype != filter::firdes::WIN_NONE) {
+ d_window = filter::firdes::window(d_wintype, d_fftsize, 6.76);
}
+}
- void
- waterfall_sink_f_impl::fftresize()
- {
- gr::thread::scoped_lock lock(d_setlock);
+void waterfall_sink_f_impl::fftresize()
+{
+ gr::thread::scoped_lock lock(d_setlock);
- int newfftsize = d_main_gui->getFFTSize();
- d_fftavg = d_main_gui->getFFTAverage();
+ int newfftsize = d_main_gui->getFFTSize();
+ d_fftavg = d_main_gui->getFFTAverage();
- if(newfftsize != d_fftsize) {
+ if (newfftsize != d_fftsize) {
- // Resize residbuf and replace data
- for(int i = 0; i < d_nconnections; i++) {
- volk_free(d_residbufs[i]);
- volk_free(d_magbufs[i]);
+ // Resize residbuf and replace data
+ for (int i = 0; i < d_nconnections; i++) {
+ volk_free(d_residbufs[i]);
+ volk_free(d_magbufs[i]);
- d_residbufs[i] = (float*)volk_malloc(newfftsize*sizeof(float),
- volk_get_alignment());
- d_magbufs[i] = (double*)volk_malloc(newfftsize*sizeof(double),
- volk_get_alignment());
+ d_residbufs[i] =
+ (float*)volk_malloc(newfftsize * sizeof(float), volk_get_alignment());
+ d_magbufs[i] =
+ (double*)volk_malloc(newfftsize * sizeof(double), volk_get_alignment());
- memset(d_residbufs[i], 0, newfftsize*sizeof(float));
- memset(d_magbufs[i], 0, newfftsize*sizeof(double));
- }
+ memset(d_residbufs[i], 0, newfftsize * sizeof(float));
+ memset(d_magbufs[i], 0, newfftsize * sizeof(double));
+ }
// Handle the PDU buffers separately because of the different
// size requirement of the pdu_magbuf.
volk_free(d_residbufs[d_nconnections]);
volk_free(d_pdu_magbuf);
- d_residbufs[d_nconnections] = (float*)volk_malloc(newfftsize*sizeof(float),
- volk_get_alignment());
- d_pdu_magbuf = (double*)volk_malloc(newfftsize*sizeof(double)*d_nrows,
+ d_residbufs[d_nconnections] =
+ (float*)volk_malloc(newfftsize * sizeof(float), volk_get_alignment());
+ d_pdu_magbuf = (double*)volk_malloc(newfftsize * sizeof(double) * d_nrows,
volk_get_alignment());
d_magbufs[d_nconnections] = d_pdu_magbuf;
- memset(d_residbufs[d_nconnections], 0, newfftsize*sizeof(float));
- memset(d_pdu_magbuf, 0, newfftsize*sizeof(double)*d_nrows);
+ memset(d_residbufs[d_nconnections], 0, newfftsize * sizeof(float));
+ memset(d_pdu_magbuf, 0, newfftsize * sizeof(double) * d_nrows);
- // Set new fft size and reset buffer index
- // (throws away any currently held data, but who cares?)
- d_fftsize = newfftsize;
- d_index = 0;
+ // Set new fft size and reset buffer index
+ // (throws away any currently held data, but who cares?)
+ d_fftsize = newfftsize;
+ d_index = 0;
- // Reset window to reflect new size
- buildwindow();
+ // Reset window to reflect new size
+ buildwindow();
- // Reset FFTW plan for new size
- delete d_fft;
- d_fft = new fft::fft_complex(d_fftsize, true);
+ // Reset FFTW plan for new size
+ delete d_fft;
+ d_fft = new fft::fft_complex(d_fftsize, true);
- d_fft_shift.resize(d_fftsize);
+ d_fft_shift.resize(d_fftsize);
- volk_free(d_fbuf);
- d_fbuf = (float*)volk_malloc(d_fftsize*sizeof(float),
- volk_get_alignment());
- memset(d_fbuf, 0, d_fftsize*sizeof(float));
+ volk_free(d_fbuf);
+ d_fbuf = (float*)volk_malloc(d_fftsize * sizeof(float), volk_get_alignment());
+ memset(d_fbuf, 0, d_fftsize * sizeof(float));
d_last_time = 0;
- }
}
+}
- void
- waterfall_sink_f_impl::check_clicked()
- {
- if(d_main_gui->checkClicked()) {
+void waterfall_sink_f_impl::check_clicked()
+{
+ if (d_main_gui->checkClicked()) {
double freq = d_main_gui->getClickedFreq();
- message_port_pub(d_port,
- pmt::cons(d_port,
- pmt::from_double(freq)));
- }
+ message_port_pub(d_port, pmt::cons(d_port, pmt::from_double(freq)));
}
+}
- void
- waterfall_sink_f_impl::handle_set_freq(pmt::pmt_t msg)
- {
- if(pmt::is_pair(msg)) {
+void waterfall_sink_f_impl::handle_set_freq(pmt::pmt_t msg)
+{
+ if (pmt::is_pair(msg)) {
pmt::pmt_t x = pmt::cdr(msg);
- if(pmt::is_real(x)) {
- d_center_freq = pmt::to_double(x);
- d_qApplication->postEvent(d_main_gui,
- new SetFreqEvent(d_center_freq, d_bandwidth));
+ if (pmt::is_real(x)) {
+ d_center_freq = pmt::to_double(x);
+ d_qApplication->postEvent(d_main_gui,
+ new SetFreqEvent(d_center_freq, d_bandwidth));
}
- }
}
+}
- void
- waterfall_sink_f_impl::handle_set_bw(pmt::pmt_t msg)
- {
- if(pmt::is_pair(msg)) {
+void waterfall_sink_f_impl::handle_set_bw(pmt::pmt_t msg)
+{
+ if (pmt::is_pair(msg)) {
pmt::pmt_t x = pmt::cdr(msg);
- if(pmt::is_real(x)) {
- d_bandwidth = pmt::to_double(x);
- d_qApplication->postEvent(d_main_gui,
- new SetFreqEvent(d_center_freq, d_bandwidth));
+ if (pmt::is_real(x)) {
+ d_bandwidth = pmt::to_double(x);
+ d_qApplication->postEvent(d_main_gui,
+ new SetFreqEvent(d_center_freq, d_bandwidth));
}
- }
}
+}
+
+void waterfall_sink_f_impl::set_time_per_fft(double t) { d_main_gui->setTimePerFFT(t); }
+
+int waterfall_sink_f_impl::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ int j = 0;
+ const float* in = (const float*)input_items[0];
+
+ // Update the FFT size from the application
+ fftresize();
+ windowreset();
+ check_clicked();
+
+ for (int i = 0; i < noutput_items; i += d_fftsize) {
+ unsigned int datasize = noutput_items - i;
+ unsigned int resid = d_fftsize - d_index;
+
+ // If we have enough input for one full FFT, do it
+ if (datasize >= resid) {
+
+ if (gr::high_res_timer_now() - d_last_time > d_update_time) {
+ for (int n = 0; n < d_nconnections; n++) {
+ // Fill up residbuf with d_fftsize number of items
+ in = (const float*)input_items[n];
+ memcpy(d_residbufs[n] + d_index, &in[j], sizeof(float) * resid);
+
+ fft(d_fbuf, d_residbufs[n], d_fftsize);
+ for (int x = 0; x < d_fftsize; x++) {
+ d_magbufs[n][x] = (double)((1.0 - d_fftavg) * d_magbufs[n][x] +
+ (d_fftavg)*d_fbuf[x]);
+ }
+ // volk_32f_convert_64f(d_magbufs[n], d_fbuf, d_fftsize);
+ }
+
+ d_last_time = gr::high_res_timer_now();
+ d_qApplication->postEvent(
+ d_main_gui,
+ new WaterfallUpdateEvent(d_magbufs, d_fftsize, d_last_time));
+ }
- void
- waterfall_sink_f_impl::set_time_per_fft(double t)
- {
- d_main_gui->setTimePerFFT(t);
+ d_index = 0;
+ j += resid;
+ }
+ // Otherwise, copy what we received into the residbuf for next time
+ else {
+ for (int n = 0; n < d_nconnections; n++) {
+ in = (const float*)input_items[n];
+ memcpy(d_residbufs[n] + d_index, &in[j], sizeof(float) * datasize);
+ }
+ d_index += datasize;
+ j += datasize;
+ }
}
- int
- waterfall_sink_f_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- int j=0;
- const float *in = (const float*)input_items[0];
-
- // Update the FFT size from the application
- fftresize();
- windowreset();
- check_clicked();
-
- for(int i=0; i < noutput_items; i+=d_fftsize) {
- unsigned int datasize = noutput_items - i;
- unsigned int resid = d_fftsize-d_index;
-
- // If we have enough input for one full FFT, do it
- if(datasize >= resid) {
-
- if(gr::high_res_timer_now() - d_last_time > d_update_time) {
- for(int n = 0; n < d_nconnections; n++) {
- // Fill up residbuf with d_fftsize number of items
- in = (const float*)input_items[n];
- memcpy(d_residbufs[n]+d_index, &in[j], sizeof(float)*resid);
-
- fft(d_fbuf, d_residbufs[n], d_fftsize);
- for(int x = 0; x < d_fftsize; x++) {
- d_magbufs[n][x] = (double)((1.0-d_fftavg)*d_magbufs[n][x] + (d_fftavg)*d_fbuf[x]);
- }
- //volk_32f_convert_64f(d_magbufs[n], d_fbuf, d_fftsize);
- }
+ return j;
+}
- d_last_time = gr::high_res_timer_now();
- d_qApplication->postEvent(d_main_gui,
- new WaterfallUpdateEvent(d_magbufs,
- d_fftsize,
- d_last_time));
- }
-
- d_index = 0;
- j += resid;
- }
- // Otherwise, copy what we received into the residbuf for next time
- else {
- for(int n = 0; n < d_nconnections; n++) {
- in = (const float*)input_items[n];
- memcpy(d_residbufs[n]+d_index, &in[j], sizeof(float)*datasize);
- }
- d_index += datasize;
- j += datasize;
- }
- }
-
- return j;
- }
+void waterfall_sink_f_impl::handle_pdus(pmt::pmt_t msg)
+{
+ size_t len;
+ size_t start = 0;
+ pmt::pmt_t dict, samples;
- void
- waterfall_sink_f_impl::handle_pdus(pmt::pmt_t msg)
- {
- size_t len;
- size_t start = 0;
- pmt::pmt_t dict, samples;
-
- // Test to make sure this is either a PDU or a uniform vector of
- // samples. Get the samples PMT and the dictionary if it's a PDU.
- // If not, we throw an error and exit.
- if(pmt::is_pair(msg)) {
+ // Test to make sure this is either a PDU or a uniform vector of
+ // samples. Get the samples PMT and the dictionary if it's a PDU.
+ // If not, we throw an error and exit.
+ if (pmt::is_pair(msg)) {
dict = pmt::car(msg);
samples = pmt::cdr(msg);
pmt::pmt_t start_key = pmt::string_to_symbol("start");
- if(pmt::dict_has_key(dict, start_key)) {
- start = pmt::to_uint64(pmt::dict_ref(dict, start_key, pmt::PMT_NIL));
+ if (pmt::dict_has_key(dict, start_key)) {
+ start = pmt::to_uint64(pmt::dict_ref(dict, start_key, pmt::PMT_NIL));
}
- }
- else if(pmt::is_uniform_vector(msg)) {
+ } else if (pmt::is_uniform_vector(msg)) {
samples = msg;
- }
- else {
+ } else {
throw std::runtime_error("time_sink_c: message must be either "
"a PDU or a uniform vector of samples.");
- }
+ }
- len = pmt::length(samples);
+ len = pmt::length(samples);
- const float *in;
- if(pmt::is_f32vector(samples)) {
+ const float* in;
+ if (pmt::is_f32vector(samples)) {
in = (const float*)pmt::f32vector_elements(samples, len);
- }
- else {
+ } else {
throw std::runtime_error("waterfall sink: unknown data type "
"of samples; must be float.");
- }
+ }
- // Plot if we're past the last update time
- if(gr::high_res_timer_now() - d_last_time > d_update_time) {
+ // Plot if we're past the last update time
+ if (gr::high_res_timer_now() - d_last_time > d_update_time) {
d_last_time = gr::high_res_timer_now();
// Update the FFT size from the application
@@ -643,11 +550,12 @@ namespace gr {
windowreset();
check_clicked();
- gr::high_res_timer_type ref_start = (uint64_t)start * (double)(1.0/d_bandwidth) * 1000000;
+ gr::high_res_timer_type ref_start =
+ (uint64_t)start * (double)(1.0 / d_bandwidth) * 1000000;
- int stride = std::max(0, (int)(len - d_fftsize)/(int)(d_nrows));
+ int stride = std::max(0, (int)(len - d_fftsize) / (int)(d_nrows));
- set_time_per_fft(1.0/d_bandwidth * stride);
+ set_time_per_fft(1.0 / d_bandwidth * stride);
std::ostringstream title("");
title << "Time (+" << (uint64_t)ref_start << "us)";
set_time_title(title.str());
@@ -655,34 +563,32 @@ namespace gr {
int j = 0;
size_t min = 0;
size_t max = std::min(d_fftsize, static_cast<int>(len));
- for(size_t i=0; j < d_nrows; i+=stride) {
- // Clear residbufs if len < d_fftsize
- memset(d_residbufs[d_nconnections], 0x00, sizeof(float)*d_fftsize);
-
- // Copy in as much of the input samples as we can
- memcpy(d_residbufs[d_nconnections], &in[min], sizeof(float)*(max-min));
-
- // Apply the window and FFT; copy data into the PDU
- // magnitude buffer.
- fft(d_fbuf, d_residbufs[d_nconnections], d_fftsize);
- for(int x = 0; x < d_fftsize; x++) {
- d_pdu_magbuf[j * d_fftsize + x] = (double)d_fbuf[x];
- }
-
- // Increment our indices; set max up to the number of
- // samples in the input PDU.
- min += stride;
- max = std::min(max + stride, len);
- j++;
+ for (size_t i = 0; j < d_nrows; i += stride) {
+ // Clear residbufs if len < d_fftsize
+ memset(d_residbufs[d_nconnections], 0x00, sizeof(float) * d_fftsize);
+
+ // Copy in as much of the input samples as we can
+ memcpy(d_residbufs[d_nconnections], &in[min], sizeof(float) * (max - min));
+
+ // Apply the window and FFT; copy data into the PDU
+ // magnitude buffer.
+ fft(d_fbuf, d_residbufs[d_nconnections], d_fftsize);
+ for (int x = 0; x < d_fftsize; x++) {
+ d_pdu_magbuf[j * d_fftsize + x] = (double)d_fbuf[x];
+ }
+
+ // Increment our indices; set max up to the number of
+ // samples in the input PDU.
+ min += stride;
+ max = std::min(max + stride, len);
+ j++;
}
- //update gui per-pdu
- d_qApplication->postEvent(d_main_gui,
- new WaterfallUpdateEvent(d_magbufs,
- d_fftsize*d_nrows,
- 0));
- }
+ // update gui per-pdu
+ d_qApplication->postEvent(
+ d_main_gui, new WaterfallUpdateEvent(d_magbufs, d_fftsize * d_nrows, 0));
}
+}
- } /* namespace qtgui */
+} /* namespace qtgui */
} /* namespace gr */
diff --git a/gr-qtgui/lib/waterfall_sink_f_impl.h b/gr-qtgui/lib/waterfall_sink_f_impl.h
index d474a4f079..036dd23e61 100644
--- a/gr-qtgui/lib/waterfall_sink_f_impl.h
+++ b/gr-qtgui/lib/waterfall_sink_f_impl.h
@@ -32,125 +32,127 @@
#include <gnuradio/qtgui/waterfalldisplayform.h>
namespace gr {
- namespace qtgui {
-
- class QTGUI_API waterfall_sink_f_impl : public waterfall_sink_f
- {
- private:
- void forecast(int noutput_items, gr_vector_int &ninput_items_required);
-
- void initialize();
-
- int d_fftsize;
- fft::fft_shift<float> d_fft_shift;
- float d_fftavg;
- filter::firdes::win_type d_wintype;
- std::vector<float> d_window;
- double d_center_freq;
- double d_bandwidth;
- std::string d_name;
- int d_nconnections;
- int d_nrows;
-
- const pmt::pmt_t d_port;
- const pmt::pmt_t d_port_bw;
-
- bool d_shift;
- fft::fft_complex *d_fft;
-
- int d_index;
- std::vector<float*> d_residbufs;
- std::vector<double*> d_magbufs;
- double *d_pdu_magbuf;
- float *d_fbuf;
-
- int d_argc;
- char *d_argv;
- QWidget *d_parent;
- WaterfallDisplayForm *d_main_gui;
-
- gr::high_res_timer_type d_update_time;
- gr::high_res_timer_type d_last_time;
-
- void windowreset();
- void buildwindow();
- void fftresize();
- void check_clicked();
- void fft(float *data_out, const float *data_in, int size);
-
- // Handles message input port for setting new bandwidth
- // The message is a PMT pair (intern('bw'), double(bw))
- void handle_set_bw(pmt::pmt_t msg);
-
- // Handles message input port for setting new center frequency.
- // The message is a PMT pair (intern('freq'), double(frequency)).
- void handle_set_freq(pmt::pmt_t msg);
-
- // Handles message input port for displaying PDU samples.
- void handle_pdus(pmt::pmt_t msg);
-
- public:
- waterfall_sink_f_impl(int size, int wintype,
- double fc, double bw,
- const std::string &name,
- int nconnections,
- QWidget *parent=NULL);
- ~waterfall_sink_f_impl();
-
- bool check_topology(int ninputs, int noutputs);
-
- void exec_();
- QWidget* qwidget();
+namespace qtgui {
+
+class QTGUI_API waterfall_sink_f_impl : public waterfall_sink_f
+{
+private:
+ void forecast(int noutput_items, gr_vector_int& ninput_items_required);
+
+ void initialize();
+
+ int d_fftsize;
+ fft::fft_shift<float> d_fft_shift;
+ float d_fftavg;
+ filter::firdes::win_type d_wintype;
+ std::vector<float> d_window;
+ double d_center_freq;
+ double d_bandwidth;
+ std::string d_name;
+ int d_nconnections;
+ int d_nrows;
+
+ const pmt::pmt_t d_port;
+ const pmt::pmt_t d_port_bw;
+
+ bool d_shift;
+ fft::fft_complex* d_fft;
+
+ int d_index;
+ std::vector<float*> d_residbufs;
+ std::vector<double*> d_magbufs;
+ double* d_pdu_magbuf;
+ float* d_fbuf;
+
+ int d_argc;
+ char* d_argv;
+ QWidget* d_parent;
+ WaterfallDisplayForm* d_main_gui;
+
+ gr::high_res_timer_type d_update_time;
+ gr::high_res_timer_type d_last_time;
+
+ void windowreset();
+ void buildwindow();
+ void fftresize();
+ void check_clicked();
+ void fft(float* data_out, const float* data_in, int size);
+
+ // Handles message input port for setting new bandwidth
+ // The message is a PMT pair (intern('bw'), double(bw))
+ void handle_set_bw(pmt::pmt_t msg);
+
+ // Handles message input port for setting new center frequency.
+ // The message is a PMT pair (intern('freq'), double(frequency)).
+ void handle_set_freq(pmt::pmt_t msg);
+
+ // Handles message input port for displaying PDU samples.
+ void handle_pdus(pmt::pmt_t msg);
+
+public:
+ waterfall_sink_f_impl(int size,
+ int wintype,
+ double fc,
+ double bw,
+ const std::string& name,
+ int nconnections,
+ QWidget* parent = NULL);
+ ~waterfall_sink_f_impl();
+
+ bool check_topology(int ninputs, int noutputs);
+
+ void exec_();
+ QWidget* qwidget();
#ifdef ENABLE_PYTHON
- PyObject* pyqwidget();
+ PyObject* pyqwidget();
#else
- void* pyqwidget();
+ void* pyqwidget();
#endif
- void clear_data();
-
- void set_fft_size(const int fftsize);
- int fft_size() const;
- void set_fft_average(const float fftavg);
- float fft_average() const;
- void set_fft_window(const gr::filter::firdes::win_type win);
- gr::filter::firdes::win_type fft_window();
-
- void set_frequency_range(const double centerfreq, const double bandwidth);
- void set_intensity_range(const double min, const double max);
-
- void set_update_time(double t);
- void set_time_per_fft(double t);
- void set_title(const std::string &title);
- void set_time_title(const std::string &title);
- void set_line_label(unsigned int which, const std::string &label);
- void set_line_alpha(unsigned int which, double alpha);
- void set_color_map(unsigned int which, const int color);
- void set_plot_pos_half(bool half);
-
- std::string title();
- std::string line_label(unsigned int which);
- double line_alpha(unsigned int which);
- int color_map(unsigned int which);
-
- void set_size(int width, int height);
-
- void auto_scale();
- double min_intensity(unsigned int which);
- double max_intensity(unsigned int which);
-
- void enable_menu(bool en);
- void enable_grid(bool en);
- void disable_legend();
- void enable_axis_labels(bool en);
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace qtgui */
+ void clear_data();
+
+ void set_fft_size(const int fftsize);
+ int fft_size() const;
+ void set_fft_average(const float fftavg);
+ float fft_average() const;
+ void set_fft_window(const gr::filter::firdes::win_type win);
+ gr::filter::firdes::win_type fft_window();
+
+ void set_frequency_range(const double centerfreq, const double bandwidth);
+ void set_intensity_range(const double min, const double max);
+
+ void set_update_time(double t);
+ void set_time_per_fft(double t);
+ void set_title(const std::string& title);
+ void set_time_title(const std::string& title);
+ void set_line_label(unsigned int which, const std::string& label);
+ void set_line_alpha(unsigned int which, double alpha);
+ void set_color_map(unsigned int which, const int color);
+ void set_plot_pos_half(bool half);
+
+ std::string title();
+ std::string line_label(unsigned int which);
+ double line_alpha(unsigned int which);
+ int color_map(unsigned int which);
+
+ void set_size(int width, int height);
+
+ void auto_scale();
+ double min_intensity(unsigned int which);
+ double max_intensity(unsigned int which);
+
+ void enable_menu(bool en);
+ void enable_grid(bool en);
+ void disable_legend();
+ void enable_axis_labels(bool en);
+
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+};
+
+} /* namespace qtgui */
} /* namespace gr */
#endif /* INCLUDED_QTGUI_WATERFALL_SINK_F_IMPL_H */
diff --git a/gr-qtgui/lib/waterfalldisplayform.cc b/gr-qtgui/lib/waterfalldisplayform.cc
index 4ada967d90..d97c815d05 100644
--- a/gr-qtgui/lib/waterfalldisplayform.cc
+++ b/gr-qtgui/lib/waterfalldisplayform.cc
@@ -29,338 +29,299 @@
#include <iostream>
WaterfallDisplayForm::WaterfallDisplayForm(int nplots, QWidget* parent)
- : DisplayForm(nplots, parent)
+ : DisplayForm(nplots, parent)
{
- d_int_validator = new QIntValidator(this);
- d_int_validator->setBottom(0);
-
- d_layout = new QGridLayout(this);
- d_display_plot = new WaterfallDisplayPlot(nplots, this);
- d_layout->addWidget(d_display_plot, 0, 0);
- setLayout(d_layout);
-
- d_center_freq = 0;
- d_samp_rate = 0;
-
- d_fftsize = 1024;
- d_fftavg = 1.0;
-
- d_min_val = 1000;
- d_max_val = -1000;
-
- d_clicked = false;
- d_clicked_freq = 0;
- d_time_per_fft = 0;
- // We don't use the normal menus that are part of the displayform.
- // Clear them out to get rid of their resources.
- for(int i = 0; i < nplots; i++) {
- d_lines_menu[i]->clear();
- }
- d_line_title_act.clear();
- d_line_color_menu.clear();
- d_line_width_menu.clear();
- d_line_style_menu.clear();
- d_line_marker_menu.clear();
- d_marker_alpha_menu.clear();
-
- // Now create our own menus
- for(int i = 0; i < nplots; i++) {
- ColorMapMenu *colormap = new ColorMapMenu(i, this);
- connect(colormap, SIGNAL(whichTrigger(unsigned int, const int, const QColor&, const QColor&)),
- this, SLOT(setColorMap(unsigned int, const int, const QColor&, const QColor&)));
- d_lines_menu[i]->addMenu(colormap);
-
- d_marker_alpha_menu.push_back(new MarkerAlphaMenu(i, this));
- connect(d_marker_alpha_menu[i], SIGNAL(whichTrigger(unsigned int, unsigned int)),
- this, SLOT(setAlpha(unsigned int, unsigned int)));
- d_lines_menu[i]->addMenu(d_marker_alpha_menu[i]);
- }
-
- // One scales once when clicked, so no on/off toggling
- d_autoscale_act->setText(tr("Auto Scale"));
- d_autoscale_act->setCheckable(false);
-
- d_sizemenu = new FFTSizeMenu(this);
- d_avgmenu = new FFTAverageMenu(this);
- d_winmenu = new FFTWindowMenu(this);
- d_menu->addMenu(d_sizemenu);
- d_menu->addMenu(d_avgmenu);
- d_menu->addMenu(d_winmenu);
- connect(d_sizemenu, SIGNAL(whichTrigger(int)),
- this, SLOT(setFFTSize(const int)));
- connect(d_avgmenu, SIGNAL(whichTrigger(float)),
- this, SLOT(setFFTAverage(const float)));
- connect(d_winmenu, SIGNAL(whichTrigger(gr::filter::firdes::win_type)),
- this, SLOT(setFFTWindowType(const gr::filter::firdes::win_type)));
-
- PopupMenu *maxintmenu = new PopupMenu("Int. Max", this);
- d_menu->addAction(maxintmenu);
- connect(maxintmenu, SIGNAL(whichTrigger(QString)),
- this, SLOT(setMaxIntensity(QString)));
-
- PopupMenu *minintmenu = new PopupMenu("Int. Min", this);
- d_menu->addAction(minintmenu);
- connect(minintmenu, SIGNAL(whichTrigger(QString)),
- this, SLOT(setMinIntensity(QString)));
-
- Reset();
-
- connect(d_display_plot, SIGNAL(plotPointSelected(const QPointF)),
- this, SLOT(onPlotPointSelected(const QPointF)));
+ d_int_validator = new QIntValidator(this);
+ d_int_validator->setBottom(0);
+
+ d_layout = new QGridLayout(this);
+ d_display_plot = new WaterfallDisplayPlot(nplots, this);
+ d_layout->addWidget(d_display_plot, 0, 0);
+ setLayout(d_layout);
+
+ d_center_freq = 0;
+ d_samp_rate = 0;
+
+ d_fftsize = 1024;
+ d_fftavg = 1.0;
+
+ d_min_val = 1000;
+ d_max_val = -1000;
+
+ d_clicked = false;
+ d_clicked_freq = 0;
+ d_time_per_fft = 0;
+ // We don't use the normal menus that are part of the displayform.
+ // Clear them out to get rid of their resources.
+ for (int i = 0; i < nplots; i++) {
+ d_lines_menu[i]->clear();
+ }
+ d_line_title_act.clear();
+ d_line_color_menu.clear();
+ d_line_width_menu.clear();
+ d_line_style_menu.clear();
+ d_line_marker_menu.clear();
+ d_marker_alpha_menu.clear();
+
+ // Now create our own menus
+ for (int i = 0; i < nplots; i++) {
+ ColorMapMenu* colormap = new ColorMapMenu(i, this);
+ connect(
+ colormap,
+ SIGNAL(whichTrigger(unsigned int, const int, const QColor&, const QColor&)),
+ this,
+ SLOT(setColorMap(unsigned int, const int, const QColor&, const QColor&)));
+ d_lines_menu[i]->addMenu(colormap);
+
+ d_marker_alpha_menu.push_back(new MarkerAlphaMenu(i, this));
+ connect(d_marker_alpha_menu[i],
+ SIGNAL(whichTrigger(unsigned int, unsigned int)),
+ this,
+ SLOT(setAlpha(unsigned int, unsigned int)));
+ d_lines_menu[i]->addMenu(d_marker_alpha_menu[i]);
+ }
+
+ // One scales once when clicked, so no on/off toggling
+ d_autoscale_act->setText(tr("Auto Scale"));
+ d_autoscale_act->setCheckable(false);
+
+ d_sizemenu = new FFTSizeMenu(this);
+ d_avgmenu = new FFTAverageMenu(this);
+ d_winmenu = new FFTWindowMenu(this);
+ d_menu->addMenu(d_sizemenu);
+ d_menu->addMenu(d_avgmenu);
+ d_menu->addMenu(d_winmenu);
+ connect(d_sizemenu, SIGNAL(whichTrigger(int)), this, SLOT(setFFTSize(const int)));
+ connect(
+ d_avgmenu, SIGNAL(whichTrigger(float)), this, SLOT(setFFTAverage(const float)));
+ connect(d_winmenu,
+ SIGNAL(whichTrigger(gr::filter::firdes::win_type)),
+ this,
+ SLOT(setFFTWindowType(const gr::filter::firdes::win_type)));
+
+ PopupMenu* maxintmenu = new PopupMenu("Int. Max", this);
+ d_menu->addAction(maxintmenu);
+ connect(
+ maxintmenu, SIGNAL(whichTrigger(QString)), this, SLOT(setMaxIntensity(QString)));
+
+ PopupMenu* minintmenu = new PopupMenu("Int. Min", this);
+ d_menu->addAction(minintmenu);
+ connect(
+ minintmenu, SIGNAL(whichTrigger(QString)), this, SLOT(setMinIntensity(QString)));
+
+ Reset();
+
+ connect(d_display_plot,
+ SIGNAL(plotPointSelected(const QPointF)),
+ this,
+ SLOT(onPlotPointSelected(const QPointF)));
}
WaterfallDisplayForm::~WaterfallDisplayForm()
{
- // Qt deletes children when parent is deleted
+ // Qt deletes children when parent is deleted
- // Don't worry about deleting Display Plots - they are deleted when parents are deleted
- delete d_int_validator;
+ // Don't worry about deleting Display Plots - they are deleted when parents are
+ // deleted
+ delete d_int_validator;
}
-WaterfallDisplayPlot*
-WaterfallDisplayForm::getPlot()
+WaterfallDisplayPlot* WaterfallDisplayForm::getPlot()
{
- return ((WaterfallDisplayPlot*)d_display_plot);
+ return ((WaterfallDisplayPlot*)d_display_plot);
}
-void
-WaterfallDisplayForm::newData(const QEvent *updateEvent)
+void WaterfallDisplayForm::newData(const QEvent* updateEvent)
{
- WaterfallUpdateEvent *event = (WaterfallUpdateEvent*)updateEvent;
- const std::vector<double*> dataPoints = event->getPoints();
- const uint64_t numDataPoints = event->getNumDataPoints();
- const gr::high_res_timer_type dataTimestamp = event->getDataTimestamp();
-
- for(size_t i=0; i < dataPoints.size(); i++) {
- double *min_val = std::min_element(&dataPoints[i][0], &dataPoints[i][numDataPoints-1]);
- double *max_val = std::max_element(&dataPoints[i][0], &dataPoints[i][numDataPoints-1]);
- if(*min_val < d_min_val)
- d_min_val = *min_val;
- if(*max_val > d_max_val)
- d_max_val = *max_val;
- }
-
- getPlot()->plotNewData(dataPoints, numDataPoints, d_time_per_fft, dataTimestamp, 0);
-}
-
-void
-WaterfallDisplayForm::customEvent( QEvent * e)
+ WaterfallUpdateEvent* event = (WaterfallUpdateEvent*)updateEvent;
+ const std::vector<double*> dataPoints = event->getPoints();
+ const uint64_t numDataPoints = event->getNumDataPoints();
+ const gr::high_res_timer_type dataTimestamp = event->getDataTimestamp();
+
+ for (size_t i = 0; i < dataPoints.size(); i++) {
+ double* min_val =
+ std::min_element(&dataPoints[i][0], &dataPoints[i][numDataPoints - 1]);
+ double* max_val =
+ std::max_element(&dataPoints[i][0], &dataPoints[i][numDataPoints - 1]);
+ if (*min_val < d_min_val)
+ d_min_val = *min_val;
+ if (*max_val > d_max_val)
+ d_max_val = *max_val;
+ }
+
+ getPlot()->plotNewData(dataPoints, numDataPoints, d_time_per_fft, dataTimestamp, 0);
+}
+
+void WaterfallDisplayForm::customEvent(QEvent* e)
{
- if(e->type() == WaterfallUpdateEvent::Type()) {
- newData(e);
- }
- else if(e->type() == SpectrumFrequencyRangeEventType) {
- SetFreqEvent *fevent = (SetFreqEvent*)e;
- setFrequencyRange(fevent->getCenterFrequency(), fevent->getBandwidth());
- }
+ if (e->type() == WaterfallUpdateEvent::Type()) {
+ newData(e);
+ } else if (e->type() == SpectrumFrequencyRangeEventType) {
+ SetFreqEvent* fevent = (SetFreqEvent*)e;
+ setFrequencyRange(fevent->getCenterFrequency(), fevent->getBandwidth());
+ }
}
-int
-WaterfallDisplayForm::getFFTSize() const
-{
- return d_fftsize;
-}
+int WaterfallDisplayForm::getFFTSize() const { return d_fftsize; }
-float
-WaterfallDisplayForm::getFFTAverage() const
-{
- return d_fftavg;
-}
+float WaterfallDisplayForm::getFFTAverage() const { return d_fftavg; }
-gr::filter::firdes::win_type
-WaterfallDisplayForm::getFFTWindowType() const
+gr::filter::firdes::win_type WaterfallDisplayForm::getFFTWindowType() const
{
- return d_fftwintype;
+ return d_fftwintype;
}
-int
-WaterfallDisplayForm::getColorMap(unsigned int which)
+int WaterfallDisplayForm::getColorMap(unsigned int which)
{
- return getPlot()->getIntensityColorMapType(which);
+ return getPlot()->getIntensityColorMapType(which);
}
-int
-WaterfallDisplayForm::getAlpha(unsigned int which)
+int WaterfallDisplayForm::getAlpha(unsigned int which)
{
- return getPlot()->getAlpha(which);
+ return getPlot()->getAlpha(which);
}
-double
-WaterfallDisplayForm::getMinIntensity(unsigned int which)
+double WaterfallDisplayForm::getMinIntensity(unsigned int which)
{
- return getPlot()->getMinIntensity(which);
+ return getPlot()->getMinIntensity(which);
}
-double
-WaterfallDisplayForm::getMaxIntensity(unsigned int which)
+double WaterfallDisplayForm::getMaxIntensity(unsigned int which)
{
- return getPlot()->getMaxIntensity(which);
+ return getPlot()->getMaxIntensity(which);
}
-void
-WaterfallDisplayForm::setSampleRate(const QString &samprate)
+void WaterfallDisplayForm::setSampleRate(const QString& samprate)
{
- setFrequencyRange(d_center_freq, samprate.toDouble());
+ setFrequencyRange(d_center_freq, samprate.toDouble());
}
-void
-WaterfallDisplayForm::setFFTSize(const int newsize)
+void WaterfallDisplayForm::setFFTSize(const int newsize)
{
- d_fftsize = newsize;
- d_sizemenu->getActionFromSize(newsize)->setChecked(true);
- getPlot()->replot();
+ d_fftsize = newsize;
+ d_sizemenu->getActionFromSize(newsize)->setChecked(true);
+ getPlot()->replot();
}
-void
-WaterfallDisplayForm::setFFTAverage(const float newavg)
+void WaterfallDisplayForm::setFFTAverage(const float newavg)
{
- d_fftavg = newavg;
- d_avgmenu->getActionFromAvg(newavg)->setChecked(true);
- getPlot()->replot();
+ d_fftavg = newavg;
+ d_avgmenu->getActionFromAvg(newavg)->setChecked(true);
+ getPlot()->replot();
}
-void
-WaterfallDisplayForm::setFFTWindowType(const gr::filter::firdes::win_type newwin)
+void WaterfallDisplayForm::setFFTWindowType(const gr::filter::firdes::win_type newwin)
{
- d_fftwintype = newwin;
- d_winmenu->getActionFromWindow(newwin)->setChecked(true);
- getPlot()->replot();
+ d_fftwintype = newwin;
+ d_winmenu->getActionFromWindow(newwin)->setChecked(true);
+ getPlot()->replot();
}
-void
-WaterfallDisplayForm::setFrequencyRange(const double centerfreq,
- const double bandwidth)
+void WaterfallDisplayForm::setFrequencyRange(const double centerfreq,
+ const double bandwidth)
{
- std::string strunits[4] = {"Hz", "kHz", "MHz", "GHz"};
- double units10 = floor(log10(bandwidth));
- double units3 = std::max(floor(units10 / 3.0), 0.0);
- d_units = pow(10, (units10-fmod(units10, 3.0)));
- int iunit = static_cast<int>(units3);
-
- d_center_freq = centerfreq;
- d_samp_rate = bandwidth;
-
- getPlot()->setFrequencyRange(centerfreq, bandwidth,
- d_units, strunits[iunit]);
- getPlot()->replot();
+ std::string strunits[4] = { "Hz", "kHz", "MHz", "GHz" };
+ double units10 = floor(log10(bandwidth));
+ double units3 = std::max(floor(units10 / 3.0), 0.0);
+ d_units = pow(10, (units10 - fmod(units10, 3.0)));
+ int iunit = static_cast<int>(units3);
+
+ d_center_freq = centerfreq;
+ d_samp_rate = bandwidth;
+
+ getPlot()->setFrequencyRange(centerfreq, bandwidth, d_units, strunits[iunit]);
+ getPlot()->replot();
}
-void
-WaterfallDisplayForm::setColorMap(unsigned int which,
- const int newType,
- const QColor lowColor,
- const QColor highColor)
+void WaterfallDisplayForm::setColorMap(unsigned int which,
+ const int newType,
+ const QColor lowColor,
+ const QColor highColor)
{
- getPlot()->setIntensityColorMapType(which, newType,
- lowColor, highColor);
- getPlot()->replot();
+ getPlot()->setIntensityColorMapType(which, newType, lowColor, highColor);
+ getPlot()->replot();
}
-void
-WaterfallDisplayForm::setAlpha(unsigned int which, unsigned int alpha)
+void WaterfallDisplayForm::setAlpha(unsigned int which, unsigned int alpha)
{
- getPlot()->setAlpha(which, alpha);
- getPlot()->replot();
+ getPlot()->setAlpha(which, alpha);
+ getPlot()->replot();
}
-void
-WaterfallDisplayForm::setIntensityRange(const double minIntensity,
- const double maxIntensity)
+void WaterfallDisplayForm::setIntensityRange(const double minIntensity,
+ const double maxIntensity)
{
- // reset max and min values
- d_min_val = 1000;
- d_max_val = -1000;
-
- d_cur_min_val = minIntensity;
- d_cur_max_val = maxIntensity;
- getPlot()->setIntensityRange(minIntensity, maxIntensity);
- getPlot()->replot();
+ // reset max and min values
+ d_min_val = 1000;
+ d_max_val = -1000;
+
+ d_cur_min_val = minIntensity;
+ d_cur_max_val = maxIntensity;
+ getPlot()->setIntensityRange(minIntensity, maxIntensity);
+ getPlot()->replot();
}
-void
-WaterfallDisplayForm::setMaxIntensity(const QString &m)
+void WaterfallDisplayForm::setMaxIntensity(const QString& m)
{
- double new_max = m.toDouble();
- if(new_max > d_cur_min_val)
- setIntensityRange(d_cur_min_val, new_max);
+ double new_max = m.toDouble();
+ if (new_max > d_cur_min_val)
+ setIntensityRange(d_cur_min_val, new_max);
}
-void
-WaterfallDisplayForm::setMinIntensity(const QString &m)
+void WaterfallDisplayForm::setMinIntensity(const QString& m)
{
- double new_min = m.toDouble();
- if(new_min < d_cur_max_val)
- setIntensityRange(new_min, d_cur_max_val);
+ double new_min = m.toDouble();
+ if (new_min < d_cur_max_val)
+ setIntensityRange(new_min, d_cur_max_val);
}
-void
-WaterfallDisplayForm::autoScale(bool en)
+void WaterfallDisplayForm::autoScale(bool en)
{
- double min_int = d_min_val - 5;
- double max_int = d_max_val + 10;
+ double min_int = d_min_val - 5;
+ double max_int = d_max_val + 10;
- setIntensityRange(min_int, max_int);
+ setIntensityRange(min_int, max_int);
}
-void
-WaterfallDisplayForm::clearData()
-{
- getPlot()->clearData();
-}
+void WaterfallDisplayForm::clearData() { getPlot()->clearData(); }
-void
-WaterfallDisplayForm::onPlotPointSelected(const QPointF p)
+void WaterfallDisplayForm::onPlotPointSelected(const QPointF p)
{
- d_clicked = true;
- d_clicked_freq = d_units*p.x();
+ d_clicked = true;
+ d_clicked_freq = d_units * p.x();
}
-bool
-WaterfallDisplayForm::checkClicked()
+bool WaterfallDisplayForm::checkClicked()
{
- if(d_clicked) {
- d_clicked = false;
- return true;
- }
- else {
- return false;
- }
+ if (d_clicked) {
+ d_clicked = false;
+ return true;
+ } else {
+ return false;
+ }
}
-void
-WaterfallDisplayForm::setTimeTitle(const std::string title) {
+void WaterfallDisplayForm::setTimeTitle(const std::string title)
+{
getPlot()->setAxisTitle(QwtPlot::yLeft, title.c_str());
}
-float
-WaterfallDisplayForm::getClickedFreq() const
-{
- return d_clicked_freq;
-}
+float WaterfallDisplayForm::getClickedFreq() const { return d_clicked_freq; }
-void
-WaterfallDisplayForm::setPlotPosHalf(bool half)
+void WaterfallDisplayForm::setPlotPosHalf(bool half)
{
- getPlot()->setPlotPosHalf(half);
- getPlot()->replot();
+ getPlot()->setPlotPosHalf(half);
+ getPlot()->replot();
}
-void
-WaterfallDisplayForm::setTimePerFFT(double t)
-{
- d_time_per_fft = t;
-}
+void WaterfallDisplayForm::setTimePerFFT(double t) { d_time_per_fft = t; }
-double WaterfallDisplayForm::getTimePerFFT()
-{
- return d_time_per_fft;
-}
+double WaterfallDisplayForm::getTimePerFFT() { return d_time_per_fft; }
// Override displayform SetUpdateTime() to set FFT time
-void
-WaterfallDisplayForm::setUpdateTime(double t)
+void WaterfallDisplayForm::setUpdateTime(double t)
{
- d_update_time = t;
- // Assume times are equal unless explicitly told by setTimePerFFT()
- // This is the case when plotting using gr_spectrogram_plot
- d_time_per_fft = t;
+ d_update_time = t;
+ // Assume times are equal unless explicitly told by setTimePerFFT()
+ // This is the case when plotting using gr_spectrogram_plot
+ d_time_per_fft = t;
}