[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 01/08: qtgui: allow float freq plot to only
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 01/08: qtgui: allow float freq plot to only plot positive half of spectrum. |
Date: |
Thu, 23 Oct 2014 22:03:16 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
trondeau pushed a commit to branch master
in repository gnuradio.
commit cf14017d8a5228bd792ad0ea7a1c0e97548f6988
Author: Tom Rondeau <address@hidden>
Date: Wed Oct 22 11:24:52 2014 -0400
qtgui: allow float freq plot to only plot positive half of spectrum.
---
gr-qtgui/grc/qtgui_freq_sink_x.xml | 23 +++++++++++++++
.../include/gnuradio/qtgui/FrequencyDisplayPlot.h | 3 ++
gr-qtgui/include/gnuradio/qtgui/freq_sink_f.h | 1 +
gr-qtgui/include/gnuradio/qtgui/freqdisplayform.h | 1 +
gr-qtgui/lib/FrequencyDisplayPlot.cc | 34 +++++++++++++++++-----
gr-qtgui/lib/freq_sink_c_impl.cc | 4 +--
gr-qtgui/lib/freq_sink_f_impl.cc | 10 +++++--
gr-qtgui/lib/freq_sink_f_impl.h | 1 +
gr-qtgui/lib/freqdisplayform.cc | 7 +++++
9 files changed, 72 insertions(+), 12 deletions(-)
diff --git a/gr-qtgui/grc/qtgui_freq_sink_x.xml
b/gr-qtgui/grc/qtgui_freq_sink_x.xml
index 94989f5..5a8a860 100644
--- a/gr-qtgui/grc/qtgui_freq_sink_x.xml
+++ b/gr-qtgui/grc/qtgui_freq_sink_x.xml
@@ -26,6 +26,10 @@ self.$(id).enable_autoscale($autoscale)
self.$(id).enable_grid($grid)
self.$(id).set_fft_average($average)
+print $type, type(float())
+if $type == type(float()):
+ self.$(id).set_plot_pos_half(not $freqhalf)
+
labels = [$label1, $label2, $label3, $label4, $label5,
$label6, $label7, $label8, $label9, $label10]
widths = [$width1, $width2, $width3, $width4, $width5,
@@ -80,6 +84,25 @@ $(gui_hint()($win))</make>
<type>int</type>
</param>
+
+ <param>
+ <name>Spectrum Width</name>
+ <key>freqhalf</key>
+ <value>True</value>
+ <type>enum</type>
+ <hide>#if $type() == "float" then 'part' else 'all'#</hide>
+ <option>
+ <name>Full</name>
+ <key>True</key>
+ </option>
+ <option>
+ <name>Half</name>
+ <key>False</key>
+ </option>
+ </param>
+
+
+
<param>
<name>Window Type</name>
<key>wintype</key>
diff --git a/gr-qtgui/include/gnuradio/qtgui/FrequencyDisplayPlot.h
b/gr-qtgui/include/gnuradio/qtgui/FrequencyDisplayPlot.h
index ac7dfe8..cb44fbe 100644
--- a/gr-qtgui/include/gnuradio/qtgui/FrequencyDisplayPlot.h
+++ b/gr-qtgui/include/gnuradio/qtgui/FrequencyDisplayPlot.h
@@ -118,6 +118,8 @@ public slots:
void setAutoScale(bool state);
+ void setPlotPosHalf(bool half);
+
private:
void _resetXAxisPoints();
void _autoScale(double bottom, double top);
@@ -143,6 +145,7 @@ private:
double d_stop_frequency;
double d_ymax;
double d_ymin;
+ bool d_half_freq;
QwtPlotMarker* d_lower_intensity_marker;
QwtPlotMarker* d_upper_intensity_marker;
diff --git a/gr-qtgui/include/gnuradio/qtgui/freq_sink_f.h
b/gr-qtgui/include/gnuradio/qtgui/freq_sink_f.h
index 81f9c0c..cbd8c97 100644
--- a/gr-qtgui/include/gnuradio/qtgui/freq_sink_f.h
+++ b/gr-qtgui/include/gnuradio/qtgui/freq_sink_f.h
@@ -116,6 +116,7 @@ namespace gr {
virtual void set_line_style(int which, int style) = 0;
virtual void set_line_marker(int which, int marker) = 0;
virtual void set_line_alpha(int which, double alpha) = 0;
+ virtual void set_plot_pos_half(bool half) = 0;
virtual std::string title() = 0;
virtual std::string line_label(int which) = 0;
diff --git a/gr-qtgui/include/gnuradio/qtgui/freqdisplayform.h
b/gr-qtgui/include/gnuradio/qtgui/freqdisplayform.h
index 7cd077e..2fea33d 100644
--- a/gr-qtgui/include/gnuradio/qtgui/freqdisplayform.h
+++ b/gr-qtgui/include/gnuradio/qtgui/freqdisplayform.h
@@ -69,6 +69,7 @@ public slots:
void setYMax(const QString &m);
void setYMin(const QString &m);
void autoScale(bool en);
+ void setPlotPosHalf(bool half);
void clearMaxHold();
void clearMinHold();
diff --git a/gr-qtgui/lib/FrequencyDisplayPlot.cc
b/gr-qtgui/lib/FrequencyDisplayPlot.cc
index 12835bc..6e0983e 100644
--- a/gr-qtgui/lib/FrequencyDisplayPlot.cc
+++ b/gr-qtgui/lib/FrequencyDisplayPlot.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2008-2011 Free Software Foundation, Inc.
+ * Copyright 2008-2011,2014 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -94,6 +94,7 @@ FrequencyDisplayPlot::FrequencyDisplayPlot(int nplots,
QWidget* parent)
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;
setAxisTitle(QwtPlot::xBottom, "Frequency (Hz)");
setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(0));
@@ -279,8 +280,13 @@ FrequencyDisplayPlot::setFrequencyRange(const double
centerfreq,
const double bandwidth,
const double units, const std::string
&strunits)
{
- double startFreq = (centerfreq - bandwidth/2.0f) / units;
- double stopFreq = (centerfreq + bandwidth/2.0f) / units;
+ double startFreq;
+ double stopFreq = (centerfreq + bandwidth/2.0f) / units;
+ if(d_half_freq)
+ startFreq = 0;
+ else
+ startFreq = (centerfreq - bandwidth/2.0f) / units;
+
d_xdata_multiplier = units;
@@ -346,10 +352,13 @@ FrequencyDisplayPlot::plotNewData(const
std::vector<double*> dataPoints,
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;
+
if(!d_stop) {
if(numDataPoints > 0) {
- if(numDataPoints != d_numPoints) {
- d_numPoints = numDataPoints;
+ if(_npoints_in != d_numPoints) {
+ d_numPoints = _npoints_in;
delete[] d_min_fft_data;
delete[] d_max_fft_data;
@@ -383,9 +392,9 @@ FrequencyDisplayPlot::plotNewData(const
std::vector<double*> dataPoints,
double bottom=1e20, top=-1e20;
for(int n = 0; n < d_nplots; n++) {
- memcpy(d_ydata[n], dataPoints[n], numDataPoints*sizeof(double));
+ memcpy(d_ydata[n], &(dataPoints[n][_in_index]),
_npoints_in*sizeof(double));
- for(int64_t point = 0; point < numDataPoints; point++) {
+ 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];
}
@@ -462,6 +471,15 @@ FrequencyDisplayPlot::setAutoScale(bool state)
}
void
+FrequencyDisplayPlot::setPlotPosHalf(bool half)
+{
+ d_half_freq = half;
+ if(half)
+ d_start_frequency = 0;
+}
+
+
+void
FrequencyDisplayPlot::setMaxFFTVisible(const bool visibleFlag)
{
d_max_fft_visible = visibleFlag;
@@ -491,7 +509,7 @@ void
FrequencyDisplayPlot::_resetXAxisPoints()
{
double fft_bin_size = (d_stop_frequency - d_start_frequency)
- / static_cast<double>(d_numPoints-1);
+ / static_cast<double>(d_numPoints - (d_half_freq ? 0 : 1));
double freqValue = d_start_frequency;
for(int64_t loc = 0; loc < d_numPoints; loc++) {
d_xdata[loc] = freqValue;
diff --git a/gr-qtgui/lib/freq_sink_c_impl.cc b/gr-qtgui/lib/freq_sink_c_impl.cc
index 1782b58..72648e3 100644
--- a/gr-qtgui/lib/freq_sink_c_impl.cc
+++ b/gr-qtgui/lib/freq_sink_c_impl.cc
@@ -54,8 +54,8 @@ namespace gr {
int nconnections,
QWidget *parent)
: sync_block("freq_sink_c",
- io_signature::make(1, -1, sizeof(gr_complex)),
- io_signature::make(0, 0, 0)),
+ io_signature::make(1, -1, sizeof(gr_complex)),
+ io_signature::make(0, 0, 0)),
d_fftsize(fftsize), d_fftavg(1.0),
d_wintype((filter::firdes::win_type)(wintype)),
d_center_freq(fc), d_bandwidth(bw), d_name(name),
diff --git a/gr-qtgui/lib/freq_sink_f_impl.cc b/gr-qtgui/lib/freq_sink_f_impl.cc
index fb98db2..d01c535 100644
--- a/gr-qtgui/lib/freq_sink_f_impl.cc
+++ b/gr-qtgui/lib/freq_sink_f_impl.cc
@@ -54,8 +54,8 @@ namespace gr {
int nconnections,
QWidget *parent)
: sync_block("freq_sink_f",
- io_signature::make(1, -1, sizeof(float)),
- io_signature::make(0, 0, 0)),
+ io_signature::make(1, -1, sizeof(float)),
+ io_signature::make(0, 0, 0)),
d_fftsize(fftsize), d_fftavg(1.0),
d_wintype((filter::firdes::win_type)(wintype)),
d_center_freq(fc), d_bandwidth(bw), d_name(name),
@@ -305,6 +305,12 @@ namespace gr {
d_main_gui->resize(QSize(width, height));
}
+ void
+ freq_sink_f_impl::set_plot_pos_half(bool half)
+ {
+ d_main_gui->setPlotPosHalf(half);
+ }
+
std::string
freq_sink_f_impl::title()
{
diff --git a/gr-qtgui/lib/freq_sink_f_impl.h b/gr-qtgui/lib/freq_sink_f_impl.h
index f2e82bb..d03acba 100644
--- a/gr-qtgui/lib/freq_sink_f_impl.h
+++ b/gr-qtgui/lib/freq_sink_f_impl.h
@@ -112,6 +112,7 @@ namespace gr {
void set_line_style(int which, int style);
void set_line_marker(int which, int marker);
void set_line_alpha(int which, double alpha);
+ void set_plot_pos_half(bool half);
std::string title();
std::string line_label(int which);
diff --git a/gr-qtgui/lib/freqdisplayform.cc b/gr-qtgui/lib/freqdisplayform.cc
index ccc7fe9..8004c99 100644
--- a/gr-qtgui/lib/freqdisplayform.cc
+++ b/gr-qtgui/lib/freqdisplayform.cc
@@ -222,6 +222,13 @@ FreqDisplayForm::autoScale(bool en)
}
void
+FreqDisplayForm::setPlotPosHalf(bool half)
+{
+ getPlot()->setPlotPosHalf(half);
+ getPlot()->replot();
+}
+
+void
FreqDisplayForm::clearMaxHold()
{
getPlot()->clearMaxData();
- [Commit-gnuradio] [gnuradio] branch master updated (d814381 -> 82779dc), git, 2014/10/23
- [Commit-gnuradio] [gnuradio] 04/08: qtgui: fixed comment., git, 2014/10/23
- [Commit-gnuradio] [gnuradio] 05/08: qtgui: added triggering to freq sinks., git, 2014/10/23
- [Commit-gnuradio] [gnuradio] 07/08: qtgui: removing malloc/free in fft function; doing once in ctor and when fftsize changes, instead., git, 2014/10/23
- [Commit-gnuradio] [gnuradio] 06/08: qtgui: removes use of outputsize in freq sinks., git, 2014/10/23
- [Commit-gnuradio] [gnuradio] 03/08: qtgui: allow toggle to only show positive half of waterfall spectrum., git, 2014/10/23
- [Commit-gnuradio] [gnuradio] 02/08: qtgui: fixed problem with setting fft size and averaging of the float waterfall at runtime., git, 2014/10/23
- [Commit-gnuradio] [gnuradio] 01/08: qtgui: allow float freq plot to only plot positive half of spectrum.,
git <=
- [Commit-gnuradio] [gnuradio] 08/08: Merge branch 'maint', git, 2014/10/23