SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Signals | Public Member Functions | Static Public Attributes | Protected Slots | Private Member Functions | Private Attributes | List of all members
TVScreen Class Reference

#include <tvscreen.h>

+ Inheritance diagram for TVScreen:
+ Collaboration diagram for TVScreen:

Signals

void traceSizeChanged (int)
 
void sampleRateChanged (int)
 

Public Member Functions

 TVScreen (bool blnColor, QWidget *parent=0)
 
virtual ~TVScreen ()
 
void setColor (bool blnColor)
 
void resizeTVScreen (int intCols, int intRows)
 
void getSize (int &intCols, int &intRows) const
 
void renderImage (unsigned char *objData)
 
QRgb * getRowBuffer (int intRow)
 
void resetImage ()
 
void resetImage (int alpha)
 
bool selectRow (int intLine)
 
bool setDataColor (int intCol, int intRed, int intGreen, int intBlue)
 
bool setDataColor (int intCol, int intRed, int intGreen, int intBlue, int intAlpha)
 
void setAlphaBlend (bool blnAlphaBlend)
 
void setAlphaReset ()
 
void connectTimer (const QTimer &timer)
 

Static Public Attributes

static const int TV_COLS =256
 
static const int TV_ROWS =256
 

Protected Slots

void cleanup ()
 
void tick ()
 

Private Member Functions

void initializeGL ()
 
void resizeGL (int width, int height)
 
void paintGL ()
 
void mousePressEvent (QMouseEvent *)
 

Private Attributes

bool m_blnGLContextInitialized
 
int m_intAskedCols
 
int m_intAskedRows
 
QTimer m_objTimer
 
QMutex m_objMutex
 
bool m_blnDataChanged
 
bool m_blnConfigChanged
 
GLShaderTVArray m_objGLShaderArray
 
int m_cols
 
int m_rows
 
unsigned char * m_chrLastData
 

Detailed Description

Definition at line 39 of file tvscreen.h.

Constructor & Destructor Documentation

◆ TVScreen()

TVScreen::TVScreen ( bool  blnColor,
QWidget *  parent = 0 
)

Definition at line 31 of file tvscreen.cpp.

References m_blnConfigChanged, m_blnDataChanged, m_blnGLContextInitialized, m_chrLastData, m_cols, m_intAskedCols, m_intAskedRows, m_objTimer, m_rows, tick(), TV_COLS, and TV_ROWS.

31  :
32  QGLWidget(parent), m_objMutex(QMutex::NonRecursive), m_objGLShaderArray(blnColor)
33 {
34  setAttribute(Qt::WA_OpaquePaintEvent);
35  connect(&m_objTimer, SIGNAL(timeout()), this, SLOT(tick()));
36  m_objTimer.start(40); // capped at 25 FPS
37 
38  m_chrLastData = NULL;
39  m_blnConfigChanged = false;
40  m_blnDataChanged = false;
42 
43  //Par défaut
46  m_cols = TV_COLS;
47  m_rows = TV_ROWS;
48 }
int m_rows
Definition: tvscreen.h:87
unsigned char * m_chrLastData
Definition: tvscreen.h:95
bool m_blnGLContextInitialized
Definition: tvscreen.h:73
bool m_blnDataChanged
Definition: tvscreen.h:81
static const int TV_COLS
Definition: tvscreen.h:65
QMutex m_objMutex
Definition: tvscreen.h:80
int m_intAskedRows
Definition: tvscreen.h:75
GLShaderTVArray m_objGLShaderArray
Definition: tvscreen.h:84
void tick()
Definition: tvscreen.cpp:189
int m_cols
Definition: tvscreen.h:86
static const int TV_ROWS
Definition: tvscreen.h:66
bool m_blnConfigChanged
Definition: tvscreen.h:82
int m_intAskedCols
Definition: tvscreen.h:74
QTimer m_objTimer
Definition: tvscreen.h:79
+ Here is the call graph for this function:

◆ ~TVScreen()

TVScreen::~TVScreen ( )
virtual

Definition at line 50 of file tvscreen.cpp.

References cleanup().

51 {
52  cleanup();
53 }
void cleanup()
Definition: tvscreen.cpp:204
+ Here is the call graph for this function:

Member Function Documentation

◆ cleanup

void TVScreen::cleanup ( )
protectedslot

Definition at line 204 of file tvscreen.cpp.

References GLShaderTVArray::Cleanup(), m_blnGLContextInitialized, and m_objGLShaderArray.

Referenced by initializeGL(), and ~TVScreen().

205 {
207  {
209  }
210 }
bool m_blnGLContextInitialized
Definition: tvscreen.h:73
GLShaderTVArray m_objGLShaderArray
Definition: tvscreen.h:84
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ connectTimer()

void TVScreen::connectTimer ( const QTimer &  timer)

Definition at line 196 of file tvscreen.cpp.

References m_objTimer, and tick().

197 {
198  qDebug() << "TVScreen::connectTimer";
199  disconnect(&m_objTimer, SIGNAL(timeout()), this, SLOT(tick()));
200  connect(&objTimer, SIGNAL(timeout()), this, SLOT(tick()));
201  m_objTimer.stop();
202 }
void tick()
Definition: tvscreen.cpp:189
QTimer m_objTimer
Definition: tvscreen.h:79
+ Here is the call graph for this function:

◆ getRowBuffer()

QRgb * TVScreen::getRowBuffer ( int  intRow)

Definition at line 60 of file tvscreen.cpp.

References GLShaderTVArray::GetRowBuffer(), m_blnGLContextInitialized, and m_objGLShaderArray.

61 {
63  {
64  return NULL;
65  }
66 
67  return m_objGLShaderArray.GetRowBuffer(intRow);
68 }
QRgb * GetRowBuffer(int intRow)
bool m_blnGLContextInitialized
Definition: tvscreen.h:73
GLShaderTVArray m_objGLShaderArray
Definition: tvscreen.h:84
+ Here is the call graph for this function:

◆ getSize()

void TVScreen::getSize ( int &  intCols,
int &  intRows 
) const

Definition at line 95 of file tvscreen.cpp.

References m_cols, and m_rows.

Referenced by ScopeVisXY::feed().

96 {
97  intCols = m_cols;
98  intRows = m_rows;
99 }
int m_rows
Definition: tvscreen.h:87
int m_cols
Definition: tvscreen.h:86
+ Here is the caller graph for this function:

◆ initializeGL()

void TVScreen::initializeGL ( )
private

Definition at line 101 of file tvscreen.cpp.

References cleanup(), m_blnGLContextInitialized, and m_objMutex.

102 {
103  m_objMutex.lock();
104 
105  QOpenGLContext *objGlCurrentContext = QOpenGLContext::currentContext();
106 
107  if (objGlCurrentContext)
108  {
109  if (QOpenGLContext::currentContext()->isValid())
110  {
111  qDebug() << "TVScreen::initializeGL: context:"
112  << " major: " << (QOpenGLContext::currentContext()->format()).majorVersion()
113  << " minor: " << (QOpenGLContext::currentContext()->format()).minorVersion()
114  << " ES: " << (QOpenGLContext::currentContext()->isOpenGLES() ? "yes" : "no");
115  }
116  else
117  {
118  qDebug() << "TVScreen::initializeGL: current context is invalid";
119  }
120  }
121  else
122  {
123  qCritical() << "TVScreen::initializeGL: no current context";
124  return;
125  }
126 
127  QSurface *objSurface = objGlCurrentContext->surface();
128 
129  if (objSurface == NULL)
130  {
131  qCritical() << "TVScreen::initializeGL: no surface attached";
132  return;
133  }
134  else
135  {
136  if (objSurface->surfaceType() != QSurface::OpenGLSurface)
137  {
138  qCritical() << "TVScreen::initializeGL: surface is not an OpenGLSurface: "
139  << objSurface->surfaceType()
140  << " cannot use an OpenGL context";
141  return;
142  }
143  else
144  {
145  qDebug() << "TVScreen::initializeGL: OpenGL surface:"
146  << " class: " << (objSurface->surfaceClass() == QSurface::Window ? "Window" : "Offscreen");
147  }
148  }
149 
150  connect(objGlCurrentContext, &QOpenGLContext::aboutToBeDestroyed, this,
151  &TVScreen::cleanup); // TODO: when migrating to QOpenGLWidget
152 
154 
155  m_objMutex.unlock();
156 }
bool m_blnGLContextInitialized
Definition: tvscreen.h:73
QMutex m_objMutex
Definition: tvscreen.h:80
void cleanup()
Definition: tvscreen.cpp:204
+ Here is the call graph for this function:

◆ mousePressEvent()

void TVScreen::mousePressEvent ( QMouseEvent *  event)
private

Definition at line 184 of file tvscreen.cpp.

185 {
186  (void) event;
187 }

◆ paintGL()

void TVScreen::paintGL ( )
private

Definition at line 165 of file tvscreen.cpp.

References GLShaderTVArray::InitializeGL(), m_blnDataChanged, m_chrLastData, m_intAskedCols, m_intAskedRows, m_objGLShaderArray, m_objMutex, and GLShaderTVArray::RenderPixels().

166 {
167  if (!m_objMutex.tryLock(2))
168  return;
169 
170  m_blnDataChanged = false;
171 
172  if ((m_intAskedCols != 0) && (m_intAskedRows != 0))
173  {
175  m_intAskedCols = 0;
176  m_intAskedRows = 0;
177  }
178 
180 
181  m_objMutex.unlock();
182 }
unsigned char * m_chrLastData
Definition: tvscreen.h:95
bool m_blnDataChanged
Definition: tvscreen.h:81
void RenderPixels(unsigned char *chrData)
void InitializeGL(int intCols, int intRows)
QMutex m_objMutex
Definition: tvscreen.h:80
int m_intAskedRows
Definition: tvscreen.h:75
GLShaderTVArray m_objGLShaderArray
Definition: tvscreen.h:84
int m_intAskedCols
Definition: tvscreen.h:74
+ Here is the call graph for this function:

◆ renderImage()

void TVScreen::renderImage ( unsigned char *  objData)

Definition at line 70 of file tvscreen.cpp.

References m_blnDataChanged, and m_chrLastData.

Referenced by ScopeVisXY::feed(), ATVDemod::processClassic(), ATVDemod::processHSkip(), DATVideoRender::RenderStream(), leansdr::datvconstellation< leansdr::f32 >::run(), and leansdr::datvdvbs2constellation< leansdr::f32 >::run().

71 {
72  m_chrLastData = objData;
73  m_blnDataChanged = true;
74 }
unsigned char * m_chrLastData
Definition: tvscreen.h:95
bool m_blnDataChanged
Definition: tvscreen.h:81
+ Here is the caller graph for this function:

◆ resetImage() [1/2]

void TVScreen::resetImage ( )

Definition at line 76 of file tvscreen.cpp.

References m_objGLShaderArray, and GLShaderTVArray::ResetPixels().

Referenced by ScopeVisXY::feed(), DATVideoRender::RenderStream(), leansdr::datvconstellation< leansdr::f32 >::run(), and leansdr::datvdvbs2constellation< leansdr::f32 >::run().

77 {
79 }
GLShaderTVArray m_objGLShaderArray
Definition: tvscreen.h:84
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetImage() [2/2]

void TVScreen::resetImage ( int  alpha)

Definition at line 81 of file tvscreen.cpp.

References m_objGLShaderArray, and GLShaderTVArray::ResetPixels().

82 {
84 }
GLShaderTVArray m_objGLShaderArray
Definition: tvscreen.h:84
+ Here is the call graph for this function:

◆ resizeGL()

void TVScreen::resizeGL ( int  width,
int  height 
)
private

Definition at line 158 of file tvscreen.cpp.

References m_blnConfigChanged.

159 {
160  QOpenGLFunctions *ptrF = QOpenGLContext::currentContext()->functions();
161  ptrF->glViewport(0, 0, intWidth, intHeight);
162  m_blnConfigChanged = true;
163 }
bool m_blnConfigChanged
Definition: tvscreen.h:82

◆ resizeTVScreen()

void TVScreen::resizeTVScreen ( int  intCols,
int  intRows 
)

Definition at line 86 of file tvscreen.cpp.

References m_cols, m_intAskedCols, m_intAskedRows, and m_rows.

Referenced by ATVDemod::applySettings(), and DATVideoRender::RenderStream().

87 {
88  qDebug("TVScreen::resizeTVScreen: cols: %d, rows: %d", intCols, intRows);
89  m_intAskedCols = intCols;
90  m_intAskedRows = intRows;
91  m_cols = intCols;
92  m_rows = intRows;
93 }
int m_rows
Definition: tvscreen.h:87
int m_intAskedRows
Definition: tvscreen.h:75
int m_cols
Definition: tvscreen.h:86
int m_intAskedCols
Definition: tvscreen.h:74
+ Here is the caller graph for this function:

◆ sampleRateChanged

void TVScreen::sampleRateChanged ( int  )
signal

◆ selectRow()

bool TVScreen::selectRow ( int  intLine)

Definition at line 212 of file tvscreen.cpp.

References m_blnGLContextInitialized, m_objGLShaderArray, and GLShaderTVArray::SelectRow().

Referenced by ScopeVisXY::drawGraticule(), ScopeVisXY::feed(), ATVDemod::processClassic(), ATVDemod::processHSkip(), leansdr::datvconstellation< leansdr::f32 >::run(), and leansdr::datvdvbs2constellation< leansdr::f32 >::run().

213 {
215  {
216  return m_objGLShaderArray.SelectRow(intLine);
217  }
218  else
219  {
220  return false;
221  }
222 }
bool SelectRow(int intLine)
bool m_blnGLContextInitialized
Definition: tvscreen.h:73
GLShaderTVArray m_objGLShaderArray
Definition: tvscreen.h:84
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAlphaBlend()

void TVScreen::setAlphaBlend ( bool  blnAlphaBlend)
inline

Definition at line 59 of file tvscreen.h.

Referenced by ScopeVisXY::ScopeVisXY().

59 { m_objGLShaderArray.setAlphaBlend(blnAlphaBlend); }
GLShaderTVArray m_objGLShaderArray
Definition: tvscreen.h:84
void setAlphaBlend(bool blnAlphaBlend)
+ Here is the caller graph for this function:

◆ setAlphaReset()

void TVScreen::setAlphaReset ( )
inline

Definition at line 60 of file tvscreen.h.

Referenced by ScopeVisXY::setPixelsPerFrame().

GLShaderTVArray m_objGLShaderArray
Definition: tvscreen.h:84
+ Here is the caller graph for this function:

◆ setColor()

void TVScreen::setColor ( bool  blnColor)

Definition at line 55 of file tvscreen.cpp.

References m_objGLShaderArray, and GLShaderTVArray::setColor().

56 {
57  m_objGLShaderArray.setColor(blnColor);
58 }
GLShaderTVArray m_objGLShaderArray
Definition: tvscreen.h:84
void setColor(bool blnColor)
+ Here is the call graph for this function:

◆ setDataColor() [1/2]

bool TVScreen::setDataColor ( int  intCol,
int  intRed,
int  intGreen,
int  intBlue 
)

Definition at line 224 of file tvscreen.cpp.

References m_blnGLContextInitialized, m_objGLShaderArray, and GLShaderTVArray::SetDataColor().

Referenced by ScopeVisXY::drawGraticule(), ScopeVisXY::feed(), ATVDemod::processClassic(), ATVDemod::processHSkip(), leansdr::datvconstellation< leansdr::f32 >::run(), and leansdr::datvdvbs2constellation< leansdr::f32 >::run().

225 {
227  {
228  return m_objGLShaderArray.SetDataColor(intCol, qRgb(intBlue, intGreen, intRed)); // FIXME: blue <> red inversion in shader
229  }
230  else
231  {
232  return false;
233  }
234 }
bool m_blnGLContextInitialized
Definition: tvscreen.h:73
bool SetDataColor(int intCol, QRgb objColor)
GLShaderTVArray m_objGLShaderArray
Definition: tvscreen.h:84
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDataColor() [2/2]

bool TVScreen::setDataColor ( int  intCol,
int  intRed,
int  intGreen,
int  intBlue,
int  intAlpha 
)

Definition at line 236 of file tvscreen.cpp.

References m_blnGLContextInitialized, m_objGLShaderArray, and GLShaderTVArray::SetDataColor().

237 {
239  {
240  return m_objGLShaderArray.SetDataColor(intCol, qRgba(intBlue, intGreen, intRed, intAlpha)); // FIXME: blue <> red inversion in shader
241  }
242  else
243  {
244  return false;
245  }
246 }
bool m_blnGLContextInitialized
Definition: tvscreen.h:73
bool SetDataColor(int intCol, QRgb objColor)
GLShaderTVArray m_objGLShaderArray
Definition: tvscreen.h:84
+ Here is the call graph for this function:

◆ tick

void TVScreen::tick ( )
protectedslot

Definition at line 189 of file tvscreen.cpp.

References m_blnDataChanged.

Referenced by connectTimer(), and TVScreen().

190 {
191  if (m_blnDataChanged) {
192  update();
193  }
194 }
bool m_blnDataChanged
Definition: tvscreen.h:81
+ Here is the caller graph for this function:

◆ traceSizeChanged

void TVScreen::traceSizeChanged ( int  )
signal

Member Data Documentation

◆ m_blnConfigChanged

bool TVScreen::m_blnConfigChanged
private

Definition at line 82 of file tvscreen.h.

Referenced by resizeGL(), and TVScreen().

◆ m_blnDataChanged

bool TVScreen::m_blnDataChanged
private

Definition at line 81 of file tvscreen.h.

Referenced by paintGL(), renderImage(), tick(), and TVScreen().

◆ m_blnGLContextInitialized

bool TVScreen::m_blnGLContextInitialized
private

Definition at line 73 of file tvscreen.h.

Referenced by cleanup(), getRowBuffer(), initializeGL(), selectRow(), setDataColor(), and TVScreen().

◆ m_chrLastData

unsigned char* TVScreen::m_chrLastData
private

Definition at line 95 of file tvscreen.h.

Referenced by paintGL(), renderImage(), and TVScreen().

◆ m_cols

int TVScreen::m_cols
private

Definition at line 86 of file tvscreen.h.

Referenced by getSize(), resizeTVScreen(), and TVScreen().

◆ m_intAskedCols

int TVScreen::m_intAskedCols
private

Definition at line 74 of file tvscreen.h.

Referenced by paintGL(), resizeTVScreen(), and TVScreen().

◆ m_intAskedRows

int TVScreen::m_intAskedRows
private

Definition at line 75 of file tvscreen.h.

Referenced by paintGL(), resizeTVScreen(), and TVScreen().

◆ m_objGLShaderArray

GLShaderTVArray TVScreen::m_objGLShaderArray
private

Definition at line 84 of file tvscreen.h.

Referenced by cleanup(), getRowBuffer(), paintGL(), resetImage(), selectRow(), setColor(), and setDataColor().

◆ m_objMutex

QMutex TVScreen::m_objMutex
private

Definition at line 80 of file tvscreen.h.

Referenced by initializeGL(), and paintGL().

◆ m_objTimer

QTimer TVScreen::m_objTimer
private

Definition at line 79 of file tvscreen.h.

Referenced by connectTimer(), and TVScreen().

◆ m_rows

int TVScreen::m_rows
private

Definition at line 87 of file tvscreen.h.

Referenced by getSize(), resizeTVScreen(), and TVScreen().

◆ TV_COLS

const int TVScreen::TV_COLS =256
static

Definition at line 65 of file tvscreen.h.

Referenced by TVScreen().

◆ TV_ROWS

const int TVScreen::TV_ROWS =256
static

Definition at line 66 of file tvscreen.h.

Referenced by TVScreen().


The documentation for this class was generated from the following files: