From c9c19f412c03707b813603002dfb9b4bf6cf609f Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 12 Aug 2018 15:49:14 +0200 Subject: [PATCH] Cleanup of old scope objects --- httpserver/httpconnectionhandler.cpp | 2 +- .../channelrx/chanalyzer/chanalyzergui.cpp | 1 - plugins/channelrx/demoddsd/dsddemodgui.cpp | 2 - sdrgui/CMakeLists.txt | 9 - sdrgui/dsp/scopevis.cpp | 459 ---- sdrgui/dsp/scopevis.h | 171 -- sdrgui/dsp/spectrumscopecombovis.cpp | 41 - sdrgui/dsp/spectrumscopecombovis.h | 27 - sdrgui/gui/glscope.cpp | 2209 ----------------- sdrgui/gui/glscope.h | 193 -- sdrgui/gui/glscopegui.cpp | 919 ------- sdrgui/gui/glscopegui.h | 119 - sdrgui/gui/glscopegui.ui | 1287 ---------- 13 files changed, 1 insertion(+), 5438 deletions(-) delete mode 100644 sdrgui/dsp/scopevis.cpp delete mode 100644 sdrgui/dsp/scopevis.h delete mode 100644 sdrgui/dsp/spectrumscopecombovis.cpp delete mode 100644 sdrgui/dsp/spectrumscopecombovis.h delete mode 100644 sdrgui/gui/glscope.cpp delete mode 100644 sdrgui/gui/glscope.h delete mode 100644 sdrgui/gui/glscopegui.cpp delete mode 100644 sdrgui/gui/glscopegui.h delete mode 100644 sdrgui/gui/glscopegui.ui diff --git a/httpserver/httpconnectionhandler.cpp b/httpserver/httpconnectionhandler.cpp index d6046c260..4b3fc9a31 100644 --- a/httpserver/httpconnectionhandler.cpp +++ b/httpserver/httpconnectionhandler.cpp @@ -234,7 +234,7 @@ void HttpConnectionHandler::read() if (currentRequest->getStatus()==HttpRequest::complete) { readTimer.stop(); - qDebug("HttpConnectionHandler (%p) received request from %s (%s) %s", + qDebug("HttpConnectionHandler (%p): received request from %s (%s) %s", this, qPrintable(currentRequest->getPeerAddress().toString()), currentRequest->getMethod().toStdString().c_str(), diff --git a/plugins/channelrx/chanalyzer/chanalyzergui.cpp b/plugins/channelrx/chanalyzer/chanalyzergui.cpp index bcb9564da..966bb6898 100644 --- a/plugins/channelrx/chanalyzer/chanalyzergui.cpp +++ b/plugins/channelrx/chanalyzer/chanalyzergui.cpp @@ -24,7 +24,6 @@ #include "ui_chanalyzergui.h" #include "dsp/spectrumscopengcombovis.h" #include "dsp/spectrumvis.h" -#include "dsp/scopevis.h" #include "gui/glspectrum.h" #include "gui/glscopeng.h" #include "gui/basicchannelsettingsdialog.h" diff --git a/plugins/channelrx/demoddsd/dsddemodgui.cpp b/plugins/channelrx/demoddsd/dsddemodgui.cpp index 3b2dc2653..8c37b095b 100644 --- a/plugins/channelrx/demoddsd/dsddemodgui.cpp +++ b/plugins/channelrx/demoddsd/dsddemodgui.cpp @@ -23,9 +23,7 @@ #include "dsp/threadedbasebandsamplesink.h" #include "ui_dsddemodgui.h" -#include "dsp/scopevis.h" #include "dsp/scopevisxy.h" -#include "gui/glscope.h" #include "plugin/pluginapi.h" #include "util/simpleserializer.h" #include "util/db.h" diff --git a/sdrgui/CMakeLists.txt b/sdrgui/CMakeLists.txt index 401f3b677..78223583c 100644 --- a/sdrgui/CMakeLists.txt +++ b/sdrgui/CMakeLists.txt @@ -20,8 +20,6 @@ set(sdrgui_SOURCES gui/editcommanddialog.cpp gui/externalclockbutton.cpp gui/externalclockdialog.cpp - gui/glscope.cpp - gui/glscopegui.cpp gui/glscopeng.cpp gui/glscopemulti.cpp gui/glscopenggui.cpp @@ -48,12 +46,10 @@ set(sdrgui_SOURCES gui/valuedial.cpp gui/valuedialz.cpp - dsp/scopevis.cpp dsp/scopevisng.cpp dsp/scopevismulti.cpp dsp/scopevisxy.cpp dsp/spectrumvis.cpp - dsp/spectrumscopecombovis.cpp dsp/spectrumscopengcombovis.cpp device/deviceuiset.cpp @@ -80,8 +76,6 @@ set(sdrgui_HEADERS gui/editcommanddialog.h gui/externalclockbutton.h gui/externalclockdialog.h - gui/glscope.h - gui/glscopegui.h gui/glscopeng.h gui/glscopemulti.h gui/glscopenggui.h @@ -109,12 +103,10 @@ set(sdrgui_HEADERS gui/valuedial.h gui/valuedialz.h - dsp/scopevis.h dsp/scopevisng.h dsp/scopevismulti.h dsp/scopevisxy.h dsp/spectrumvis.h - dsp/spectrumscopecombovis.h dsp/spectrumscopengcombovis.h device/deviceuiset.h @@ -136,7 +128,6 @@ set(sdrgui_FORMS gui/cwkeyergui.ui gui/editcommanddialog.ui gui/externalclockdialog.ui - gui/glscopegui.ui gui/glscopenggui.ui gui/glscopemultigui.ui gui/glspectrumgui.ui diff --git a/sdrgui/dsp/scopevis.cpp b/sdrgui/dsp/scopevis.cpp deleted file mode 100644 index 0fd0426e5..000000000 --- a/sdrgui/dsp/scopevis.cpp +++ /dev/null @@ -1,459 +0,0 @@ -#include "dsp/scopevis.h" -#include "gui/glscope.h" -#include "dsp/dspcommands.h" -#include "util/messagequeue.h" -#include - -#include - -#ifndef LINUX -inline double log2f(double n) -{ - return log(n) / log(2.0); -} -#endif - -MESSAGE_CLASS_DEFINITION(ScopeVis::MsgConfigureScopeVis, Message) - -const uint ScopeVis::m_traceChunkSize = 4800; - -ScopeVis::ScopeVis(Real scalef, GLScope* glScope) : - m_glScope(glScope), - m_scalef(scalef), - m_tracebackCount(0), - m_fill(0), - m_triggerState(Untriggered), - m_triggerIndex(0), - m_prevTrigger(false), - m_triggerPre(0), - m_triggerOneShot(false), - m_armed(false), - m_triggerDelayCount(0), - m_triggerCount(0), - m_sampleRate(0), - m_prevArg(0.0), - m_firstArg(true) -{ - setObjectName("ScopeVis"); - m_trace.reserve(100*m_traceChunkSize); - m_trace.resize(20*m_traceChunkSize); - m_traceback.resize(20*m_traceChunkSize); - - for (unsigned int i = 0; i < m_nbTriggers; i++) - { - m_triggerChannel[i] = TriggerFreeRun; - m_triggerLevel[i] = 0.0; - m_triggerPositiveEdge[i] = true; - m_triggerBothEdges[i] = false; - m_triggerDelay[i] = 0; - m_triggerCounts[i] = 0; - } -} - -ScopeVis::~ScopeVis() -{ -} - -void ScopeVis::configure(MessageQueue* msgQueue, - uint triggerIndex, - TriggerChannel triggerChannel, - Real triggerLevel, - bool triggerPositiveEdge, - bool triggerBothEdges, - uint triggerPre, - uint triggerDelay, - uint triggerCounts, - uint traceSize) -{ - Message* cmd = MsgConfigureScopeVis::create(triggerIndex, - triggerChannel, - triggerLevel, - triggerPositiveEdge, - triggerBothEdges, - triggerPre, - triggerDelay, - triggerCounts, - traceSize); - msgQueue->push(cmd); -} - -void ScopeVis::feed(const SampleVector::const_iterator& cbegin, const SampleVector::const_iterator& end, bool positiveOnly __attribute__((unused))) -{ - SampleVector::const_iterator begin(cbegin); - - if (m_triggerChannel[m_triggerIndex] == TriggerFreeRun) { - m_triggerPoint = begin; - } - else if (m_triggerState == Triggered) { - m_triggerPoint = begin; - } - else if (m_triggerState == Untriggered) { - m_triggerPoint = end; - } - else if (m_triggerState == WaitForReset) { - m_triggerPoint = end; - } - else { - m_triggerPoint = begin; - } - - while(begin < end) - { - if (m_triggerChannel[m_triggerIndex] == TriggerFreeRun) - { - int count = end - begin; - - if(count > (int)(m_trace.size() - m_fill)) - { - count = m_trace.size() - m_fill; - } - - std::vector::iterator it = m_trace.begin() + m_fill; - - for(int i = 0; i < count; ++i) - { - *it++ = Complex(begin->real() / m_scalef, begin->imag() / m_scalef); - ++begin; - } - - m_fill += count; - - if(m_fill >= m_trace.size()) - { - m_glScope->newTrace(m_trace, m_sampleRate); - m_fill = 0; - } - } - else - { - if(m_triggerState == WaitForReset) - { - break; - } - if(m_triggerState == Config) - { - m_glScope->newTrace(m_trace, m_sampleRate); // send a dummy trace - m_triggerState = Untriggered; - m_triggerIndex = 0; - } - if(m_triggerState == Delay) - { - int count = end - begin; - if (count > (int)(m_trace.size() - m_fill)) - { - count = m_trace.size() - m_fill; - } - begin += count; - m_fill += count; - if(m_fill >= m_trace.size()) - { - m_fill = 0; - m_triggerDelayCount--; - if (m_triggerDelayCount == 0) - { - if (nextTrigger()) - { - m_triggerState = Untriggered; - } - else - { - m_triggerState = Triggered; - } - } - } - } - - if(m_triggerState == Untriggered) - { - m_firstArg = true; - - while(begin < end) - { - bool triggerCdt = triggerCondition(begin); - - if (m_tracebackCount > m_triggerPre) - { - bool trigger; - - if (m_triggerBothEdges[m_triggerIndex]) { - trigger = m_prevTrigger ^ triggerCdt; - } else { - trigger = triggerCdt ^ !m_triggerPositiveEdge[m_triggerIndex]; - } - - if (trigger) - { - if (m_armed) - { - m_armed = false; - if (m_triggerDelay[m_triggerIndex] > 0) - { - m_triggerDelayCount = m_triggerDelay[m_triggerIndex]; - m_fill = 0; - m_triggerState = Delay; - } - else - { - if (nextTrigger()) - { - m_triggerState = Untriggered; - } - else - { - m_triggerState = Triggered; - m_triggerPoint = begin; - // fill beginning of m_trace with delayed samples from the trace memory FIFO. Increment m_fill accordingly. - if (m_triggerPre) { // do this process only if there is a pre-trigger delay - std::copy(m_traceback.end() - m_triggerPre - 1, m_traceback.end() - 1, m_trace.begin()); - m_fill = m_triggerPre; // Increment m_fill accordingly (from 0). - } - } - } - break; - } - } - else - { - m_armed = true; - } - } - m_prevTrigger = triggerCdt; - ++begin; - } - } - - if(m_triggerState == Triggered) - { - int count = end - begin; - - if(count > (int)(m_trace.size() - m_fill)) - { - count = m_trace.size() - m_fill; - } - - std::vector::iterator it = m_trace.begin() + m_fill; - - for(int i = 0; i < count; ++i) - { - *it++ = Complex(begin->real() / m_scalef, begin->imag() / m_scalef); - ++begin; - } - - m_fill += count; - - if(m_fill >= m_trace.size()) - { - m_glScope->newTrace(m_trace, m_sampleRate); - m_fill = 0; - - if (m_triggerOneShot) { - m_triggerState = WaitForReset; - } else { - m_tracebackCount = 0; - m_triggerState = Untriggered; - m_triggerIndex = 0; - } - } - } - } - } -} - -void ScopeVis::start() -{ -} - -void ScopeVis::stop() -{ -} - -bool ScopeVis::handleMessage(const Message& message) -{ - qDebug() << "ScopeVis::handleMessage"; - - if (DSPSignalNotification::match(message)) - { - DSPSignalNotification& notif = (DSPSignalNotification&) message; - m_sampleRate = notif.getSampleRate(); - qDebug() << " - DSPSignalNotification: m_sampleRate: " << m_sampleRate; - - return true; - } - else if (MsgConfigureScopeVis::match(message)) - { - MsgConfigureScopeVis& conf = (MsgConfigureScopeVis&) message; - - m_tracebackCount = 0; - m_triggerState = Config; - uint index = conf.getTriggerIndex(); - m_triggerChannel[index] = (TriggerChannel) conf.getTriggerChannel(); - m_triggerLevel[index] = conf.getTriggerLevel(); - m_triggerPositiveEdge[index] = conf.getTriggerPositiveEdge(); - m_triggerBothEdges[index] = conf.getTriggerBothEdges(); - m_triggerPre = conf.getTriggerPre(); - - if (m_triggerChannel[index] == TriggerDPhase) - { - m_firstArg = true; - } - - if (m_triggerPre >= m_traceback.size()) - { - m_triggerPre = m_traceback.size() - 1; // top sample in FIFO is always the triggering one (pre-trigger delay = 0) - } - - m_triggerDelay[index] = conf.getTriggerDelay(); - m_triggerCounts[index] = conf.getTriggerCounts(); - uint newSize = conf.getTraceSize(); - - if (newSize != m_trace.size()) - { - m_trace.resize(newSize); - } - - if (newSize > m_traceback.size()) // fitting the exact required space is not a requirement for the back trace - { - m_traceback.resize(newSize); - } - - qDebug() << " - MsgConfigureScopeVis:" - << " triggerIndex: " << index - << " m_triggerChannel: " << m_triggerChannel[index] - << " m_triggerLevel: " << m_triggerLevel[index] - << " m_triggerPositiveEdge: " << (m_triggerPositiveEdge[index] ? "edge+" : "edge-") - << " m_triggerBothEdges: " << (m_triggerBothEdges[index] ? "yes" : "no") - << " m_preTrigger: " << m_triggerPre - << " m_triggerDelay: " << m_triggerDelay[index] - << " m_triggerCounts: " << m_triggerCounts[index] - << " m_traceSize: " << m_trace.size(); - - return true; - } - else - { - return false; - } -} - -void ScopeVis::setSampleRate(int sampleRate) -{ - m_sampleRate = sampleRate; -} - -bool ScopeVis::triggerCondition(SampleVector::const_iterator& it) -{ - Complex c(it->real()/m_scalef, it->imag()/m_scalef); - m_traceback.push_back(c); // store into trace memory FIFO - - if (m_tracebackCount < m_traceback.size()) - { // increment count up to trace memory size - m_tracebackCount++; - } - - if (m_triggerChannel[m_triggerIndex] == TriggerChannelI) - { - return c.real() > m_triggerLevel[m_triggerIndex]; - } - else if (m_triggerChannel[m_triggerIndex] == TriggerChannelQ) - { - return c.imag() > m_triggerLevel[m_triggerIndex]; - } - else if (m_triggerChannel[m_triggerIndex] == TriggerMagLin) - { - return abs(c) > m_triggerLevel[m_triggerIndex]; - } - else if (m_triggerChannel[m_triggerIndex] == TriggerMagDb) - { - Real mult = (10.0f / log2f(10.0f)); - Real v = c.real() * c.real() + c.imag() * c.imag(); - return mult * log2f(v) > m_triggerLevel[m_triggerIndex]; - } - else if (m_triggerChannel[m_triggerIndex] == TriggerPhase) - { - return arg(c) / M_PI > m_triggerLevel[m_triggerIndex]; - } - else if (m_triggerChannel[m_triggerIndex] == TriggerDPhase) - { - Real curArg = arg(c) - m_prevArg; - m_prevArg = arg(c); - - if (curArg < -M_PI) { - curArg += 2.0 * M_PI; - } else if (curArg > M_PI) { - curArg -= 2.0 * M_PI; - } - - if (m_firstArg) - { - m_firstArg = false; - return false; - } - else - { - return curArg / M_PI > m_triggerLevel[m_triggerIndex]; - } - } - else - { - return false; - } -} - -void ScopeVis::setOneShot(bool oneShot) -{ - m_triggerOneShot = oneShot; - - if ((m_triggerState == WaitForReset) && !oneShot) { - m_tracebackCount = 0; - m_triggerState = Untriggered; - m_triggerIndex = 0; - } -} - -void ScopeVis::blockTrigger(bool blocked) -{ - if (blocked) - { - m_triggerState = WaitForReset; - } - else - { - if (!m_triggerOneShot) { - m_tracebackCount = 0; - m_triggerState = Untriggered; - m_triggerIndex = 0; - } - } -} - -bool ScopeVis::nextTrigger() -{ - if (m_triggerCount < m_triggerCounts[m_triggerIndex]) - { - m_triggerCount++; - return true; - } - else - { - m_triggerIndex++; - m_prevTrigger = false; - m_triggerDelayCount = 0; - m_triggerCount = 0; - m_armed = false; - - if (m_triggerIndex == m_nbTriggers) - { - m_triggerIndex = 0; - return false; - } - else if (m_triggerChannel[m_triggerIndex] == TriggerFreeRun) - { - m_triggerIndex = 0; - return false; - } - else - { - return true; - } - } -} diff --git a/sdrgui/dsp/scopevis.h b/sdrgui/dsp/scopevis.h deleted file mode 100644 index 0c08e59bd..000000000 --- a/sdrgui/dsp/scopevis.h +++ /dev/null @@ -1,171 +0,0 @@ -#ifndef INCLUDE_SCOPEVIS_H -#define INCLUDE_SCOPEVIS_H - -#include -#include -#include "export.h" -#include "util/message.h" - -class GLScope; -class MessageQueue; - -class SDRGUI_API ScopeVis : public BasebandSampleSink { -public: - enum TriggerChannel { - TriggerFreeRun, - TriggerChannelI, - TriggerChannelQ, - TriggerMagLin, - TriggerMagDb, - TriggerPhase, - TriggerDPhase - }; - - static const uint m_traceChunkSize; - static const uint m_nbTriggers = 10; - - ScopeVis(Real scalef, GLScope* glScope = 0); - virtual ~ScopeVis(); - - void configure(MessageQueue* msgQueue, - uint triggerIndex, - TriggerChannel triggerChannel, - Real triggerLevel, - bool triggerPositiveEdge, - bool triggerBothEdges, - uint triggerPre, - uint triggerDelay, - uint triggerCounts, - uint traceSize); - void setOneShot(bool oneShot); - void blockTrigger(bool blecked); - - virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly); - virtual void start(); - virtual void stop(); - virtual bool handleMessage(const Message& message); - - void setSampleRate(int sampleRate); - int getSampleRate() const { return m_sampleRate; } - SampleVector::const_iterator getTriggerPoint() const { return m_triggerPoint; } - -private: - class MsgConfigureScopeVis : public Message { - MESSAGE_CLASS_DECLARATION - - public: - uint getTriggerIndex() const { return m_triggerIndex; } - int getTriggerChannel() const { return m_triggerChannel; } - Real getTriggerLevel() const { return m_triggerLevel; } - bool getTriggerPositiveEdge() const { return m_triggerPositiveEdge; } - bool getTriggerBothEdges() const { return m_triggerBothEdges; } - uint getTriggerPre() const { return m_triggerPre; } - uint getTriggerDelay() const { return m_triggerDelay; } - uint getTriggerCounts() const { return m_triggerCounts; } - uint getTraceSize() const { return m_traceSize; } - - static MsgConfigureScopeVis* create(uint triggerIndex, - int triggerChannel, - Real triggerLevel, - bool triggerPositiveEdge, - bool triggerBothEdges, - uint triggerPre, - uint triggerDelay, - uint triggerCounts, - uint traceSize) - { - return new MsgConfigureScopeVis(triggerIndex, - triggerChannel, - triggerLevel, - triggerPositiveEdge, - triggerBothEdges, - triggerPre, - triggerDelay, - triggerCounts, - traceSize); - } - - private: - uint m_triggerIndex; - int m_triggerChannel; - Real m_triggerLevel; - bool m_triggerPositiveEdge; - bool m_triggerBothEdges; - uint m_triggerPre; - uint m_triggerDelay; - uint m_triggerCounts; - uint m_traceSize; - - MsgConfigureScopeVis(uint triggerIndex, - int triggerChannel, - Real triggerLevel, - bool triggerPositiveEdge, - bool triggerBothEdges, - uint triggerPre, - uint triggerDelay, - uint triggerCounts, - uint traceSize) : - Message(), - m_triggerIndex(triggerIndex), - m_triggerChannel(triggerChannel), - m_triggerLevel(triggerLevel), - m_triggerPositiveEdge(triggerPositiveEdge), - m_triggerBothEdges(triggerBothEdges), - m_triggerPre(triggerPre), - m_triggerDelay(triggerDelay), - m_triggerCounts(triggerCounts), - m_traceSize(traceSize) - { } - }; - - /** - * TriggerState: (repeat at each successive non freerun trigger) - * - * send a Trigger condition +--------------------+ - * dummy trace - Immediate m_triggerOneShot | | - * Config -------------> Untriggered ----------------------------------> Triggered ----------------> WaitForReset | - * ^ ^ | ^ | | ^ | - * | | | - Delayed Delay expired | | | | setOneShot(true)| - * | | +---------------------> Delay ----------------+ | | +-----------------+ - * | | !m_triggerOneShot | | - * | +--------------------------------------------------+ setOneShot(false) | - * +-------------------------------------------------------------------------------+ - */ - enum TriggerState { - Untriggered, //!< Search for trigger - Config, //!< New configuration has just been received - Triggered, //!< Trigger was kicked off - WaitForReset, //!< Wait for release from GUI - Delay //!< Trigger delay engaged - }; - - GLScope* m_glScope; - Real m_scalef; //!< Sample scale factor from [-1,+1] to integer sample size range - std::vector m_trace; //!< Raw trace to be used by GLScope - boost::circular_buffer m_traceback; //!< FIFO for samples prior to triggering point to support pre-trigger (when in triggered mode) - uint m_tracebackCount; //!< Count of samples stored into trace memory since triggering is active up to trace memory size - uint m_fill; - TriggerState m_triggerState; - uint m_triggerIndex; //!< current active trigger index - TriggerChannel m_triggerChannel[m_nbTriggers]; - Real m_triggerLevel[m_nbTriggers]; - bool m_triggerPositiveEdge[m_nbTriggers]; - bool m_triggerBothEdges[m_nbTriggers]; - bool m_prevTrigger; - uint m_triggerPre; //!< Pre-trigger delay in number of samples - bool m_triggerOneShot; - bool m_armed; - uint m_triggerDelay[m_nbTriggers]; //!< Trigger delay in number of trace sizes - uint m_triggerDelayCount; //!< trace sizes delay counter - uint m_triggerCounts[m_nbTriggers]; //!< Number of trigger events before the actual trigger is kicked off - uint m_triggerCount; - int m_sampleRate; - SampleVector::const_iterator m_triggerPoint; - Real m_prevArg; - bool m_firstArg; - - bool triggerCondition(SampleVector::const_iterator& it); - bool nextTrigger(); //!< move to next trigger. Returns true if next trigger is active. -}; - -#endif // INCLUDE_SCOPEVIS_H diff --git a/sdrgui/dsp/spectrumscopecombovis.cpp b/sdrgui/dsp/spectrumscopecombovis.cpp deleted file mode 100644 index feb482022..000000000 --- a/sdrgui/dsp/spectrumscopecombovis.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "dsp/spectrumscopecombovis.h" -#include "dsp/dspcommands.h" -#include "util/messagequeue.h" - -SpectrumScopeComboVis::SpectrumScopeComboVis(SpectrumVis* spectrumVis, ScopeVis* scopeVis) : - m_spectrumVis(spectrumVis), - m_scopeVis(scopeVis) -{ - setObjectName("SpectrumScopeComboVis"); -} - -SpectrumScopeComboVis::~SpectrumScopeComboVis() -{ -} - -void SpectrumScopeComboVis::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly __attribute__((unused))) -{ - m_scopeVis->feed(begin, end, false); - SampleVector::const_iterator triggerPoint = m_scopeVis->getTriggerPoint(); - m_spectrumVis->feedTriggered(triggerPoint, end, positiveOnly); -} - -void SpectrumScopeComboVis::start() -{ - m_spectrumVis->start(); - m_scopeVis->start(); -} - -void SpectrumScopeComboVis::stop() -{ - m_spectrumVis->stop(); - m_scopeVis->stop(); -} - -bool SpectrumScopeComboVis::handleMessage(const Message& message) -{ - bool spectDone = m_spectrumVis->handleMessage(message); - bool scopeDone = m_scopeVis->handleMessage(message); - - return (spectDone || scopeDone); -} diff --git a/sdrgui/dsp/spectrumscopecombovis.h b/sdrgui/dsp/spectrumscopecombovis.h deleted file mode 100644 index 6e7b6f612..000000000 --- a/sdrgui/dsp/spectrumscopecombovis.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef INCLUDE_SPECTRUMSCOPECOMBOVIS_H -#define INCLUDE_SPECTRUMSCOPECOMBOVIS_H - -#include -#include "dsp/spectrumvis.h" -#include "dsp/scopevis.h" -#include "export.h" - -class Message; - -class SDRGUI_API SpectrumScopeComboVis : public BasebandSampleSink { -public: - - SpectrumScopeComboVis(SpectrumVis* spectrumVis, ScopeVis* scopeVis); - virtual ~SpectrumScopeComboVis(); - - virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly); - virtual void start(); - virtual void stop(); - virtual bool handleMessage(const Message& message); - -private: - SpectrumVis* m_spectrumVis; - ScopeVis* m_scopeVis; -}; - -#endif // INCLUDE_SPECTRUMSCOPECOMBOVIS_H diff --git a/sdrgui/gui/glscope.cpp b/sdrgui/gui/glscope.cpp deleted file mode 100644 index 32ade47b5..000000000 --- a/sdrgui/gui/glscope.cpp +++ /dev/null @@ -1,2209 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2016 F4EXB // -// written by Edouard Griffiths // -// // -// OpenGL interface modernization. // -// // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation as version 3 of the License, or // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License V3 for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program. If not, see . // -/////////////////////////////////////////////////////////////////////////////////// - -#include -#include -#include -#include -#include -#include "gui/glscope.h" - -#include -#include - -#undef M_PI -#define M_PI 3.14159265358979323846 - -/* -#ifdef _WIN32 -static double log2f(double n) -{ - return log(n) / log(2.0); -} -#endif*/ - -GLScope::GLScope(QWidget* parent) : - QGLWidget(parent), - m_dataChanged(false), - m_configChanged(true), - m_mode(ModeIQ), - m_displays(DisplayBoth), - m_orientation(Qt::Horizontal), - m_memTraceIndex(0), - m_memTraceHistory(0), - m_memTraceIndexMax(0), - m_memTraceRecall(false), - m_displayTrace(&m_rawTrace[0]), - //m_amp(1.0), - //m_ofs(0.0), - m_maxPow(0.0f), - m_sumPow(0.0f), - m_oldTraceSize(-1), - m_sampleRate(0), - m_amp1(1.0), - m_amp2(1.0), - m_ofs1(0.0), - m_ofs2(0.0), - m_timeBase(1), - m_timeOfsProMill(0), - m_triggerChannel(ScopeVis::TriggerFreeRun), - m_triggerLevel(0.0), - m_triggerPre(0.0), - m_triggerLevelDis1(0.0), - m_triggerLevelDis2(0.0), - m_nbPow(1), - m_prevArg(0), - m_displayGridIntensity(5), - m_displayTraceIntensity(50), - m_powerOverlayFont(font()) -{ - setAttribute(Qt::WA_OpaquePaintEvent); - connect(&m_timer, SIGNAL(timeout()), this, SLOT(tick())); - m_timer.start(50); - m_y1Scale.setFont(font()); - m_y1Scale.setOrientation(Qt::Vertical); - m_y2Scale.setFont(font()); - m_y2Scale.setOrientation(Qt::Vertical); - m_x1Scale.setFont(font()); - m_x1Scale.setOrientation(Qt::Horizontal); - m_x2Scale.setFont(font()); - m_x2Scale.setOrientation(Qt::Horizontal); - m_powerOverlayFont.setBold(true); - m_powerOverlayFont.setPointSize(font().pointSize()+1); - memset(m_sampleRates, 0, (1< 100) { - m_displayGridIntensity = 100; - } else if (m_displayGridIntensity < 0) { - m_displayGridIntensity = 0; - } - update(); -} - -void GLScope::setDisplayTraceIntensity(int intensity) -{ - m_displayTraceIntensity = intensity; - if (m_displayTraceIntensity > 100) { - m_displayTraceIntensity = 100; - } else if (m_displayTraceIntensity < 0) { - m_displayTraceIntensity = 0; - } - update(); -} - -void GLScope::newTrace(const std::vector& trace, int sampleRate) -{ - if (!m_memTraceRecall) - { - if(!m_mutex.tryLock(2)) - return; - if(m_dataChanged) { - m_mutex.unlock(); - return; - } - - m_memTraceIndex++; - m_rawTrace[m_memTraceIndex] = trace; - m_sampleRates[m_memTraceIndex] = sampleRate; - - if(m_memTraceIndexMax < (1<isValid()) { - qDebug() << "GLScope::initializeGL: context:" - << " major: " << (QOpenGLContext::currentContext()->format()).majorVersion() - << " minor: " << (QOpenGLContext::currentContext()->format()).minorVersion() - << " ES: " << (QOpenGLContext::currentContext()->isOpenGLES() ? "yes" : "no"); - } - else { - qDebug() << "GLScope::initializeGL: current context is invalid"; - } - } else { - qCritical() << "GLScope::initializeGL: no current context"; - return; - } - - QSurface *surface = glCurrentContext->surface(); - - if (surface == 0) - { - qCritical() << "GLScope::initializeGL: no surface attached"; - return; - } - else - { - if (surface->surfaceType() != QSurface::OpenGLSurface) - { - qCritical() << "GLScope::initializeGL: surface is not an OpenGLSurface: " << surface->surfaceType() - << " cannot use an OpenGL context"; - return; - } - else - { - qDebug() << "GLScope::initializeGL: OpenGL surface:" - << " class: " << (surface->surfaceClass() == QSurface::Window ? "Window" : "Offscreen"); - } - } - - connect(glCurrentContext, &QOpenGLContext::aboutToBeDestroyed, this, &GLScope::cleanup); // TODO: when migrating to QOpenGLWidget - - QOpenGLFunctions *glFunctions = QOpenGLContext::currentContext()->functions(); - glFunctions->initializeOpenGLFunctions(); - - //glDisable(GL_DEPTH_TEST); - m_glShaderSimple.initializeGL(); - m_glShaderLeft1Scale.initializeGL(); - m_glShaderBottom1Scale.initializeGL(); - m_glShaderLeft2Scale.initializeGL(); - m_glShaderBottom2Scale.initializeGL(); - m_glShaderPowerOverlay.initializeGL(); -} - -void GLScope::resizeGL(int width, int height) -{ - QOpenGLFunctions *glFunctions = QOpenGLContext::currentContext()->functions(); - glFunctions->glViewport(0, 0, width, height); - m_configChanged = true; -} - -void GLScope::paintGL() -{ - if(!m_mutex.tryLock(2)) - return; - - if(m_configChanged) { - applyConfig(); - } - - handleMode(); - - if(m_displayTrace->size() - m_oldTraceSize != 0) { - m_oldTraceSize = m_displayTrace->size(); - emit traceSizeChanged((int) m_displayTrace->size()); - } - - QOpenGLFunctions *glFunctions = QOpenGLContext::currentContext()->functions(); - glFunctions->glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - glFunctions->glClear(GL_COLOR_BUFFER_BIT); - - // I - primary display - - if ((m_displays == DisplayBoth) || (m_displays == DisplayFirstOnly)) - { - // draw rect around - { - GLfloat q3[] { - 1, 1, - 0, 1, - 0, 0, - 1, 0 - }; - - QVector4D color(1.0f, 1.0f, 1.0f, 0.5f); - m_glShaderSimple.drawContour(m_glScopeMatrix1, color, q3, 4); - - } - - // paint grid - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; - - // Horizontal Y1 - tickList = &m_y1Scale.getTickList(); - - { - //GLfloat q3[4*tickList->count()]; - GLfloat *q3 = m_q3TickY1.m_array; - int effectiveTicks = 0; - - for (int i= 0; i < tickList->count(); i++) - { - tick = &(*tickList)[i]; - - if (tick->major) - { - if (tick->textSize > 0) - { - float y = 1 - (tick->pos / m_y1Scale.getSize()); - q3[4*effectiveTicks] = 0; - q3[4*effectiveTicks+1] = y; - q3[4*effectiveTicks+2] = 1; - q3[4*effectiveTicks+3] = y; - effectiveTicks++; - } - } - } - - float blue = (m_mode == ModeIQPolar ? 0.25f : 1.0f); - QVector4D color(1.0f, 1.0f, blue, (float) m_displayGridIntensity / 100.0f); - m_glShaderSimple.drawSegments(m_glScopeMatrix1, color, q3, 2*effectiveTicks); - } - - { - // Vertical X1 - tickList = &m_x1Scale.getTickList(); - - //GLfloat q3[4*tickList->count()]; - GLfloat *q3 = m_q3TickX1.m_array; - int effectiveTicks = 0; - for(int i= 0; i < tickList->count(); i++) { - tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - float x = tick->pos / m_x1Scale.getSize(); - q3[4*effectiveTicks] = x; - q3[4*effectiveTicks+1] = 0; - q3[4*effectiveTicks+2] = x; - q3[4*effectiveTicks+3] = 1; - effectiveTicks++; - } - } - } - - QVector4D color(1.0f, 1.0f, 1.0f, (float) m_displayGridIntensity / 100.0f); - m_glShaderSimple.drawSegments(m_glScopeMatrix1, color, q3, 2*effectiveTicks); - } - - // paint left #1 scale - { - GLfloat vtx1[] = { - 0, 1, - 1, 1, - 1, 0, - 0, 0 - }; - GLfloat tex1[] = { - 0, 1, - 1, 1, - 1, 0, - 0, 0 - }; - - m_glShaderLeft1Scale.drawSurface(m_glLeft1ScaleMatrix, tex1, vtx1, 4); - } - - // paint bottom #1 scale - { - GLfloat vtx1[] = { - 0, 1, - 1, 1, - 1, 0, - 0, 0 - }; - GLfloat tex1[] = { - 0, 1, - 1, 1, - 1, 0, - 0, 0 - }; - - m_glShaderBottom1Scale.drawSurface(m_glBot1ScaleMatrix, tex1, vtx1, 4); - } - - // paint trigger level #1 - if ((m_triggerChannel == ScopeVis::TriggerChannelI) - || (m_triggerChannel == ScopeVis::TriggerMagLin) - || (m_triggerChannel == ScopeVis::TriggerMagDb) - ) - { - float posLimit = 1.0 / m_amp1; - float negLimit = -1.0 / m_amp1; - - if ((m_triggerLevelDis1 > negLimit) && (m_triggerLevelDis1 < posLimit)) - { - GLfloat q3[] { - 0, m_triggerLevelDis1, - 1, m_triggerLevelDis1 - }; - - float rectX = m_glScopeRect1.x(); - float rectY = m_glScopeRect1.y() + m_glScopeRect1.height() / 2.0f; - float rectW = m_glScopeRect1.width(); - float rectH = -(m_glScopeRect1.height() / 2.0f) * m_amp1; - - QVector4D color(0.0f, 1.0f, 0.0f, 0.4f); - QMatrix4x4 mat; - mat.setToIdentity(); - mat.translate(-1.0f + 2.0f * rectX, 1.0f - 2.0f * rectY); - mat.scale(2.0f * rectW, -2.0f * rectH); - m_glShaderSimple.drawSegments(mat, color, q3, 2); - -// glPushMatrix(); -// glTranslatef(m_glScopeRect1.x(), m_glScopeRect1.y() + m_glScopeRect1.height() / 2.0, 0); -// glScalef(m_glScopeRect1.width(), -(m_glScopeRect1.height() / 2) * m_amp1, 1); - } - } - - // paint trace #1 - if(m_displayTrace->size() > 0) - { - { - - int start = (m_timeOfsProMill/1000.0) * m_displayTrace->size(); - int end = std::min(start + m_displayTrace->size()/m_timeBase, m_displayTrace->size()); - if(end - start < 2) - start--; - float posLimit = 1.0 / m_amp1; - float negLimit = -1.0 / m_amp1; - - //GLfloat q3[2*(end -start)]; - m_q3Trace.allocate(2*(end - start)); - GLfloat *q3 = m_q3Trace.m_array; - - for (int i = start; i < end; i++) - { - float v = (*m_displayTrace)[i].real(); - if(v > posLimit) - v = posLimit; - else if(v < negLimit) - v = negLimit; - - q3[2*(i-start)] = i - start; - q3[2*(i-start) + 1] = v; - - if ((m_mode == ModeMagdBPha) || (m_mode == ModeMagdBDPha)) - { - if (i == start) - { - m_maxPow = m_powTrace[i]; - m_sumPow = m_powTrace[i]; - } - else - { - if (m_powTrace[i] > m_maxPow) - { - m_maxPow = m_powTrace[i]; - } - - m_sumPow += m_powTrace[i]; - } - } - } - - float rectX = m_glScopeRect1.x(); - float rectY = m_glScopeRect1.y() + m_glScopeRect1.height() / 2.0f; - float rectW = m_glScopeRect1.width() * (float)m_timeBase / (float)(m_displayTrace->size() - 1); - float rectH = -(m_glScopeRect1.height() / 2.0f) * m_amp1; - - QVector4D color(1.0f, 1.0f, 0.25f, m_displayTraceIntensity / 100.0f); - QMatrix4x4 mat; - mat.setToIdentity(); - mat.translate(-1.0f + 2.0f * rectX, 1.0f - 2.0f * rectY); - mat.scale(2.0f * rectW, -2.0f * rectH); - m_glShaderSimple.drawPolyline(mat, color, q3, end -start); - -// glPushMatrix(); -// glTranslatef(m_glScopeRect1.x(), m_glScopeRect1.y() + m_glScopeRect1.height() / 2.0, 0); -// glScalef(m_glScopeRect1.width() * (float)m_timeBase / (float)(m_displayTrace->size() - 1), -(m_glScopeRect1.height() / 2) * m_amp1, 1); - m_nbPow = end - start; - } - } - - // Paint powers overlays - - if ((m_mode == ModeMagdBPha) || (m_mode == ModeMagdBDPha)) - { - if (m_nbPow > 0) - { - drawPowerOverlay(); - } - } - - if (m_mode == ModeIQPolar) - { - // Paint trace 2 (Q) over - if (m_displayTrace->size() > 0) - { - { - - int start = (m_timeOfsProMill/1000.0) * m_displayTrace->size(); - int end = std::min(start + m_displayTrace->size()/m_timeBase, m_displayTrace->size()); - - if(end - start < 2) { - start--; - } - - - float posLimit = 1.0 / m_amp2; - float negLimit = -1.0 / m_amp2; - - //GLfloat q3[2*(end - start)]; - m_q3Trace.allocate(2*(end - start)); - GLfloat *q3 = m_q3Trace.m_array; - - for(int i = start; i < end; i++) - { - float v = (*m_displayTrace)[i].imag(); - if(v > posLimit) - v = posLimit; - else if(v < negLimit) - v = negLimit; - q3[2*(i-start)] = i - start; - q3[2*(i-start) + 1] = v; - } - - float rectX = m_glScopeRect1.x(); - float rectY = m_glScopeRect1.y() + m_glScopeRect1.height() / 2.0f; - float rectW = m_glScopeRect1.width() * (float)m_timeBase / (float)(m_displayTrace->size() - 1); - float rectH = -(m_glScopeRect1.height() / 2.0f) * m_amp2; - - QVector4D color(0.25f, 1.0f, 1.0f, m_displayTraceIntensity / 100.0); - QMatrix4x4 mat; - mat.setToIdentity(); - mat.translate(-1.0f + 2.0f * rectX, 1.0f - 2.0f * rectY); - mat.scale(2.0f * rectW, -2.0f * rectH); - m_glShaderSimple.drawPolyline(mat, color, q3, end -start); - -// glPushMatrix(); -// glTranslatef(m_glScopeRect1.x(), m_glScopeRect1.y() + m_glScopeRect1.height() / 2.0, 0); -// glScalef(m_glScopeRect1.width() * (float)m_timeBase / (float)(m_displayTrace->size() - 1), -(m_glScopeRect1.height() / 2) * m_amp2, 1); - } - } - - // Paint secondary grid - // draw rect around - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; - // Horizontal Y2 - tickList = &m_y2Scale.getTickList(); - { - //GLfloat q3[4*tickList->count()]; - GLfloat *q3 = m_q3TickY2.m_array; - int effectiveTicks = 0; - for(int i= 0; i < tickList->count(); i++) { - tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - float y = 1 - (tick->pos / m_y2Scale.getSize()); - q3[4*effectiveTicks] = 0; - q3[4*effectiveTicks+1] = y; - q3[4*effectiveTicks+2] = 1; - q3[4*effectiveTicks+3] = y; - effectiveTicks++; - } - } - } - - QVector4D color(0.25f, 1.0f, 1.0f, (float) m_displayGridIntensity / 100.0f); - m_glShaderSimple.drawSegments(m_glScopeMatrix1, color, q3, 2*effectiveTicks); - } - - // Paint secondary scale - { - GLfloat vtx1[] = { - 0, 1, - 1, 1, - 1, 0, - 0, 0 - }; - GLfloat tex1[] = { - 0, 1, - 1, 1, - 1, 0, - 0, 0 - }; - - m_glShaderLeft2Scale.drawSurface(m_glRight1ScaleMatrix, tex1, vtx1, 4); - } - } - } // Both displays or primary only - - // Q - secondary display - - if ((m_displays == DisplayBoth) || (m_displays == DisplaySecondOnly)) - { - // draw rect around - { - GLfloat q3[] { - 1, 1, - 0, 1, - 0, 0, - 1, 0 - }; - - QVector4D color(1.0f, 1.0f, 1.0f, 0.5f); - m_glShaderSimple.drawContour(m_glScopeMatrix2, color, q3, 4); - } - - // paint grid - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; - - // Horizontal Y2 - tickList = &m_y2Scale.getTickList(); - { - //GLfloat q3[4*tickList->count()]; - GLfloat *q3 = m_q3TickY2.m_array; - int effectiveTicks = 0; - for(int i= 0; i < tickList->count(); i++) { - tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - float y = 1 - (tick->pos / m_y2Scale.getSize()); - q3[4*effectiveTicks] = 0; - q3[4*effectiveTicks+1] = y; - q3[4*effectiveTicks+2] = 1; - q3[4*effectiveTicks+3] = y; - effectiveTicks++; - } - } - } - - QVector4D color(1.0f, 1.0f, 1.0f, (float) m_displayGridIntensity / 100.0f); - m_glShaderSimple.drawSegments(m_glScopeMatrix2, color, q3, 2*effectiveTicks); - } - - // Vertical X2 - tickList = &m_x2Scale.getTickList(); - { - //GLfloat q3[4*tickList->count()]; - GLfloat *q3 = m_q3TickX2.m_array; - int effectiveTicks = 0; - for(int i= 0; i < tickList->count(); i++) { - tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - float x = tick->pos / m_x2Scale.getSize(); - q3[4*effectiveTicks] = x; - q3[4*effectiveTicks+1] = 0; - q3[4*effectiveTicks+2] = x; - q3[4*effectiveTicks+3] = 1; - effectiveTicks++; - } - } - } - - QVector4D color(1.0f, 1.0f, 1.0f, (float) m_displayGridIntensity / 100.0f); - m_glShaderSimple.drawSegments(m_glScopeMatrix2, color, q3, 2*effectiveTicks); - } - - // paint left #2 scale - { - GLfloat vtx1[] = { - 0, 1, - 1, 1, - 1, 0, - 0, 0 - }; - GLfloat tex1[] = { - 0, 1, - 1, 1, - 1, 0, - 0, 0 - }; - - m_glShaderLeft2Scale.drawSurface(m_glLeft2ScaleMatrix, tex1, vtx1, 4); - } - - // paint bottom #2 scale - { - GLfloat vtx1[] = { - 0, 1, - 1, 1, - 1, 0, - 0, 0 - }; - GLfloat tex1[] = { - 0, 1, - 1, 1, - 1, 0, - 0, 0 - }; - - m_glShaderBottom2Scale.drawSurface(m_glBot2ScaleMatrix, tex1, vtx1, 4); - } - - // paint trigger level #2 - if ((m_triggerChannel == ScopeVis::TriggerPhase) - || (m_triggerChannel == ScopeVis::TriggerDPhase) - || (m_triggerChannel == ScopeVis::TriggerChannelQ)) - { - float posLimit = 1.0 / m_amp2; - float negLimit = -1.0 / m_amp2; - - if ((m_triggerLevelDis2 > negLimit) && (m_triggerLevelDis2 < posLimit)) - { - GLfloat q3[] { - 0, m_triggerLevelDis2, - 1, m_triggerLevelDis2 - }; - - float rectX = m_glScopeRect2.x(); - float rectY = m_glScopeRect2.y() + m_glScopeRect2.height() / 2.0f; - float rectW = m_glScopeRect2.width(); - float rectH = -(m_glScopeRect2.height() / 2.0f) * m_amp2; - - QVector4D color(0.0f, 1.0f, 0.0f, 0.4f); - QMatrix4x4 mat; - mat.setToIdentity(); - mat.translate(-1.0f + 2.0f * rectX, 1.0f - 2.0f * rectY); - mat.scale(2.0f * rectW, -2.0f * rectH); - m_glShaderSimple.drawSegments(mat, color, q3, 2); - } - } - - // paint trace #2 - if(m_displayTrace->size() > 0) - { - if (m_mode == ModeIQPolar) - { - - int start = (m_timeOfsProMill/1000.0) * m_displayTrace->size(); - int end = std::min(start + m_displayTrace->size()/m_timeBase, m_displayTrace->size()); - - if (end - start < 2) { - start--; - } - - - { - //GLfloat q3[2*(end - start)]; - m_q3Trace.allocate(2*(end - start)); - GLfloat *q3 = m_q3Trace.m_array; - - for(int i = start; i < end; i++) - { - float x = (*m_displayTrace)[i].real() * m_amp1; - float y = (*m_displayTrace)[i].imag() * m_amp2; - if(x > 1.0f) - x = 1.0f; - else if(x < -1.0f) - x = -1.0f; - if(y > 1.0f) - y = 1.0f; - else if(y < -1.0f) - y = -1.0f; - q3[2*(i-start)] = x; - q3[2*(i-start)+1] = y; - } - - float rectX = m_glScopeRect2.x() + m_glScopeRect2.width() / 2.0f; - float rectY = m_glScopeRect2.y() + m_glScopeRect2.height() / 2.0f; - float rectW = m_glScopeRect2.width() / 2.0f; - float rectH = -(m_glScopeRect2.height() / 2.0f); - - QVector4D color(1.0f, 1.0f, 0.25f, m_displayTraceIntensity / 100.0f); - QMatrix4x4 mat; - mat.setToIdentity(); - mat.translate(-1.0f + 2.0f * rectX, 1.0f - 2.0f * rectY); - mat.scale(2.0f * rectW, -2.0f * rectH); - m_glShaderSimple.drawPolyline(mat, color, q3, end -start); - -// glPushMatrix(); -// glTranslatef(m_glScopeRect2.x() + m_glScopeRect2.width() / 2.0, m_glScopeRect2.y() + m_glScopeRect2.height() / 2.0, 0); -// glScalef(m_glScopeRect2.width() / 2, -(m_glScopeRect2.height() / 2), 1); - } - } - else - { - { - int start = (m_timeOfsProMill/1000.0) * m_displayTrace->size(); - int end = std::min(start + m_displayTrace->size()/m_timeBase, m_displayTrace->size()); - - if (end - start < 2) { - start--; - } - - - float posLimit = 1.0 / m_amp2; - float negLimit = -1.0 / m_amp2; - - //GLfloat q3[2*(end - start)]; - m_q3Trace.allocate(2*(end - start)); - GLfloat *q3 = m_q3Trace.m_array; - - for(int i = start; i < end; i++) { - float v = (*m_displayTrace)[i].imag(); - if(v > posLimit) - v = posLimit; - else if(v < negLimit) - v = negLimit; - - q3[2*(i-start)] = i - start; - q3[2*(i-start)+1] = v; - } - - float rectX = m_glScopeRect2.x(); - float rectY = m_glScopeRect2.y() + m_glScopeRect2.height() / 2.0f; - float rectW = m_glScopeRect2.width() * (float)m_timeBase / (float)(m_displayTrace->size() - 1); - float rectH = -(m_glScopeRect2.height() / 2.0f) * m_amp2; - - QVector4D color(1.0f, 1.0f, 0.25f, m_displayTraceIntensity / 100.0f); - QMatrix4x4 mat; - mat.setToIdentity(); - mat.translate(-1.0f + 2.0f * rectX, 1.0f - 2.0f * rectY); - mat.scale(2.0f * rectW, -2.0f * rectH); - m_glShaderSimple.drawPolyline(mat, color, q3, end -start); - -// glPushMatrix(); -// glTranslatef(m_glScopeRect2.x(), m_glScopeRect2.y() + m_glScopeRect2.height() / 2.0, 0); -// glScalef(m_glScopeRect2.width() * (float)m_timeBase / (float)(m_displayTrace->size() - 1), -(m_glScopeRect2.height() / 2) * m_amp2, 1); - } - } - } - } // Both displays or secondary display only - -// glPopMatrix(); - m_dataChanged = false; - m_mutex.unlock(); -} - -void GLScope::mousePressEvent(QMouseEvent* event __attribute__((unused))) -{ -#if 0 - int x = event->x() - 10; - int y = event->y() - 10; - Real time; - Real amplitude; - ScopeVis::TriggerChannel channel; - if((x < 0) || (x >= width() - 20)) - return; - if((y < 0) || (y >= height() - 20)) - return; - - if((m_sampleRate != 0) && (m_timeBase != 0) && (width() > 20)) - time = ((Real)x * (Real)m_displayTrace->size()) / ((Real)m_sampleRate * (Real)m_timeBase * (Real)(width() - 20)); - else time = -1.0; - - if(y < (height() - 30) / 2) { - channel = ScopeVis::TriggerChannelI; - if((m_amp != 0) && (height() > 30)) - amplitude = 2.0 * ((height() - 30) * 0.25 - (Real)y) / (m_amp * (height() - 30) / 2.0); - else amplitude = -1; - } else if(y > (height() - 30) / 2 + 10) { - y -= 10 + (height() - 30) / 2; - channel = ScopeVis::TriggerChannelQ; - if((m_amp != 0) && (height() > 30)) - amplitude = 2.0 * ((height() - 30) * 0.25 - (Real)y) / (m_amp * (height() - 30) / 2.0); - else amplitude = -1; - } else { - channel = ScopeVis::TriggerFreeRun; - } - - if(m_dspEngine != NULL) { - qDebug("amp %f", amplitude); - m_triggerLevel = amplitude + 0.01 / m_amp; - m_triggerLevelLow = amplitude - 0.01 / m_amp; - if(m_triggerLevel > 1.0) - m_triggerLevel = 1.0; - else if(m_triggerLevel < -1.0) - m_triggerLevel = -1.0; - if(m_triggerLevelLow > 1.0) - m_triggerLevelLow = 1.0; - else if(m_triggerLevelLow < -1.0) - m_triggerLevelLow = -1.0; - m_scopeVis->configure(m_dspEngine->getMessageQueue(), channel, m_triggerLevel, m_triggerLevelLow); - m_triggerChannel = channel; - m_changed = true; - update(); - } -#endif -} - -void GLScope::handleMode() -{ - BitfieldIndex memIndex = m_memTraceIndex - m_memTraceHistory; - - switch(m_mode) { - case ModeIQ: - case ModeIQPolar: - { - m_mathTrace.resize(m_rawTrace[memIndex].size()); - std::vector::iterator dst = m_mathTrace.begin(); - m_displayTrace = &m_rawTrace[memIndex]; - - for(std::vector::const_iterator src = m_rawTrace[memIndex].begin(); src != m_rawTrace[memIndex].end(); ++src) { - *dst++ = Complex(src->real() - m_ofs1, src->imag() - m_ofs2); - } - - m_triggerLevelDis1 = m_triggerLevel - m_ofs1; - m_triggerLevelDis2 = m_triggerLevel - m_ofs2; - - m_displayTrace = &m_mathTrace; - - break; - } - case ModeMagLinPha: - { - m_mathTrace.resize(m_rawTrace[memIndex].size()); - std::vector::iterator dst = m_mathTrace.begin(); - - for(std::vector::const_iterator src = m_rawTrace[memIndex].begin(); src != m_rawTrace[memIndex].end(); ++src) - { - *dst++ = Complex(abs(*src) - m_ofs1/2.0 - 1.0/m_amp1, (arg(*src) / M_PI) - m_ofs2); - } - - m_triggerLevelDis1 = (m_triggerLevel + 1) - m_ofs1/2.0 - 1.0/m_amp1; - m_triggerLevelDis2 = m_triggerLevel - m_ofs2; - - m_displayTrace = &m_mathTrace; - - break; - } - case ModeMagdBPha: - { - m_mathTrace.resize(m_rawTrace[memIndex].size()); - m_powTrace.resize(m_rawTrace[memIndex].size()); - std::vector::iterator dst = m_mathTrace.begin(); - std::vector::iterator powDst = m_powTrace.begin(); - - for(std::vector::const_iterator src = m_rawTrace[memIndex].begin(); src != m_rawTrace[memIndex].end(); ++src) { - Real v = src->real() * src->real() + src->imag() * src->imag(); - *powDst++ = v; - v = 1.0f + 2.0f*(((10.0f*log10f(v))/100.0f) - m_ofs1) + 1.0f - 1.0f/m_amp1; - *dst++ = Complex(v, (arg(*src) / M_PI) - m_ofs2); - } - - Real tdB = (m_triggerLevel - 1) * 100.0f; - m_triggerLevelDis1 = 1.0f + 2.0f*(((tdB)/100.0f) - m_ofs1) + 1.0f - 1.0f/m_amp1; - m_triggerLevelDis2 = m_triggerLevel - m_ofs2; - - m_displayTrace = &m_mathTrace; - - break; - } - case ModeMagLinDPha: - { - m_mathTrace.resize(m_rawTrace[memIndex].size()); - std::vector::iterator dst = m_mathTrace.begin(); - Real curArg; - - for(std::vector::const_iterator src = m_rawTrace[memIndex].begin(); src != m_rawTrace[memIndex].end(); ++src) - { - curArg = arg(*src) - m_prevArg; - - if (curArg < -M_PI) { - curArg += 2.0 * M_PI; - } else if (curArg > M_PI) { - curArg -= 2.0 * M_PI; - } - - *dst++ = Complex(abs(*src) - m_ofs1/2.0 - 1.0/m_amp1, (curArg / M_PI) - m_ofs2); - m_prevArg = arg(*src); - } - - m_triggerLevelDis1 = (m_triggerLevel + 1) - m_ofs1/2.0 - 1.0/m_amp1; - m_triggerLevelDis2 = m_triggerLevel - m_ofs2; - - m_displayTrace = &m_mathTrace; - - break; - } - case ModeMagdBDPha: - { - m_mathTrace.resize(m_rawTrace[memIndex].size()); - m_powTrace.resize(m_rawTrace[memIndex].size()); - std::vector::iterator dst = m_mathTrace.begin(); - std::vector::iterator powDst = m_powTrace.begin(); - Real curArg; - - for(std::vector::const_iterator src = m_rawTrace[memIndex].begin(); src != m_rawTrace[memIndex].end(); ++src) - { - Real v = src->real() * src->real() + src->imag() * src->imag(); - *powDst++ = v; - v = 1.0f + 2.0f*(((10.0f*log10f(v))/100.0f) - m_ofs1) + 1.0f - 1.0f/m_amp1; - curArg = arg(*src) - m_prevArg; - - if (curArg < -M_PI) { - curArg += 2.0 * M_PI; - } else if (curArg > M_PI) { - curArg -= 2.0 * M_PI; - } - - *dst++ = Complex(v, (curArg / M_PI) - m_ofs2); - m_prevArg = arg(*src); - } - - Real tdB = (m_triggerLevel - 1) * 100.0f; - m_triggerLevelDis1 = 1.0f + 2.0f*(((tdB)/100.0f) - m_ofs1) + 1.0f - 1.0f/m_amp1; - m_triggerLevelDis2 = m_triggerLevel - m_ofs2; - - m_displayTrace = &m_mathTrace; - - break; - } - case ModeDerived12: - { - if(m_rawTrace[memIndex].size() > 3) - { - m_mathTrace.resize(m_rawTrace[memIndex].size() - 3); - std::vector::iterator dst = m_mathTrace.begin(); - - for(uint i = 3; i < m_rawTrace[memIndex].size() ; i++) - { - *dst++ = Complex( - abs(m_rawTrace[memIndex][i] - m_rawTrace[memIndex][i - 1]), - abs(m_rawTrace[memIndex][i] - m_rawTrace[memIndex][i - 1]) - abs(m_rawTrace[memIndex][i - 2] - m_rawTrace[0][i - 3])); - } - - m_displayTrace = &m_mathTrace; - } - - break; - } - case ModeCyclostationary: - { - if(m_rawTrace[0].size() > 2) - { - m_mathTrace.resize(m_rawTrace[memIndex].size() - 2); - std::vector::iterator dst = m_mathTrace.begin(); - - for(uint i = 2; i < m_rawTrace[memIndex].size() ; i++) - *dst++ = Complex(abs(m_rawTrace[memIndex][i] - conj(m_rawTrace[memIndex][i - 1])), 0); - - m_displayTrace = &m_mathTrace; - } - - break; - } - } -} - -void GLScope::drawPowerOverlay() -{ - double maxPow = 10.0f * log10f(m_maxPow); - double avgPow = 10.0f * log10f(m_sumPow / m_nbPow); - double peakToAvgPow = maxPow - avgPow; - - QString text = QString("%1 %2 %3").arg(maxPow, 0, 'f', 1).arg(avgPow, 0, 'f', 1).arg(peakToAvgPow, 0, 'f', 1); - - QFontMetricsF metrics(m_powerOverlayFont); - QRectF rect = metrics.boundingRect(text); - m_powerOverlayPixmap1 = QPixmap(rect.width() + 4.0f, rect.height()); - m_powerOverlayPixmap1.fill(Qt::transparent); - QPainter painter(&m_powerOverlayPixmap1); - painter.setRenderHints(QPainter::Antialiasing|QPainter::TextAntialiasing, false); - painter.fillRect(rect, QColor(0, 0, 0, 0x80)); - painter.setPen(QColor(0xff, 0xff, 0xff, 0x80)); - painter.setFont(m_powerOverlayFont); - painter.drawText(QPointF(0, rect.height() - 2.0f), text); - painter.end(); - - m_glShaderPowerOverlay.initTexture(m_powerOverlayPixmap1.toImage()); - - { - GLfloat vtx1[] = { - 0, 1, - 1, 1, - 1, 0, - 0, 0 - }; - GLfloat tex1[] = { - 0, 1, - 1, 1, - 1, 0, - 0, 0 - }; - - float shiftX = m_glScopeRect1.width() - ((rect.width() + 4.0f) / width()); - float rectX = m_glScopeRect1.x() + shiftX; - float rectY = 0; - float rectW = rect.width() / (float) width(); - float rectH = rect.height() / (float) height(); - - QMatrix4x4 mat; - mat.setToIdentity(); - mat.translate(-1.0f + 2.0f * rectX, 1.0f - 2.0f * rectY); - mat.scale(2.0f * rectW, -2.0f * rectH); - m_glShaderPowerOverlay.drawSurface(mat, tex1, vtx1, 4); - -// glPushMatrix(); -// glTranslatef(m_glScopeRect1.x() + shiftX, m_glScopeRect1.y(), 0); -// glScalef(rect.width() / (float) width(), rect.height() / (float) height(), 1); - } -} - -void GLScope::applyConfig() -{ - m_configChanged = false; - - QFontMetrics fm(font()); - int M = fm.width("-"); - - int topMargin = 5; - int botMargin = 20; - int leftMargin = 35; - int rightMargin = 5; - - float pow_floor = -100.0 + m_ofs1 * 100.0; - float pow_range = 100.0 / m_amp1; - float amp1_range = 2.0 / m_amp1; - float amp1_ofs = m_ofs1; - float amp2_range = 2.0 / m_amp2; - float amp2_ofs = m_ofs2; - float t_start = ((m_timeOfsProMill / 1000.0) - m_triggerPre) * ((float) m_displayTrace->size() / m_sampleRates[m_memTraceIndex-m_memTraceHistory]); - float t_len = ((float) m_displayTrace->size() / m_sampleRates[m_memTraceIndex-m_memTraceHistory]) / (float) m_timeBase; - - m_x1Scale.setRange(Unit::Time, t_start, t_start + t_len); - - if (m_mode == ModeIQPolar) - { - if (amp1_range < 2.0) { - m_x2Scale.setRange(Unit::None, - amp1_range * 500.0 + amp1_ofs * 1000.0, amp1_range * 500.0 + amp1_ofs * 1000.0); - } else { - m_x2Scale.setRange(Unit::None, - amp1_range * 0.5 + amp1_ofs, amp1_range * 0.5 + amp1_ofs); - } - } - else - { - m_x2Scale.setRange(Unit::Time, t_start, t_start + t_len); - } - - switch(m_mode) { - case ModeIQ: - case ModeIQPolar: - { - if (amp1_range < 2.0) { - m_y1Scale.setRange(Unit::None, - amp1_range * 500.0 + amp1_ofs * 1000.0, amp1_range * 500.0 + amp1_ofs * 1000.0); - } else { - m_y1Scale.setRange(Unit::None, - amp1_range * 0.5 + amp1_ofs, amp1_range * 0.5 + amp1_ofs); - } - if (amp2_range < 2.0) { - m_y2Scale.setRange(Unit::None, - amp2_range * 500.0 + amp2_ofs * 1000.0, amp2_range * 500.0 + amp2_ofs * 1000.0); - } else { - m_y2Scale.setRange(Unit::None, - amp2_range * 0.5 + amp2_ofs, amp2_range * 0.5 + amp2_ofs); - } - - break; - } - case ModeMagLinPha: - case ModeMagLinDPha: - { - if (amp1_range < 2.0) { - m_y1Scale.setRange(Unit::None, amp1_ofs * 500.0, amp1_range * 1000.0 + amp1_ofs * 500.0); - } else { - m_y1Scale.setRange(Unit::None, amp1_ofs/2.0, amp1_range + amp1_ofs/2.0); - } - - m_y2Scale.setRange(Unit::None, -1.0/m_amp2 + amp2_ofs, 1.0/m_amp2 + amp2_ofs); // Scale to Pi*A2 - - break; - } - case ModeMagdBPha: - case ModeMagdBDPha: - { - m_y1Scale.setRange(Unit::Decibel, pow_floor, pow_floor + pow_range); - m_y2Scale.setRange(Unit::None, -1.0/m_amp2 + amp2_ofs, 1.0/m_amp2 + amp2_ofs); // Scale to Pi*A2 - break; - } - case ModeDerived12: { - if (amp1_range < 2.0) { - m_y1Scale.setRange(Unit::None, 0.0, amp1_range * 1000.0); - } else { - m_y1Scale.setRange(Unit::None, 0.0, amp1_range); - } - if (amp2_range < 2.0) { - m_y2Scale.setRange(Unit::None, - amp2_range * 500.0, amp2_range * 500.0); - } else { - m_y2Scale.setRange(Unit::None, - amp2_range * 0.5, amp2_range * 0.5); - } - break; - } - case ModeCyclostationary: { - if (amp1_range < 2.0) { - m_y1Scale.setRange(Unit::None, 0.0, amp1_range * 1000.0); - } else { - m_y1Scale.setRange(Unit::None, 0.0, amp1_range); - } - if (amp2_range < 2.0) { - m_y2Scale.setRange(Unit::None, - amp2_range * 500.0, amp2_range * 500.0); - } else { - m_y2Scale.setRange(Unit::None, - amp2_range * 0.5, amp2_range * 0.5); - } - break; - } - } - - // QRectF(x, y, w, h); (x, y) = top left corner - - if (m_displays == DisplayBoth) - { - if(m_orientation == Qt::Vertical) { - int scopeHeight = (height() - topMargin) / 2 - botMargin; - int scopeWidth = width() - leftMargin - rightMargin; - - if (m_mode == ModeIQPolar) - { - m_glScopeRect1 = QRectF( - (float) leftMargin / (float) width(), - (float) topMargin / (float) height(), - (float) (width() - 2*leftMargin - rightMargin) / (float) width(), - (float) scopeHeight / (float) height() - ); - m_glScopeMatrix1.setToIdentity(); - m_glScopeMatrix1.translate ( - -1.0f + ((float) 2*leftMargin / (float) width()), - 1.0f - ((float) 2*topMargin / (float) height()) - ); - m_glScopeMatrix1.scale ( - (float) 2*(width() - 2*leftMargin - rightMargin) / (float) width(), - (float) -2*scopeHeight / (float) height() - ); - - m_glBot1ScaleMatrix.setToIdentity(); - m_glBot1ScaleMatrix.translate ( - -1.0f + ((float) 2*leftMargin / (float) width()), - 1.0f - ((float) 2*(scopeHeight + topMargin + 1) / (float) height()) - ); - m_glBot1ScaleMatrix.scale ( - (float) 2*(width() - 2*leftMargin - rightMargin) / (float) width(), - (float) -2*(botMargin - 1) / (float) height() - ); - - m_glRight1ScaleMatrix.setToIdentity(); - m_glRight1ScaleMatrix.translate ( - -1.0f + ((float)(2*(width() - leftMargin)) / (float) width()), - 1.0f - ((float) 2*topMargin / (float) height()) - ); - m_glRight1ScaleMatrix.scale ( - (float) 2*(leftMargin-1) / (float) width(), - (float) -2*scopeHeight / (float) height() - ); - } - else - { - m_glScopeRect1 = QRectF( - (float) leftMargin / (float) width(), - (float) topMargin / (float) height(), - (float) scopeWidth / (float) width(), - (float) scopeHeight / (float) height() - ); - m_glScopeMatrix1.setToIdentity(); - m_glScopeMatrix1.translate ( - -1.0f + ((float) 2*leftMargin / (float) width()), - 1.0f - ((float) 2*topMargin / (float) height()) - ); - m_glScopeMatrix1.scale ( - (float) 2*scopeWidth / (float) width(), - (float) -2*scopeHeight / (float) height() - ); - - m_glBot1ScaleMatrix.setToIdentity(); - m_glBot1ScaleMatrix.translate ( - -1.0f + ((float) 2*leftMargin / (float) width()), - 1.0f - ((float) 2*(scopeHeight + topMargin + 1) / (float) height()) - ); - m_glBot1ScaleMatrix.scale ( - (float) 2*scopeWidth / (float) width(), - (float) -2*(botMargin - 1) / (float) height() - ); - } - - m_glLeft1ScaleMatrix.setToIdentity(); - m_glLeft1ScaleMatrix.translate ( - -1.0f, - 1.0f - ((float) 2*topMargin / (float) height()) - ); - m_glLeft1ScaleMatrix.scale ( - (float) 2*(leftMargin-1) / (float) width(), - (float) -2*scopeHeight / (float) height() - ); - - { // Y1 scale - m_y1Scale.setSize(scopeHeight); - - m_left1ScalePixmap = QPixmap( - leftMargin - 1, - scopeHeight - ); - - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; - - m_left1ScalePixmap.fill(Qt::black); - QPainter painter(&m_left1ScalePixmap); - painter.setPen(QColor(0xf0, 0xf0, 0xff)); - painter.setFont(font()); - tickList = &m_y1Scale.getTickList(); - - for(int i = 0; i < tickList->count(); i++) { - tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - painter.drawText(QPointF(leftMargin - M - tick->textSize, topMargin + scopeHeight - tick->textPos - fm.ascent()/2), tick->text); - } - } - } - - m_glShaderLeft1Scale.initTexture(m_left1ScalePixmap.toImage()); - - } // Y1 scale - { // X1 scale - m_x1Scale.setSize(scopeWidth); - - m_bot1ScalePixmap = QPixmap( - scopeWidth, - botMargin - 1 - ); - - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; - - m_bot1ScalePixmap.fill(Qt::black); - QPainter painter(&m_bot1ScalePixmap); - painter.setPen(QColor(0xf0, 0xf0, 0xff)); - painter.setFont(font()); - tickList = &m_x1Scale.getTickList(); - - for(int i = 0; i < tickList->count(); i++) { - tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - painter.drawText(QPointF(tick->textPos, fm.height() - 1), tick->text); - } - } - } - - m_glShaderBottom1Scale.initTexture(m_bot1ScalePixmap.toImage()); - - } // X1 scale - - if (m_mode == ModeIQPolar) - { - int scopeDim = std::min(scopeWidth, scopeHeight); - - m_glScopeRect2 = QRectF( - (float) leftMargin / (float)width(), - (float) (botMargin + topMargin + scopeDim) / (float)height(), - (float) scopeDim / (float)width(), - (float) scopeDim / (float)height() - ); - m_glScopeMatrix2.setToIdentity(); - m_glScopeMatrix2.translate ( - -1.0f + ((float) 2*leftMargin / (float) width()), - 1.0f - ((float) 2*(botMargin + topMargin + scopeDim) / (float) height()) - ); - m_glScopeMatrix2.scale ( - (float) 2*scopeDim / (float) width(), - (float) -2*scopeDim / (float) height() - ); - - m_glLeft2ScaleMatrix.setToIdentity(); - m_glLeft2ScaleMatrix.translate ( - -1.0f, - 1.0f - ((float) 2*(topMargin + scopeDim + botMargin) / (float) height()) - ); - m_glLeft2ScaleMatrix.scale ( - (float) 2*(leftMargin-1) / (float) width(), - (float) -2*scopeDim / (float) height() - ); - - m_glBot2ScaleMatrix.setToIdentity(); - m_glBot2ScaleMatrix.translate ( - -1.0f + ((float) 2*leftMargin / (float) width()), - 1.0f - ((float) 2*(scopeDim + topMargin + scopeDim + botMargin + 1) / (float) height()) - ); - m_glBot2ScaleMatrix.scale ( - (float) 2*scopeDim / (float) width(), - (float) -2*(botMargin - 1) / (float) height() - ); - } - else - { - m_glScopeRect2 = QRectF( - (float) leftMargin / (float)width(), - (float) (botMargin + topMargin + scopeHeight) / (float)height(), - (float) scopeWidth / (float)width(), - (float) scopeHeight / (float)height() - ); - m_glScopeMatrix2.setToIdentity(); - m_glScopeMatrix2.translate ( - -1.0f + ((float) 2*leftMargin / (float) width()), - 1.0f - ((float) 2*(botMargin + topMargin + scopeHeight) / (float) height()) - ); - m_glScopeMatrix2.scale ( - (float) 2*scopeWidth / (float) width(), - (float) -2*scopeHeight / (float) height() - ); - - m_glLeft2ScaleMatrix.setToIdentity(); - m_glLeft2ScaleMatrix.translate ( - -1.0f, - 1.0f - ((float) 2*(topMargin + scopeHeight + botMargin) / (float) height()) - ); - m_glLeft2ScaleMatrix.scale ( - (float) 2*(leftMargin-1) / (float) width(), - (float) -2*scopeHeight / (float) height() - ); - - m_glBot2ScaleMatrix.setToIdentity(); - m_glBot2ScaleMatrix.translate ( - -1.0f + ((float) 2*leftMargin / (float) width()), - 1.0f - ((float) 2*(scopeHeight + topMargin + scopeHeight + botMargin + 1) / (float) height()) - ); - m_glBot2ScaleMatrix.scale ( - (float) 2*scopeWidth / (float) width(), - (float) -2*(botMargin - 1) / (float) height() - ); - } - { // Y2 scale - m_y2Scale.setSize(scopeHeight); - - m_left2ScalePixmap = QPixmap( - leftMargin - 1, - scopeHeight - ); - - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; - - m_left2ScalePixmap.fill(Qt::black); - QPainter painter(&m_left2ScalePixmap); - painter.setPen(QColor(0xf0, 0xf0, 0xff)); - painter.setFont(font()); - tickList = &m_y2Scale.getTickList(); - - for(int i = 0; i < tickList->count(); i++) { - tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - painter.drawText(QPointF(leftMargin - M - tick->textSize, topMargin + scopeHeight - tick->textPos - fm.ascent()/2), tick->text); - } - } - } - - m_glShaderLeft2Scale.initTexture(m_left2ScalePixmap.toImage()); - - } // Y2 scale - { // X2 scale - if (m_mode == ModeIQPolar) - { - int scopeDim = std::min(scopeWidth, scopeHeight); - - m_x2Scale.setSize(scopeDim); - m_bot2ScalePixmap = QPixmap( - scopeDim, - botMargin - 1 - ); - } - else - { - m_x2Scale.setSize(scopeWidth); - m_bot2ScalePixmap = QPixmap( - scopeWidth, - botMargin - 1 - ); - } - - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; - - m_bot2ScalePixmap.fill(Qt::black); - QPainter painter(&m_bot2ScalePixmap); - painter.setPen(QColor(0xf0, 0xf0, 0xff)); - painter.setFont(font()); - tickList = &m_x2Scale.getTickList(); - - for(int i = 0; i < tickList->count(); i++) { - tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - painter.drawText(QPointF(tick->textPos, fm.height() - 1), tick->text); - } - } - } - - m_glShaderBottom2Scale.initTexture(m_bot2ScalePixmap.toImage()); - - } // X2 scale - } - else // Horizontal - { - int scopeHeight = height() - topMargin - botMargin; - int scopeWidth = (width() - rightMargin)/2 - leftMargin; - - if (m_mode == ModeIQPolar) - { - m_glScopeRect1 = QRectF( - (float) leftMargin / (float) width(), - (float) topMargin / (float) height(), - (float) (scopeWidth-leftMargin) / (float) width(), - (float) scopeHeight / (float) height() - ); - m_glScopeMatrix1.setToIdentity(); - m_glScopeMatrix1.translate ( - -1.0f + ((float) 2*leftMargin / (float) width()), - 1.0f - ((float) 2*topMargin / (float) height()) - ); - m_glScopeMatrix1.scale ( - (float) 2*(scopeWidth-leftMargin) / (float) width(), - (float) -2*scopeHeight / (float) height() - ); - - m_glBot1ScaleMatrix.setToIdentity(); - m_glBot1ScaleMatrix.translate ( - -1.0f + ((float) 2*leftMargin / (float) width()), - 1.0f - ((float) 2*(scopeHeight + topMargin + 1) / (float) height()) - ); - m_glBot1ScaleMatrix.scale ( - (float) 2*(scopeWidth-leftMargin) / (float) width(), - (float) -2*(botMargin - 1) / (float) height() - ); - - m_glRight1ScaleMatrix.setToIdentity(); - m_glRight1ScaleMatrix.translate ( - -1.0f + ((float) 2*scopeWidth / (float) width()), - 1.0f - ((float) 2*topMargin / (float) height()) - ); - m_glRight1ScaleMatrix.scale ( - (float) 2*(leftMargin-1) / (float) width(), - (float) -2*scopeHeight / (float) height() - ); - } - else - { - m_glScopeRect1 = QRectF( - (float) leftMargin / (float) width(), - (float) topMargin / (float) height(), - (float) scopeWidth / (float) width(), - (float) scopeHeight / (float) height() - ); - m_glScopeMatrix1.setToIdentity(); - m_glScopeMatrix1.translate ( - -1.0f + ((float) 2*leftMargin / (float) width()), - 1.0f - ((float) 2*topMargin / (float) height()) - ); - m_glScopeMatrix1.scale ( - (float) 2*scopeWidth / (float) width(), - (float) -2*scopeHeight / (float) height() - ); - - m_glBot1ScaleMatrix.setToIdentity(); - m_glBot1ScaleMatrix.translate ( - -1.0f + ((float) 2*leftMargin / (float) width()), - 1.0f - ((float) 2*(scopeHeight + topMargin + 1) / (float) height()) - ); - m_glBot1ScaleMatrix.scale ( - (float) 2*scopeWidth / (float) width(), - (float) -2*(botMargin - 1) / (float) height() - ); - } - - m_glLeft1ScaleMatrix.setToIdentity(); - m_glLeft1ScaleMatrix.translate ( - -1.0f, - 1.0f - ((float) 2*topMargin / (float) height()) - ); - m_glLeft1ScaleMatrix.scale ( - (float) 2*(leftMargin-1) / (float) width(), - (float) -2*scopeHeight / (float) height() - ); - - { // Y1 scale - m_y1Scale.setSize(scopeHeight); - - m_left1ScalePixmap = QPixmap( - leftMargin - 1, - scopeHeight - ); - - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; - - m_left1ScalePixmap.fill(Qt::black); - QPainter painter(&m_left1ScalePixmap); - painter.setPen(QColor(0xf0, 0xf0, 0xff)); - painter.setFont(font()); - tickList = &m_y1Scale.getTickList(); - - for(int i = 0; i < tickList->count(); i++) { - tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - painter.drawText(QPointF(leftMargin - M - tick->textSize, topMargin + scopeHeight - tick->textPos - fm.ascent()/2), tick->text); - } - } - } - - m_glShaderLeft1Scale.initTexture(m_left1ScalePixmap.toImage()); - - } // Y1 scale - { // X1 scale - m_x1Scale.setSize(scopeWidth); - - m_bot1ScalePixmap = QPixmap( - scopeWidth, - botMargin - 1 - ); - - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; - - m_bot1ScalePixmap.fill(Qt::black); - QPainter painter(&m_bot1ScalePixmap); - painter.setPen(QColor(0xf0, 0xf0, 0xff)); - painter.setFont(font()); - tickList = &m_x1Scale.getTickList(); - - for(int i = 0; i < tickList->count(); i++) { - tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - painter.drawText(QPointF(tick->textPos, fm.height() - 1), tick->text); - } - } - } - - m_glShaderBottom1Scale.initTexture(m_bot1ScalePixmap.toImage()); - - } // X1 scale - - if (m_mode == ModeIQPolar) - { - int scopeDim = std::min(scopeWidth, scopeHeight); - - m_glScopeRect2 = QRectF( - (float)(leftMargin + scopeWidth + leftMargin) / (float)width(), - (float)topMargin / (float)height(), - (float) scopeDim / (float)width(), - (float)(height() - topMargin - botMargin) / (float)height() - ); - m_glScopeMatrix2.setToIdentity(); - m_glScopeMatrix2.translate ( - -1.0f + ((float) 2*(leftMargin + scopeWidth + leftMargin) / (float) width()), - 1.0f - ((float) 2*topMargin / (float) height()) - ); - m_glScopeMatrix2.scale ( - (float) 2*scopeDim / (float) width(), - (float) -2*(height() - topMargin - botMargin) / (float) height() - ); - - m_glLeft2ScaleMatrix.setToIdentity(); - m_glLeft2ScaleMatrix.translate ( - -1.0f + (float) 2*(leftMargin + scopeWidth) / (float) width(), - 1.0f - ((float) 2*topMargin / (float) height()) - ); - m_glLeft2ScaleMatrix.scale ( - (float) 2*(leftMargin-1) / (float) width(), - (float) -2*scopeHeight / (float) height() - ); - - m_glBot2ScaleMatrix.setToIdentity(); - m_glBot2ScaleMatrix.translate ( - -1.0f + ((float) 2*(leftMargin + leftMargin + scopeWidth) / (float) width()), - 1.0f - ((float) 2*(scopeHeight + topMargin + 1) / (float) height()) - ); - m_glBot2ScaleMatrix.scale ( - (float) 2*scopeDim / (float) width(), - (float) -2*(botMargin - 1) / (float) height() - ); - } - else - { - m_glScopeRect2 = QRectF( - (float)(leftMargin + leftMargin + ((width() - leftMargin - leftMargin - rightMargin) / 2)) / (float)width(), - (float)topMargin / (float)height(), - (float)((width() - leftMargin - leftMargin - rightMargin) / 2) / (float)width(), - (float)(height() - topMargin - botMargin) / (float)height() - ); - m_glScopeMatrix2.setToIdentity(); - m_glScopeMatrix2.translate ( - -1.0f + ((float) 2*(leftMargin + leftMargin + ((width() - leftMargin - leftMargin - rightMargin) / 2)) / (float) width()), - 1.0f - ((float) 2*topMargin / (float) height()) - ); - m_glScopeMatrix2.scale ( - (float) 2*((width() - leftMargin - leftMargin - rightMargin) / 2) / (float) width(), - (float) -2*(height() - topMargin - botMargin) / (float) height() - ); - - m_glLeft2ScaleMatrix.setToIdentity(); - m_glLeft2ScaleMatrix.translate ( - -1.0f + (float) 2*(leftMargin + scopeWidth) / (float) width(), - 1.0f - ((float) 2*topMargin / (float) height()) - ); - m_glLeft2ScaleMatrix.scale ( - (float) 2*(leftMargin-1) / (float) width(), - (float) -2*scopeHeight / (float) height() - ); - - m_glBot2ScaleMatrix.setToIdentity(); - m_glBot2ScaleMatrix.translate ( - -1.0f + ((float) 2*(leftMargin + leftMargin + scopeWidth) / (float) width()), - 1.0f - ((float) 2*(scopeHeight + topMargin + 1) / (float) height()) - ); - m_glBot2ScaleMatrix.scale ( - (float) 2*scopeWidth / (float) width(), - (float) -2*(botMargin - 1) / (float) height() - ); - } - { // Y2 scale - m_y2Scale.setSize(scopeHeight); - - m_left2ScalePixmap = QPixmap( - leftMargin - 1, - scopeHeight - ); - - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; - - m_left2ScalePixmap.fill(Qt::black); - QPainter painter(&m_left2ScalePixmap); - painter.setPen(QColor(0xf0, 0xf0, 0xff)); - painter.setFont(font()); - tickList = &m_y2Scale.getTickList(); - - for(int i = 0; i < tickList->count(); i++) { - tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - painter.drawText(QPointF(leftMargin - M - tick->textSize, topMargin + scopeHeight - tick->textPos - fm.ascent()/2), tick->text); - } - } - } - - m_glShaderLeft2Scale.initTexture(m_left2ScalePixmap.toImage()); - - } // Y2 scale - { // X2 scale - if (m_mode == ModeIQPolar) - { - int scopeDim = std::min(scopeWidth, scopeHeight); - - m_x2Scale.setSize(scopeDim); - m_bot2ScalePixmap = QPixmap( - scopeDim, - botMargin - 1 - ); - } - else - { - m_x2Scale.setSize(scopeWidth); - m_bot2ScalePixmap = QPixmap( - scopeWidth, - botMargin - 1 - ); - } - - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; - - m_bot2ScalePixmap.fill(Qt::black); - QPainter painter(&m_bot2ScalePixmap); - painter.setPen(QColor(0xf0, 0xf0, 0xff)); - painter.setFont(font()); - tickList = &m_x2Scale.getTickList(); - - for(int i = 0; i < tickList->count(); i++) { - tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - painter.drawText(QPointF(tick->textPos, fm.height() - 1), tick->text); - } - } - } - - m_glShaderBottom2Scale.initTexture(m_bot2ScalePixmap.toImage()); - - } // X2 scale - } - } // Both displays - else if (m_displays == DisplayFirstOnly) - { - int scopeHeight = height() - topMargin - botMargin; - int scopeWidth = width() - leftMargin - rightMargin; - - if (m_mode == ModeIQPolar) - { - m_glScopeRect1 = QRectF( - (float) leftMargin / (float) width(), - (float) topMargin / (float) height(), - (float) (scopeWidth-leftMargin) / (float) width(), - (float) scopeHeight / (float) height() - ); - m_glScopeMatrix1.setToIdentity(); - m_glScopeMatrix1.translate ( - -1.0f + ((float) 2*leftMargin / (float) width()), - 1.0f - ((float) 2*topMargin / (float) height()) - ); - m_glScopeMatrix1.scale ( - (float) 2*(scopeWidth-leftMargin) / (float) width(), - (float) -2*scopeHeight / (float) height() - ); - - m_glBot1ScaleMatrix.setToIdentity(); - m_glBot1ScaleMatrix.translate ( - -1.0f + ((float) 2*leftMargin / (float) width()), - 1.0f - ((float) 2*(scopeHeight + topMargin + 1) / (float) height()) - ); - m_glBot1ScaleMatrix.scale ( - (float) 2*(scopeWidth-leftMargin) / (float) width(), - (float) -2*(botMargin - 1) / (float) height() - ); - - m_glRight1ScaleMatrix.setToIdentity(); - m_glRight1ScaleMatrix.translate ( - -1.0f + ((float) 2*(width() - leftMargin) / (float) width()), - 1.0f - ((float) 2*topMargin / (float) height()) - ); - m_glRight1ScaleMatrix.scale ( - (float) 2*(leftMargin-1) / (float) width(), - (float) -2*scopeHeight / (float) height() - ); - } - else - { - m_glScopeRect1 = QRectF( - (float) leftMargin / (float) width(), - (float) topMargin / (float) height(), - (float) scopeWidth / (float) width(), - (float) scopeHeight / (float) height() - ); - m_glScopeMatrix1.setToIdentity(); - m_glScopeMatrix1.translate ( - -1.0f + ((float) 2*leftMargin / (float) width()), - 1.0f - ((float) 2*topMargin / (float) height()) - ); - m_glScopeMatrix1.scale ( - (float) 2*scopeWidth / (float) width(), - (float) -2*scopeHeight / (float) height() - ); - - m_glBot1ScaleMatrix.setToIdentity(); - m_glBot1ScaleMatrix.translate ( - -1.0f + ((float) 2*leftMargin / (float) width()), - 1.0f - ((float) 2*(scopeHeight + topMargin + 1) / (float) height()) - ); - m_glBot1ScaleMatrix.scale ( - (float) 2*scopeWidth / (float) width(), - (float) -2*(botMargin - 1) / (float) height() - ); - } - - m_glLeft1ScaleMatrix.setToIdentity(); - m_glLeft1ScaleMatrix.translate ( - -1.0f, - 1.0f - ((float) 2*topMargin / (float) height()) - ); - m_glLeft1ScaleMatrix.scale ( - (float) 2*(leftMargin-1) / (float) width(), - (float) -2*scopeHeight / (float) height() - ); - - { // Y1 scale - m_y1Scale.setSize(scopeHeight); - - m_left1ScalePixmap = QPixmap( - leftMargin - 1, - scopeHeight - ); - - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; - - m_left1ScalePixmap.fill(Qt::black); - QPainter painter(&m_left1ScalePixmap); - if (m_mode == ModeIQPolar) { - painter.setPen(QColor(0xff, 0xff, 0x80)); - } else { - painter.setPen(QColor(0xf0, 0xf0, 0xff)); - } - painter.setFont(font()); - tickList = &m_y1Scale.getTickList(); - - for(int i = 0; i < tickList->count(); i++) { - tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - painter.drawText(QPointF(leftMargin - M - tick->textSize, topMargin + scopeHeight - tick->textPos - fm.ascent()/2), tick->text); - } - } - } - - m_glShaderLeft1Scale.initTexture(m_left1ScalePixmap.toImage()); - - } // Y1 scale - if (m_mode == ModeIQPolar) { // Y2 scale - m_y2Scale.setSize(scopeHeight); - - m_left2ScalePixmap = QPixmap( - leftMargin - 1, - scopeHeight - ); - - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; - - m_left2ScalePixmap.fill(Qt::black); - QPainter painter(&m_left2ScalePixmap); - painter.setPen(QColor(0x80, 0xff, 0xff)); - painter.setFont(font()); - tickList = &m_y2Scale.getTickList(); - - for(int i = 0; i < tickList->count(); i++) { - tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - painter.drawText(QPointF(leftMargin - M - tick->textSize, topMargin + scopeHeight - tick->textPos - fm.ascent()/2), tick->text); - } - } - } - - m_glShaderLeft2Scale.initTexture(m_left2ScalePixmap.toImage()); - - } // Y2 scale - { // X1 scale - m_x1Scale.setSize(scopeWidth); - - m_bot1ScalePixmap = QPixmap( - scopeWidth, - botMargin - 1 - ); - - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; - - m_bot1ScalePixmap.fill(Qt::black); - QPainter painter(&m_bot1ScalePixmap); - painter.setPen(QColor(0xf0, 0xf0, 0xff)); - painter.setFont(font()); - tickList = &m_x1Scale.getTickList(); - - for(int i = 0; i < tickList->count(); i++) { - tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - painter.drawText(QPointF(tick->textPos, fm.height() - 1), tick->text); - } - } - } - - m_glShaderBottom1Scale.initTexture(m_bot1ScalePixmap.toImage()); - - } // X1 scale - } // Primary display only - else if (m_displays == DisplaySecondOnly) - { - int scopeHeight = height() - topMargin - botMargin; - int scopeWidth = width() - leftMargin - rightMargin; - - if (m_mode == ModeIQPolar) - { - int scopeDim = std::min(scopeWidth, scopeHeight); - - m_glScopeRect2 = QRectF( - (float) leftMargin / (float) width(), - (float) topMargin / (float) height(), - (float) scopeDim / (float) width(), - (float) scopeDim / (float) height() - ); - m_glScopeMatrix2.setToIdentity(); - m_glScopeMatrix2.translate ( - -1.0f + ((float) 2*leftMargin / (float) width()), - 1.0f - ((float) 2*topMargin / (float) height()) - ); - m_glScopeMatrix2.scale ( - (float) 2*scopeDim / (float) width(), - (float) -2*scopeDim / (float) height() - ); - - m_glLeft2ScaleMatrix.setToIdentity(); - m_glLeft2ScaleMatrix.translate ( - -1.0f, - 1.0f - ((float) 2*topMargin / (float) height()) - ); - m_glLeft2ScaleMatrix.scale ( - (float) 2*(leftMargin-1) / (float) width(), - (float) -2*scopeDim / (float) height() - ); - - m_glBot2ScaleMatrix.setToIdentity(); - m_glBot2ScaleMatrix.translate ( - -1.0f + ((float) 2*leftMargin / (float) width()), - 1.0f - ((float) 2*(scopeDim + topMargin + 1) / (float) height()) - ); - m_glBot2ScaleMatrix.scale ( - (float) 2*scopeDim / (float) width(), - (float) -2*(botMargin - 1) / (float) height() - ); - } - else - { - m_glScopeRect2 = QRectF( - (float) leftMargin / (float) width(), - (float) topMargin / (float) height(), - (float) scopeWidth / (float) width(), - (float) scopeHeight / (float) height() - ); - m_glScopeMatrix2.setToIdentity(); - m_glScopeMatrix2.translate ( - -1.0f + ((float) 2*leftMargin / (float) width()), - 1.0f - ((float) 2*topMargin / (float) height()) - ); - m_glScopeMatrix2.scale ( - (float) 2*scopeWidth / (float) width(), - (float) -2*scopeHeight / (float) height() - ); - - m_glLeft2ScaleMatrix.setToIdentity(); - m_glLeft2ScaleMatrix.translate ( - -1.0f, - 1.0f - ((float) 2*topMargin / (float) height()) - ); - m_glLeft2ScaleMatrix.scale ( - (float) 2*(leftMargin-1) / (float) width(), - (float) -2*scopeHeight / (float) height() - ); - - m_glBot2ScaleMatrix.setToIdentity(); - m_glBot2ScaleMatrix.translate ( - -1.0f + ((float) 2*leftMargin / (float) width()), - 1.0f - ((float) 2*(scopeHeight + topMargin + 1) / (float) height()) - ); - m_glBot2ScaleMatrix.scale ( - (float) 2*scopeWidth / (float) width(), - (float) -2*(botMargin - 1) / (float) height() - ); - } - - { // Y2 scale - m_y2Scale.setSize(scopeHeight); - - m_left2ScalePixmap = QPixmap( - leftMargin - 1, - scopeHeight - ); - - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; - - m_left2ScalePixmap.fill(Qt::black); - QPainter painter(&m_left2ScalePixmap); - painter.setPen(QColor(0xf0, 0xf0, 0xff)); - painter.setFont(font()); - tickList = &m_y2Scale.getTickList(); - - for(int i = 0; i < tickList->count(); i++) { - tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - painter.drawText(QPointF(leftMargin - M - tick->textSize, topMargin + scopeHeight - tick->textPos - fm.ascent()/2), tick->text); - } - } - } - - m_glShaderLeft2Scale.initTexture(m_left2ScalePixmap.toImage()); - - } // Y2 scale - { // X2 scale - if (m_mode == ModeIQPolar) - { - int scopeDim = std::min(scopeWidth, scopeHeight); - - m_x2Scale.setSize(scopeDim); - m_bot2ScalePixmap = QPixmap( - scopeDim, - botMargin - 1 - ); - } - else - { - m_x2Scale.setSize(scopeWidth); - m_bot2ScalePixmap = QPixmap( - scopeWidth, - botMargin - 1 - ); - } - - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; - - m_bot2ScalePixmap.fill(Qt::black); - QPainter painter(&m_bot2ScalePixmap); - painter.setPen(QColor(0xf0, 0xf0, 0xff)); - painter.setFont(font()); - tickList = &m_x2Scale.getTickList(); - - for(int i = 0; i < tickList->count(); i++) { - tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - painter.drawText(QPointF(tick->textPos, fm.height() - 1), tick->text); - } - } - } - - m_glShaderBottom2Scale.initTexture(m_bot2ScalePixmap.toImage()); - - } // X2 scale - } // Secondary display only - - m_q3TickY1.allocate(4*m_y1Scale.getTickList().count()); - m_q3TickY2.allocate(4*m_y2Scale.getTickList().count()); - m_q3TickX1.allocate(4*m_x1Scale.getTickList().count()); - m_q3TickX2.allocate(4*m_x2Scale.getTickList().count()); -} - -void GLScope::applyTraceConfig(uint32_t size) -{ - m_q3Trace.allocate(2*size); -} - -void GLScope::tick() -{ - if(m_dataChanged) - update(); -} - -void GLScope::setTriggerChannel(ScopeVis::TriggerChannel triggerChannel) -{ - m_triggerChannel = triggerChannel; -} - -void GLScope::setTriggerLevel(Real triggerLevel) -{ - qDebug("GLScope::setTriggerLevel: %f", triggerLevel); - m_triggerLevel = triggerLevel; -} - -void GLScope::setTriggerPre(Real triggerPre) -{ - m_triggerPre = triggerPre; - m_configChanged = true; - update(); -} - -void GLScope::setMemHistoryShift(int value) -{ - if (value < m_memTraceIndexMax) - { - m_memTraceHistory = value; - m_configChanged = true; - update(); - } -} - -void GLScope::connectTimer(const QTimer& timer) -{ - qDebug() << "GLScope::connectTimer"; - disconnect(&m_timer, SIGNAL(timeout()), this, SLOT(tick())); - connect(&timer, SIGNAL(timeout()), this, SLOT(tick())); - m_timer.stop(); -} - -void GLScope::cleanup() -{ - //makeCurrent(); - m_glShaderSimple.cleanup(); - m_glShaderBottom1Scale.cleanup(); - m_glShaderBottom2Scale.cleanup(); - m_glShaderLeft1Scale.cleanup(); - m_glShaderPowerOverlay.cleanup(); - //doneCurrent(); -} diff --git a/sdrgui/gui/glscope.h b/sdrgui/gui/glscope.h deleted file mode 100644 index 6e0e1ce30..000000000 --- a/sdrgui/gui/glscope.h +++ /dev/null @@ -1,193 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2016 F4EXB // -// written by Edouard Griffiths // -// // -// OpenGL interface modernization. // -// See: http://doc.qt.io/qt-5/qopenglshaderprogram.html // -// // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation as version 3 of the License, or // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License V3 for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program. If not, see . // -/////////////////////////////////////////////////////////////////////////////////// - -#ifndef INCLUDE_GLSCOPE_H -#define INCLUDE_GLSCOPE_H - -#include -#include -#include -#include -#include -#include -#include "dsp/dsptypes.h" -#include "dsp/scopevis.h" -#include "gui/scaleengine.h" -#include "gui/glshadersimple.h" -#include "gui/glshadertextured.h" -#include "export.h" -#include "util/bitfieldindex.h" -#include "util/incrementalarray.h" - -class ScopeVis; -class QPainter; - -class SDRGUI_API GLScope: public QGLWidget { - Q_OBJECT - -public: - enum Mode { - ModeIQ, - ModeMagLinPha, - ModeMagdBPha, - ModeMagLinDPha, - ModeMagdBDPha, - ModeDerived12, - ModeCyclostationary, - ModeIQPolar - }; - - enum Displays { - DisplayBoth, - DisplayFirstOnly, - DisplaySecondOnly - }; - - GLScope(QWidget* parent = NULL); - ~GLScope(); - -// void setDSPEngine(DSPEngine* dspEngine); - void setAmp1(Real amp); - void setAmp1Ofs(Real ampOfs); - void setAmp2(Real amp); - void setAmp2Ofs(Real ampOfs); - void setTimeBase(int timeBase); - void setTimeOfsProMill(int timeOfsProMill); - void setMode(Mode mode); - void setDisplays(Displays displays); - void setOrientation(Qt::Orientation orientation); - void setDisplayGridIntensity(int intensity); - void setDisplayTraceIntensity(int intensity); - void setTriggerChannel(ScopeVis::TriggerChannel triggerChannel); - void setTriggerLevel(Real triggerLevel); - void setTriggerPre(Real triggerPre); - void setMemHistoryShift(int value); - - void newTrace(const std::vector& trace, int sampleRate); - int getTraceSize() const { return m_rawTrace[m_memTraceIndex - m_memTraceHistory].size(); } - - void setSampleRate(int sampleRate); - int getSampleRate() const { return m_sampleRates[m_memTraceIndex - m_memTraceHistory]; } - Mode getDataMode() const { return m_mode; } - void connectTimer(const QTimer& timer); - - static const int m_memHistorySizeLog2 = 5; - -signals: - void traceSizeChanged(int); - void sampleRateChanged(int); - -private: - // state - QTimer m_timer; - QMutex m_mutex; - bool m_dataChanged; - bool m_configChanged; - Mode m_mode; - Displays m_displays; - Qt::Orientation m_orientation; - - // traces - std::vector m_rawTrace[1< m_memTraceIndex; //!< current index of trace being written - BitfieldIndex m_memTraceHistory; //!< trace index shift into history - int m_memTraceIndexMax; - bool m_memTraceRecall; - std::vector m_mathTrace; - std::vector* m_displayTrace; - std::vector m_powTrace; - Real m_maxPow; - Real m_sumPow; - int m_oldTraceSize; - int m_sampleRate; - Real m_amp1; - Real m_amp2; - Real m_ofs1; - Real m_ofs2; - - // config - int m_timeBase; - int m_timeOfsProMill; - ScopeVis::TriggerChannel m_triggerChannel; - Real m_triggerLevel; - Real m_triggerPre; - Real m_triggerLevelDis1; - Real m_triggerLevelDis2; - int m_nbPow; - Real m_prevArg; - - // graphics stuff - QRectF m_glScopeRect1; - QRectF m_glScopeRect2; - QMatrix4x4 m_glScopeMatrix1; - QMatrix4x4 m_glScopeMatrix2; - QMatrix4x4 m_glLeft1ScaleMatrix; - QMatrix4x4 m_glRight1ScaleMatrix; - QMatrix4x4 m_glLeft2ScaleMatrix; - QMatrix4x4 m_glBot1ScaleMatrix; - QMatrix4x4 m_glBot2ScaleMatrix; - - QPixmap m_left1ScalePixmap; - QPixmap m_left2ScalePixmap; - QPixmap m_bot1ScalePixmap; - QPixmap m_bot2ScalePixmap; - QPixmap m_powerOverlayPixmap1; - - int m_displayGridIntensity; - int m_displayTraceIntensity; - - ScaleEngine m_x1Scale; - ScaleEngine m_x2Scale; - ScaleEngine m_y1Scale; - ScaleEngine m_y2Scale; - - QFont m_powerOverlayFont; - - GLShaderSimple m_glShaderSimple; - GLShaderTextured m_glShaderLeft1Scale; - GLShaderTextured m_glShaderBottom1Scale; - GLShaderTextured m_glShaderLeft2Scale; - GLShaderTextured m_glShaderBottom2Scale; - GLShaderTextured m_glShaderPowerOverlay; - - IncrementalArray m_q3Trace; - IncrementalArray m_q3TickY1; - IncrementalArray m_q3TickY2; - IncrementalArray m_q3TickX1; - IncrementalArray m_q3TickX2; - - void initializeGL(); - void resizeGL(int width, int height); - void paintGL(); - - void mousePressEvent(QMouseEvent*); - - void handleMode(); - void applyConfig(); - void applyTraceConfig(uint32_t size); - void drawPowerOverlay(); - -protected slots: - void cleanup(); - void tick(); -}; - -#endif // INCLUDE_GLSCOPE_H diff --git a/sdrgui/gui/glscopegui.cpp b/sdrgui/gui/glscopegui.cpp deleted file mode 100644 index 777aed8c6..000000000 --- a/sdrgui/gui/glscopegui.cpp +++ /dev/null @@ -1,919 +0,0 @@ -#include "gui/glscopegui.h" -#include "dsp/scopevis.h" -#include "dsp/dspcommands.h" -#include "gui/glscope.h" -#include "util/simpleserializer.h" -#include "ui_glscopegui.h" - -#include - -const qreal GLScopeGUI::amps[11] = { 0.2, 0.1, 0.05, 0.02, 0.01, 0.005, 0.002, 0.001, 0.0005, 0.0002, 0.0001 }; - -GLScopeGUI::GLScopeGUI(QWidget* parent) : - QWidget(parent), - ui(new Ui::GLScopeGUI), - m_messageQueue(0), - m_scopeVis(0), - m_glScope(0), - m_sampleRate(1), - m_displayData(GLScope::ModeIQ), - m_displayOrientation(Qt::Horizontal), - m_displays(GLScope::DisplayBoth), - m_timeBase(1), - m_timeOffset(0), - m_amplification1(0), - m_amp1OffsetCoarse(0), - m_amp1OffsetFine(0), - m_amplification2(0), - m_amp2OffsetCoarse(0), - m_amp2OffsetFine(0), - m_displayGridIntensity(1), - m_displayTraceIntensity(50), - m_triggerIndex(0), - m_triggerPre(0), - m_traceLenMult(20) -{ - for (unsigned int i = 0; i < ScopeVis::m_nbTriggers; i++) - { - m_triggerChannel[i] = ScopeVis::TriggerFreeRun; - m_triggerLevelCoarse[i] = 0; - m_triggerLevelFine[i] = 0; - m_triggerPositiveEdge[i] = true; - m_triggerBothEdges[i] = false; - m_triggerDelay[i] = 0; - m_triggerCounts[i] = 0; - } - - ui->setupUi(this); -} - -GLScopeGUI::~GLScopeGUI() -{ - delete ui; -} - -void GLScopeGUI::setBuddies(MessageQueue* messageQueue, ScopeVis* scopeVis, GLScope* glScope) -{ - m_messageQueue = messageQueue; - m_scopeVis = scopeVis; - m_glScope = glScope; - ui->memIndex->setMaximum((1<trigPre->setValue(m_triggerPre); - setTrigPreDisplay(); - d.readS32(14, &m_traceLenMult, 20); - ui->traceLen->setValue(m_traceLenMult); - setTraceLenDisplay(); - setTrigDelayDisplay(); - d.readS32(18, &m_amp1OffsetFine, 0); - d.readS32(19, &m_amplification2, 0); - d.readS32(20, &m_amp2OffsetCoarse, 0); - d.readS32(21, &m_amp2OffsetFine, 0); - - for (unsigned int i = 0; i < ScopeVis::m_nbTriggers; i++) - { - d.readS32(50 + 10*i, &m_triggerChannel[i], ScopeVis::TriggerFreeRun); - d.readS32(51 + 10*i, &m_triggerLevelCoarse[i], 0); - d.readS32(52 + 10*i, &m_triggerLevelFine[i], 0); - d.readBool(53 + 10*i, &m_triggerPositiveEdge[i], true); - d.readBool(54 + 10*i, &m_triggerBothEdges[i], false); - d.readS32(55 + 10*i, &m_triggerDelay[i], 0); - d.readS32(56 + 10*i, &m_triggerCounts[i], 0); - m_triggerIndex = i; - applyTriggerSettings(); - } - - m_triggerIndex = 0; - - setTrigUI(m_triggerIndex); - setTrigLevelDisplay(); - applySettings(); - return true; - } else { - resetToDefaults(); - return false; - } -} - -void GLScopeGUI::applyAllTriggerSettings() -{ - quint32 currentTriggerIndex = m_triggerIndex; - - for (unsigned int i = 0; i < ScopeVis::m_nbTriggers; i++) - { - m_triggerIndex = i; - applyTriggerSettings(); - } - - m_triggerIndex = currentTriggerIndex; -} - -void GLScopeGUI::setTrigUI(uint index) -{ - index %= ScopeVis::m_nbTriggers; - - ui->trigMode->setCurrentIndex(m_triggerChannel[index]); - ui->trigLevelCoarse->setValue(m_triggerLevelCoarse[index]); - ui->trigLevelFine->setValue(m_triggerLevelFine[index]); - ui->trigDelay->setValue(m_triggerDelay[index]); - ui->trigCount->setValue(m_triggerCounts[index]); - - if (m_triggerBothEdges[index]) { - ui->slopePos->setChecked(false); - ui->slopeNeg->setChecked(false); - ui->slopeBoth->setChecked(true); - } else { - ui->slopeBoth->setChecked(false); - ui->slopePos->setChecked(m_triggerPositiveEdge[index]); - ui->slopeNeg->setChecked(!m_triggerPositiveEdge[index]); - } -} - -void GLScopeGUI::applySettings() -{ - ui->dataMode->setCurrentIndex(m_displayData); - if (m_displays == GLScope::DisplayBoth) - { - if(m_displayOrientation == Qt::Horizontal) { - m_glScope->setOrientation(Qt::Horizontal); - ui->horizView->setChecked(true); - ui->vertView->setChecked(false); - ui->onlyPrimeView->setChecked(false); - ui->onlySecondView->setChecked(false); - } else { - m_glScope->setOrientation(Qt::Vertical); - ui->horizView->setChecked(false); - ui->vertView->setChecked(true); - ui->onlyPrimeView->setChecked(false); - ui->onlySecondView->setChecked(false); - } - } - else if (m_displays == GLScope::DisplayFirstOnly) - { - m_glScope->setDisplays(GLScope::DisplayFirstOnly); - ui->onlyPrimeView->setChecked(true); - ui->horizView->setChecked(false); - ui->vertView->setChecked(false); - ui->onlySecondView->setChecked(false); - } - else if (m_displays == GLScope::DisplaySecondOnly) - { - m_glScope->setDisplays(GLScope::DisplaySecondOnly); - ui->onlySecondView->setChecked(true); - ui->onlyPrimeView->setChecked(false); - ui->horizView->setChecked(false); - ui->vertView->setChecked(false); - } - ui->time->setValue(m_timeBase); - ui->timeOfs->setValue(m_timeOffset); - ui->amp1->setValue(m_amplification1); - ui->amp1OfsCoarse->setValue(m_amp1OffsetCoarse); - ui->amp1OfsFine->setValue(m_amp1OffsetFine); - ui->amp2->setValue(m_amplification2); - ui->amp2OfsCoarse->setValue(m_amp2OffsetCoarse); - ui->amp2OfsFine->setValue(m_amp2OffsetFine); - ui->gridIntensity->setSliderPosition(m_displayGridIntensity); - ui->traceIntensity->setSliderPosition(m_displayTraceIntensity); -} - -void GLScopeGUI::applyTriggerSettings() -{ - qreal t = (m_triggerLevelCoarse[m_triggerIndex] / 100.0) + (m_triggerLevelFine[m_triggerIndex] / 20000.0); // [-1.0, 1.0] - qreal triggerLevel; - quint32 preTriggerSamples = (m_glScope->getTraceSize() * m_triggerPre) / 100; - - if (m_triggerChannel[m_triggerIndex] == ScopeVis::TriggerMagDb) { - triggerLevel = 100.0 * (t - 1.0); // [-200.0, 0.0] - } - else if (m_triggerChannel[m_triggerIndex] == ScopeVis::TriggerMagLin) { - triggerLevel = 1.0 + t; // [0.0, 2.0] - } - else { - triggerLevel = t; // [-1.0, 1.0] - } - - m_glScope->setTriggerChannel((ScopeVis::TriggerChannel) m_triggerChannel[m_triggerIndex]); - m_glScope->setTriggerLevel(t); // [-1.0, 1.0] - m_glScope->setTriggerPre(m_triggerPre/100.0); // [0.0, 1.0] - - m_scopeVis->configure(m_messageQueue, - m_triggerIndex, - (ScopeVis::TriggerChannel) m_triggerChannel[m_triggerIndex], - triggerLevel, - m_triggerPositiveEdge[m_triggerIndex], - m_triggerBothEdges[m_triggerIndex], - preTriggerSamples, - m_triggerDelay[m_triggerIndex], - m_triggerCounts[m_triggerIndex], - m_traceLenMult * ScopeVis::m_traceChunkSize); -} - -void GLScopeGUI::setTrigLevelDisplay() -{ - qreal t = (m_triggerLevelCoarse[m_triggerIndex] / 100.0) + (m_triggerLevelFine[m_triggerIndex] / 20000.0); - - ui->trigLevelCoarse->setToolTip(QString("Trigger level coarse: %1 %").arg(m_triggerLevelCoarse[m_triggerIndex])); - ui->trigLevelFine->setToolTip(QString("Trigger level fine: %1 ppm").arg(m_triggerLevelFine[m_triggerIndex] * 50)); - - if (m_triggerChannel[m_triggerIndex] == ScopeVis::TriggerMagDb) { - ui->trigText->setText(tr("%1\ndB").arg(100.0 * (t - 1.0), 0, 'f', 1)); - } - else - { - qreal a; - - if (m_triggerChannel[m_triggerIndex] == ScopeVis::TriggerMagLin) { - a = 1.0 + t; - } else { - a = t; - } - - if(fabs(a) < 0.000001) - ui->trigText->setText(tr("%1\nn").arg(a * 1000000000.0)); - else if(fabs(a) < 0.001) - ui->trigText->setText(tr("%1\nµ").arg(a * 1000000.0)); - else if(fabs(a) < 1.0) - ui->trigText->setText(tr("%1\nm").arg(a * 1000.0)); - else - ui->trigText->setText(tr("%1").arg(a * 1.0)); - } -} - -void GLScopeGUI::setAmp1ScaleDisplay() -{ - if ((m_glScope->getDataMode() == GLScope::ModeMagdBPha) || (m_glScope->getDataMode() == GLScope::ModeMagdBDPha)) - { - ui->amp1Text->setText(tr("%1\ndB").arg(amps[m_amplification1]*500.0, 0, 'f', 1)); - } - else - { - qreal a = amps[m_amplification1]*10.0; - - if(a < 0.000001) - ui->amp1Text->setText(tr("%1\nn").arg(a * 1000000000.0)); - else if(a < 0.001) - ui->amp1Text->setText(tr("%1\nµ").arg(a * 1000000.0)); - else if(a < 1.0) - ui->amp1Text->setText(tr("%1\nm").arg(a * 1000.0)); - else - ui->amp1Text->setText(tr("%1").arg(a * 1.0)); - } -} - -void GLScopeGUI::setAmp2ScaleDisplay() -{ - if ((m_glScope->getDataMode() == GLScope::ModeMagdBPha) - || (m_glScope->getDataMode() == GLScope::ModeMagdBDPha) - || (m_glScope->getDataMode() == GLScope::ModeMagLinPha) - || (m_glScope->getDataMode() == GLScope::ModeMagLinDPha)) - { - ui->amp2Text->setText(tr("%1").arg(amps[m_amplification2]*5.0, 0, 'f', 3)); - } - else - { - qreal a = amps[m_amplification2]*10.0; - - if(a < 0.000001) - ui->amp2Text->setText(tr("%1\nn").arg(a * 1000000000.0)); - else if(a < 0.001) - ui->amp2Text->setText(tr("%1\nµ").arg(a * 1000000.0)); - else if(a < 1.0) - ui->amp2Text->setText(tr("%1\nm").arg(a * 1000.0)); - else - ui->amp2Text->setText(tr("%1").arg(a * 1.0)); - } -} - -void GLScopeGUI::setAmp1OfsDisplay() -{ - qreal o = (m_amp1OffsetCoarse * 10.0) + (m_amp1OffsetFine / 20.0); - - if ((m_glScope->getDataMode() == GLScope::ModeMagdBPha) || (m_glScope->getDataMode() == GLScope::ModeMagdBDPha)) - { - ui->amp1OfsText->setText(tr("%1\ndB").arg(o/10.0 - 100.0, 0, 'f', 1)); - } - else - { - qreal a; - - if ((m_glScope->getDataMode() == GLScope::ModeMagLinPha) || (m_glScope->getDataMode() == GLScope::ModeMagLinDPha)) - { - a = o/2000.0; - } - else - { - a = o/1000.0; - } - - if(fabs(a) < 0.000001) - ui->amp1OfsText->setText(tr("%1\nn").arg(a * 1000000000.0)); - else if(fabs(a) < 0.001) - ui->amp1OfsText->setText(tr("%1\nµ").arg(a * 1000000.0)); - else if(fabs(a) < 1.0) - ui->amp1OfsText->setText(tr("%1\nm").arg(a * 1000.0)); - else - ui->amp1OfsText->setText(tr("%1").arg(a * 1.0)); - } -} - -void GLScopeGUI::setAmp2OfsDisplay() -{ - qreal o = (m_amp2OffsetCoarse * 10.0) + (m_amp2OffsetFine / 20.0); - - if ((m_glScope->getDataMode() == GLScope::ModeMagdBPha) - || (m_glScope->getDataMode() == GLScope::ModeMagdBDPha) - || (m_glScope->getDataMode() == GLScope::ModeMagLinPha) - || (m_glScope->getDataMode() == GLScope::ModeMagLinDPha)) - { - ui->amp2OfsText->setText(tr("%1").arg(o/1000.0, 0, 'f', 4)); - } - else - { - qreal a = o/1000.0; - - if(fabs(a) < 0.000001) - ui->amp2OfsText->setText(tr("%1\nn").arg(a * 1000000000.0)); - else if(fabs(a) < 0.001) - ui->amp2OfsText->setText(tr("%1\nµ").arg(a * 1000000.0)); - else if(fabs(a) < 1.0) - ui->amp2OfsText->setText(tr("%1\nm").arg(a * 1000.0)); - else - ui->amp2OfsText->setText(tr("%1").arg(a * 1.0)); - } -} - -void GLScopeGUI::on_amp1_valueChanged(int value) -{ - m_amplification1 = value; - setAmp1ScaleDisplay(); - m_glScope->setAmp1(0.2 / amps[m_amplification1]); -} - -void GLScopeGUI::on_amp1OfsCoarse_valueChanged(int value) -{ - m_amp1OffsetCoarse = value; - setAmp1OfsDisplay(); - qreal o = (m_amp1OffsetCoarse * 10.0) + (m_amp1OffsetFine / 20.0); - m_glScope->setAmp1Ofs(o/1000.0); // scale to [-1.0,1.0] -} - -void GLScopeGUI::on_amp1OfsFine_valueChanged(int value) -{ - m_amp1OffsetFine = value; - setAmp1OfsDisplay(); - qreal o = (m_amp1OffsetCoarse * 10.0) + (m_amp1OffsetFine / 20.0); - m_glScope->setAmp1Ofs(o/1000.0); // scale to [-1.0,1.0] -} - -void GLScopeGUI::on_amp2_valueChanged(int value) -{ - m_amplification2 = value; - setAmp2ScaleDisplay(); - m_glScope->setAmp2(0.2 / amps[m_amplification2]); -} - -void GLScopeGUI::on_amp2OfsCoarse_valueChanged(int value) -{ - m_amp2OffsetCoarse = value; - setAmp2OfsDisplay(); - qreal o = (m_amp2OffsetCoarse * 10.0) + (m_amp2OffsetFine / 20.0); - m_glScope->setAmp2Ofs(o/1000.0); // scale to [-1.0,1.0] -} - -void GLScopeGUI::on_amp2OfsFine_valueChanged(int value) -{ - m_amp2OffsetFine = value; - setAmp2OfsDisplay(); - qreal o = (m_amp2OffsetCoarse * 10.0) + (m_amp2OffsetFine / 20.0); - m_glScope->setAmp2Ofs(o/1000.0); // scale to [-1.0,1.0] -} - -void GLScopeGUI::on_scope_traceSizeChanged(int) -{ - setTimeScaleDisplay(); - setTraceLenDisplay(); - setTimeOfsDisplay(); - setTrigPreDisplay(); - setTrigDelayDisplay(); - applySettings(); - - if (m_triggerPre > 0) { - applyAllTriggerSettings(); // change of trace size changes number of pre-trigger samples - } -} - -void GLScopeGUI::on_scope_sampleRateChanged(int) -{ - m_sampleRate = m_glScope->getSampleRate(); - ui->sampleRateText->setText(tr("%1\nkS/s").arg(m_sampleRate / 1000.0f, 0, 'f', 2)); - setTimeScaleDisplay(); - setTraceLenDisplay(); - setTimeOfsDisplay(); - setTrigPreDisplay(); - setTrigDelayDisplay(); - applySettings(); -} - -void GLScopeGUI::setTimeScaleDisplay() -{ - m_sampleRate = m_glScope->getSampleRate(); - double t = (m_glScope->getTraceSize() * 1.0 / m_sampleRate) / (qreal)m_timeBase; - - if(t < 0.000001) - { - t = round(t * 100000000000.0) / 100.0; - ui->timeText->setText(tr("%1\nns").arg(t)); - } - else if(t < 0.001) - { - t = round(t * 100000000.0) / 100.0; - ui->timeText->setText(tr("%1\nµs").arg(t)); - } - else if(t < 1.0) - { - t = round(t * 100000.0) / 100.0; - ui->timeText->setText(tr("%1\nms").arg(t)); - } - else - { - t = round(t * 100.0) / 100.0; - ui->timeText->setText(tr("%1\ns").arg(t)); - } -} - -void GLScopeGUI::setTraceLenDisplay() -{ - uint n_samples = m_traceLenMult * ScopeVis::m_traceChunkSize; - - if (n_samples < 1000) { - ui->traceLenText->setToolTip(tr("%1S").arg(n_samples)); - } else if (n_samples < 1000000) { - ui->traceLenText->setToolTip(tr("%1kS").arg(n_samples/1000.0)); - } else { - ui->traceLenText->setToolTip(tr("%1MS").arg(n_samples/1000000.0)); - } - - m_sampleRate = m_glScope->getSampleRate(); - qreal t = (m_glScope->getTraceSize() * 1.0 / m_sampleRate); - - if(t < 0.000001) - ui->traceLenText->setText(tr("%1\nns").arg(t * 1000000000.0)); - else if(t < 0.001) - ui->traceLenText->setText(tr("%1\nµs").arg(t * 1000000.0)); - else if(t < 1.0) - ui->traceLenText->setText(tr("%1\nms").arg(t * 1000.0)); - else - ui->traceLenText->setText(tr("%1\ns").arg(t * 1.0)); -} - -void GLScopeGUI::setTrigDelayDisplay() -{ - uint n_samples_delay = m_traceLenMult * ScopeVis::m_traceChunkSize * m_triggerDelay[m_triggerIndex]; - - if (n_samples_delay < 1000) { - ui->trigDelayText->setToolTip(tr("%1S").arg(n_samples_delay)); - } else if (n_samples_delay < 1000000) { - ui->trigDelayText->setToolTip(tr("%1kS").arg(n_samples_delay/1000.0)); - } else if (n_samples_delay < 1000000000) { - ui->trigDelayText->setToolTip(tr("%1MS").arg(n_samples_delay/1000000.0)); - } else { - ui->trigDelayText->setToolTip(tr("%1GS").arg(n_samples_delay/1000000000.0)); - } - - m_sampleRate = m_glScope->getSampleRate(); - qreal t = (n_samples_delay * 1.0 / m_sampleRate); - - if(t < 0.000001) - ui->trigDelayText->setText(tr("%1\nns").arg(t * 1000000000.0)); - else if(t < 0.001) - ui->trigDelayText->setText(tr("%1\nµs").arg(t * 1000000.0)); - else if(t < 1.0) - ui->trigDelayText->setText(tr("%1\nms").arg(t * 1000.0)); - else - ui->trigDelayText->setText(tr("%1\ns").arg(t * 1.0)); -} - -void GLScopeGUI::setTimeOfsDisplay() -{ - qreal dt = m_glScope->getTraceSize() * (m_timeOffset/100.0) / m_sampleRate; - - if(dt < 0.000001) - ui->timeOfsText->setText(tr("%1\nns").arg(dt * 1000000000.0)); - else if(dt < 0.001) - ui->timeOfsText->setText(tr("%1\nµs").arg(dt * 1000000.0)); - else if(dt < 1.0) - ui->timeOfsText->setText(tr("%1\nms").arg(dt * 1000.0)); - else - ui->timeOfsText->setText(tr("%1\ns").arg(dt * 1.0)); - - //ui->timeOfsText->setText(tr("%1").arg(value/100.0, 0, 'f', 2)); -} - -void GLScopeGUI::setTrigPreDisplay() -{ - qreal dt = m_glScope->getTraceSize() * (m_triggerPre/100.0) / m_sampleRate; - - if(dt < 0.000001) - ui->trigPreText->setText(tr("%1\nns").arg(dt * 1000000000.0)); - else if(dt < 0.001) - ui->trigPreText->setText(tr("%1\nµs").arg(dt * 1000000.0)); - else if(dt < 1.0) - ui->trigPreText->setText(tr("%1\nms").arg(dt * 1000.0)); - else - ui->trigPreText->setText(tr("%1\ns").arg(dt * 1.0)); -} - -void GLScopeGUI::on_time_valueChanged(int value) -{ - m_timeBase = value; - setTimeScaleDisplay(); - m_glScope->setTimeBase(m_timeBase); -} - -void GLScopeGUI::on_traceLen_valueChanged(int value) -{ - if ((value < 1) || (value > 100)) { - return; - } - m_traceLenMult = value; - setTraceLenDisplay(); - applyTriggerSettings(); -} - -void GLScopeGUI::on_timeOfs_valueChanged(int value) -{ - if ((value < 0) || (value > 100)) { - return; - } - m_timeOffset = value; - setTimeOfsDisplay(); - m_glScope->setTimeOfsProMill(value*10); -} - -void GLScopeGUI::on_trigPre_valueChanged(int value) -{ - if ((value < 0) || (value > 100)) { - return; - } - m_triggerPre = value; - setTrigPreDisplay(); - applyTriggerSettings(); -} - -void GLScopeGUI::on_trigDelay_valueChanged(int value) -{ - if ((value < 0) || (value > 100)) { - return; - } - m_triggerDelay[m_triggerIndex] = value; - setTrigDelayDisplay(); - applyTriggerSettings(); -} - -void GLScopeGUI::on_dataMode_currentIndexChanged(int index) -{ - m_displayData = index; - - switch(index) { - case 0: // i+q - m_glScope->setMode(GLScope::ModeIQ); - break; - case 1: // clostationary - m_glScope->setMode(GLScope::ModeIQPolar); - break; - case 2: // mag(lin)+pha - m_glScope->setMode(GLScope::ModeMagLinPha); - break; - case 3: // mag(dB)+pha - m_glScope->setMode(GLScope::ModeMagdBPha); - break; - case 4: // mag(lin)+dPha - m_glScope->setMode(GLScope::ModeMagLinDPha); - break; - case 5: // mag(dB)+dPha - m_glScope->setMode(GLScope::ModeMagdBDPha); - break; - case 6: // derived1+derived2 - m_glScope->setMode(GLScope::ModeDerived12); - break; - case 7: // clostationary - m_glScope->setMode(GLScope::ModeCyclostationary); - break; - - default: - break; - } - - setAmp1ScaleDisplay(); - setAmp1OfsDisplay(); -} - -void GLScopeGUI::on_horizView_clicked() -{ - m_displayOrientation = Qt::Horizontal; - m_displays = GLScope::DisplayBoth; - if(ui->horizView->isChecked()) { - ui->vertView->setChecked(false); - ui->onlyPrimeView->setChecked(false); - ui->onlySecondView->setChecked(false); - m_glScope->setOrientation(Qt::Horizontal); - m_glScope->setDisplays(GLScope::DisplayBoth); - } else { - ui->horizView->setChecked(true); - m_glScope->setOrientation(Qt::Horizontal); - m_glScope->setDisplays(GLScope::DisplayBoth); - } -} - -void GLScopeGUI::on_vertView_clicked() -{ - m_displayOrientation = Qt::Vertical; - m_displays = GLScope::DisplayBoth; - if(ui->vertView->isChecked()) { - ui->horizView->setChecked(false); - ui->onlyPrimeView->setChecked(false); - ui->onlySecondView->setChecked(false); - m_glScope->setOrientation(Qt::Vertical); - m_glScope->setDisplays(GLScope::DisplayBoth); - } else { - ui->vertView->setChecked(true); - m_glScope->setOrientation(Qt::Vertical); - m_glScope->setDisplays(GLScope::DisplayBoth); - } -} - -void GLScopeGUI::on_onlyPrimeView_clicked() -{ - m_displays = GLScope::DisplayFirstOnly; - if(ui->onlyPrimeView->isChecked()) { - ui->horizView->setChecked(false); - ui->vertView->setChecked(false); - ui->onlySecondView->setChecked(false); - m_glScope->setDisplays(GLScope::DisplayFirstOnly); - } else { - ui->onlyPrimeView->setChecked(true); - m_glScope->setDisplays(GLScope::DisplayFirstOnly); - } -} - -void GLScopeGUI::on_onlySecondView_clicked() -{ - m_displays = GLScope::DisplaySecondOnly; - if(ui->onlySecondView->isChecked()) { - ui->horizView->setChecked(false); - ui->vertView->setChecked(false); - ui->onlyPrimeView->setChecked(false); - m_glScope->setDisplays(GLScope::DisplaySecondOnly); - } else { - ui->onlySecondView->setChecked(true); - m_glScope->setDisplays(GLScope::DisplaySecondOnly); - } -} - -void GLScopeGUI::on_gridIntensity_valueChanged(int index) -{ - m_displayGridIntensity = index; - ui->gridIntensity->setToolTip(QString("Grid intensity: %1").arg(m_displayGridIntensity)); - if(m_glScope != 0) - m_glScope->setDisplayGridIntensity(m_displayGridIntensity); -} - -void GLScopeGUI::on_traceIntensity_valueChanged(int index) -{ - m_displayTraceIntensity = index; - ui->traceIntensity->setToolTip(QString("Trace intensity: %1").arg(m_displayTraceIntensity)); - if(m_glScope != 0) - m_glScope->setDisplayTraceIntensity(m_displayTraceIntensity); -} - -void GLScopeGUI::on_trigMode_currentIndexChanged(int index) -{ - m_triggerChannel[m_triggerIndex] = index; - setTrigLevelDisplay(); - applyTriggerSettings(); -} - -void GLScopeGUI::on_trigLevelCoarse_valueChanged(int value) -{ - m_triggerLevelCoarse[m_triggerIndex] = value; - setTrigLevelDisplay(); - applyTriggerSettings(); -} - -void GLScopeGUI::on_trigLevelFine_valueChanged(int value) -{ - m_triggerLevelFine[m_triggerIndex] = value; - setTrigLevelDisplay(); - applyTriggerSettings(); -} - -void GLScopeGUI::on_memIndex_valueChanged(int value) -{ - QString text; - text.sprintf("%02d", value % (1<memIndexText->setText(text); - - if(m_glScope != 0) - { - // If entering memory history block new triggers and all trigger controls - m_scopeVis->blockTrigger(value != 0); - ui->traceLen->setDisabled(value != 0); - ui->trigIndex->setDisabled(value != 0); - ui->trigCount->setDisabled(value != 0); - ui->trigMode->setDisabled(value != 0); - ui->slopePos->setDisabled(value != 0); - ui->slopeNeg->setDisabled(value != 0); - ui->slopeBoth->setDisabled(value != 0); - ui->oneShot->setDisabled(value != 0); - ui->trigLevelCoarse->setDisabled(value != 0); - ui->trigLevelFine->setDisabled(value != 0); - ui->trigDelay->setDisabled(value != 0); - ui->trigPre->setDisabled(value != 0); - // Set value - m_glScope->setMemHistoryShift(value); - ui->sampleRateText->setText(tr("%1\nkS/s").arg(m_glScope->getSampleRate() / 1000.0f, 0, 'f', 2)); - } -} - -void GLScopeGUI::on_trigCount_valueChanged(int value) -{ - m_triggerCounts[m_triggerIndex] = value; - - QString text; - text.sprintf("%02d", value); - ui->trigCountText->setText(text); - - applyTriggerSettings(); -} - -void GLScopeGUI::on_trigIndex_valueChanged(int value) -{ - m_triggerIndex = value; - QString text; - text.sprintf("%d", value); - ui->trigIndexText->setText(text); - setTrigLevelDisplay(); - setTrigUI(m_triggerIndex); -} - -void GLScopeGUI::on_slopePos_clicked() -{ - m_triggerPositiveEdge[m_triggerIndex] = true; - m_triggerBothEdges[m_triggerIndex] = false; - - ui->slopeBoth->setChecked(false); - - if(ui->slopePos->isChecked()) { - ui->slopeNeg->setChecked(false); - } else { - ui->slopePos->setChecked(true); - } - - applyTriggerSettings(); -} - -void GLScopeGUI::on_slopeNeg_clicked() -{ - m_triggerPositiveEdge[m_triggerIndex] = false; - m_triggerBothEdges[m_triggerIndex] = false; - - ui->slopeBoth->setChecked(false); - - if(ui->slopeNeg->isChecked()) { - ui->slopePos->setChecked(false); - } else { - ui->slopeNeg->setChecked(true); - } - - applyTriggerSettings(); -} - -void GLScopeGUI::on_slopeBoth_clicked() -{ - qDebug() << "GLScopeGUI::on_slopeBoth_clicked"; - ui->slopePos->setChecked(false); - ui->slopeNeg->setChecked(false); - ui->slopeBoth->setChecked(true); - m_triggerBothEdges[m_triggerIndex] = true; - - applyTriggerSettings(); -} - -void GLScopeGUI::on_oneShot_clicked() -{ - m_scopeVis->setOneShot(ui->oneShot->isChecked()); -} - -bool GLScopeGUI::handleMessage(Message* cmd __attribute__((unused))) -{ - return false; - /* - if(DSPSignalNotification::match(cmd)) - { - DSPSignalNotification* signal = (DSPSignalNotification*)cmd; - //fprintf(stderr, "GLScopeGUI::handleMessage: %d samples/sec, %lld Hz offset", signal->getSampleRate(), signal->getFrequencyOffset()); - m_sampleRate = signal->getSampleRate(); - cmd->completed(); - return true; - } - else - { - return false; - } - */ -} diff --git a/sdrgui/gui/glscopegui.h b/sdrgui/gui/glscopegui.h deleted file mode 100644 index 6b1c6d5aa..000000000 --- a/sdrgui/gui/glscopegui.h +++ /dev/null @@ -1,119 +0,0 @@ -#ifndef INCLUDE_GLSCOPEGUI_H -#define INCLUDE_GLSCOPEGUI_H - -#include -#include "dsp/dsptypes.h" -#include "export.h" -#include "util/message.h" -#include "dsp/scopevis.h" -#include "settings/serializable.h" - -namespace Ui { - class GLScopeGUI; -} - -class MessageQueue; -class GLScope; - -class SDRGUI_API GLScopeGUI : public QWidget, public Serializable { - Q_OBJECT - -public: - explicit GLScopeGUI(QWidget* parent = NULL); - ~GLScopeGUI(); - - void setBuddies(MessageQueue* messageQueue, ScopeVis* scopeVis, GLScope* glScope); - - void setSampleRate(int sampleRate); - void resetToDefaults(); - virtual QByteArray serialize() const; - virtual bool deserialize(const QByteArray& data); - - bool handleMessage(Message* message); - -private: - Ui::GLScopeGUI* ui; - - MessageQueue* m_messageQueue; - ScopeVis* m_scopeVis; - GLScope* m_glScope; - - int m_sampleRate; - - qint32 m_displayData; - qint32 m_displayOrientation; - qint32 m_displays; - qint32 m_timeBase; - qint32 m_timeOffset; - qint32 m_amplification1; - qint32 m_amp1OffsetCoarse; - qint32 m_amp1OffsetFine; - qint32 m_amplification2; - qint32 m_amp2OffsetCoarse; - qint32 m_amp2OffsetFine; - int m_displayGridIntensity; - int m_displayTraceIntensity; - quint32 m_triggerIndex; - qint32 m_triggerChannel[ScopeVis::m_nbTriggers]; - qint32 m_triggerLevelCoarse[ScopeVis::m_nbTriggers]; // percent of full range - qint32 m_triggerLevelFine[ScopeVis::m_nbTriggers]; // percent of coarse - bool m_triggerPositiveEdge[ScopeVis::m_nbTriggers]; - bool m_triggerBothEdges[ScopeVis::m_nbTriggers]; - qint32 m_triggerPre; - qint32 m_triggerDelay[ScopeVis::m_nbTriggers]; - qint32 m_triggerCounts[ScopeVis::m_nbTriggers]; - qint32 m_traceLenMult; - - static const qreal amps[11]; - - void applySettings(); - void applyTriggerSettings(); - void applyAllTriggerSettings(); - void setTimeScaleDisplay(); - void setTraceLenDisplay(); - void setTimeOfsDisplay(); - void setAmp1ScaleDisplay(); - void setAmp1OfsDisplay(); - void setAmp2ScaleDisplay(); - void setAmp2OfsDisplay(); - void setTrigLevelDisplay(); - void setTrigPreDisplay(); - void setTrigDelayDisplay(); - void setTrigUI(uint index); - -private slots: - void on_amp1_valueChanged(int value); - void on_amp1OfsCoarse_valueChanged(int value); - void on_amp1OfsFine_valueChanged(int value); - void on_amp2_valueChanged(int value); - void on_amp2OfsCoarse_valueChanged(int value); - void on_amp2OfsFine_valueChanged(int value); - void on_scope_traceSizeChanged(int value); - void on_scope_sampleRateChanged(int value); - void on_time_valueChanged(int value); - void on_traceLen_valueChanged(int value); - void on_timeOfs_valueChanged(int value); - void on_dataMode_currentIndexChanged(int index); - void on_gridIntensity_valueChanged(int index); - void on_traceIntensity_valueChanged(int index); - void on_trigPre_valueChanged(int value); - void on_trigDelay_valueChanged(int value); - void on_memIndex_valueChanged(int value); - void on_trigCount_valueChanged(int value); - void on_trigIndex_valueChanged(int value); - - void on_horizView_clicked(); - void on_vertView_clicked(); - void on_onlyPrimeView_clicked(); - void on_onlySecondView_clicked(); - - void on_trigMode_currentIndexChanged(int index); - void on_slopePos_clicked(); - void on_slopeNeg_clicked(); - void on_slopeBoth_clicked(); - void on_oneShot_clicked(); - void on_trigLevelCoarse_valueChanged(int value); - void on_trigLevelFine_valueChanged(int value); -}; - -#endif // INCLUDE_GLSCOPEGUI_H diff --git a/sdrgui/gui/glscopegui.ui b/sdrgui/gui/glscopegui.ui deleted file mode 100644 index 8b07d6067..000000000 --- a/sdrgui/gui/glscopegui.ui +++ /dev/null @@ -1,1287 +0,0 @@ - - - GLScopeGUI - - - - 0 - 0 - 634 - 117 - - - - - 634 - 0 - - - - - Liberation Sans - 8 - - - - Oscilloscope - - - - 3 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - 3 - - - 2 - - - 0 - - - 2 - - - 0 - - - - - - 8 - - - - Data - - - - - - - - 0 - 0 - - - - - 8 - - - - Displayed data - - - QComboBox::AdjustToContentsOnFirstShow - - - - 1:I 2:Q (lin) - - - - - 1:IQ (lin) 2:IQ (pol) - - - - - 1:Mag (lin) 2:Phi - - - - - 1:Mag (dB) 2:Phi - - - - - 1:Mag (lin) 2:dPhi - - - - - 1:Mag(dB) 2:dPhi - - - - - 1:Derived 1 2:2nd - - - - - 1,2:Cyclostationary - - - - - - - - Qt::Vertical - - - - - - - Only primary display - - - - - - - :/display1_w.png:/display1_w.png - - - - 16 - 16 - - - - true - - - true - - - - - - - Only secondary display - - - - - - - :/display2_w.png:/display2_w.png - - - - 16 - 16 - - - - true - - - true - - - - - - - Both displays horizontally arranged - - - - - - - :/horizontal_w.png:/horizontal_w.png - - - - 16 - 16 - - - - true - - - true - - - true - - - - - - - Both displays vertically arranged - - - - - - - :/vertical_w.png:/vertical_w.png - - - - 16 - 16 - - - - true - - - true - - - - - - - Qt::Vertical - - - - - - - - 8 - - - - t - - - - - - - - 0 - 0 - - - - - 8 - - - - Time range - - - 1 - - - 100 - - - 1 - - - Qt::Horizontal - - - QSlider::NoTicks - - - 5 - - - - - - - - 32 - 0 - - - - - 8 - - - - 0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - Time offset - - - 0 - - - 100 - - - 1 - - - Qt::Horizontal - - - QSlider::NoTicks - - - 1 - - - - - - - - 32 - 0 - - - - - 8 - - - - 0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Vertical - - - - - - - - 8 - - - - Len - - - - - - - Trace length - - - 1 - - - 100 - - - 1 - - - 20 - - - Qt::Horizontal - - - - - - - - 32 - 0 - - - - - 8 - - - - 0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Vertical - - - - - - - - 52 - 0 - - - - Currently displayed trace sample rate (kS/s) - - - 00000.00 -kS/s - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - Qt::Horizontal - - - - - - - 3 - - - 2 - - - 2 - - - - - Mem - - - - - - - - 24 - 24 - - - - Move in trace history - - - 15 - - - 1 - - - - - - - Trace history index - - - 00 - - - - - - - Qt::Vertical - - - - - - - - 8 - - - - A1 - - - - - - - - 0 - 0 - - - - Y range for display 1 - - - 0 - - - 10 - - - 1 - - - 0 - - - Qt::Horizontal - - - QSlider::NoTicks - - - 1 - - - - - - - - 32 - 0 - - - - - 8 - - - - 000 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - 0 - 0 - - - - Y coarse offset for display 1 - - - -100 - - - 99 - - - 1 - - - Qt::Horizontal - - - QSlider::NoTicks - - - 10 - - - - - - - Y fine offset for display 1 - - - 200 - - - 1 - - - Qt::Horizontal - - - - - - - - - - 32 - 0 - - - - - 8 - - - - 0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Vertical - - - - - - - A2 - - - - - - - Y range for display 2 - - - 10 - - - 1 - - - Qt::Horizontal - - - - - - - - 32 - 0 - - - - 0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - Y coarse offset for display 2 - - - -100 - - - 1 - - - Qt::Horizontal - - - - - - - Y fine offset for display 2 - - - 200 - - - 1 - - - Qt::Horizontal - - - - - - - - - - 32 - 0 - - - - 0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Vertical - - - - - - - - 24 - 24 - - - - Trace intensity - - - 100 - - - 1 - - - 50 - - - - - - - - 24 - 24 - - - - Grid intensity - - - 100 - - - 1 - - - - - - - - - Qt::Horizontal - - - - - - - 3 - - - 2 - - - 0 - - - 2 - - - 0 - - - - - - 8 - - - - Trig. - - - - - - - - 24 - 24 - - - - Navigate through triggers - - - 9 - - - 1 - - - - - - - Current trigger index - - - 0 - - - - - - - Qt::Vertical - - - - - - - - 24 - 24 - - - - Control number of trigger events - - - 1 - - - - - - - Number of trigger events before trigger is kicked off - - - 00 - - - - - - - - 8 - - - - Trigger source - - - - Freerun - - - - - I (lin) - - - - - Q (lin) - - - - - Mag (lin) - - - - - Mag (dB) - - - - - Phi - - - - - dPhi - - - - - - - - - 8 - - - - Trigger positive edge - - - - - - - :/slopep_icon.png:/slopep_icon.png - - - - 16 - 16 - - - - true - - - true - - - Qt::ToolButtonIconOnly - - - true - - - - - - - - 8 - - - - Trigger negative edge - - - - - - - :/slopen_icon.png:/slopen_icon.png - - - - 16 - 16 - - - - true - - - true - - - - - - - Trigger on both edges - - - - - - - :/slopeb_icon.png:/slopeb_icon.png - - - - 16 - 16 - - - - true - - - false - - - true - - - - - - - One shot trigger - - - - - - - :/display1_w.png:/display1_w.png - - - - 16 - 16 - - - - true - - - true - - - - - - - Qt::Vertical - - - - - - - - 8 - - - - Lvl - - - - - - - - - - 16777215 - 9 - - - - Trigger level coarse - - - -100 - - - 99 - - - 1 - - - Qt::Horizontal - - - - - - - - 16777215 - 9 - - - - Trigger level fine - - - 0 - - - 200 - - - 1 - - - Qt::Horizontal - - - - - - - - - - 32 - 0 - - - - - 8 - - - - 0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Dly - - - - - - - Trigger delay - - - 100 - - - 1 - - - Qt::Horizontal - - - - - - - - 32 - 0 - - - - 0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Vertical - - - - - - - - 8 - - - - Pre - - - - - - - Pre-trigger delay - - - 99 - - - 1 - - - Qt::Horizontal - - - - - - - - 32 - 0 - - - - - 8 - - - - 0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - ButtonSwitch - QToolButton -
gui/buttonswitch.h
-
-
- - - - -