Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Periodogram/Periodogram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ class Periodogram : public Pothos::Topology
this->connect(this, "clearChannels", _display, "clearChannels");
this->connect(_display, "frequencySelected", this, "frequencySelected");
this->connect(_display, "relativeFrequencySelected", this, "relativeFrequencySelected");
this->connect(_display, "levelSelected", this, "levelSelected");

//connect to the internal snooper block
this->connect(this, "setDisplayRate", _trigger, "setEventRate");
Expand Down
3 changes: 3 additions & 0 deletions Periodogram/PeriodogramDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ PeriodogramDisplay::PeriodogramDisplay(void):
this->registerSlot("clearChannels");
this->registerSignal("frequencySelected");
this->registerSignal("relativeFrequencySelected");
this->registerSignal("levelSelected");
this->setupInput(0);

//layout
Expand Down Expand Up @@ -230,6 +231,8 @@ void PeriodogramDisplay::handlePickerSelected(const QPointF &p)
const double freq = p.x()*_sampleRate/_sampleRateWoAxisUnits;
this->emitSignal("frequencySelected", freq);
this->emitSignal("relativeFrequencySelected", freq - _centerFreq);
const double level = p.y();
this->emitSignal("levelSelected", level);
}

void PeriodogramDisplay::handleLegendChecked(const QVariant &itemInfo, bool on, int)
Expand Down
2 changes: 2 additions & 0 deletions Spectrogram/Spectrogram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ class Spectrogram : public Pothos::Topology
this->connect(this, "setColorMap", _display, "setColorMap");
this->connect(_display, "frequencySelected", this, "frequencySelected");
this->connect(_display, "relativeFrequencySelected", this, "relativeFrequencySelected");
this->connect(_display, "timeSelected", this, "timeSelected");
this->connect(_display, "levelSelected", this, "levelSelected");

//connect to the internal snooper block
this->connect(_display, "updateRateChanged", _trigger, "setEventRate");
Expand Down
17 changes: 13 additions & 4 deletions Spectrogram/SpectrogramDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ SpectrogramDisplay::SpectrogramDisplay(void):
_centerFreqWoAxisUnits(0.0),
_numBins(1024),
_timeSpan(10.0),
_timeSpanWoAxisUnits(1.0),
_refLevel(0.0),
_dynRange(100.0),
_fullScale(1.0),
Expand Down Expand Up @@ -68,6 +69,8 @@ SpectrogramDisplay::SpectrogramDisplay(void):
this->registerCall(this, POTHOS_FCN_TUPLE(SpectrogramDisplay, setRateLabelId));
this->registerSignal("frequencySelected");
this->registerSignal("relativeFrequencySelected");
this->registerSignal("timeSelected");
this->registerSignal("levelSelected");
this->registerSignal("updateRateChanged");
this->setupInput(0);

Expand Down Expand Up @@ -180,22 +183,24 @@ void SpectrogramDisplay::setDynamicRange(const double dynRange)
void SpectrogramDisplay::handleUpdateAxis(void)
{
QString timeAxisTitle("secs");
double timeFactor = 1.0;
if (_timeSpan <= 100e-9)
{
_timeSpan *= 1e9;
timeFactor = 1e9;
timeAxisTitle = "nsecs";
}
else if (_timeSpan <= 100e-6)
{
_timeSpan *= 1e6;
timeFactor = 1e6;
timeAxisTitle = "usecs";
}
else if (_timeSpan <= 100e-3)
{
_timeSpan *= 1e3;
timeFactor = 1e3;
timeAxisTitle = "msecs";
}
_mainPlot->setAxisTitle(QwtPlot::yLeft, timeAxisTitle);
_timeSpanWoAxisUnits = _timeSpan*timeFactor;

QString freqAxisTitle("Hz");
double factor = std::max(_sampleRate, _centerFreq);
Expand Down Expand Up @@ -224,7 +229,7 @@ void SpectrogramDisplay::handleUpdateAxis(void)
//update main plot axis
const qreal freqLow = _fftModeComplex?(_centerFreqWoAxisUnits-_sampleRateWoAxisUnits/2):0.0;
_mainPlot->setAxisScale(QwtPlot::xBottom, freqLow, _centerFreqWoAxisUnits+_sampleRateWoAxisUnits/2);
_mainPlot->setAxisScale(QwtPlot::yLeft, 0, _timeSpan);
_mainPlot->setAxisScale(QwtPlot::yLeft, 0, _timeSpanWoAxisUnits);
_mainPlot->setAxisScale(QwtPlot::yRight, _refLevel-_dynRange, _refLevel);

_mainPlot->updateAxes(); //update after axis changes before setting raster
Expand Down Expand Up @@ -268,6 +273,10 @@ void SpectrogramDisplay::handlePickerSelected(const QPointF &p)
const double freq = p.x()*_sampleRate/_sampleRateWoAxisUnits;
this->emitSignal("frequencySelected", freq);
this->emitSignal("relativeFrequencySelected", freq - _centerFreq);
const double time = p.y()*_timeSpan/_timeSpanWoAxisUnits;
this->emitSignal("timeSelected", time);
const double level = _plotRaster->value(p.x(), p.y());
this->emitSignal("levelSelected", level);
}

void SpectrogramDisplay::appendBins(const std::valarray<float> &bins)
Expand Down
1 change: 1 addition & 0 deletions Spectrogram/SpectrogramDisplay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ private slots:
double _centerFreqWoAxisUnits;
size_t _numBins;
double _timeSpan;
double _timeSpanWoAxisUnits;
double _refLevel;
double _dynRange;
double _fullScale;
Expand Down