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.
Classes | Public Member Functions | Private Types | Private Slots | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
GLSpectrum Class Reference

#include <glspectrum.h>

Inherits QGLWidget.

+ Collaboration diagram for GLSpectrum:

Classes

struct  ChannelMarkerState
 
class  MsgReportSampleRate
 

Public Member Functions

 GLSpectrum (QWidget *parent=NULL)
 
 ~GLSpectrum ()
 
void setCenterFrequency (qint64 frequency)
 
void setSampleRate (qint32 sampleRate)
 
void setTimingRate (qint32 timingRate)
 
void setReferenceLevel (Real referenceLevel)
 
void setPowerRange (Real powerRange)
 
void setDecay (int decay)
 
void setDecayDivisor (int decayDivisor)
 
void setHistoStroke (int stroke)
 
void setDisplayWaterfall (bool display)
 
void setSsbSpectrum (bool ssbSpectrum)
 
void setLsbDisplay (bool lsbDisplay)
 
void setInvertedWaterfall (bool inv)
 
void setDisplayMaxHold (bool display)
 
void setDisplayCurrent (bool display)
 
void setDisplayHistogram (bool display)
 
void setDisplayGrid (bool display)
 
void setDisplayGridIntensity (int intensity)
 
void setDisplayTraceIntensity (int intensity)
 
void setLinear (bool linear)
 
qint32 getSampleRate () const
 
void addChannelMarker (ChannelMarker *channelMarker)
 
void removeChannelMarker (ChannelMarker *channelMarker)
 
void setMessageQueueToGUI (MessageQueue *messageQueue)
 
void newSpectrum (const std::vector< Real > &spectrum, int fftSize)
 
void clearSpectrumHistogram ()
 
Real getWaterfallShare () const
 
void setWaterfallShare (Real waterfallShare)
 
void connectTimer (const QTimer &timer)
 
void setDisplayedStream (bool sourceOrSink, int streamIndex)
 

Private Types

enum  CursorState {
  CSNormal, CSSplitter, CSSplitterMoving, CSChannel,
  CSChannelMoving
}
 

Private Slots

void cleanup ()
 
void tick ()
 
void channelMarkerChanged ()
 
void channelMarkerDestroyed (QObject *object)
 

Private Member Functions

void updateWaterfall (const std::vector< Real > &spectrum)
 
void updateHistogram (const std::vector< Real > &spectrum)
 
void initializeGL ()
 
void resizeGL (int width, int height)
 
void paintGL ()
 
void stopDrag ()
 
void applyChanges ()
 
void mouseMoveEvent (QMouseEvent *event)
 
void mousePressEvent (QMouseEvent *event)
 
void mouseReleaseEvent (QMouseEvent *event)
 
void wheelEvent (QWheelEvent *)
 
void enterEvent (QEvent *event)
 
void leaveEvent (QEvent *event)
 

Private Attributes

QList< ChannelMarkerState * > m_channelMarkerStates
 
CursorState m_cursorState
 
int m_cursorChannel
 
QTimer m_timer
 
QMutex m_mutex
 
bool m_mouseInside
 
bool m_changesPending
 
qint64 m_centerFrequency
 
Real m_referenceLevel
 
Real m_powerRange
 
bool m_linear
 
int m_decay
 
quint32 m_sampleRate
 
quint32 m_timingRate
 
int m_fftSize
 
bool m_displayGrid
 
int m_displayGridIntensity
 
int m_displayTraceIntensity
 
bool m_invertedWaterfall
 
std::vector< Realm_maxHold
 
bool m_displayMaxHold
 
const std::vector< Real > * m_currentSpectrum
 
bool m_displayCurrent
 
Real m_waterfallShare
 
int m_leftMargin
 
QPixmap m_leftMarginPixmap
 
QPixmap m_frequencyPixmap
 
ScaleEngine m_timeScale
 
ScaleEngine m_powerScale
 
ScaleEngine m_frequencyScale
 
QRect m_frequencyScaleRect
 
QMatrix4x4 m_glFrequencyScaleBoxMatrix
 
QMatrix4x4 m_glLeftScaleBoxMatrix
 
QRgb m_waterfallPalette [240]
 
QImage * m_waterfallBuffer
 
int m_waterfallBufferPos
 
int m_waterfallTextureHeight
 
int m_waterfallTexturePos
 
QMatrix4x4 m_glWaterfallBoxMatrix
 
bool m_displayWaterfall
 
bool m_ssbSpectrum
 
bool m_lsbDisplay
 
QRgb m_histogramPalette [240]
 
QImage * m_histogramBuffer
 
quint8 * m_histogram
 Spectrum phosphor matrix of FFT width and PSD height scaled to 100. values [0..239]. More...
 
int m_decayDivisor
 
int m_decayDivisorCount
 
int m_histogramStroke
 
QMatrix4x4 m_glHistogramSpectrumMatrix
 
QMatrix4x4 m_glHistogramBoxMatrix
 
bool m_displayHistogram
 
bool m_displayChanged
 
bool m_displaySourceOrSink
 
int m_displayStreamIndex
 
GLShaderSimple m_glShaderSimple
 
GLShaderTextured m_glShaderLeftScale
 
GLShaderTextured m_glShaderFrequencyScale
 
GLShaderTextured m_glShaderWaterfall
 
GLShaderTextured m_glShaderHistogram
 
int m_matrixLoc
 
int m_colorLoc
 
IncrementalArray< GLfloat > m_q3TickTime
 
IncrementalArray< GLfloat > m_q3TickFrequency
 
IncrementalArray< GLfloat > m_q3TickPower
 
IncrementalArray< GLfloat > m_q3FFT
 
MessageQueuem_messageQueueToGUI
 

Static Private Attributes

static const int m_waterfallBufferHeight = 256
 

Detailed Description

Definition at line 43 of file glspectrum.h.

Member Enumeration Documentation

◆ CursorState

Enumerator
CSNormal 
CSSplitter 
CSSplitterMoving 
CSChannel 
CSChannelMoving 

Definition at line 122 of file glspectrum.h.

Constructor & Destructor Documentation

◆ GLSpectrum()

GLSpectrum::GLSpectrum ( QWidget *  parent = NULL)

Definition at line 34 of file glspectrum.cpp.

References i, and Unit::Time.

34  :
35  QGLWidget(parent),
37  m_cursorChannel(0),
38  m_mouseInside(false),
39  m_changesPending(true),
40  m_centerFrequency(100000000),
42  m_powerRange(100),
43  m_linear(false),
44  m_decay(1),
45  m_sampleRate(500000),
46  m_timingRate(1),
47  m_fftSize(512),
48  m_displayGrid(true),
51  m_invertedWaterfall(false),
52  m_displayMaxHold(false),
54  m_displayCurrent(false),
55  m_leftMargin(0),
60  m_displayWaterfall(true),
61  m_ssbSpectrum(false),
62  m_lsbDisplay(false),
64  m_histogram(0),
65  m_displayHistogram(true),
66  m_displayChanged(false),
69  m_matrixLoc(0),
70  m_colorLoc(0),
72 {
73  setAutoFillBackground(false);
74  setAttribute(Qt::WA_OpaquePaintEvent, true);
75  setAttribute(Qt::WA_NoSystemBackground, true);
76  setMouseTracking(true);
77 
78  setMinimumSize(200, 200);
79 
80  m_waterfallShare = 0.66;
81 
82  for(int i = 0; i <= 239; i++) {
83  QColor c;
84  c.setHsv(239 - i, 255, 15 + i);
85  ((quint8*)&m_waterfallPalette[i])[0] = c.red();
86  ((quint8*)&m_waterfallPalette[i])[1] = c.green();
87  ((quint8*)&m_waterfallPalette[i])[2] = c.blue();
88  ((quint8*)&m_waterfallPalette[i])[3] = c.alpha();
89  }
90  m_waterfallPalette[239] = 0xffffffff;
91 
92  m_histogramPalette[0] = 0;
93 
94  for (int i = 1; i < 240; i++)
95  {
96  QColor c;
97  int light = i < 60 ? 128 + (60-i) : 128;
98  int sat = i < 60 ? 140 + i : i < 180 ? 200 : 200 - (i-180);
99  c.setHsl(239 - i, sat, light);
100  ((quint8*)&m_histogramPalette[i])[0] = c.red();
101  ((quint8*)&m_histogramPalette[i])[1] = c.green();
102  ((quint8*)&m_histogramPalette[i])[2] = c.blue();
103  ((quint8*)&m_histogramPalette[i])[3] = c.alpha();
104  }
105 
106  // 4.2.3 palette
107 // for (int i = 1; i < 240; i++)
108 // {
109 // QColor c;
110 // int val = i < 60 ? 255 : 200;
111 // int sat = i < 60 ? 128 : i < 180 ? 255 : 180;
112 // c.setHsv(239 - i, sat, val);
113 // ((quint8*)&m_histogramPalette[i])[0] = c.red();
114 // ((quint8*)&m_histogramPalette[i])[1] = c.green();
115 // ((quint8*)&m_histogramPalette[i])[2] = c.blue();
116 // ((quint8*)&m_histogramPalette[i])[3] = c.alpha();
117 // }
118 
119  // Original palette:
120 // for(int i = 16; i < 240; i++) {
121 // QColor c;
122 // c.setHsv(239 - i, 255 - ((i < 200) ? 0 : (i - 200) * 3), 150 + ((i < 100) ? i : 100));
123 // ((quint8*)&m_histogramPalette[i])[0] = c.red();
124 // ((quint8*)&m_histogramPalette[i])[1] = c.green();
125 // ((quint8*)&m_histogramPalette[i])[2] = c.blue();
126 // ((quint8*)&m_histogramPalette[i])[3] = c.alpha();
127 // }
128 // for(int i = 1; i < 16; i++) {
129 // QColor c;
130 // c.setHsv(255, 128, 48 + i * 4);
131 // ((quint8*)&m_histogramPalette[i])[0] = c.red();
132 // ((quint8*)&m_histogramPalette[i])[1] = c.green();
133 // ((quint8*)&m_histogramPalette[i])[2] = c.blue();
134 // ((quint8*)&m_histogramPalette[i])[3] = c.alpha();
135 // }
136 
137  m_decayDivisor = 1;
139  m_histogramStroke = 30;
140 
141  m_timeScale.setFont(font());
142  m_timeScale.setOrientation(Qt::Vertical);
144  m_powerScale.setFont(font());
145  m_powerScale.setOrientation(Qt::Vertical);
146  m_frequencyScale.setFont(font());
147  m_frequencyScale.setOrientation(Qt::Horizontal);
148 
149  connect(&m_timer, SIGNAL(timeout()), this, SLOT(tick()));
150  m_timer.start(50);
151 }
int m_cursorChannel
Definition: glspectrum.h:131
int m_displayStreamIndex
Definition: glspectrum.h:191
Real m_referenceLevel
Definition: glspectrum.h:139
int m_displayTraceIntensity
Definition: glspectrum.h:150
bool m_displayGrid
Definition: glspectrum.h:148
Real m_powerRange
Definition: glspectrum.h:140
QTimer m_timer
Definition: glspectrum.h:133
bool m_linear
Definition: glspectrum.h:141
QRgb m_histogramPalette[240]
Definition: glspectrum.h:180
bool m_invertedWaterfall
Definition: glspectrum.h:151
bool m_displayChanged
Definition: glspectrum.h:189
ScaleEngine m_frequencyScale
Definition: glspectrum.h:165
qint64 m_centerFrequency
Definition: glspectrum.h:138
bool m_changesPending
Definition: glspectrum.h:136
CursorState m_cursorState
Definition: glspectrum.h:130
int m_decayDivisor
Definition: glspectrum.h:183
bool m_displayWaterfall
Definition: glspectrum.h:176
quint32 m_sampleRate
Definition: glspectrum.h:143
bool m_ssbSpectrum
Definition: glspectrum.h:177
int m_waterfallTextureHeight
Definition: glspectrum.h:173
int m_matrixLoc
Definition: glspectrum.h:198
ScaleEngine m_powerScale
Definition: glspectrum.h:164
bool m_displaySourceOrSink
Definition: glspectrum.h:190
bool m_displayMaxHold
Definition: glspectrum.h:154
int m_decayDivisorCount
Definition: glspectrum.h:184
int32_t i
Definition: decimators.h:244
const std::vector< Real > * m_currentSpectrum
Definition: glspectrum.h:155
QImage * m_waterfallBuffer
Definition: glspectrum.h:171
QRgb m_waterfallPalette[240]
Definition: glspectrum.h:170
bool m_displayCurrent
Definition: glspectrum.h:156
Real m_waterfallShare
Definition: glspectrum.h:158
int m_colorLoc
Definition: glspectrum.h:199
void setFont(const QFont &font)
int m_displayGridIntensity
Definition: glspectrum.h:149
int m_waterfallTexturePos
Definition: glspectrum.h:174
quint8 * m_histogram
Spectrum phosphor matrix of FFT width and PSD height scaled to 100. values [0..239].
Definition: glspectrum.h:182
int m_histogramStroke
Definition: glspectrum.h:185
MessageQueue * m_messageQueueToGUI
Definition: glspectrum.h:205
quint32 m_timingRate
Definition: glspectrum.h:144
void setRange(Unit::Physical physicalUnit, float rangeMin, float rangeMax)
QImage * m_histogramBuffer
Definition: glspectrum.h:181
bool m_displayHistogram
Definition: glspectrum.h:188
int m_fftSize
Definition: glspectrum.h:146
ScaleEngine m_timeScale
Definition: glspectrum.h:163
void setOrientation(Qt::Orientation orientation)
bool m_lsbDisplay
Definition: glspectrum.h:178
int m_waterfallBufferPos
Definition: glspectrum.h:172
bool m_mouseInside
Definition: glspectrum.h:135
int m_leftMargin
Definition: glspectrum.h:160

◆ ~GLSpectrum()

GLSpectrum::~GLSpectrum ( )

Definition at line 153 of file glspectrum.cpp.

References cleanup(), m_changesPending, m_histogram, m_histogramBuffer, m_mutex, and m_waterfallBuffer.

154 {
155  cleanup();
156 
157  QMutexLocker mutexLocker(&m_mutex);
158 
159  m_changesPending = true;
160 
161  if(m_waterfallBuffer != NULL) {
162  delete m_waterfallBuffer;
163  m_waterfallBuffer = NULL;
164  }
165  if(m_histogramBuffer != NULL) {
166  delete m_histogramBuffer;
167  m_histogramBuffer = NULL;
168  }
169  if(m_histogram != NULL) {
170  delete[] m_histogram;
171  m_histogram = NULL;
172  }
173 }
bool m_changesPending
Definition: glspectrum.h:136
QImage * m_waterfallBuffer
Definition: glspectrum.h:171
quint8 * m_histogram
Spectrum phosphor matrix of FFT width and PSD height scaled to 100. values [0..239].
Definition: glspectrum.h:182
QImage * m_histogramBuffer
Definition: glspectrum.h:181
QMutex m_mutex
Definition: glspectrum.h:134
void cleanup()
+ Here is the call graph for this function:

Member Function Documentation

◆ addChannelMarker()

void GLSpectrum::addChannelMarker ( ChannelMarker channelMarker)

Definition at line 315 of file glspectrum.cpp.

References channelMarkerChanged(), channelMarkerDestroyed(), m_changesPending, m_channelMarkerStates, m_mutex, and stopDrag().

Referenced by DeviceUISet::addChannelMarker().

316 {
317  QMutexLocker mutexLocker(&m_mutex);
318 
319  connect(channelMarker, SIGNAL(changedByAPI()), this, SLOT(channelMarkerChanged()));
320  connect(channelMarker, SIGNAL(destroyed(QObject*)), this, SLOT(channelMarkerDestroyed(QObject*)));
321  m_channelMarkerStates.append(new ChannelMarkerState(channelMarker));
322  m_changesPending = true;
323  stopDrag();
324  update();
325 }
void stopDrag()
QList< ChannelMarkerState * > m_channelMarkerStates
Definition: glspectrum.h:120
void channelMarkerChanged()
bool m_changesPending
Definition: glspectrum.h:136
void channelMarkerDestroyed(QObject *object)
QMutex m_mutex
Definition: glspectrum.h:134
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applyChanges()

void GLSpectrum::applyChanges ( )
private

Definition at line 1031 of file glspectrum.cpp.

References IncrementalArray< T >::allocate(), Unit::Decibel, Unit::Frequency, ChannelMarker::FScaleDisplay_addressReceive, ChannelMarker::FScaleDisplay_addressSend, ChannelMarker::FScaleDisplay_freq, ChannelMarker::FScaleDisplay_title, ChannelMarker::getBandwidth(), ChannelMarker::getCenterFrequency(), ChannelMarker::getDisplayAddressReceive(), ChannelMarker::getDisplayAddressSend(), ChannelMarker::getFrequencyScaleDisplayType(), ChannelMarker::getHighlighted(), ChannelMarker::getLowCutoff(), ChannelMarker::getOppositeBandwidth(), ScaleEngine::getPosFromValue(), ScaleEngine::getScaleWidth(), ChannelMarker::getSidebands(), ChannelMarker::getSourceOrSinkStream(), ChannelMarker::getStreamIndex(), ScaleEngine::getTickList(), ChannelMarker::getTitle(), i, GLShaderTextured::initTexture(), ChannelMarker::lsb, m_centerFrequency, m_changesPending, GLSpectrum::ChannelMarkerState::m_channelMarker, m_channelMarkerStates, m_displayCurrent, m_displayHistogram, m_displayMaxHold, m_displaySourceOrSink, m_displayStreamIndex, m_displayWaterfall, m_fftSize, m_frequencyPixmap, m_frequencyScale, m_frequencyScaleRect, m_glFrequencyScaleBoxMatrix, m_glHistogramBoxMatrix, m_glHistogramSpectrumMatrix, m_glLeftScaleBoxMatrix, GLSpectrum::ChannelMarkerState::m_glMatrixDsbFreqScale, GLSpectrum::ChannelMarkerState::m_glMatrixDsbHistogram, GLSpectrum::ChannelMarkerState::m_glMatrixDsbWaterfall, GLSpectrum::ChannelMarkerState::m_glMatrixFreqScale, GLSpectrum::ChannelMarkerState::m_glMatrixHistogram, GLSpectrum::ChannelMarkerState::m_glMatrixWaterfall, m_glShaderFrequencyScale, m_glShaderHistogram, m_glShaderLeftScale, m_glShaderWaterfall, m_glWaterfallBoxMatrix, m_histogram, m_histogramBuffer, m_invertedWaterfall, m_leftMargin, m_leftMarginPixmap, m_linear, m_lsbDisplay, m_powerRange, m_powerScale, m_q3FFT, m_q3TickFrequency, m_q3TickPower, m_q3TickTime, GLSpectrum::ChannelMarkerState::m_rect, m_referenceLevel, m_sampleRate, m_ssbSpectrum, m_timeScale, m_timingRate, m_waterfallBuffer, m_waterfallBufferPos, m_waterfallShare, m_waterfallTextureHeight, m_waterfallTexturePos, ScaleEngine::Tick::major, Unit::Scientific, ScaleEngine::setMakeOpposite(), ScaleEngine::setRange(), ScaleEngine::setSize(), ScaleEngine::Tick::text, ScaleEngine::Tick::textPos, ScaleEngine::Tick::textSize, tick(), Unit::Time, Unit::TimeHMS, ChannelMarker::usb, ChannelMarker::vlsb, and ChannelMarker::vusb.

Referenced by paintGL().

1032 {
1033  m_changesPending = false;
1034 
1035  if(m_fftSize <= 0)
1036  return;
1037 
1038  QFontMetrics fm(font());
1039  int M = fm.width("-");
1040 
1041  int topMargin = fm.ascent() * 1.5;
1042  int bottomMargin = fm.ascent() * 1.5;
1043 
1044  int waterfallHeight = 0;
1045  int waterfallTop = 0;
1046  int frequencyScaleHeight = fm.height() * 3; // +1 line for marker frequency scale
1047  int frequencyScaleTop = 0;
1048  int histogramTop = 0;
1049  int histogramHeight = 20;
1050  //int m_leftMargin;
1051  int rightMargin = fm.width("000");
1052 
1053  // displays both histogram and waterfall
1055  {
1056  waterfallHeight = height() * m_waterfallShare - 1;
1057 
1058  if(waterfallHeight < 0)
1059  {
1060  waterfallHeight = 0;
1061  }
1062 
1063  if(!m_invertedWaterfall)
1064  {
1065  waterfallTop = topMargin;
1066  frequencyScaleTop = waterfallTop + waterfallHeight + 1;
1067  histogramTop = waterfallTop + waterfallHeight + frequencyScaleHeight + 1;
1068  histogramHeight = height() - topMargin - waterfallHeight - frequencyScaleHeight - bottomMargin;
1069  }
1070  else
1071  {
1072  histogramTop = topMargin;
1073  histogramHeight = height() - topMargin - waterfallHeight - frequencyScaleHeight - bottomMargin;
1074  waterfallTop = histogramTop + histogramHeight + frequencyScaleHeight + 1;
1075  frequencyScaleTop = histogramTop + histogramHeight + 1;
1076  }
1077 
1078  m_timeScale.setSize(waterfallHeight);
1079 
1080  if(m_sampleRate > 0)
1081  {
1082  float scaleDiv = ((float)m_sampleRate / (float)m_timingRate) * (m_ssbSpectrum ? 2 : 1);
1083 
1084  if(!m_invertedWaterfall)
1085  {
1086  m_timeScale.setRange(m_timingRate > 1 ? Unit::TimeHMS : Unit::Time, (waterfallHeight * m_fftSize) / scaleDiv, 0);
1087  }
1088  else
1089  {
1090  m_timeScale.setRange(m_timingRate > 1 ? Unit::TimeHMS : Unit::Time, 0, (waterfallHeight * m_fftSize) / scaleDiv);
1091  }
1092  }
1093  else
1094  {
1095  m_timeScale.setRange(Unit::Time, 0, 1);
1096  }
1097 
1098  m_powerScale.setSize(histogramHeight);
1099 
1100  if (m_linear) {
1102  } else {
1104  }
1105 
1107 
1109  {
1111  }
1112 
1113  m_leftMargin += 2 * M;
1114 
1115  m_frequencyScale.setSize(width() - m_leftMargin - rightMargin);
1118 
1119  m_glWaterfallBoxMatrix.setToIdentity();
1120  m_glWaterfallBoxMatrix.translate(
1121  -1.0f + ((float)(2*m_leftMargin) / (float) width()),
1122  1.0f - ((float)(2*waterfallTop) / (float) height())
1123  );
1124  m_glWaterfallBoxMatrix.scale(
1125  ((float) 2 * (width() - m_leftMargin - rightMargin)) / (float) width(),
1126  (float) (-2*waterfallHeight) / (float) height()
1127  );
1128 
1129  m_glHistogramBoxMatrix.setToIdentity();
1130  m_glHistogramBoxMatrix.translate(
1131  -1.0f + ((float)(2*m_leftMargin) / (float) width()),
1132  1.0f - ((float)(2*histogramTop) / (float) height())
1133  );
1134  m_glHistogramBoxMatrix.scale(
1135  ((float) 2 * (width() - m_leftMargin - rightMargin)) / (float) width(),
1136  (float) (-2*histogramHeight) / (float) height()
1137  );
1138 
1139  m_glHistogramSpectrumMatrix.setToIdentity();
1140  m_glHistogramSpectrumMatrix.translate(
1141  -1.0f + ((float)(2*m_leftMargin) / (float) width()),
1142  1.0f - ((float)(2*histogramTop) / (float) height())
1143  );
1145  ((float) 2 * (width() - m_leftMargin - rightMargin)) / ((float) width() * (float)(m_fftSize - 1)),
1146  ((float) 2*histogramHeight / height()) / m_powerRange
1147  );
1148 
1149  m_frequencyScaleRect = QRect(
1150  0,
1151  frequencyScaleTop,
1152  width(),
1153  frequencyScaleHeight
1154  );
1155 
1156  m_glFrequencyScaleBoxMatrix.setToIdentity();
1157  m_glFrequencyScaleBoxMatrix.translate (
1158  -1.0f,
1159  1.0f - ((float) 2*frequencyScaleTop / (float) height())
1160  );
1162  2.0f,
1163  (float) -2*frequencyScaleHeight / (float) height()
1164  );
1165 
1166  m_glLeftScaleBoxMatrix.setToIdentity();
1167  m_glLeftScaleBoxMatrix.translate(-1.0f, 1.0f);
1168  m_glLeftScaleBoxMatrix.scale(
1169  (float)(2*(m_leftMargin - 1)) / (float) width(),
1170  -2.0f
1171  );
1172  }
1173  // displays waterfall only
1174  else if(m_displayWaterfall)
1175  {
1176  bottomMargin = frequencyScaleHeight;
1177  waterfallTop = topMargin;
1178  waterfallHeight = height() - topMargin - frequencyScaleHeight;
1179  frequencyScaleTop = topMargin + waterfallHeight + 1;
1180  histogramTop = 0;
1181 
1182  m_timeScale.setSize(waterfallHeight);
1183 
1184  if(m_sampleRate > 0)
1185  {
1186  float scaleDiv = ((float)m_sampleRate / (float)m_timingRate) * (m_ssbSpectrum ? 2 : 1);
1187 
1188  if(!m_invertedWaterfall)
1189  {
1190  m_timeScale.setRange(m_timingRate > 1 ? Unit::TimeHMS : Unit::Time, (waterfallHeight * m_fftSize) / scaleDiv, 0);
1191  }
1192  else
1193  {
1194  m_timeScale.setRange(m_timingRate > 1 ? Unit::TimeHMS : Unit::Time, 0, (waterfallHeight * m_fftSize) / scaleDiv);
1195  }
1196  }
1197  else
1198  {
1199  if(!m_invertedWaterfall)
1200  {
1201  m_timeScale.setRange(m_timingRate > 1 ? Unit::TimeHMS : Unit::Time, 10, 0);
1202  }
1203  else
1204  {
1205  m_timeScale.setRange(m_timingRate > 1 ? Unit::TimeHMS : Unit::Time, 0, 10);
1206  }
1207  }
1208 
1210  m_leftMargin += 2 * M;
1211 
1212  m_frequencyScale.setSize(width() - m_leftMargin - rightMargin);
1215 
1216  m_glWaterfallBoxMatrix.setToIdentity();
1217  m_glWaterfallBoxMatrix.translate(
1218  -1.0f + ((float)(2*m_leftMargin) / (float) width()),
1219  1.0f - ((float)(2*topMargin) / (float) height())
1220  );
1221  m_glWaterfallBoxMatrix.scale(
1222  ((float) 2 * (width() - m_leftMargin - rightMargin)) / (float) width(),
1223  (float) (-2*waterfallHeight) / (float) height()
1224  );
1225 
1226  m_frequencyScaleRect = QRect(
1227  0,
1228  frequencyScaleTop,
1229  width(),
1230  frequencyScaleHeight
1231  );
1232 
1233  m_glFrequencyScaleBoxMatrix.setToIdentity();
1234  m_glFrequencyScaleBoxMatrix.translate (
1235  -1.0f,
1236  1.0f - ((float) 2*frequencyScaleTop / (float) height())
1237  );
1239  2.0f,
1240  (float) -2*frequencyScaleHeight / (float) height()
1241  );
1242 
1243  m_glLeftScaleBoxMatrix.setToIdentity();
1244  m_glLeftScaleBoxMatrix.translate(-1.0f, 1.0f);
1245  m_glLeftScaleBoxMatrix.scale(
1246  (float)(2*(m_leftMargin - 1)) / (float) width(),
1247  -2.0f
1248  );
1249  }
1250  // displays histogram only
1252  {
1253  bottomMargin = frequencyScaleHeight;
1254  frequencyScaleTop = height() - bottomMargin;
1255  histogramTop = topMargin - 1;
1256  waterfallHeight = 0;
1257  histogramHeight = height() - topMargin - frequencyScaleHeight;
1258 
1259  m_powerScale.setSize(histogramHeight);
1262  m_leftMargin += 2 * M;
1263 
1264  m_frequencyScale.setSize(width() - m_leftMargin - rightMargin);
1267 
1268  m_glHistogramSpectrumMatrix.setToIdentity();
1269  m_glHistogramSpectrumMatrix.translate(
1270  -1.0f + ((float)(2*m_leftMargin) / (float) width()),
1271  1.0f - ((float)(2*histogramTop) / (float) height())
1272  );
1274  ((float) 2 * (width() - m_leftMargin - rightMargin)) / ((float) width() * (float)(m_fftSize - 1)),
1275  ((float) 2*(height() - topMargin - frequencyScaleHeight) / height()) / m_powerRange
1276  );
1277 
1278  m_glHistogramBoxMatrix.setToIdentity();
1279  m_glHistogramBoxMatrix.translate(
1280  -1.0f + ((float)(2*m_leftMargin) / (float) width()),
1281  1.0f - ((float)(2*histogramTop) / (float) height())
1282  );
1283  m_glHistogramBoxMatrix.scale(
1284  ((float) 2 * (width() - m_leftMargin - rightMargin)) / (float) width(),
1285  (float) (-2*(height() - topMargin - frequencyScaleHeight)) / (float) height()
1286  );
1287 
1288  m_frequencyScaleRect = QRect(
1289  0,
1290  frequencyScaleTop,
1291  width(),
1292  frequencyScaleHeight
1293  );
1294 
1295  m_glFrequencyScaleBoxMatrix.setToIdentity();
1296  m_glFrequencyScaleBoxMatrix.translate (
1297  -1.0f,
1298  1.0f - ((float) 2*frequencyScaleTop / (float) height())
1299  );
1301  2.0f,
1302  (float) -2*frequencyScaleHeight / (float) height()
1303  );
1304 
1305  m_glLeftScaleBoxMatrix.setToIdentity();
1306  m_glLeftScaleBoxMatrix.translate(-1.0f, 1.0f);
1307  m_glLeftScaleBoxMatrix.scale(
1308  (float)(2*(m_leftMargin - 1)) / (float) width(),
1309  -2.0f
1310  );
1311  }
1312  else
1313  {
1314  m_leftMargin = 2;
1315  waterfallHeight = 0;
1316  }
1317 
1318  // channel overlays
1319  for(int i = 0; i < m_channelMarkerStates.size(); ++i)
1320  {
1321  ChannelMarkerState* dv = m_channelMarkerStates[i];
1322 
1323  qreal xc, pw, nw, dsbw;
1324  ChannelMarker::sidebands_t sidebands = dv->m_channelMarker->getSidebands();
1325  xc = m_centerFrequency + dv->m_channelMarker->getCenterFrequency(); // marker center frequency
1326  dsbw = dv->m_channelMarker->getBandwidth();
1327 
1328  if (sidebands == ChannelMarker::usb) {
1329  nw = dv->m_channelMarker->getLowCutoff(); // negative bandwidth
1330  int bw = dv->m_channelMarker->getBandwidth() / 2;
1331  pw = (qreal) bw; // positive bandwidth
1332  } else if (sidebands == ChannelMarker::lsb) {
1333  pw = dv->m_channelMarker->getLowCutoff();
1334  int bw = dv->m_channelMarker->getBandwidth() / 2;
1335  nw = (qreal) bw;
1336  } else if (sidebands == ChannelMarker::vusb) {
1337  nw = -dv->m_channelMarker->getOppositeBandwidth(); // negative bandwidth
1338  pw = dv->m_channelMarker->getBandwidth(); // positive bandwidth
1339  } else if (sidebands == ChannelMarker::vlsb) {
1340  pw = dv->m_channelMarker->getOppositeBandwidth(); // positive bandwidth
1341  nw = -dv->m_channelMarker->getBandwidth(); // negative bandwidth
1342  } else {
1343  pw = dsbw / 2;
1344  nw = -pw;
1345  }
1346 
1347  // draw the DSB rectangle
1348 
1349  QMatrix4x4 glMatrixDsb;
1350  glMatrixDsb.setToIdentity();
1351  glMatrixDsb.translate(
1352  -1.0f + 2.0f * ((m_leftMargin + m_frequencyScale.getPosFromValue(xc - (dsbw/2))) / (float) width()),
1353  1.0f
1354  );
1355  glMatrixDsb.scale(
1356  2.0f * (dsbw / (float)m_sampleRate),
1357  -2.0f
1358  );
1359 
1360  dv->m_glMatrixDsbWaterfall = glMatrixDsb;
1361  dv->m_glMatrixDsbWaterfall.translate(
1362  0.0f,
1363  (float) waterfallTop / (float) height()
1364  );
1365  dv->m_glMatrixDsbWaterfall.scale(
1366  (float) (width() - m_leftMargin - rightMargin) / (float) width(),
1367  (float) waterfallHeight / (float) height()
1368  );
1369 
1370  dv->m_glMatrixDsbHistogram = glMatrixDsb;
1371  dv->m_glMatrixDsbHistogram.translate(
1372  0.0f,
1373  (float) histogramTop / (float) height()
1374  );
1375  dv->m_glMatrixDsbHistogram.scale(
1376  (float) (width() - m_leftMargin - rightMargin) / (float) width(),
1377  (float) histogramHeight / (float) height()
1378  );
1379 
1380  dv->m_glMatrixDsbFreqScale = glMatrixDsb;
1381  dv->m_glMatrixDsbFreqScale.translate(
1382  0.0f,
1383  (float) frequencyScaleTop / (float) height()
1384  );
1385  dv->m_glMatrixDsbFreqScale.scale(
1386  (float) (width() - m_leftMargin - rightMargin) / (float) width(),
1387  (float) frequencyScaleHeight / (float) height()
1388  );
1389 
1390  // draw the effective BW rectangle
1391 
1392  QMatrix4x4 glMatrix;
1393  glMatrix.setToIdentity();
1394  glMatrix.translate(
1395  -1.0f + 2.0f * ((m_leftMargin + m_frequencyScale.getPosFromValue(xc + nw)) / (float) width()),
1396  1.0f
1397  );
1398  glMatrix.scale(
1399  2.0f * ((pw-nw) / (float)m_sampleRate),
1400  -2.0f
1401  );
1402 
1403  dv->m_glMatrixWaterfall = glMatrix;
1404  dv->m_glMatrixWaterfall.translate(
1405  0.0f,
1406  (float) waterfallTop / (float) height()
1407  );
1408  dv->m_glMatrixWaterfall.scale(
1409  (float) (width() - m_leftMargin - rightMargin) / (float) width(),
1410  (float) waterfallHeight / (float) height()
1411  );
1412 
1413  dv->m_glMatrixHistogram = glMatrix;
1414  dv->m_glMatrixHistogram.translate(
1415  0.0f,
1416  (float) histogramTop / (float) height()
1417  );
1418  dv->m_glMatrixHistogram.scale(
1419  (float) (width() - m_leftMargin - rightMargin) / (float) width(),
1420  (float) histogramHeight / (float) height()
1421  );
1422 
1423  dv->m_glMatrixFreqScale = glMatrix;
1424  dv->m_glMatrixFreqScale.translate(
1425  0.0f,
1426  (float) frequencyScaleTop / (float) height()
1427  );
1428  dv->m_glMatrixFreqScale.scale(
1429  (float) (width() - m_leftMargin - rightMargin) / (float) width(),
1430  (float) frequencyScaleHeight / (float) height()
1431  );
1432 
1433 
1434  /*
1435  dv->m_glRect.setRect(
1436  m_frequencyScale.getPosFromValue(m_centerFrequency + dv->m_channelMarker->getCenterFrequency() - dv->m_channelMarker->getBandwidth() / 2) / (float)(width() - m_leftMargin - rightMargin),
1437  0,
1438  (dv->m_channelMarker->getBandwidth() / (float)m_sampleRate),
1439  1);
1440  */
1441 
1443  {
1444  dv->m_rect.setRect(m_frequencyScale.getPosFromValue(xc) + m_leftMargin - 1,
1445  topMargin,
1446  5,
1447  height() - topMargin - bottomMargin);
1448  }
1449 
1450  /*
1451  if(m_displayHistogram || m_displayMaxHold || m_displayWaterfall) {
1452  dv->m_rect.setRect(m_frequencyScale.getPosFromValue(m_centerFrequency + dv->m_channelMarker->getCenterFrequency()) + m_leftMargin - 1,
1453  topMargin,
1454  5,
1455  height() - topMargin - bottomMargin);
1456  }
1457  */
1458  }
1459 
1460  // prepare left scales (time and power)
1461  {
1462  m_leftMarginPixmap = QPixmap(m_leftMargin - 1, height());
1463  m_leftMarginPixmap.fill(Qt::black);
1464  {
1465  QPainter painter(&m_leftMarginPixmap);
1466  painter.setPen(QColor(0xf0, 0xf0, 0xff));
1467  painter.setFont(font());
1468  const ScaleEngine::TickList* tickList;
1469  const ScaleEngine::Tick* tick;
1470  if(m_displayWaterfall) {
1471  tickList = &m_timeScale.getTickList();
1472  for(int i = 0; i < tickList->count(); i++) {
1473  tick = &(*tickList)[i];
1474  if(tick->major) {
1475  if(tick->textSize > 0)
1476  painter.drawText(QPointF(m_leftMargin - M - tick->textSize, waterfallTop + fm.ascent() + tick->textPos), tick->text);
1477  }
1478  }
1479  }
1481  tickList = &m_powerScale.getTickList();
1482  for(int i = 0; i < tickList->count(); i++) {
1483  tick = &(*tickList)[i];
1484  if(tick->major) {
1485  if(tick->textSize > 0)
1486  painter.drawText(QPointF(m_leftMargin - M - tick->textSize, histogramTop + histogramHeight - tick->textPos - 1), tick->text);
1487  }
1488  }
1489  }
1490  }
1491 
1493  }
1494  // prepare frequency scale
1496  m_frequencyPixmap = QPixmap(width(), frequencyScaleHeight);
1497  m_frequencyPixmap.fill(Qt::transparent);
1498  {
1499  QPainter painter(&m_frequencyPixmap);
1500  painter.setPen(Qt::NoPen);
1501  painter.setBrush(Qt::black);
1502  painter.setBrush(Qt::transparent);
1503  painter.drawRect(m_leftMargin, 0, width() - m_leftMargin, frequencyScaleHeight);
1504  painter.setPen(QColor(0xf0, 0xf0, 0xff));
1505  painter.setFont(font());
1506  const ScaleEngine::TickList* tickList = &m_frequencyScale.getTickList();
1507  const ScaleEngine::Tick* tick;
1508  for(int i = 0; i < tickList->count(); i++) {
1509  tick = &(*tickList)[i];
1510  if(tick->major) {
1511  if(tick->textSize > 0)
1512  painter.drawText(QPointF(m_leftMargin + tick->textPos, fm.height() + fm.ascent() / 2 - 1), tick->text);
1513  }
1514  }
1515 
1516  // Frequency overlay on highlighted marker
1517  for(int i = 0; i < m_channelMarkerStates.size(); ++i) {
1518  ChannelMarkerState* dv = m_channelMarkerStates[i];
1519 
1520  if (dv->m_channelMarker->getHighlighted()
1521  && (dv->m_channelMarker->getSourceOrSinkStream() == m_displaySourceOrSink)
1522  && (dv->m_channelMarker->getStreamIndex() == m_displayStreamIndex))
1523  {
1524  qreal xc;
1525  int shift;
1526  //ChannelMarker::sidebands_t sidebands = dv->m_channelMarker->getSidebands();
1527  xc = m_centerFrequency + dv->m_channelMarker->getCenterFrequency(); // marker center frequency
1528  QString ftext;
1529  switch (dv->m_channelMarker->getFrequencyScaleDisplayType())
1530  {
1532  ftext = QString::number((m_centerFrequency + dv->m_channelMarker->getCenterFrequency())/1e6, 'f', 6);
1533  break;
1535  ftext = dv->m_channelMarker->getTitle();
1536  break;
1538  ftext = dv->m_channelMarker->getDisplayAddressSend();
1539  break;
1541  ftext = dv->m_channelMarker->getDisplayAddressReceive();
1542  break;
1543  default:
1544  ftext = QString::number((m_centerFrequency + dv->m_channelMarker->getCenterFrequency())/1e6, 'f', 6);
1545  break;
1546  }
1547  if (dv->m_channelMarker->getCenterFrequency() < 0) { // left half of scale
1548  ftext = " " + ftext;
1549  shift = 0;
1550  } else { // right half of scale
1551  ftext = ftext + " ";
1552  shift = - fm.width(ftext);
1553  }
1554  painter.drawText(QPointF(m_leftMargin + m_frequencyScale.getPosFromValue(xc) + shift, 2*fm.height() + fm.ascent() / 2 - 1), ftext);
1555  }
1556  }
1557 
1558  }
1559 
1561  }
1562 
1563  bool fftSizeChanged = true;
1564 
1565  if(m_waterfallBuffer != NULL) {
1566  fftSizeChanged = m_waterfallBuffer->width() != m_fftSize;
1567  }
1568 
1569  bool windowSizeChanged = m_waterfallTextureHeight != waterfallHeight;
1570 
1571  if (fftSizeChanged || windowSizeChanged)
1572  {
1573  if(m_waterfallBuffer != 0) {
1574  delete m_waterfallBuffer;
1575  }
1576 
1577  m_waterfallBuffer = new QImage(m_fftSize, waterfallHeight, QImage::Format_ARGB32);
1578 
1579  m_waterfallBuffer->fill(qRgb(0x00, 0x00, 0x00));
1582  }
1583 
1584  if(fftSizeChanged)
1585  {
1586  if(m_histogramBuffer != NULL) {
1587  delete m_histogramBuffer;
1588  m_histogramBuffer = NULL;
1589  }
1590  if(m_histogram != NULL) {
1591  delete[] m_histogram;
1592  m_histogram = NULL;
1593  }
1594 
1595  m_histogramBuffer = new QImage(m_fftSize, 100, QImage::Format_RGB32);
1596 
1597  m_histogramBuffer->fill(qRgb(0x00, 0x00, 0x00));
1598  m_glShaderHistogram.initTexture(*m_histogramBuffer, QOpenGLTexture::ClampToEdge);
1599 
1600  m_histogram = new quint8[100 * m_fftSize];
1601  memset(m_histogram, 0x00, 100 * m_fftSize);
1602 
1604  }
1605 
1606  if(fftSizeChanged || windowSizeChanged)
1607  {
1608  m_waterfallTextureHeight = waterfallHeight;
1610  }
1611 
1615 }
void setSize(float size)
int m_displayStreamIndex
Definition: glspectrum.h:191
Real m_referenceLevel
Definition: glspectrum.h:139
Real m_powerRange
Definition: glspectrum.h:140
QMatrix4x4 m_glFrequencyScaleBoxMatrix
Definition: glspectrum.h:167
QMatrix4x4 m_glHistogramBoxMatrix
Definition: glspectrum.h:187
bool m_linear
Definition: glspectrum.h:141
QList< ChannelMarkerState * > m_channelMarkerStates
Definition: glspectrum.h:120
IncrementalArray< GLfloat > m_q3TickFrequency
Definition: glspectrum.h:201
float getPosFromValue(double value)
bool m_invertedWaterfall
Definition: glspectrum.h:151
ScaleEngine m_frequencyScale
Definition: glspectrum.h:165
qint64 m_centerFrequency
Definition: glspectrum.h:138
bool m_changesPending
Definition: glspectrum.h:136
void initTexture(const QImage &image, QOpenGLTexture::WrapMode wrapMode=QOpenGLTexture::Repeat)
bool m_displayWaterfall
Definition: glspectrum.h:176
QMatrix4x4 m_glWaterfallBoxMatrix
Definition: glspectrum.h:175
QMatrix4x4 m_glLeftScaleBoxMatrix
Definition: glspectrum.h:168
QRect m_frequencyScaleRect
Definition: glspectrum.h:166
IncrementalArray< GLfloat > m_q3TickTime
Definition: glspectrum.h:200
quint32 m_sampleRate
Definition: glspectrum.h:143
QPixmap m_leftMarginPixmap
Definition: glspectrum.h:161
bool m_ssbSpectrum
Definition: glspectrum.h:177
int m_waterfallTextureHeight
Definition: glspectrum.h:173
LSB with vestigial USB.
Definition: channelmarker.h:21
ScaleEngine m_powerScale
Definition: glspectrum.h:164
bool m_displaySourceOrSink
Definition: glspectrum.h:190
QPixmap m_frequencyPixmap
Definition: glspectrum.h:162
GLShaderTextured m_glShaderFrequencyScale
Definition: glspectrum.h:195
bool m_displayMaxHold
Definition: glspectrum.h:154
GLShaderTextured m_glShaderWaterfall
Definition: glspectrum.h:196
USB with vestigial LSB.
Definition: channelmarker.h:20
int32_t i
Definition: decimators.h:244
QImage * m_waterfallBuffer
Definition: glspectrum.h:171
bool m_displayCurrent
Definition: glspectrum.h:156
enum ChannelMarker::sidebands_e sidebands_t
Real m_waterfallShare
Definition: glspectrum.h:158
int m_waterfallTexturePos
Definition: glspectrum.h:174
quint8 * m_histogram
Spectrum phosphor matrix of FFT width and PSD height scaled to 100. values [0..239].
Definition: glspectrum.h:182
QMatrix4x4 m_glHistogramSpectrumMatrix
Definition: glspectrum.h:186
void allocate(uint32_t size)
const TickList & getTickList()
IncrementalArray< GLfloat > m_q3FFT
Definition: glspectrum.h:203
QList< Tick > TickList
Definition: scaleengine.h:37
quint32 m_timingRate
Definition: glspectrum.h:144
void setRange(Unit::Physical physicalUnit, float rangeMin, float rangeMax)
GLShaderTextured m_glShaderLeftScale
Definition: glspectrum.h:194
QImage * m_histogramBuffer
Definition: glspectrum.h:181
bool m_displayHistogram
Definition: glspectrum.h:188
int m_fftSize
Definition: glspectrum.h:146
GLShaderTextured m_glShaderHistogram
Definition: glspectrum.h:197
float getScaleWidth()
void setMakeOpposite(bool makeOpposite)
Definition: scaleengine.h:82
ScaleEngine m_timeScale
Definition: glspectrum.h:163
bool m_lsbDisplay
Definition: glspectrum.h:178
int m_waterfallBufferPos
Definition: glspectrum.h:172
int m_leftMargin
Definition: glspectrum.h:160
IncrementalArray< GLfloat > m_q3TickPower
Definition: glspectrum.h:202
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ channelMarkerChanged

void GLSpectrum::channelMarkerChanged ( )
privateslot

Definition at line 1842 of file glspectrum.cpp.

References m_changesPending.

Referenced by addChannelMarker(), mouseMoveEvent(), and mousePressEvent().

1843 {
1844  m_changesPending = true;
1845  update();
1846 }
bool m_changesPending
Definition: glspectrum.h:136
+ Here is the caller graph for this function:

◆ channelMarkerDestroyed

void GLSpectrum::channelMarkerDestroyed ( QObject *  object)
privateslot

Definition at line 1848 of file glspectrum.cpp.

References removeChannelMarker().

Referenced by addChannelMarker().

1849 {
1851 }
void removeChannelMarker(ChannelMarker *channelMarker)
Definition: glspectrum.cpp:327
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cleanup

void GLSpectrum::cleanup ( )
privateslot

Definition at line 1874 of file glspectrum.cpp.

References GLShaderSimple::cleanup(), GLShaderTextured::cleanup(), m_glShaderFrequencyScale, m_glShaderHistogram, m_glShaderLeftScale, m_glShaderSimple, and m_glShaderWaterfall.

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

1875 {
1876  //makeCurrent();
1882  //doneCurrent();
1883 }
GLShaderTextured m_glShaderFrequencyScale
Definition: glspectrum.h:195
GLShaderTextured m_glShaderWaterfall
Definition: glspectrum.h:196
GLShaderTextured m_glShaderLeftScale
Definition: glspectrum.h:194
GLShaderTextured m_glShaderHistogram
Definition: glspectrum.h:197
GLShaderSimple m_glShaderSimple
Definition: glspectrum.h:193
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clearSpectrumHistogram()

void GLSpectrum::clearSpectrumHistogram ( )

Definition at line 535 of file glspectrum.cpp.

References m_fftSize, m_histogram, and m_mutex.

Referenced by GLSpectrumGUI::on_clearSpectrum_clicked().

536 {
537  if(!m_mutex.tryLock(2))
538  return;
539 
540  memset(m_histogram, 0x00, 100 * m_fftSize);
541 
542  m_mutex.unlock();
543  update();
544 }
quint8 * m_histogram
Spectrum phosphor matrix of FFT width and PSD height scaled to 100. values [0..239].
Definition: glspectrum.h:182
int m_fftSize
Definition: glspectrum.h:146
QMutex m_mutex
Definition: glspectrum.h:134
+ Here is the caller graph for this function:

◆ connectTimer()

void GLSpectrum::connectTimer ( const QTimer &  timer)

Definition at line 1866 of file glspectrum.cpp.

References m_timer, and tick().

Referenced by DeviceUISet::DeviceUISet().

1867 {
1868  qDebug() << "GLSpectrum::connectTimer";
1869  disconnect(&m_timer, SIGNAL(timeout()), this, SLOT(tick()));
1870  connect(&timer, SIGNAL(timeout()), this, SLOT(tick()));
1871  m_timer.stop();
1872 }
QTimer m_timer
Definition: glspectrum.h:133
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ enterEvent()

void GLSpectrum::enterEvent ( QEvent *  event)
private

Definition at line 1820 of file glspectrum.cpp.

References m_mouseInside.

1821 {
1822  m_mouseInside = true;
1823  update();
1824  QGLWidget::enterEvent(event);
1825 }
bool m_mouseInside
Definition: glspectrum.h:135

◆ getSampleRate()

qint32 GLSpectrum::getSampleRate ( ) const
inline

Definition at line 86 of file glspectrum.h.

Referenced by GLSpectrumGUI::setAveragingToolitp().

86 { return m_sampleRate; }
quint32 m_sampleRate
Definition: glspectrum.h:143
+ Here is the caller graph for this function:

◆ getWaterfallShare()

Real GLSpectrum::getWaterfallShare ( ) const
inline

Definition at line 95 of file glspectrum.h.

Referenced by GLSpectrumGUI::serialize().

95 { return m_waterfallShare; }
Real m_waterfallShare
Definition: glspectrum.h:158
+ Here is the caller graph for this function:

◆ initializeGL()

void GLSpectrum::initializeGL ( )
private

Definition at line 496 of file glspectrum.cpp.

References cleanup(), GLShaderSimple::initializeGL(), GLShaderTextured::initializeGL(), m_glShaderFrequencyScale, m_glShaderHistogram, m_glShaderLeftScale, m_glShaderSimple, and m_glShaderWaterfall.

497 {
498  QOpenGLContext *glCurrentContext = QOpenGLContext::currentContext();
499 
500  if (glCurrentContext) {
501  if (QOpenGLContext::currentContext()->isValid()) {
502  qDebug() << "GLSpectrum::initializeGL: context:"
503  << " major: " << (QOpenGLContext::currentContext()->format()).majorVersion()
504  << " minor: " << (QOpenGLContext::currentContext()->format()).minorVersion()
505  << " ES: " << (QOpenGLContext::currentContext()->isOpenGLES() ? "yes" : "no");
506  }
507  else {
508  qDebug() << "GLSpectrum::initializeGL: current context is invalid";
509  }
510  } else {
511  qCritical() << "GLSpectrum::initializeGL: no current context";
512  return;
513  }
514 
515  connect(glCurrentContext, &QOpenGLContext::aboutToBeDestroyed, this, &GLSpectrum::cleanup); // TODO: when migrating to QOpenGLWidget
516 
517  QOpenGLFunctions *glFunctions = QOpenGLContext::currentContext()->functions();
518  glFunctions->initializeOpenGLFunctions();
519 
520  //glDisable(GL_DEPTH_TEST);
526 }
GLShaderTextured m_glShaderFrequencyScale
Definition: glspectrum.h:195
GLShaderTextured m_glShaderWaterfall
Definition: glspectrum.h:196
GLShaderTextured m_glShaderLeftScale
Definition: glspectrum.h:194
GLShaderTextured m_glShaderHistogram
Definition: glspectrum.h:197
GLShaderSimple m_glShaderSimple
Definition: glspectrum.h:193
void cleanup()
+ Here is the call graph for this function:

◆ leaveEvent()

void GLSpectrum::leaveEvent ( QEvent *  event)
private

Definition at line 1827 of file glspectrum.cpp.

References m_mouseInside.

1828 {
1829  m_mouseInside = false;
1830  update();
1831  QGLWidget::enterEvent(event);
1832 }
bool m_mouseInside
Definition: glspectrum.h:135

◆ mouseMoveEvent()

void GLSpectrum::mouseMoveEvent ( QMouseEvent *  event)
private

Definition at line 1617 of file glspectrum.cpp.

References channelMarkerChanged(), CSChannel, CSChannelMoving, CSNormal, CSSplitter, CSSplitterMoving, ScaleEngine::getValueFromPos(), i, m_centerFrequency, m_changesPending, m_channelMarkerStates, m_cursorChannel, m_cursorState, m_displayCurrent, m_displayHistogram, m_displayMaxHold, m_displaySourceOrSink, m_displayStreamIndex, m_displayWaterfall, m_frequencyScale, m_frequencyScaleRect, m_invertedWaterfall, m_leftMarginPixmap, and m_waterfallShare.

1618 {
1620  {
1621  if(m_frequencyScaleRect.contains(event->pos()))
1622  {
1623  if(m_cursorState == CSNormal)
1624  {
1625  setCursor(Qt::SizeVerCursor);
1627  return;
1628  }
1629  }
1630  else
1631  {
1632  if(m_cursorState == CSSplitter)
1633  {
1634  setCursor(Qt::ArrowCursor);
1636  return;
1637  }
1638  }
1639  }
1640 
1642  {
1643  float newShare;
1644 
1645  if (!m_invertedWaterfall) {
1646  newShare = (float) (event->y() - m_frequencyScaleRect.height()) / (float) height();
1647  } else {
1648  newShare = 1.0 - (float) (event->y() + m_frequencyScaleRect.height()) / (float) height();
1649  }
1650 
1651  if (newShare < 0.1) {
1652  newShare = 0.1f;
1653  } else if (newShare > 0.8) {
1654  newShare = 0.8f;
1655  }
1656 
1657  m_waterfallShare = newShare;
1658  m_changesPending = true;
1659 
1660  update();
1661  return;
1662  }
1663  else if (m_cursorState == CSChannelMoving)
1664  {
1665  Real freq = m_frequencyScale.getValueFromPos(event->x() - m_leftMarginPixmap.width() - 1) - m_centerFrequency;
1666 
1667  if (m_channelMarkerStates[m_cursorChannel]->m_channelMarker->getMovable()
1668  && (m_channelMarkerStates[m_cursorChannel]->m_channelMarker->getSourceOrSinkStream() == m_displaySourceOrSink)
1669  && (m_channelMarkerStates[m_cursorChannel]->m_channelMarker->getStreamIndex() == m_displayStreamIndex))
1670  {
1671  m_channelMarkerStates[m_cursorChannel]->m_channelMarker->setCenterFrequencyByCursor(freq);
1673  }
1674  }
1675 
1677  {
1678  for (int i = 0; i < m_channelMarkerStates.size(); ++i)
1679  {
1680  if ((m_channelMarkerStates[i]->m_channelMarker->getSourceOrSinkStream() != m_displaySourceOrSink)
1681  || (m_channelMarkerStates[i]->m_channelMarker->getStreamIndex() != m_displayStreamIndex))
1682  {
1683  continue;
1684  }
1685 
1686  if (m_channelMarkerStates[i]->m_rect.contains(event->pos()))
1687  {
1688  if (m_cursorState == CSNormal)
1689  {
1690  setCursor(Qt::SizeHorCursor);
1692  m_cursorChannel = i;
1693  m_channelMarkerStates[i]->m_channelMarker->setHighlightedByCursor(true);
1695 
1696  return;
1697  }
1698  else if (m_cursorState == CSChannel)
1699  {
1700  return;
1701  }
1702  }
1703  else if (m_channelMarkerStates[i]->m_channelMarker->getHighlighted())
1704  {
1705  m_channelMarkerStates[i]->m_channelMarker->setHighlightedByCursor(false);
1707  }
1708  }
1709  }
1710 
1711  if(m_cursorState == CSChannel)
1712  {
1713  setCursor(Qt::ArrowCursor);
1715 
1716  return;
1717  }
1718 }
int m_cursorChannel
Definition: glspectrum.h:131
int m_displayStreamIndex
Definition: glspectrum.h:191
QList< ChannelMarkerState * > m_channelMarkerStates
Definition: glspectrum.h:120
void channelMarkerChanged()
bool m_invertedWaterfall
Definition: glspectrum.h:151
ScaleEngine m_frequencyScale
Definition: glspectrum.h:165
qint64 m_centerFrequency
Definition: glspectrum.h:138
bool m_changesPending
Definition: glspectrum.h:136
CursorState m_cursorState
Definition: glspectrum.h:130
bool m_displayWaterfall
Definition: glspectrum.h:176
float getValueFromPos(double pos)
QRect m_frequencyScaleRect
Definition: glspectrum.h:166
QPixmap m_leftMarginPixmap
Definition: glspectrum.h:161
bool m_displaySourceOrSink
Definition: glspectrum.h:190
bool m_displayMaxHold
Definition: glspectrum.h:154
int32_t i
Definition: decimators.h:244
bool m_displayCurrent
Definition: glspectrum.h:156
Real m_waterfallShare
Definition: glspectrum.h:158
bool m_displayHistogram
Definition: glspectrum.h:188
float Real
Definition: dsptypes.h:42
+ Here is the call graph for this function:

◆ mousePressEvent()

void GLSpectrum::mousePressEvent ( QMouseEvent *  event)
private

Definition at line 1720 of file glspectrum.cpp.

References channelMarkerChanged(), CSChannel, CSChannelMoving, CSNormal, CSSplitter, CSSplitterMoving, ScaleEngine::getValueFromPos(), m_centerFrequency, m_channelMarkerStates, m_cursorChannel, m_cursorState, m_displaySourceOrSink, m_displayStreamIndex, m_frequencyScale, and m_leftMarginPixmap.

1721 {
1722  if(event->button() != 1)
1723  return;
1724 
1725  if(m_cursorState == CSSplitter)
1726  {
1727  grabMouse();
1729  return;
1730  }
1731  else if(m_cursorState == CSChannel)
1732  {
1733  grabMouse();
1735  return;
1736  }
1737  else if((m_cursorState == CSNormal) && (m_channelMarkerStates.size() == 1))
1738  {
1739  grabMouse();
1740  setCursor(Qt::SizeHorCursor);
1742  m_cursorChannel = 0;
1743  Real freq = m_frequencyScale.getValueFromPos(event->x() - m_leftMarginPixmap.width() - 1) - m_centerFrequency;
1744 
1745  if (m_channelMarkerStates[m_cursorChannel]->m_channelMarker->getMovable()
1746  && (m_channelMarkerStates[m_cursorChannel]->m_channelMarker->getSourceOrSinkStream() == m_displaySourceOrSink)
1747  && (m_channelMarkerStates[m_cursorChannel]->m_channelMarker->getStreamIndex() == m_displayStreamIndex))
1748  {
1749  m_channelMarkerStates[m_cursorChannel]->m_channelMarker->setCenterFrequencyByCursor(freq);
1751  }
1752 
1753  return;
1754  }
1755 }
int m_cursorChannel
Definition: glspectrum.h:131
int m_displayStreamIndex
Definition: glspectrum.h:191
QList< ChannelMarkerState * > m_channelMarkerStates
Definition: glspectrum.h:120
void channelMarkerChanged()
ScaleEngine m_frequencyScale
Definition: glspectrum.h:165
qint64 m_centerFrequency
Definition: glspectrum.h:138
CursorState m_cursorState
Definition: glspectrum.h:130
float getValueFromPos(double pos)
QPixmap m_leftMarginPixmap
Definition: glspectrum.h:161
bool m_displaySourceOrSink
Definition: glspectrum.h:190
float Real
Definition: dsptypes.h:42
+ Here is the call graph for this function:

◆ mouseReleaseEvent()

void GLSpectrum::mouseReleaseEvent ( QMouseEvent *  event)
private

Definition at line 1757 of file glspectrum.cpp.

References CSChannel, CSChannelMoving, CSSplitter, CSSplitterMoving, and m_cursorState.

1758 {
1760  releaseMouse();
1762  } else if(m_cursorState == CSChannelMoving) {
1763  releaseMouse();
1765  }
1766 }
CursorState m_cursorState
Definition: glspectrum.h:130

◆ newSpectrum()

void GLSpectrum::newSpectrum ( const std::vector< Real > &  spectrum,
int  fftSize 
)

Definition at line 343 of file glspectrum.cpp.

References m_changesPending, m_displayChanged, m_fftSize, m_mutex, updateHistogram(), and updateWaterfall().

Referenced by SpectrumVis::feed().

344 {
345  QMutexLocker mutexLocker(&m_mutex);
346 
347  m_displayChanged = true;
348 
349  if(m_changesPending) {
350  m_fftSize = fftSize;
351  return;
352  }
353 
354  if(fftSize != m_fftSize) {
355  m_fftSize = fftSize;
356  m_changesPending = true;
357  return;
358  }
359 
360  updateWaterfall(spectrum);
361  updateHistogram(spectrum);
362 }
bool m_displayChanged
Definition: glspectrum.h:189
bool m_changesPending
Definition: glspectrum.h:136
void updateWaterfall(const std::vector< Real > &spectrum)
Definition: glspectrum.cpp:364
void updateHistogram(const std::vector< Real > &spectrum)
Definition: glspectrum.cpp:383
int m_fftSize
Definition: glspectrum.h:146
QMutex m_mutex
Definition: glspectrum.h:134
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ paintGL()

void GLSpectrum::paintGL ( )
private

Definition at line 546 of file glspectrum.cpp.

References applyChanges(), GLShaderSimple::drawContour(), GLShaderSimple::drawPolyline(), GLShaderSimple::drawSegments(), GLShaderSimple::drawSurface(), GLShaderTextured::drawSurface(), ChannelMarker::dsb, ChannelMarker::getColor(), ChannelMarker::getHighlighted(), ChannelMarker::getSidebands(), ScaleEngine::getSize(), ChannelMarker::getSourceOrSinkStream(), ChannelMarker::getStreamIndex(), ScaleEngine::getTickList(), ChannelMarker::getVisible(), i, IncrementalArray< T >::m_array, m_changesPending, GLSpectrum::ChannelMarkerState::m_channelMarker, m_channelMarkerStates, m_currentSpectrum, m_displayCurrent, m_displayGrid, m_displayGridIntensity, m_displayHistogram, m_displayMaxHold, m_displaySourceOrSink, m_displayStreamIndex, m_displayTraceIntensity, m_displayWaterfall, m_fftSize, m_frequencyScale, m_glFrequencyScaleBoxMatrix, m_glHistogramBoxMatrix, m_glHistogramSpectrumMatrix, m_glLeftScaleBoxMatrix, GLSpectrum::ChannelMarkerState::m_glMatrixDsbFreqScale, GLSpectrum::ChannelMarkerState::m_glMatrixDsbHistogram, GLSpectrum::ChannelMarkerState::m_glMatrixDsbWaterfall, GLSpectrum::ChannelMarkerState::m_glMatrixFreqScale, GLSpectrum::ChannelMarkerState::m_glMatrixHistogram, GLSpectrum::ChannelMarkerState::m_glMatrixWaterfall, m_glShaderFrequencyScale, m_glShaderHistogram, m_glShaderLeftScale, m_glShaderSimple, m_glShaderWaterfall, m_glWaterfallBoxMatrix, m_histogram, m_histogramBuffer, m_histogramPalette, m_invertedWaterfall, m_maxHold, m_mouseInside, m_mutex, m_powerRange, m_powerScale, m_q3FFT, m_q3TickFrequency, m_q3TickPower, m_q3TickTime, m_referenceLevel, m_timeScale, m_waterfallBuffer, m_waterfallBufferPos, m_waterfallTextureHeight, m_waterfallTexturePos, ScaleEngine::Tick::major, ScaleEngine::Tick::pos, GLShaderTextured::subTexture(), ScaleEngine::Tick::textSize, and tick().

547 {
548  if(!m_mutex.tryLock(2))
549  return;
550 
551  if(m_changesPending)
552  applyChanges();
553 
554  if(m_fftSize <= 0) {
555  m_mutex.unlock();
556  return;
557  }
558 
559  QOpenGLFunctions *glFunctions = QOpenGLContext::currentContext()->functions();
560  glFunctions->glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
561  glFunctions->glClear(GL_COLOR_BUFFER_BIT);
562 
563  // paint waterfall
564  if (m_displayWaterfall)
565  {
566  {
567  GLfloat vtx1[] = {
568  0, m_invertedWaterfall ? 0.0f : 1.0f,
569  1, m_invertedWaterfall ? 0.0f : 1.0f,
570  1, m_invertedWaterfall ? 1.0f : 0.0f,
571  0, m_invertedWaterfall ? 1.0f : 0.0f
572  };
573 
574 
576  {
579  }
580  else
581  {
583  int linesLeft = m_waterfallTexturePos + m_waterfallBufferPos - m_waterfallTextureHeight;
584  m_glShaderWaterfall.subTexture(0, m_waterfallTexturePos, m_fftSize, breakLine, m_waterfallBuffer->scanLine(0));
585  m_glShaderWaterfall.subTexture(0, 0, m_fftSize, linesLeft, m_waterfallBuffer->scanLine(breakLine));
586  m_waterfallTexturePos = linesLeft;
587  }
588 
590 
591  float prop_y = m_waterfallTexturePos / (m_waterfallTextureHeight - 1.0);
592  float off = 1.0 / (m_waterfallTextureHeight - 1.0);
593 
594  GLfloat tex1[] = {
595  0, prop_y + 1 - off,
596  1, prop_y + 1 - off,
597  1, prop_y,
598  0, prop_y
599  };
600 
602  }
603 
604  // paint channels
605  if (m_mouseInside)
606  {
607  for (int i = 0; i < m_channelMarkerStates.size(); ++i)
608  {
609  ChannelMarkerState* dv = m_channelMarkerStates[i];
610 
611  if (dv->m_channelMarker->getVisible()
612  && (dv->m_channelMarker->getSourceOrSinkStream() == m_displaySourceOrSink)
613  && (dv->m_channelMarker->getStreamIndex() == m_displayStreamIndex))
614  {
615  {
616  GLfloat q3[] {
617  0, 0,
618  1, 0,
619  1, 1,
620  0, 1,
621  0.5, 0,
622  0.5, 1,
623  };
624 
625  QVector4D color(dv->m_channelMarker->getColor().redF(), dv->m_channelMarker->getColor().greenF(), dv->m_channelMarker->getColor().blueF(), 0.3f);
626  m_glShaderSimple.drawSurface(dv->m_glMatrixWaterfall, color, q3, 4);
627 
628  QVector4D colorLine(0.8f, 0.8f, 0.6f, 1.0f);
629  m_glShaderSimple.drawSegments(dv->m_glMatrixDsbWaterfall, colorLine, &q3[8], 2);
630 
631  }
632  }
633  }
634  }
635 
636  // draw rect around
637  {
638  GLfloat q3[] {
639  1, 1,
640  0, 1,
641  0, 0,
642  1, 0
643  };
644 
645  QVector4D color(1.0f, 1.0f, 1.0f, 0.5f);
647  }
648  }
649 
650  // paint histogram
652  {
654  {
655  {
656  // import new lines into the texture
657  quint32* pix;
658  quint8* bs = m_histogram;
659 
660  for (int y = 0; y < 100; y++)
661  {
662  quint8* b = bs;
663  pix = (quint32*)m_histogramBuffer->scanLine(99 - y);
664 
665  for (int x = 0; x < m_fftSize; x++)
666  {
667  *pix = m_histogramPalette[*b];
668  pix++;
669  b += 100;
670  }
671 
672  bs++;
673  }
674 
675  GLfloat vtx1[] = {
676  0, 0,
677  1, 0,
678  1, 1,
679  0, 1
680  };
681  GLfloat tex1[] = {
682  0, 0,
683  1, 0,
684  1, 1,
685  0, 1
686  };
687 
688  m_glShaderHistogram.subTexture(0, 0, m_fftSize, 100, m_histogramBuffer->scanLine(0));
690  }
691  }
692 
693 
694  // paint channels
695  if(m_mouseInside)
696  {
697  // Effective BW overlays
698  for(int i = 0; i < m_channelMarkerStates.size(); ++i)
699  {
700  ChannelMarkerState* dv = m_channelMarkerStates[i];
701 
702  if (dv->m_channelMarker->getVisible()
703  && (dv->m_channelMarker->getSourceOrSinkStream() == m_displaySourceOrSink)
704  && (dv->m_channelMarker->getStreamIndex() == m_displayStreamIndex))
705  {
706  {
707  GLfloat q3[] {
708  0, 0,
709  1, 0,
710  1, 1,
711  0, 1,
712  0.5, 0,
713  0.5, 1
714  };
715 
716  QVector4D color(dv->m_channelMarker->getColor().redF(), dv->m_channelMarker->getColor().greenF(), dv->m_channelMarker->getColor().blueF(), 0.3f);
717  m_glShaderSimple.drawSurface(dv->m_glMatrixHistogram, color, q3, 4);
718 
719  QVector4D colorLine(0.8f, 0.8f, 0.6f, 1.0f);
720 
721  if (dv->m_channelMarker->getSidebands() != ChannelMarker::dsb) {
722  q3[6] = 0.5;
723  }
724 
725  m_glShaderSimple.drawSegments(dv->m_glMatrixDsbHistogram, colorLine, &q3[8], 2);
726  m_glShaderSimple.drawSegments(dv->m_glMatrixFreqScale, colorLine, q3, 2);
727  }
728  }
729  }
730  }
731 
732  // draw rect around
733  {
734  GLfloat q3[] {
735  1, 1,
736  0, 1,
737  0, 0,
738  1, 0
739  };
740 
741  QVector4D color(1.0f, 1.0f, 1.0f, 0.5f);
743  }
744  }
745 
746  // paint left scales (time and power)
748  {
749  {
750  GLfloat vtx1[] = {
751  0, 1,
752  1, 1,
753  1, 0,
754  0, 0
755  };
756  GLfloat tex1[] = {
757  0, 1,
758  1, 1,
759  1, 0,
760  0, 0
761  };
762 
764  }
765  }
766 
767  // paint frequency scale
769  {
770  {
771  GLfloat vtx1[] = {
772  0, 1,
773  1, 1,
774  1, 0,
775  0, 0
776  };
777  GLfloat tex1[] = {
778  0, 1,
779  1, 1,
780  1, 0,
781  0, 0
782  };
783 
785  }
786 
787  // paint channels
788 
789  // Effective bandwidth overlays
790  for(int i = 0; i < m_channelMarkerStates.size(); ++i)
791  {
792  ChannelMarkerState* dv = m_channelMarkerStates[i];
793 
794  // frequency scale channel overlay
795  if (dv->m_channelMarker->getVisible()
796  && (dv->m_channelMarker->getSourceOrSinkStream() == m_displaySourceOrSink)
797  && (dv->m_channelMarker->getStreamIndex() == m_displayStreamIndex))
798  {
799  {
800  GLfloat q3[] {
801  1, 0.2,
802  0, 0.2,
803  0, 0,
804  1, 0,
805  0.5, 0,
806  0.5, 1
807  };
808 
809  QVector4D color(dv->m_channelMarker->getColor().redF(), dv->m_channelMarker->getColor().greenF(), dv->m_channelMarker->getColor().blueF(), 0.5f);
810  m_glShaderSimple.drawSurface(dv->m_glMatrixFreqScale, color, q3, 4);
811 
812  if (dv->m_channelMarker->getHighlighted())
813  {
814  QVector4D colorLine(0.8f, 0.8f, 0.6f, 1.0f);
815  m_glShaderSimple.drawSegments(dv->m_glMatrixDsbFreqScale, colorLine, &q3[8], 2);
816  m_glShaderSimple.drawSegments(dv->m_glMatrixFreqScale, colorLine, &q3[4], 2);
817  }
818  }
819  }
820  }
821  }
822 
823  // paint max hold lines on top of histogram
824  if (m_displayMaxHold)
825  {
826  if (m_maxHold.size() < (uint) m_fftSize) {
827  m_maxHold.resize(m_fftSize);
828  }
829 
830  for (int i = 0; i < m_fftSize; i++)
831  {
832  int j;
833  quint8* bs = m_histogram + i * 100;
834 
835  for (j = 99; j >= 0; j--)
836  {
837  if (bs[j] > 0) {
838  break;
839  }
840  }
841 
842  // m_referenceLevel : top
843  // m_referenceLevel - m_powerRange : bottom
844  m_maxHold[i] = ((j - 99) * m_powerRange) / 99.0 + m_referenceLevel;
845  }
846  {
847  GLfloat *q3 = m_q3FFT.m_array;
848 
849  for (int i = 0; i < m_fftSize; i++)
850  {
852 
853  if (v >= 0) {
854  v = 0;
855  } else if (v < -m_powerRange) {
856  v = -m_powerRange;
857  }
858 
859  q3[2*i] = (Real) i;
860  q3[2*i+1] = v;
861  }
862 
863  QVector4D color(1.0f, 0.0f, 0.0f, (float) m_displayTraceIntensity / 100.0f);
865  }
866  }
867 
868  // paint current spectrum line on top of histogram
870  {
871  {
872  Real bottom = -m_powerRange;
873  GLfloat *q3 = m_q3FFT.m_array;
874 
875  for(int i = 0; i < m_fftSize; i++)
876  {
877  Real v = (*m_currentSpectrum)[i] - m_referenceLevel;
878 
879  if(v > 0) {
880  v = 0;
881  } else if(v < bottom) {
882  v = bottom;
883  }
884 
885  q3[2*i] = (Real) i;
886  q3[2*i+1] = v;
887  }
888 
889  QVector4D color(1.0f, 1.0f, 0.25f, (float) m_displayTraceIntensity / 100.0f);
891  }
892  }
893 
894  // paint waterfall grid
896  {
897  const ScaleEngine::TickList* tickList;
898  const ScaleEngine::Tick* tick;
899  tickList = &m_timeScale.getTickList();
900 
901  {
902  GLfloat *q3 = m_q3TickTime.m_array;
903  int effectiveTicks = 0;
904 
905  for (int i= 0; i < tickList->count(); i++)
906  {
907  tick = &(*tickList)[i];
908 
909  if (tick->major)
910  {
911  if(tick->textSize > 0)
912  {
913  float y = tick->pos / m_timeScale.getSize();
914  q3[4*effectiveTicks] = 0;
915  q3[4*effectiveTicks+1] = y;
916  q3[4*effectiveTicks+2] = 1;
917  q3[4*effectiveTicks+3] = y;
918  effectiveTicks++;
919  }
920  }
921  }
922 
923  QVector4D color(1.0f, 1.0f, 1.0f, (float) m_displayGridIntensity / 100.0f);
924  m_glShaderSimple.drawSegments(m_glWaterfallBoxMatrix, color, q3, 2*effectiveTicks);
925  }
926 
927  tickList = &m_frequencyScale.getTickList();
928 
929  {
930  GLfloat *q3 = m_q3TickFrequency.m_array;
931  int effectiveTicks = 0;
932 
933  for (int i= 0; i < tickList->count(); i++)
934  {
935  tick = &(*tickList)[i];
936 
937  if (tick->major)
938  {
939  if (tick->textSize > 0)
940  {
941  float x = tick->pos / m_frequencyScale.getSize();
942  q3[4*effectiveTicks] = x;
943  q3[4*effectiveTicks+1] = 0;
944  q3[4*effectiveTicks+2] = x;
945  q3[4*effectiveTicks+3] = 1;
946  effectiveTicks++;
947  }
948  }
949  }
950 
951  QVector4D color(1.0f, 1.0f, 1.0f, (float) m_displayGridIntensity / 100.0f);
952  m_glShaderSimple.drawSegments(m_glWaterfallBoxMatrix, color, q3, 2*effectiveTicks);
953  }
954  }
955 
956  // paint histogram grid
958  {
959  const ScaleEngine::TickList* tickList;
960  const ScaleEngine::Tick* tick;
961  tickList = &m_powerScale.getTickList();
962 
963  {
964  GLfloat *q3 = m_q3TickPower.m_array;
965  int effectiveTicks = 0;
966 
967  for(int i= 0; i < tickList->count(); i++)
968  {
969  tick = &(*tickList)[i];
970 
971  if(tick->major)
972  {
973  if(tick->textSize > 0)
974  {
975  float y = tick->pos / m_powerScale.getSize();
976  q3[4*effectiveTicks] = 0;
977  q3[4*effectiveTicks+1] = 1-y;
978  q3[4*effectiveTicks+2] = 1;
979  q3[4*effectiveTicks+3] = 1-y;
980  effectiveTicks++;
981  }
982  }
983  }
984 
985  QVector4D color(1.0f, 1.0f, 1.0f, (float) m_displayGridIntensity / 100.0f);
986  m_glShaderSimple.drawSegments(m_glHistogramBoxMatrix, color, q3, 2*effectiveTicks);
987  }
988 
989  tickList = &m_frequencyScale.getTickList();
990 
991  {
992  GLfloat *q3 = m_q3TickFrequency.m_array;
993  int effectiveTicks = 0;
994 
995  for(int i= 0; i < tickList->count(); i++)
996  {
997  tick = &(*tickList)[i];
998 
999  if(tick->major)
1000  {
1001  if(tick->textSize > 0)
1002  {
1003  float x = tick->pos / m_frequencyScale.getSize();
1004  q3[4*effectiveTicks] = x;
1005  q3[4*effectiveTicks+1] = 0;
1006  q3[4*effectiveTicks+2] = x;
1007  q3[4*effectiveTicks+3] = 1;
1008  effectiveTicks++;
1009  }
1010  }
1011  }
1012 
1013  QVector4D color(1.0f, 1.0f, 1.0f, (float) m_displayGridIntensity / 100.0f);
1014  m_glShaderSimple.drawSegments(m_glHistogramBoxMatrix, color, q3, 2*effectiveTicks);
1015  }
1016  }
1017 
1018  m_mutex.unlock();
1019 }
int m_displayStreamIndex
Definition: glspectrum.h:191
Real m_referenceLevel
Definition: glspectrum.h:139
int m_displayTraceIntensity
Definition: glspectrum.h:150
bool m_displayGrid
Definition: glspectrum.h:148
Real m_powerRange
Definition: glspectrum.h:140
QMatrix4x4 m_glFrequencyScaleBoxMatrix
Definition: glspectrum.h:167
QMatrix4x4 m_glHistogramBoxMatrix
Definition: glspectrum.h:187
void drawSegments(const QMatrix4x4 &transformMatrix, const QVector4D &color, GLfloat *vertices, int nbVertices)
QList< ChannelMarkerState * > m_channelMarkerStates
Definition: glspectrum.h:120
QRgb m_histogramPalette[240]
Definition: glspectrum.h:180
IncrementalArray< GLfloat > m_q3TickFrequency
Definition: glspectrum.h:201
std::vector< Real > m_maxHold
Definition: glspectrum.h:153
bool m_invertedWaterfall
Definition: glspectrum.h:151
ScaleEngine m_frequencyScale
Definition: glspectrum.h:165
bool m_changesPending
Definition: glspectrum.h:136
bool m_displayWaterfall
Definition: glspectrum.h:176
QMatrix4x4 m_glWaterfallBoxMatrix
Definition: glspectrum.h:175
QMatrix4x4 m_glLeftScaleBoxMatrix
Definition: glspectrum.h:168
IncrementalArray< GLfloat > m_q3TickTime
Definition: glspectrum.h:200
float getSize()
Definition: scaleengine.h:80
int m_waterfallTextureHeight
Definition: glspectrum.h:173
void drawSurface(const QMatrix4x4 &transformMatrix, const QVector4D &color, GLfloat *vertices, int nbVertices)
void drawSurface(const QMatrix4x4 &transformMatrix, GLfloat *textureCoords, GLfloat *vertices, int nbVertices)
ScaleEngine m_powerScale
Definition: glspectrum.h:164
bool m_displaySourceOrSink
Definition: glspectrum.h:190
void subTexture(int xOffset, int yOffset, int width, int height, const void *pixels)
GLShaderTextured m_glShaderFrequencyScale
Definition: glspectrum.h:195
bool m_displayMaxHold
Definition: glspectrum.h:154
GLShaderTextured m_glShaderWaterfall
Definition: glspectrum.h:196
int32_t i
Definition: decimators.h:244
const std::vector< Real > * m_currentSpectrum
Definition: glspectrum.h:155
QImage * m_waterfallBuffer
Definition: glspectrum.h:171
void drawContour(const QMatrix4x4 &transformMatrix, const QVector4D &color, GLfloat *vertices, int nbVertices)
bool m_displayCurrent
Definition: glspectrum.h:156
int m_displayGridIntensity
Definition: glspectrum.h:149
int m_waterfallTexturePos
Definition: glspectrum.h:174
quint8 * m_histogram
Spectrum phosphor matrix of FFT width and PSD height scaled to 100. values [0..239].
Definition: glspectrum.h:182
QMatrix4x4 m_glHistogramSpectrumMatrix
Definition: glspectrum.h:186
const TickList & getTickList()
IncrementalArray< GLfloat > m_q3FFT
Definition: glspectrum.h:203
QList< Tick > TickList
Definition: scaleengine.h:37
void drawPolyline(const QMatrix4x4 &transformMatrix, const QVector4D &color, GLfloat *vertices, int nbVertices)
GLShaderTextured m_glShaderLeftScale
Definition: glspectrum.h:194
QImage * m_histogramBuffer
Definition: glspectrum.h:181
bool m_displayHistogram
Definition: glspectrum.h:188
int m_fftSize
Definition: glspectrum.h:146
void applyChanges()
GLShaderTextured m_glShaderHistogram
Definition: glspectrum.h:197
QMutex m_mutex
Definition: glspectrum.h:134
GLShaderSimple m_glShaderSimple
Definition: glspectrum.h:193
ScaleEngine m_timeScale
Definition: glspectrum.h:163
float Real
Definition: dsptypes.h:42
int m_waterfallBufferPos
Definition: glspectrum.h:172
bool m_mouseInside
Definition: glspectrum.h:135
IncrementalArray< GLfloat > m_q3TickPower
Definition: glspectrum.h:202
+ Here is the call graph for this function:

◆ removeChannelMarker()

void GLSpectrum::removeChannelMarker ( ChannelMarker channelMarker)

Definition at line 327 of file glspectrum.cpp.

References i, m_changesPending, m_channelMarkerStates, m_mutex, and stopDrag().

Referenced by channelMarkerDestroyed().

328 {
329  QMutexLocker mutexLocker(&m_mutex);
330 
331  for(int i = 0; i < m_channelMarkerStates.size(); ++i) {
332  if(m_channelMarkerStates[i]->m_channelMarker == channelMarker) {
333  channelMarker->disconnect(this);
334  delete m_channelMarkerStates.takeAt(i);
335  m_changesPending = true;
336  stopDrag();
337  update();
338  return;
339  }
340  }
341 }
void stopDrag()
QList< ChannelMarkerState * > m_channelMarkerStates
Definition: glspectrum.h:120
bool m_changesPending
Definition: glspectrum.h:136
int32_t i
Definition: decimators.h:244
QMutex m_mutex
Definition: glspectrum.h:134
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resizeGL()

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

Definition at line 528 of file glspectrum.cpp.

References m_changesPending.

529 {
530  QOpenGLFunctions *glFunctions = QOpenGLContext::currentContext()->functions();
531  glFunctions->glViewport(0, 0, width, height);
532  m_changesPending = true;
533 }
bool m_changesPending
Definition: glspectrum.h:136

◆ setCenterFrequency()

void GLSpectrum::setCenterFrequency ( qint64  frequency)

Definition at line 175 of file glspectrum.cpp.

References m_centerFrequency, and m_changesPending.

Referenced by RemoteOutputSinkGui::analyzeApiReply(), RemoteOutputSinkGui::RemoteOutputSinkGui(), FCDProPlusGui::updateSampleRateAndFrequency(), FCDProGui::updateSampleRateAndFrequency(), SDRPlayGui::updateSampleRateAndFrequency(), TestSourceGui::updateSampleRateAndFrequency(), BladeRF2InputGui::updateSampleRateAndFrequency(), BladeRF2OutputGui::updateSampleRateAndFrequency(), Bladerf1OutputGui::updateSampleRateAndFrequency(), PlutoSDROutputGUI::updateSampleRateAndFrequency(), AirspyGui::updateSampleRateAndFrequency(), Bladerf1InputGui::updateSampleRateAndFrequency(), TestMIGui::updateSampleRateAndFrequency(), KiwiSDRGui::updateSampleRateAndFrequency(), PerseusGui::updateSampleRateAndFrequency(), PlutoSDRInputGui::updateSampleRateAndFrequency(), RTLSDRGui::updateSampleRateAndFrequency(), AirspyHFGui::updateSampleRateAndFrequency(), XTRXOutputGUI::updateSampleRateAndFrequency(), LimeSDRInputGUI::updateSampleRateAndFrequency(), LimeSDROutputGUI::updateSampleRateAndFrequency(), XTRXInputGUI::updateSampleRateAndFrequency(), FileInputGUI::updateSampleRateAndFrequency(), FileSinkGui::updateSampleRateAndFrequency(), HackRFInputGui::updateSampleRateAndFrequency(), HackRFOutputGui::updateSampleRateAndFrequency(), LocalOutputGui::updateSampleRateAndFrequency(), SoapySDRInputGui::updateSampleRateAndFrequency(), SoapySDROutputGui::updateSampleRateAndFrequency(), LocalInputGui::updateSampleRateAndFrequency(), and RemoteInputGui::updateSampleRateAndFrequency().

176 {
177  m_centerFrequency = frequency;
178  m_changesPending = true;
179  update();
180 }
qint64 m_centerFrequency
Definition: glspectrum.h:138
bool m_changesPending
Definition: glspectrum.h:136
+ Here is the caller graph for this function:

◆ setDecay()

void GLSpectrum::setDecay ( int  decay)

Definition at line 196 of file glspectrum.cpp.

References m_decay.

Referenced by GLSpectrumGUI::applySettings(), and GLSpectrumGUI::on_decay_valueChanged().

197 {
198  m_decay = decay < 0 ? 0 : decay > 20 ? 20 : decay;
199 }
+ Here is the caller graph for this function:

◆ setDecayDivisor()

void GLSpectrum::setDecayDivisor ( int  decayDivisor)

Definition at line 201 of file glspectrum.cpp.

References m_decayDivisor.

Referenced by GLSpectrumGUI::applySettings().

202 {
203  m_decayDivisor = decayDivisor < 1 ? 1 : decayDivisor > 20 ? 20 : decayDivisor;
204 }
int m_decayDivisor
Definition: glspectrum.h:183
+ Here is the caller graph for this function:

◆ setDisplayCurrent()

void GLSpectrum::setDisplayCurrent ( bool  display)

Definition at line 264 of file glspectrum.cpp.

References m_changesPending, m_displayCurrent, and stopDrag().

Referenced by GLSpectrumGUI::applySettings(), and GLSpectrumGUI::on_current_toggled().

265 {
266  m_displayCurrent = display;
267  m_changesPending = true;
268  stopDrag();
269  update();
270 }
void stopDrag()
bool m_changesPending
Definition: glspectrum.h:136
bool m_displayCurrent
Definition: glspectrum.h:156
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDisplayedStream()

void GLSpectrum::setDisplayedStream ( bool  sourceOrSink,
int  streamIndex 
)
inline

Definition at line 99 of file glspectrum.h.

Referenced by TestMIGui::on_spectrumSource_currentIndexChanged(), and TestMIGui::on_streamIndex_currentIndexChanged().

100  {
101  m_displaySourceOrSink = sourceOrSink;
102  m_displayStreamIndex = streamIndex;
103  }
int m_displayStreamIndex
Definition: glspectrum.h:191
bool m_displaySourceOrSink
Definition: glspectrum.h:190
+ Here is the caller graph for this function:

◆ setDisplayGrid()

void GLSpectrum::setDisplayGrid ( bool  display)

Definition at line 280 of file glspectrum.cpp.

References m_displayGrid.

Referenced by GLSpectrumGUI::applySettings(), and GLSpectrumGUI::on_grid_toggled().

281 {
282  m_displayGrid = display;
283  update();
284 }
bool m_displayGrid
Definition: glspectrum.h:148
+ Here is the caller graph for this function:

◆ setDisplayGridIntensity()

void GLSpectrum::setDisplayGridIntensity ( int  intensity)

Definition at line 286 of file glspectrum.cpp.

References m_displayGridIntensity.

Referenced by GLSpectrumGUI::applySettings(), and GLSpectrumGUI::on_gridIntensity_valueChanged().

287 {
288  m_displayGridIntensity = intensity;
289  if (m_displayGridIntensity > 100) {
291  } else if (m_displayGridIntensity < 0) {
293  }
294  update();
295 }
int m_displayGridIntensity
Definition: glspectrum.h:149
+ Here is the caller graph for this function:

◆ setDisplayHistogram()

void GLSpectrum::setDisplayHistogram ( bool  display)

Definition at line 272 of file glspectrum.cpp.

References m_changesPending, m_displayHistogram, and stopDrag().

Referenced by GLSpectrumGUI::applySettings(), and GLSpectrumGUI::on_histogram_toggled().

273 {
274  m_displayHistogram = display;
275  m_changesPending = true;
276  stopDrag();
277  update();
278 }
void stopDrag()
bool m_changesPending
Definition: glspectrum.h:136
bool m_displayHistogram
Definition: glspectrum.h:188
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDisplayMaxHold()

void GLSpectrum::setDisplayMaxHold ( bool  display)

Definition at line 256 of file glspectrum.cpp.

References m_changesPending, m_displayMaxHold, and stopDrag().

Referenced by GLSpectrumGUI::applySettings(), and GLSpectrumGUI::on_maxHold_toggled().

257 {
258  m_displayMaxHold = display;
259  m_changesPending = true;
260  stopDrag();
261  update();
262 }
void stopDrag()
bool m_changesPending
Definition: glspectrum.h:136
bool m_displayMaxHold
Definition: glspectrum.h:154
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDisplayTraceIntensity()

void GLSpectrum::setDisplayTraceIntensity ( int  intensity)

Definition at line 297 of file glspectrum.cpp.

References m_displayTraceIntensity.

Referenced by GLSpectrumGUI::on_traceIntensity_valueChanged().

298 {
299  m_displayTraceIntensity = intensity;
300  if (m_displayTraceIntensity > 100) {
302  } else if (m_displayTraceIntensity < 0) {
304  }
305  update();
306 }
int m_displayTraceIntensity
Definition: glspectrum.h:150
+ Here is the caller graph for this function:

◆ setDisplayWaterfall()

void GLSpectrum::setDisplayWaterfall ( bool  display)

Definition at line 228 of file glspectrum.cpp.

References m_changesPending, m_displayWaterfall, and stopDrag().

Referenced by GLSpectrumGUI::applySettings(), and GLSpectrumGUI::on_waterfall_toggled().

229 {
230  m_displayWaterfall = display;
231  m_changesPending = true;
232  stopDrag();
233  update();
234 }
void stopDrag()
bool m_changesPending
Definition: glspectrum.h:136
bool m_displayWaterfall
Definition: glspectrum.h:176
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setHistoStroke()

void GLSpectrum::setHistoStroke ( int  stroke)

Definition at line 206 of file glspectrum.cpp.

References m_histogramStroke.

Referenced by GLSpectrumGUI::applySettings().

207 {
208  m_histogramStroke = stroke < 1 ? 1 : stroke > 60 ? 60 : stroke;
209 }
int m_histogramStroke
Definition: glspectrum.h:185
+ Here is the caller graph for this function:

◆ setInvertedWaterfall()

void GLSpectrum::setInvertedWaterfall ( bool  inv)

Definition at line 248 of file glspectrum.cpp.

References m_changesPending, m_invertedWaterfall, and stopDrag().

Referenced by GLSpectrumGUI::applySettings(), and GLSpectrumGUI::on_invert_toggled().

249 {
250  m_invertedWaterfall = inv;
251  m_changesPending = true;
252  stopDrag();
253  update();
254 }
void stopDrag()
bool m_invertedWaterfall
Definition: glspectrum.h:151
bool m_changesPending
Definition: glspectrum.h:136
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setLinear()

void GLSpectrum::setLinear ( bool  linear)

Definition at line 308 of file glspectrum.cpp.

References m_changesPending, and m_linear.

Referenced by GLSpectrumGUI::applySettings(), and GLSpectrumGUI::on_linscale_toggled().

309 {
310  m_linear = linear;
311  m_changesPending = true;
312  update();
313 }
bool m_linear
Definition: glspectrum.h:141
bool m_changesPending
Definition: glspectrum.h:136
+ Here is the caller graph for this function:

◆ setLsbDisplay()

void GLSpectrum::setLsbDisplay ( bool  lsbDisplay)

Definition at line 242 of file glspectrum.cpp.

References m_lsbDisplay.

243 {
244  m_lsbDisplay = lsbDisplay;
245  update();
246 }
bool m_lsbDisplay
Definition: glspectrum.h:178

◆ setMessageQueueToGUI()

void GLSpectrum::setMessageQueueToGUI ( MessageQueue messageQueue)
inline

Definition at line 90 of file glspectrum.h.

Referenced by GLSpectrumGUI::setBuddies().

90 { m_messageQueueToGUI = messageQueue; }
MessageQueue * m_messageQueueToGUI
Definition: glspectrum.h:205
+ Here is the caller graph for this function:

◆ setPowerRange()

void GLSpectrum::setPowerRange ( Real  powerRange)

Definition at line 189 of file glspectrum.cpp.

References m_changesPending, and m_powerRange.

Referenced by GLSpectrumGUI::on_levelRange_currentIndexChanged(), GLSpectrumGUI::on_linscale_toggled(), and GLSpectrumGUI::on_refLevel_currentIndexChanged().

190 {
191  m_powerRange = powerRange;
192  m_changesPending = true;
193  update();
194 }
Real m_powerRange
Definition: glspectrum.h:140
bool m_changesPending
Definition: glspectrum.h:136
+ Here is the caller graph for this function:

◆ setReferenceLevel()

void GLSpectrum::setReferenceLevel ( Real  referenceLevel)

Definition at line 182 of file glspectrum.cpp.

References m_changesPending, and m_referenceLevel.

Referenced by GLSpectrumGUI::on_levelRange_currentIndexChanged(), GLSpectrumGUI::on_linscale_toggled(), and GLSpectrumGUI::on_refLevel_currentIndexChanged().

183 {
184  m_referenceLevel = referenceLevel;
185  m_changesPending = true;
186  update();
187 }
Real m_referenceLevel
Definition: glspectrum.h:139
bool m_changesPending
Definition: glspectrum.h:136
+ Here is the caller graph for this function:

◆ setSampleRate()

void GLSpectrum::setSampleRate ( qint32  sampleRate)

Definition at line 211 of file glspectrum.cpp.

References m_changesPending, m_messageQueueToGUI, m_sampleRate, and MessageQueue::push().

Referenced by RemoteOutputSinkGui::updateSampleRate(), FCDProPlusGui::updateSampleRateAndFrequency(), FCDProGui::updateSampleRateAndFrequency(), SDRPlayGui::updateSampleRateAndFrequency(), TestSourceGui::updateSampleRateAndFrequency(), BladeRF2OutputGui::updateSampleRateAndFrequency(), BladeRF2InputGui::updateSampleRateAndFrequency(), Bladerf1OutputGui::updateSampleRateAndFrequency(), PlutoSDROutputGUI::updateSampleRateAndFrequency(), AirspyGui::updateSampleRateAndFrequency(), TestMIGui::updateSampleRateAndFrequency(), Bladerf1InputGui::updateSampleRateAndFrequency(), KiwiSDRGui::updateSampleRateAndFrequency(), PerseusGui::updateSampleRateAndFrequency(), PlutoSDRInputGui::updateSampleRateAndFrequency(), RTLSDRGui::updateSampleRateAndFrequency(), AirspyHFGui::updateSampleRateAndFrequency(), XTRXOutputGUI::updateSampleRateAndFrequency(), LimeSDRInputGUI::updateSampleRateAndFrequency(), XTRXInputGUI::updateSampleRateAndFrequency(), LimeSDROutputGUI::updateSampleRateAndFrequency(), FileInputGUI::updateSampleRateAndFrequency(), FileSinkGui::updateSampleRateAndFrequency(), HackRFInputGui::updateSampleRateAndFrequency(), HackRFOutputGui::updateSampleRateAndFrequency(), LocalOutputGui::updateSampleRateAndFrequency(), SoapySDRInputGui::updateSampleRateAndFrequency(), SoapySDROutputGui::updateSampleRateAndFrequency(), LocalInputGui::updateSampleRateAndFrequency(), and RemoteInputGui::updateSampleRateAndFrequency().

212 {
213  m_sampleRate = sampleRate;
214  if (m_messageQueueToGUI) {
215  m_messageQueueToGUI->push(new MsgReportSampleRate(m_sampleRate));
216  }
217  m_changesPending = true;
218  update();
219 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
bool m_changesPending
Definition: glspectrum.h:136
quint32 m_sampleRate
Definition: glspectrum.h:143
MessageQueue * m_messageQueueToGUI
Definition: glspectrum.h:205
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setSsbSpectrum()

void GLSpectrum::setSsbSpectrum ( bool  ssbSpectrum)

Definition at line 236 of file glspectrum.cpp.

References m_ssbSpectrum.

237 {
238  m_ssbSpectrum = ssbSpectrum;
239  update();
240 }
bool m_ssbSpectrum
Definition: glspectrum.h:177

◆ setTimingRate()

void GLSpectrum::setTimingRate ( qint32  timingRate)

Definition at line 221 of file glspectrum.cpp.

References m_changesPending, and m_timingRate.

Referenced by GLSpectrumGUI::on_averaging_currentIndexChanged(), and GLSpectrumGUI::on_averagingMode_currentIndexChanged().

222 {
223  m_timingRate = timingRate;
224  m_changesPending = true;
225  update();
226 }
bool m_changesPending
Definition: glspectrum.h:136
quint32 m_timingRate
Definition: glspectrum.h:144
+ Here is the caller graph for this function:

◆ setWaterfallShare()

void GLSpectrum::setWaterfallShare ( Real  waterfallShare)

Definition at line 1853 of file glspectrum.cpp.

References m_changesPending, and m_waterfallShare.

Referenced by GLSpectrumGUI::deserialize().

1854 {
1855  if (waterfallShare < 0.1f) {
1856  m_waterfallShare = 0.1f;
1857  }
1858  else if (waterfallShare > 0.8f) {
1859  m_waterfallShare = 0.8f;
1860  } else {
1861  m_waterfallShare = waterfallShare;
1862  }
1863  m_changesPending = true;
1864 }
bool m_changesPending
Definition: glspectrum.h:136
Real m_waterfallShare
Definition: glspectrum.h:158
+ Here is the caller graph for this function:

◆ stopDrag()

void GLSpectrum::stopDrag ( )
private

Definition at line 1021 of file glspectrum.cpp.

References CSChannelMoving, CSNormal, CSSplitterMoving, and m_cursorState.

Referenced by addChannelMarker(), removeChannelMarker(), setDisplayCurrent(), setDisplayHistogram(), setDisplayMaxHold(), setDisplayWaterfall(), and setInvertedWaterfall().

1022 {
1023  if(m_cursorState != CSNormal) {
1025  releaseMouse();
1026  setCursor(Qt::ArrowCursor);
1028  }
1029 }
CursorState m_cursorState
Definition: glspectrum.h:130
+ Here is the caller graph for this function:

◆ tick

void GLSpectrum::tick ( )
privateslot

Definition at line 1834 of file glspectrum.cpp.

References m_displayChanged.

Referenced by applyChanges(), connectTimer(), and paintGL().

1835 {
1836  if(m_displayChanged) {
1837  m_displayChanged = false;
1838  update();
1839  }
1840 }
bool m_displayChanged
Definition: glspectrum.h:189
+ Here is the caller graph for this function:

◆ updateHistogram()

void GLSpectrum::updateHistogram ( const std::vector< Real > &  spectrum)
private

Definition at line 383 of file glspectrum.cpp.

References i, m_currentSpectrum, m_decay, m_decayDivisor, m_decayDivisorCount, m_displayHistogram, m_displayMaxHold, m_fftSize, m_histogram, m_histogramStroke, m_powerRange, and m_referenceLevel.

Referenced by newSpectrum().

384 {
385  quint8* b = m_histogram;
386  int fftMulSize = 100 * m_fftSize;
387 
388  if ((m_displayHistogram || m_displayMaxHold) && (m_decay != 0))
389  {
391 
392  if ((m_decay > 1) || (m_decayDivisorCount <= 0))
393  {
394  for (int i = 0; i < fftMulSize; i++)
395  {
396  if (*b > m_decay) {
397  *b = *b - m_decay;
398  } else {
399  *b = 0;
400  }
401 
402  b++;
403  }
404 
406  }
407  }
408 
409  m_currentSpectrum = &spectrum; // Store spectrum for current spectrum line display
410 
411 #if 0 //def USE_SSE2
412  if(m_decay >= 0) { // normal
413  const __m128 refl = {m_referenceLevel, m_referenceLevel, m_referenceLevel, m_referenceLevel};
414  const __m128 power = {m_powerRange, m_powerRange, m_powerRange, m_powerRange};
415  const __m128 mul = {100.0f, 100.0f, 100.0f, 100.0f};
416 
417  for(int i = 0; i < m_fftSize; i += 4) {
418  __m128 abc = _mm_loadu_ps (&spectrum[i]);
419  abc = _mm_sub_ps(abc, refl);
420  abc = _mm_mul_ps(abc, mul);
421  abc = _mm_div_ps(abc, power);
422  abc = _mm_add_ps(abc, mul);
423  __m128i result = _mm_cvtps_epi32(abc);
424 
425  for(int j = 0; j < 4; j++) {
426  int v = ((int*)&result)[j];
427  if((v >= 0) && (v <= 99)) {
428  b = m_histogram + (i + j) * 100 + v;
429  if(*b < 220)
430  *b += m_histogramStroke; // was 4
431  else if(*b < 239)
432  *b += 1;
433  }
434  }
435  }
436  } else { // draw double pixels
437  int add = -m_decay * 4;
438  const __m128 refl = {m_referenceLevel, m_referenceLevel, m_referenceLevel, m_referenceLevel};
439  const __m128 power = {m_powerRange, m_powerRange, m_powerRange, m_powerRange};
440  const __m128 mul = {100.0f, 100.0f, 100.0f, 100.0f};
441 
442  for(int i = 0; i < m_fftSize; i += 4) {
443  __m128 abc = _mm_loadu_ps (&spectrum[i]);
444  abc = _mm_sub_ps(abc, refl);
445  abc = _mm_mul_ps(abc, mul);
446  abc = _mm_div_ps(abc, power);
447  abc = _mm_add_ps(abc, mul);
448  __m128i result = _mm_cvtps_epi32(abc);
449 
450  for(int j = 0; j < 4; j++) {
451  int v = ((int*)&result)[j];
452  if((v >= 1) && (v <= 98)) {
453  b = m_histogram + (i + j) * 100 + v;
454  if(b[-1] < 220)
455  b[-1] += add;
456  else if(b[-1] < 239)
457  b[-1] += 1;
458  if(b[0] < 220)
459  b[0] += add;
460  else if(b[0] < 239)
461  b[0] += 1;
462  if(b[1] < 220)
463  b[1] += add;
464  else if(b[1] < 239)
465  b[1] += 1;
466  } else if((v >= 0) && (v <= 99)) {
467  b = m_histogram + (i + j) * 100 + v;
468  if(*b < 220)
469  *b += add;
470  else if(*b < 239)
471  *b += 1;
472  }
473  }
474  }
475  }
476 #else
477  for (int i = 0; i < m_fftSize; i++)
478  {
479  int v = (int)((spectrum[i] - m_referenceLevel) * 100.0 / m_powerRange + 100.0);
480 
481  if ((v >= 0) && (v <= 99))
482  {
483  b = m_histogram + i * 100 + v;
484 
485  // capping to 239 as palette values are [0..239]
486  if (*b + m_histogramStroke <= 239) {
487  *b += m_histogramStroke; // was 4
488  } else {
489  *b = 239;
490  }
491  }
492  }
493 #endif
494 }
Real m_referenceLevel
Definition: glspectrum.h:139
Real m_powerRange
Definition: glspectrum.h:140
int m_decayDivisor
Definition: glspectrum.h:183
bool m_displayMaxHold
Definition: glspectrum.h:154
int m_decayDivisorCount
Definition: glspectrum.h:184
int32_t i
Definition: decimators.h:244
const std::vector< Real > * m_currentSpectrum
Definition: glspectrum.h:155
quint8 * m_histogram
Spectrum phosphor matrix of FFT width and PSD height scaled to 100. values [0..239].
Definition: glspectrum.h:182
int m_histogramStroke
Definition: glspectrum.h:185
bool m_displayHistogram
Definition: glspectrum.h:188
int m_fftSize
Definition: glspectrum.h:146
+ Here is the caller graph for this function:

◆ updateWaterfall()

void GLSpectrum::updateWaterfall ( const std::vector< Real > &  spectrum)
private

Definition at line 364 of file glspectrum.cpp.

References i, m_fftSize, m_powerRange, m_referenceLevel, m_waterfallBuffer, m_waterfallBufferPos, and m_waterfallPalette.

Referenced by newSpectrum().

365 {
366  if(m_waterfallBufferPos < m_waterfallBuffer->height()) {
367  quint32* pix = (quint32*)m_waterfallBuffer->scanLine(m_waterfallBufferPos);
368 
369  for(int i = 0; i < m_fftSize; i++) {
370  int v = (int)((spectrum[i] - m_referenceLevel) * 2.4 * 100.0 / m_powerRange + 240.0);
371  if(v > 239)
372  v = 239;
373  else if(v < 0)
374  v = 0;
375 
376  *pix++ = m_waterfallPalette[(int)v];
377  }
378 
380  }
381 }
Real m_referenceLevel
Definition: glspectrum.h:139
Real m_powerRange
Definition: glspectrum.h:140
int32_t i
Definition: decimators.h:244
QImage * m_waterfallBuffer
Definition: glspectrum.h:171
QRgb m_waterfallPalette[240]
Definition: glspectrum.h:170
int m_fftSize
Definition: glspectrum.h:146
int m_waterfallBufferPos
Definition: glspectrum.h:172
+ Here is the caller graph for this function:

◆ wheelEvent()

void GLSpectrum::wheelEvent ( QWheelEvent *  event)
private

Definition at line 1768 of file glspectrum.cpp.

References ScaleEngine::getPosFromValue(), ScaleEngine::getSize(), i, m_centerFrequency, m_channelMarkerStates, m_displaySourceOrSink, m_displayStreamIndex, m_frequencyScale, and m_leftMargin.

1769 {
1770  int mul;
1771 
1772  if (event->modifiers() & Qt::ShiftModifier) {
1773  mul = 100;
1774  } else if (event->modifiers() & Qt::ControlModifier) {
1775  mul = 10;
1776  } else {
1777  mul = 1;
1778  }
1779 
1780  for (int i = 0; i < m_channelMarkerStates.size(); ++i)
1781  {
1782  if ((m_channelMarkerStates[i]->m_channelMarker->getSourceOrSinkStream() != m_displaySourceOrSink)
1783  || (m_channelMarkerStates[i]->m_channelMarker->getStreamIndex() != m_displayStreamIndex))
1784  {
1785  continue;
1786  }
1787 
1788  if (m_channelMarkerStates[i]->m_rect.contains(event->pos()))
1789  {
1790  int freq = m_channelMarkerStates[i]->m_channelMarker->getCenterFrequency();
1791 
1792  if (event->delta() > 0) {
1793  freq += 10 * mul;
1794  } else if (event->delta() < 0) {
1795  freq -= 10 * mul;
1796  }
1797 
1798  // calculate scale relative cursor position for new frequency
1799  float x_pos = m_frequencyScale.getPosFromValue(m_centerFrequency + freq);
1800 
1801  if ((x_pos >= 0.0) && (x_pos < m_frequencyScale.getSize())) // cursor must be in scale
1802  {
1803  m_channelMarkerStates[i]->m_channelMarker->setCenterFrequencyByCursor(freq);
1804  m_channelMarkerStates[i]->m_channelMarker->setCenterFrequency(freq);
1805 
1806  // cursor follow-up
1807  int xd = x_pos + m_leftMargin;
1808  QCursor c = cursor();
1809  QPoint cp_a = c.pos();
1810  QPoint cp_w = mapFromGlobal(cp_a);
1811  cp_w.setX(xd);
1812  cp_a = mapToGlobal(cp_w);
1813  c.setPos(cp_a);
1814  setCursor(c);
1815  }
1816  }
1817  }
1818 }
int m_displayStreamIndex
Definition: glspectrum.h:191
QList< ChannelMarkerState * > m_channelMarkerStates
Definition: glspectrum.h:120
float getPosFromValue(double value)
ScaleEngine m_frequencyScale
Definition: glspectrum.h:165
qint64 m_centerFrequency
Definition: glspectrum.h:138
float getSize()
Definition: scaleengine.h:80
bool m_displaySourceOrSink
Definition: glspectrum.h:190
int32_t i
Definition: decimators.h:244
int m_leftMargin
Definition: glspectrum.h:160
+ Here is the call graph for this function:

Member Data Documentation

◆ m_centerFrequency

qint64 GLSpectrum::m_centerFrequency
private

◆ m_changesPending

bool GLSpectrum::m_changesPending
private

◆ m_channelMarkerStates

QList<ChannelMarkerState*> GLSpectrum::m_channelMarkerStates
private

◆ m_colorLoc

int GLSpectrum::m_colorLoc
private

Definition at line 199 of file glspectrum.h.

◆ m_currentSpectrum

const std::vector<Real>* GLSpectrum::m_currentSpectrum
private

Definition at line 155 of file glspectrum.h.

Referenced by paintGL(), and updateHistogram().

◆ m_cursorChannel

int GLSpectrum::m_cursorChannel
private

Definition at line 131 of file glspectrum.h.

Referenced by mouseMoveEvent(), and mousePressEvent().

◆ m_cursorState

CursorState GLSpectrum::m_cursorState
private

Definition at line 130 of file glspectrum.h.

Referenced by mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), and stopDrag().

◆ m_decay

int GLSpectrum::m_decay
private

Definition at line 142 of file glspectrum.h.

Referenced by setDecay(), and updateHistogram().

◆ m_decayDivisor

int GLSpectrum::m_decayDivisor
private

Definition at line 183 of file glspectrum.h.

Referenced by setDecayDivisor(), and updateHistogram().

◆ m_decayDivisorCount

int GLSpectrum::m_decayDivisorCount
private

Definition at line 184 of file glspectrum.h.

Referenced by updateHistogram().

◆ m_displayChanged

bool GLSpectrum::m_displayChanged
private

Definition at line 189 of file glspectrum.h.

Referenced by newSpectrum(), and tick().

◆ m_displayCurrent

bool GLSpectrum::m_displayCurrent
private

Definition at line 156 of file glspectrum.h.

Referenced by applyChanges(), mouseMoveEvent(), paintGL(), and setDisplayCurrent().

◆ m_displayGrid

bool GLSpectrum::m_displayGrid
private

Definition at line 148 of file glspectrum.h.

Referenced by paintGL(), and setDisplayGrid().

◆ m_displayGridIntensity

int GLSpectrum::m_displayGridIntensity
private

Definition at line 149 of file glspectrum.h.

Referenced by paintGL(), and setDisplayGridIntensity().

◆ m_displayHistogram

bool GLSpectrum::m_displayHistogram
private

◆ m_displayMaxHold

bool GLSpectrum::m_displayMaxHold
private

◆ m_displaySourceOrSink

bool GLSpectrum::m_displaySourceOrSink
private

Definition at line 190 of file glspectrum.h.

Referenced by applyChanges(), mouseMoveEvent(), mousePressEvent(), paintGL(), and wheelEvent().

◆ m_displayStreamIndex

int GLSpectrum::m_displayStreamIndex
private

Definition at line 191 of file glspectrum.h.

Referenced by applyChanges(), mouseMoveEvent(), mousePressEvent(), paintGL(), and wheelEvent().

◆ m_displayTraceIntensity

int GLSpectrum::m_displayTraceIntensity
private

Definition at line 150 of file glspectrum.h.

Referenced by paintGL(), and setDisplayTraceIntensity().

◆ m_displayWaterfall

bool GLSpectrum::m_displayWaterfall
private

Definition at line 176 of file glspectrum.h.

Referenced by applyChanges(), mouseMoveEvent(), paintGL(), and setDisplayWaterfall().

◆ m_fftSize

int GLSpectrum::m_fftSize
private

◆ m_frequencyPixmap

QPixmap GLSpectrum::m_frequencyPixmap
private

Definition at line 162 of file glspectrum.h.

Referenced by applyChanges().

◆ m_frequencyScale

ScaleEngine GLSpectrum::m_frequencyScale
private

Definition at line 165 of file glspectrum.h.

Referenced by applyChanges(), mouseMoveEvent(), mousePressEvent(), paintGL(), and wheelEvent().

◆ m_frequencyScaleRect

QRect GLSpectrum::m_frequencyScaleRect
private

Definition at line 166 of file glspectrum.h.

Referenced by applyChanges(), and mouseMoveEvent().

◆ m_glFrequencyScaleBoxMatrix

QMatrix4x4 GLSpectrum::m_glFrequencyScaleBoxMatrix
private

Definition at line 167 of file glspectrum.h.

Referenced by applyChanges(), and paintGL().

◆ m_glHistogramBoxMatrix

QMatrix4x4 GLSpectrum::m_glHistogramBoxMatrix
private

Definition at line 187 of file glspectrum.h.

Referenced by applyChanges(), and paintGL().

◆ m_glHistogramSpectrumMatrix

QMatrix4x4 GLSpectrum::m_glHistogramSpectrumMatrix
private

Definition at line 186 of file glspectrum.h.

Referenced by applyChanges(), and paintGL().

◆ m_glLeftScaleBoxMatrix

QMatrix4x4 GLSpectrum::m_glLeftScaleBoxMatrix
private

Definition at line 168 of file glspectrum.h.

Referenced by applyChanges(), and paintGL().

◆ m_glShaderFrequencyScale

GLShaderTextured GLSpectrum::m_glShaderFrequencyScale
private

Definition at line 195 of file glspectrum.h.

Referenced by applyChanges(), cleanup(), initializeGL(), and paintGL().

◆ m_glShaderHistogram

GLShaderTextured GLSpectrum::m_glShaderHistogram
private

Definition at line 197 of file glspectrum.h.

Referenced by applyChanges(), cleanup(), initializeGL(), and paintGL().

◆ m_glShaderLeftScale

GLShaderTextured GLSpectrum::m_glShaderLeftScale
private

Definition at line 194 of file glspectrum.h.

Referenced by applyChanges(), cleanup(), initializeGL(), and paintGL().

◆ m_glShaderSimple

GLShaderSimple GLSpectrum::m_glShaderSimple
private

Definition at line 193 of file glspectrum.h.

Referenced by cleanup(), initializeGL(), and paintGL().

◆ m_glShaderWaterfall

GLShaderTextured GLSpectrum::m_glShaderWaterfall
private

Definition at line 196 of file glspectrum.h.

Referenced by applyChanges(), cleanup(), initializeGL(), and paintGL().

◆ m_glWaterfallBoxMatrix

QMatrix4x4 GLSpectrum::m_glWaterfallBoxMatrix
private

Definition at line 175 of file glspectrum.h.

Referenced by applyChanges(), and paintGL().

◆ m_histogram

quint8* GLSpectrum::m_histogram
private

Spectrum phosphor matrix of FFT width and PSD height scaled to 100. values [0..239].

Definition at line 182 of file glspectrum.h.

Referenced by applyChanges(), clearSpectrumHistogram(), paintGL(), updateHistogram(), and ~GLSpectrum().

◆ m_histogramBuffer

QImage* GLSpectrum::m_histogramBuffer
private

Definition at line 181 of file glspectrum.h.

Referenced by applyChanges(), paintGL(), and ~GLSpectrum().

◆ m_histogramPalette

QRgb GLSpectrum::m_histogramPalette[240]
private

Definition at line 180 of file glspectrum.h.

Referenced by paintGL().

◆ m_histogramStroke

int GLSpectrum::m_histogramStroke
private

Definition at line 185 of file glspectrum.h.

Referenced by setHistoStroke(), and updateHistogram().

◆ m_invertedWaterfall

bool GLSpectrum::m_invertedWaterfall
private

Definition at line 151 of file glspectrum.h.

Referenced by applyChanges(), mouseMoveEvent(), paintGL(), and setInvertedWaterfall().

◆ m_leftMargin

int GLSpectrum::m_leftMargin
private

Definition at line 160 of file glspectrum.h.

Referenced by applyChanges(), and wheelEvent().

◆ m_leftMarginPixmap

QPixmap GLSpectrum::m_leftMarginPixmap
private

Definition at line 161 of file glspectrum.h.

Referenced by applyChanges(), mouseMoveEvent(), and mousePressEvent().

◆ m_linear

bool GLSpectrum::m_linear
private

Definition at line 141 of file glspectrum.h.

Referenced by applyChanges(), and setLinear().

◆ m_lsbDisplay

bool GLSpectrum::m_lsbDisplay
private

Definition at line 178 of file glspectrum.h.

Referenced by applyChanges(), and setLsbDisplay().

◆ m_matrixLoc

int GLSpectrum::m_matrixLoc
private

Definition at line 198 of file glspectrum.h.

◆ m_maxHold

std::vector<Real> GLSpectrum::m_maxHold
private

Definition at line 153 of file glspectrum.h.

Referenced by paintGL().

◆ m_messageQueueToGUI

MessageQueue* GLSpectrum::m_messageQueueToGUI
private

Definition at line 205 of file glspectrum.h.

Referenced by setSampleRate().

◆ m_mouseInside

bool GLSpectrum::m_mouseInside
private

Definition at line 135 of file glspectrum.h.

Referenced by enterEvent(), leaveEvent(), and paintGL().

◆ m_mutex

QMutex GLSpectrum::m_mutex
private

◆ m_powerRange

Real GLSpectrum::m_powerRange
private

Definition at line 140 of file glspectrum.h.

Referenced by applyChanges(), paintGL(), setPowerRange(), updateHistogram(), and updateWaterfall().

◆ m_powerScale

ScaleEngine GLSpectrum::m_powerScale
private

Definition at line 164 of file glspectrum.h.

Referenced by applyChanges(), and paintGL().

◆ m_q3FFT

IncrementalArray<GLfloat> GLSpectrum::m_q3FFT
private

Definition at line 203 of file glspectrum.h.

Referenced by applyChanges(), and paintGL().

◆ m_q3TickFrequency

IncrementalArray<GLfloat> GLSpectrum::m_q3TickFrequency
private

Definition at line 201 of file glspectrum.h.

Referenced by applyChanges(), and paintGL().

◆ m_q3TickPower

IncrementalArray<GLfloat> GLSpectrum::m_q3TickPower
private

Definition at line 202 of file glspectrum.h.

Referenced by applyChanges(), and paintGL().

◆ m_q3TickTime

IncrementalArray<GLfloat> GLSpectrum::m_q3TickTime
private

Definition at line 200 of file glspectrum.h.

Referenced by applyChanges(), and paintGL().

◆ m_referenceLevel

Real GLSpectrum::m_referenceLevel
private

◆ m_sampleRate

quint32 GLSpectrum::m_sampleRate
private

Definition at line 143 of file glspectrum.h.

Referenced by applyChanges(), and setSampleRate().

◆ m_ssbSpectrum

bool GLSpectrum::m_ssbSpectrum
private

Definition at line 177 of file glspectrum.h.

Referenced by applyChanges(), and setSsbSpectrum().

◆ m_timer

QTimer GLSpectrum::m_timer
private

Definition at line 133 of file glspectrum.h.

Referenced by connectTimer().

◆ m_timeScale

ScaleEngine GLSpectrum::m_timeScale
private

Definition at line 163 of file glspectrum.h.

Referenced by applyChanges(), and paintGL().

◆ m_timingRate

quint32 GLSpectrum::m_timingRate
private

Definition at line 144 of file glspectrum.h.

Referenced by applyChanges(), and setTimingRate().

◆ m_waterfallBuffer

QImage* GLSpectrum::m_waterfallBuffer
private

Definition at line 171 of file glspectrum.h.

Referenced by applyChanges(), paintGL(), updateWaterfall(), and ~GLSpectrum().

◆ m_waterfallBufferHeight

const int GLSpectrum::m_waterfallBufferHeight = 256
staticprivate

Definition at line 207 of file glspectrum.h.

◆ m_waterfallBufferPos

int GLSpectrum::m_waterfallBufferPos
private

Definition at line 172 of file glspectrum.h.

Referenced by applyChanges(), paintGL(), and updateWaterfall().

◆ m_waterfallPalette

QRgb GLSpectrum::m_waterfallPalette[240]
private

Definition at line 170 of file glspectrum.h.

Referenced by updateWaterfall().

◆ m_waterfallShare

Real GLSpectrum::m_waterfallShare
private

Definition at line 158 of file glspectrum.h.

Referenced by applyChanges(), mouseMoveEvent(), and setWaterfallShare().

◆ m_waterfallTextureHeight

int GLSpectrum::m_waterfallTextureHeight
private

Definition at line 173 of file glspectrum.h.

Referenced by applyChanges(), and paintGL().

◆ m_waterfallTexturePos

int GLSpectrum::m_waterfallTexturePos
private

Definition at line 174 of file glspectrum.h.

Referenced by applyChanges(), and paintGL().


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