From 8d984c2f09ba35b12f29c4bbdbfb6a24358b0e5a Mon Sep 17 00:00:00 2001 From: f4exb Date: Thu, 15 Mar 2018 00:16:50 +0100 Subject: [PATCH] DSD demod: TV screen graticule optimization --- plugins/channelrx/demoddsd/dsddemodgui.cpp | 2 + sdrgui/dsp/scopevisxy.cpp | 51 ++++++++++++++++------ sdrgui/dsp/scopevisxy.h | 3 ++ sdrgui/gui/glshadertvarray.h | 2 - sdrgui/gui/tvscreen.cpp | 9 +++- sdrgui/gui/tvscreen.h | 3 ++ 6 files changed, 52 insertions(+), 18 deletions(-) diff --git a/plugins/channelrx/demoddsd/dsddemodgui.cpp b/plugins/channelrx/demoddsd/dsddemodgui.cpp index 7d658f146..387c406cf 100644 --- a/plugins/channelrx/demoddsd/dsddemodgui.cpp +++ b/plugins/channelrx/demoddsd/dsddemodgui.cpp @@ -317,6 +317,8 @@ DSDDemodGUI::DSDDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban } } + m_scopeVisXY->calculateGraticule(200,200); + m_dsdDemod = (DSDDemod*) rxChannel; //new DSDDemod(m_deviceUISet->m_deviceSourceAPI); m_dsdDemod->setScopeXYSink(m_scopeVisXY); m_dsdDemod->setMessageQueueToGUI(getInputMessageQueue()); diff --git a/sdrgui/dsp/scopevisxy.cpp b/sdrgui/dsp/scopevisxy.cpp index 1a237f32a..78fd7c539 100644 --- a/sdrgui/dsp/scopevisxy.cpp +++ b/sdrgui/dsp/scopevisxy.cpp @@ -71,14 +71,22 @@ void ScopeVisXY::feed(const SampleVector::const_iterator& cbegin, const SampleVe if (m_pixelCount == m_pixelsPerFrame) { - drawGraticule(); + int rows, cols; + m_tvScreen->getSize(rows, cols); + + if ((rows != m_rows) || (cols != m_cols)) + { + calculateGraticule(rows, cols); + m_rows = rows; + m_cols = cols; + } + + drawGraticule(); m_tvScreen->renderImage(0); usleep(5000); - m_tvScreen->getSize(m_cols, m_rows); m_tvScreen->resetImage(m_alphaReset); m_pixelCount = 0; } - } } @@ -103,22 +111,37 @@ void ScopeVisXY::clearGraticule() { m_graticule.clear(); } -void ScopeVisXY::drawGraticule() +void ScopeVisXY::calculateGraticule(int rows, int cols) { - std::vector >::const_iterator grIt = m_graticule.begin(); + m_graticuleRows.clear(); + m_graticuleCols.clear(); - for (; grIt != m_graticule.end(); ++grIt) - { - int y = m_rows * ((1.0 - grIt->imag()) / 2.0); - int x = m_cols * ((1.0 + grIt->real()) / 2.0); + std::vector >::const_iterator grIt = m_graticule.begin(); + + for (; grIt != m_graticule.end(); ++grIt) + { + int y = rows * ((1.0 - grIt->imag()) / 2.0); + int x = cols * ((1.0 + grIt->real()) / 2.0); for (int d = -4; d <= 4; ++d) { - m_tvScreen->selectRow(y + d); - m_tvScreen->setDataColor(x, qRed(m_gridRGB), qGreen(m_gridRGB), qBlue(m_gridRGB)); - m_tvScreen->selectRow(y); - m_tvScreen->setDataColor(x + d, qRed(m_gridRGB), qGreen(m_gridRGB), qBlue(m_gridRGB)); + m_graticuleRows.push_back(y+d); + m_graticuleCols.push_back(x); + m_graticuleRows.push_back(y); + m_graticuleCols.push_back(x+d); } - } + } +} + +void ScopeVisXY::drawGraticule() +{ + std::vector::const_iterator rowIt = m_graticuleRows.begin(); + std::vector::const_iterator colIt = m_graticuleCols.begin(); + + for(; (rowIt != m_graticuleRows.end()) && (colIt != m_graticuleCols.end()); ++rowIt, ++colIt) + { + m_tvScreen->selectRow(*rowIt); + m_tvScreen->setDataColor(*colIt, qRed(m_gridRGB), qGreen(m_gridRGB), qBlue(m_gridRGB)); + } } diff --git a/sdrgui/dsp/scopevisxy.h b/sdrgui/dsp/scopevisxy.h index 4eedf3860..6a70f508c 100644 --- a/sdrgui/dsp/scopevisxy.h +++ b/sdrgui/dsp/scopevisxy.h @@ -47,6 +47,7 @@ public: void setGridRGB(const QRgb& gridRGB) { m_gridRGB = gridRGB; } void addGraticulePoint(const std::complex& z); + void calculateGraticule(int rows, int cols); void clearGraticule(); private: @@ -63,6 +64,8 @@ private: QRgb m_plotRGB; QRgb m_gridRGB; std::vector > m_graticule; + std::vector m_graticuleRows; + std::vector m_graticuleCols; }; diff --git a/sdrgui/gui/glshadertvarray.h b/sdrgui/gui/glshadertvarray.h index 5c5044743..f331ee4fa 100644 --- a/sdrgui/gui/glshadertvarray.h +++ b/sdrgui/gui/glshadertvarray.h @@ -46,8 +46,6 @@ public: void setAlphaBlend(bool blnAlphaBlend) { m_blnAlphaBlend = blnAlphaBlend; } void setAlphaReset() { m_blnAlphaReset = true; } void InitializeGL(int intCols, int intRows); - void ResizeContainer(int intCols, int intRows); - void getSize(int& intCols, int& intRows) const { intCols = m_intCols, intRows = m_intRows; } void Cleanup(); QRgb *GetRowBuffer(int intRow); void RenderPixels(unsigned char *chrData); diff --git a/sdrgui/gui/tvscreen.cpp b/sdrgui/gui/tvscreen.cpp index b41d471b0..1a81f36b4 100644 --- a/sdrgui/gui/tvscreen.cpp +++ b/sdrgui/gui/tvscreen.cpp @@ -43,7 +43,8 @@ TVScreen::TVScreen(bool blnColor, QWidget* parent) : //Par défaut m_intAskedCols = TV_COLS; m_intAskedRows = TV_ROWS; - + m_cols = TV_COLS; + m_rows = TV_ROWS; } TVScreen::~TVScreen() @@ -88,13 +89,17 @@ void TVScreen::resetImage(int alpha) void TVScreen::resizeTVScreen(int intCols, int intRows) { + qDebug("TVScreen::resizeTVScreen: cols: %d, rows: %d", intCols, intRows); m_intAskedCols = intCols; m_intAskedRows = intRows; + m_cols = intCols; + m_rows = intRows; } void TVScreen::getSize(int& intCols, int& intRows) const { - m_objGLShaderArray.getSize(intCols, intRows); + intCols = m_cols; + intRows = m_rows; } void TVScreen::initializeGL() diff --git a/sdrgui/gui/tvscreen.h b/sdrgui/gui/tvscreen.h index f100b9e66..c9969a475 100644 --- a/sdrgui/gui/tvscreen.h +++ b/sdrgui/gui/tvscreen.h @@ -84,6 +84,9 @@ private: GLShaderTVArray m_objGLShaderArray; + int m_cols; + int m_rows; + void initializeGL(); void resizeGL(int width, int height); void paintGL();