diff --git a/sdrgui/device/deviceuiset.cpp b/sdrgui/device/deviceuiset.cpp index 6a7a779a5..499fcc76d 100644 --- a/sdrgui/device/deviceuiset.cpp +++ b/sdrgui/device/deviceuiset.cpp @@ -70,6 +70,11 @@ DeviceUISet::~DeviceUISet() delete m_spectrum; } +void DeviceUISet::setSpectrumScalingFactor(float scalef) +{ + m_spectrumVis->setScalef(m_spectrumVis->getInputMessageQueue(), scalef); +} + void DeviceUISet::addChannelMarker(ChannelMarker* channelMarker) { m_spectrum->addChannelMarker(channelMarker); diff --git a/sdrgui/device/deviceuiset.h b/sdrgui/device/deviceuiset.h index ad065a201..4c69e5327 100644 --- a/sdrgui/device/deviceuiset.h +++ b/sdrgui/device/deviceuiset.h @@ -55,6 +55,7 @@ public: ~DeviceUISet(); GLSpectrum *getSpectrum() { return m_spectrum; } //!< Direct spectrum getter + void setSpectrumScalingFactor(float scalef); void addChannelMarker(ChannelMarker* channelMarker); //!< Add channel marker to spectrum void addRollupWidget(QWidget *widget); //!< Add rollup widget to channel window diff --git a/sdrgui/dsp/spectrumvis.cpp b/sdrgui/dsp/spectrumvis.cpp index 022145265..97adccd8e 100644 --- a/sdrgui/dsp/spectrumvis.cpp +++ b/sdrgui/dsp/spectrumvis.cpp @@ -13,6 +13,7 @@ inline double log2f(double n) #endif MESSAGE_CLASS_DEFINITION(SpectrumVis::MsgConfigureSpectrumVis, Message) +MESSAGE_CLASS_DEFINITION(SpectrumVis::MsgConfigureScalingFactor, Message) const Real SpectrumVis::m_mult = (10.0f / log2f(10.0f)); @@ -53,6 +54,12 @@ void SpectrumVis::configure(MessageQueue* msgQueue, msgQueue->push(cmd); } +void SpectrumVis::setScalef(MessageQueue* msgQueue, Real scalef) +{ + MsgConfigureScalingFactor* cmd = new MsgConfigureScalingFactor(scalef); + getInputMessageQueue()->push(cmd); +} + void SpectrumVis::feedTriggered(const SampleVector::const_iterator& triggerPoint, const SampleVector::const_iterator& end, bool positiveOnly) { feed(triggerPoint, end, positiveOnly); // normal feed from trigger point @@ -322,6 +329,12 @@ bool SpectrumVis::handleMessage(const Message& message) conf.getLinear()); return true; } + else if (MsgConfigureScalingFactor::match(message)) + { + MsgConfigureScalingFactor& conf = (MsgConfigureScalingFactor&) message; + handleScalef(conf.getScalef()); + return true; + } else { return false; @@ -376,3 +389,9 @@ void SpectrumVis::handleConfigure(int fftSize, m_ofs = 20.0f * log10f(1.0f / m_fftSize); m_powFFTDiv = m_fftSize*m_fftSize; } + +void SpectrumVis::handleScalef(Real scalef) +{ + QMutexLocker mutexLocker(&m_mutex); + m_scalef = scalef; +} \ No newline at end of file diff --git a/sdrgui/dsp/spectrumvis.h b/sdrgui/dsp/spectrumvis.h index 73d3ca254..668f67ac5 100644 --- a/sdrgui/dsp/spectrumvis.h +++ b/sdrgui/dsp/spectrumvis.h @@ -61,6 +61,22 @@ public: bool m_linear; }; + class MsgConfigureScalingFactor : public Message + { + MESSAGE_CLASS_DECLARATION + + public: + MsgConfigureScalingFactor(Real scalef) : + Message(), + m_scalef(scalef) + {} + + Real getScalef() const { return m_scalef; } + + private: + Real m_scalef; + }; + SpectrumVis(Real scalef, GLSpectrum* glSpectrum = 0); virtual ~SpectrumVis(); @@ -71,6 +87,7 @@ public: AvgMode averagingMode, FFTWindow::Function window, bool m_linear); + void setScalef(MessageQueue* msgQueue, Real scalef); virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly); void feedTriggered(const SampleVector::const_iterator& triggerPoint, const SampleVector::const_iterator& end, bool positiveOnly); @@ -113,6 +130,7 @@ private: AvgMode averagingMode, FFTWindow::Function window, bool linear); + void handleScalef(Real scalef); }; #endif // INCLUDE_SPECTRUMVIS_H