diff --git a/sdrbase/dsp/scopevisng.cpp b/sdrbase/dsp/scopevisng.cpp index f3cbb9f7a..bff03724e 100644 --- a/sdrbase/dsp/scopevisng.cpp +++ b/sdrbase/dsp/scopevisng.cpp @@ -26,10 +26,12 @@ MESSAGE_CLASS_DEFINITION(ScopeVisNG::MsgConfigureScopeVisNG, Message) MESSAGE_CLASS_DEFINITION(ScopeVisNG::MsgScopeVisNGAddTrigger, Message) MESSAGE_CLASS_DEFINITION(ScopeVisNG::MsgScopeVisNGChangeTrigger, Message) MESSAGE_CLASS_DEFINITION(ScopeVisNG::MsgScopeVisNGRemoveTrigger, Message) +MESSAGE_CLASS_DEFINITION(ScopeVisNG::MsgScopeVisNGMoveTrigger, Message) MESSAGE_CLASS_DEFINITION(ScopeVisNG::MsgScopeVisNGFocusOnTrigger, Message) MESSAGE_CLASS_DEFINITION(ScopeVisNG::MsgScopeVisNGAddTrace, Message) MESSAGE_CLASS_DEFINITION(ScopeVisNG::MsgScopeVisNGChangeTrace, Message) MESSAGE_CLASS_DEFINITION(ScopeVisNG::MsgScopeVisNGRemoveTrace, Message) +MESSAGE_CLASS_DEFINITION(ScopeVisNG::MsgScopeVisNGMoveTrace, Message) MESSAGE_CLASS_DEFINITION(ScopeVisNG::MsgScopeVisNGFocusOnTrace, Message) MESSAGE_CLASS_DEFINITION(ScopeVisNG::MsgScopeVisNGOneShot, Message) MESSAGE_CLASS_DEFINITION(ScopeVisNG::MsgScopeVisNGMemoryTrace, Message) @@ -112,6 +114,15 @@ void ScopeVisNG::removeTrace(uint32_t traceIndex) getInputMessageQueue()->push(cmd); } +void ScopeVisNG::moveTrace(uint32_t traceIndex, bool upElseDown) +{ + qDebug() << "ScopeVisNG::moveTrace:" + << " trace: " << traceIndex + << " up: " << upElseDown; + Message* cmd = MsgScopeVisNGMoveTrace::create(traceIndex, upElseDown); + getInputMessageQueue()->push(cmd); +} + void ScopeVisNG::focusOnTrace(uint32_t traceIndex) { Message* cmd = MsgScopeVisNGFocusOnTrace::create(traceIndex); @@ -136,6 +147,12 @@ void ScopeVisNG::removeTrigger(uint32_t triggerIndex) getInputMessageQueue()->push(cmd); } +void ScopeVisNG::moveTrigger(uint32_t triggerIndex, bool upElseDown) +{ + Message* cmd = MsgScopeVisNGMoveTrigger::create(triggerIndex, upElseDown); + getInputMessageQueue()->push(cmd); +} + void ScopeVisNG::focusOnTrigger(uint32_t triggerIndex) { Message* cmd = MsgScopeVisNGFocusOnTrigger::create(triggerIndex); @@ -680,6 +697,16 @@ bool ScopeVisNG::handleMessage(const Message& message) updateGLScopeDisplay(); return true; } + else if (MsgScopeVisNGMoveTrace::match(message)) + { + QMutexLocker configLocker(&m_mutex); + MsgScopeVisNGMoveTrace& conf = (MsgScopeVisNGMoveTrace&) message; + m_traces.moveTrace(conf.getTraceIndex(), conf.getMoveUp()); + //updateMaxTraceDelay(); + computeDisplayTriggerLevels(); + updateGLScopeDisplay(); + return true; + } else if (MsgScopeVisNGFocusOnTrace::match(message)) { MsgScopeVisNGFocusOnTrace& conf = (MsgScopeVisNGFocusOnTrace&) message; diff --git a/sdrbase/dsp/scopevisng.h b/sdrbase/dsp/scopevisng.h index 2b3c06f2e..1e2d8225f 100644 --- a/sdrbase/dsp/scopevisng.h +++ b/sdrbase/dsp/scopevisng.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -158,10 +159,12 @@ public: void addTrace(const TraceData& traceData); void changeTrace(const TraceData& traceData, uint32_t traceIndex); void removeTrace(uint32_t traceIndex); + void moveTrace(uint32_t traceIndex, bool upElseDown); void focusOnTrace(uint32_t traceIndex); void addTrigger(const TriggerData& triggerData); void changeTrigger(const TriggerData& triggerData, uint32_t triggerIndex); void removeTrigger(uint32_t triggerIndex); + void moveTrigger(uint32_t triggerIndex, bool upElseDown); void focusOnTrigger(uint32_t triggerIndex); void setOneShot(bool oneShot); void setMemoryIndex(uint32_t memoryIndex); @@ -301,6 +304,31 @@ private: {} }; + // --------------------------------------------- + class MsgScopeVisNGMoveTrigger : public Message { + MESSAGE_CLASS_DECLARATION + + public: + static MsgScopeVisNGMoveTrigger* create( + uint32_t triggerIndex, + bool moveUpElseDown) + { + return new MsgScopeVisNGMoveTrigger(triggerIndex, moveUpElseDown); + } + + uint32_t getTriggerIndex() const { return m_triggerIndex; } + bool getMoveUp() const { return m_moveUpElseDown; } + + private: + uint32_t m_triggerIndex; + bool m_moveUpElseDown; + + MsgScopeVisNGMoveTrigger(uint32_t triggerIndex, bool moveUpElseDown) : + m_triggerIndex(triggerIndex), + m_moveUpElseDown(moveUpElseDown) + {} + }; + // --------------------------------------------- class MsgScopeVisNGFocusOnTrigger : public Message { MESSAGE_CLASS_DECLARATION @@ -388,6 +416,31 @@ private: {} }; + // --------------------------------------------- + class MsgScopeVisNGMoveTrace : public Message { + MESSAGE_CLASS_DECLARATION + + public: + static MsgScopeVisNGMoveTrace* create( + uint32_t traceIndex, + bool moveUpElseDown) + { + return new MsgScopeVisNGMoveTrace(traceIndex, moveUpElseDown); + } + + uint32_t getTraceIndex() const { return m_traceIndex; } + bool getMoveUp() const { return m_moveUpElseDown; } + + private: + uint32_t m_traceIndex; + bool m_moveUpElseDown; + + MsgScopeVisNGMoveTrace(uint32_t traceIndex, bool moveUpElseDown) : + m_traceIndex(traceIndex), + m_moveUpElseDown(moveUpElseDown) + {} + }; + // --------------------------------------------- class MsgScopeVisNGFocusOnTrace : public Message { MESSAGE_CLASS_DECLARATION @@ -808,7 +861,30 @@ private: resize(m_traceSize); // reallocate pointers } + } + void moveTrace(uint32_t traceIndex, bool upElseDown) + { + if ((!upElseDown) && (traceIndex == 0)) { + return; + } + + int nextControlIndex = (traceIndex + (upElseDown ? 1 : -1)) % (m_tracesControl.size()); + int nextDataIndex = (traceIndex + (upElseDown ? 1 : -1)) % (m_tracesData.size()); // should be the same + + m_tracesControl[traceIndex].releaseProjector(); + m_tracesControl[nextControlIndex].releaseProjector(); + + TraceControl nextControl = m_tracesControl[nextControlIndex]; + m_tracesControl[nextControlIndex] = m_tracesControl[traceIndex]; + m_tracesControl[traceIndex] = nextControl; + + TraceData nextData = m_tracesData[nextDataIndex]; + m_tracesData[nextDataIndex] = m_tracesData[traceIndex]; + m_tracesData[traceIndex] = nextData; + + m_tracesControl[traceIndex].initProjector(m_tracesData[traceIndex].m_projectionType); + m_tracesControl[nextControlIndex].initProjector(m_tracesData[nextDataIndex].m_projectionType); } void resize(int traceSize) diff --git a/sdrbase/gui/glscopenggui.cpp b/sdrbase/gui/glscopenggui.cpp index dbf870cae..0246cd430 100644 --- a/sdrbase/gui/glscopenggui.cpp +++ b/sdrbase/gui/glscopenggui.cpp @@ -568,7 +568,7 @@ void GLScopeNGGUI::on_traceAdd_clicked(bool checked) void GLScopeNGGUI::on_traceDel_clicked(bool checked) { - if (ui->trace->value() > 0) + if (ui->trace->value() > 0) // not the X trace { ui->trace->setMaximum(ui->trace->maximum() - 1); @@ -587,6 +587,33 @@ void GLScopeNGGUI::on_traceDel_clicked(bool checked) } } +void GLScopeNGGUI::on_traceUp_clicked(bool checked) +{ + if (ui->trace->maximum() > 0) // more than one trace + { + int newTraceIndex = (ui->trace->value() + 1) % (ui->trace->maximum()+1); + m_scopeVis->moveTrace(ui->trace->value(), true); + ui->trace->setValue(newTraceIndex); // follow trace + ScopeVisNG::TraceData traceData; + m_scopeVis->getTraceData(traceData, ui->trace->value()); + setTraceUI(traceData); + m_scopeVis->focusOnTrace(ui->trace->value()); + } +} + +void GLScopeNGGUI::on_traceDown_clicked(bool checked) +{ + if (ui->trace->value() > 0) // not the X (lowest) trace + { + int newTraceIndex = (ui->trace->value() - 1) % (ui->trace->maximum()+1); + m_scopeVis->moveTrace(ui->trace->value(), false); + ui->trace->setValue(newTraceIndex); // follow trace + ScopeVisNG::TraceData traceData; + m_scopeVis->getTraceData(traceData, ui->trace->value()); + setTraceUI(traceData); + m_scopeVis->focusOnTrace(ui->trace->value()); + } +} void GLScopeNGGUI::on_trig_valueChanged(int value) { diff --git a/sdrbase/gui/glscopenggui.h b/sdrbase/gui/glscopenggui.h index fb4ba52fb..fdd43a685 100644 --- a/sdrbase/gui/glscopenggui.h +++ b/sdrbase/gui/glscopenggui.h @@ -175,6 +175,8 @@ private slots: void on_trace_valueChanged(int value); void on_traceAdd_clicked(bool checked); void on_traceDel_clicked(bool checked); + void on_traceUp_clicked(bool checked); + void on_traceDown_clicked(bool checked); void on_traceMode_currentIndexChanged(int index); void on_amp_valueChanged(int value); void on_ofsCoarse_valueChanged(int value); diff --git a/sdrbase/gui/glscopenggui.ui b/sdrbase/gui/glscopenggui.ui index edc85a43d..743d471f2 100644 --- a/sdrbase/gui/glscopenggui.ui +++ b/sdrbase/gui/glscopenggui.ui @@ -641,6 +641,65 @@ kS/s + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 18 + 18 + + + + Move trace up in trace list (wraps around) + + + + + + + :/arrow_up.png:/arrow_up.png + + + + + + + + 18 + 18 + + + + Move trace down in trace list + + + + + + + :/arrow_down.png:/arrow_down.png + + + + + @@ -1225,6 +1284,65 @@ kS/s + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 18 + 18 + + + + Move trigger up in trigger chain (wraps around) + + + + + + + :/arrow_up.png:/arrow_up.png + + + + + + + + 18 + 18 + + + + Move trigger down in trigger chain + + + + + + + :/arrow_down.png:/arrow_down.png + + + + + diff --git a/sdrbase/resources/res.qrc b/sdrbase/resources/res.qrc index b56bd59b2..50d65a8b5 100644 --- a/sdrbase/resources/res.qrc +++ b/sdrbase/resources/res.qrc @@ -69,5 +69,7 @@ morsekey.png txoff.png txon.png + arrow_down.png + arrow_up.png