From 875cf59fdac9f03f10a6d95bd03f9f0e16fefdef Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 15 Apr 2018 01:34:46 +0200 Subject: [PATCH] ATV modulator: pass text overlay switch in settings --- plugins/channeltx/modatv/atvmod.cpp | 49 +++++++++------------ plugins/channeltx/modatv/atvmod.h | 22 --------- plugins/channeltx/modatv/atvmodgui.cpp | 4 +- plugins/channeltx/modatv/atvmodsettings.cpp | 1 + plugins/channeltx/modatv/atvmodsettings.h | 1 + 5 files changed, 26 insertions(+), 51 deletions(-) diff --git a/plugins/channeltx/modatv/atvmod.cpp b/plugins/channeltx/modatv/atvmod.cpp index 726f80cdc..28feca73e 100644 --- a/plugins/channeltx/modatv/atvmod.cpp +++ b/plugins/channeltx/modatv/atvmod.cpp @@ -43,7 +43,6 @@ MESSAGE_CLASS_DEFINITION(ATVMod::MsgConfigureCameraIndex, Message) MESSAGE_CLASS_DEFINITION(ATVMod::MsgConfigureCameraData, Message) MESSAGE_CLASS_DEFINITION(ATVMod::MsgReportCameraData, Message) MESSAGE_CLASS_DEFINITION(ATVMod::MsgConfigureOverlayText, Message) -MESSAGE_CLASS_DEFINITION(ATVMod::MsgConfigureShowOverlayText, Message) MESSAGE_CLASS_DEFINITION(ATVMod::MsgReportEffectiveSampleRate, Message) const QString ATVMod::m_channelIdURI = "sdrangel.channeltx.modatv"; @@ -73,7 +72,7 @@ ATVMod::ATVMod(DeviceSinkAPI *deviceAPI) : m_videoEOF(false), m_videoOK(false), m_cameraIndex(-1), - m_showOverlayText(false), + //m_showOverlayText(false), m_SSBFilter(0), m_SSBFilterBuffer(0), m_SSBFilterBufferIndex(0), @@ -325,7 +324,7 @@ void ATVMod::pullVideo(Real& sample) if (!colorFrame.empty()) // some frames may not come out properly { - if (m_showOverlayText) { + if (m_settings.m_showOverlayText) { mixImageAndText(colorFrame); } @@ -445,7 +444,7 @@ void ATVMod::pullVideo(Real& sample) if (!colorFrame.empty()) // some frames may not come out properly { - if (m_showOverlayText) { + if (m_settings.m_showOverlayText) { mixImageAndText(colorFrame); } @@ -620,28 +619,6 @@ bool ATVMod::handleMessage(const Message& cmd) m_overlayText = cfg.getOverlayText().toStdString(); return true; } - else if (MsgConfigureShowOverlayText::match(cmd)) - { - MsgConfigureShowOverlayText& cfg = (MsgConfigureShowOverlayText&) cmd; - bool showOverlayText = cfg.getShowOverlayText(); - - if (!m_imageFromFile.empty()) - { - m_imageFromFile.copyTo(m_imageOriginal); - - if (showOverlayText) { - qDebug("ATVMod::handleMessage: overlay text"); - mixImageAndText(m_imageOriginal); - } else{ - qDebug("ATVMod::handleMessage: clear text"); - } - - resizeImage(); - } - - m_showOverlayText = showOverlayText; - return true; - } else if (DSPSignalNotification::match(cmd)) { return true; @@ -825,7 +802,7 @@ void ATVMod::openImage(const QString& fileName) { m_imageFromFile.copyTo(m_imageOriginal); - if (m_showOverlayText) { + if (m_settings.m_showOverlayText) { mixImageAndText(m_imageOriginal); } @@ -1106,6 +1083,7 @@ void ATVMod::applySettings(const ATVModSettings& settings, bool force) << " m_rfScalingFactor: " << settings.m_rfScalingFactor << " m_fmExcursion: " << settings.m_fmExcursion << " m_forceDecimator: " << settings.m_forceDecimator + << " m_showOverlayText: " << settings.m_showOverlayText << " force: " << force; if ((settings.m_atvStd != m_settings.m_atvStd) @@ -1158,6 +1136,23 @@ void ATVMod::applySettings(const ATVModSettings& settings, bool force) m_settingsMutex.unlock(); } + if ((settings.m_showOverlayText != m_settings.m_showOverlayText) || force) + { + if (!m_imageFromFile.empty()) + { + m_imageFromFile.copyTo(m_imageOriginal); + + if (settings.m_showOverlayText) { + qDebug("ATVMod::applySettings: set overlay text"); + mixImageAndText(m_imageOriginal); + } else{ + qDebug("ATVMod::applySettings: clear overlay text"); + } + + resizeImage(); + } + } + m_settings = settings; } diff --git a/plugins/channeltx/modatv/atvmod.h b/plugins/channeltx/modatv/atvmod.h index 34802047e..bcf3796f9 100644 --- a/plugins/channeltx/modatv/atvmod.h +++ b/plugins/channeltx/modatv/atvmod.h @@ -345,27 +345,6 @@ public: { } }; - class MsgConfigureShowOverlayText : public Message - { - MESSAGE_CLASS_DECLARATION - - public: - bool getShowOverlayText() const { return m_showOverlayText; } - - static MsgConfigureShowOverlayText* create(bool showOverlayText) - { - return new MsgConfigureShowOverlayText(showOverlayText); - } - - private: - bool m_showOverlayText; - - MsgConfigureShowOverlayText(bool showOverlayText) : - Message(), - m_showOverlayText(showOverlayText) - { } - }; - class MsgReportEffectiveSampleRate : public Message { MESSAGE_CLASS_DECLARATION @@ -555,7 +534,6 @@ private: int m_cameraIndex; //!< curent camera index in list of available cameras std::string m_overlayText; - bool m_showOverlayText; // Used for standard SSB fftfilt* m_SSBFilter; diff --git a/plugins/channeltx/modatv/atvmodgui.cpp b/plugins/channeltx/modatv/atvmodgui.cpp index cb13c662d..6324c57ac 100644 --- a/plugins/channeltx/modatv/atvmodgui.cpp +++ b/plugins/channeltx/modatv/atvmodgui.cpp @@ -563,8 +563,8 @@ void ATVModGUI::on_cameraManualFPS_valueChanged(int value) void ATVModGUI::on_overlayTextShow_toggled(bool checked) { - ATVMod::MsgConfigureShowOverlayText* message = ATVMod::MsgConfigureShowOverlayText::create(checked); - m_atvMod->getInputMessageQueue()->push(message); + m_settings.m_showOverlayText = checked; + applySettings(); } void ATVModGUI::on_overlayText_textEdited(const QString& arg1 __attribute__((unused))) diff --git a/plugins/channeltx/modatv/atvmodsettings.cpp b/plugins/channeltx/modatv/atvmodsettings.cpp index d7859453f..e74212334 100644 --- a/plugins/channeltx/modatv/atvmodsettings.cpp +++ b/plugins/channeltx/modatv/atvmodsettings.cpp @@ -46,6 +46,7 @@ void ATVModSettings::resetToDefaults() m_rfScalingFactor = 0.891235351562f * SDR_TX_SCALEF; // -1dB m_fmExcursion = 0.5f; // half bandwidth m_forceDecimator = false; + m_showOverlayText = false; m_overlayText = "ATV"; m_rgbColor = QColor(255, 255, 255).rgb(); m_title = "ATV Modulator"; diff --git a/plugins/channeltx/modatv/atvmodsettings.h b/plugins/channeltx/modatv/atvmodsettings.h index 694d2f4db..633c179fd 100644 --- a/plugins/channeltx/modatv/atvmodsettings.h +++ b/plugins/channeltx/modatv/atvmodsettings.h @@ -75,6 +75,7 @@ struct ATVModSettings float m_rfScalingFactor; //!< Scaling factor from +/-1 to +/-2^15 float m_fmExcursion; //!< FM excursion factor relative to full bandwidth bool m_forceDecimator; //!< Forces decimator even when channel and source sample rates are equal + bool m_showOverlayText; //!< Show overlay text on image QString m_overlayText; quint32 m_rgbColor; QString m_title;