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.
glscope.h
Go to the documentation of this file.
1 // Copyright (C) 2017 F4EXB //
3 // written by Edouard Griffiths //
4 // //
5 // This program is free software; you can redistribute it and/or modify //
6 // it under the terms of the GNU General Public License as published by //
7 // the Free Software Foundation as version 3 of the License, or //
8 // (at your option) any later version. //
9 // //
10 // This program is distributed in the hope that it will be useful, //
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
13 // GNU General Public License V3 for more details. //
14 // //
15 // You should have received a copy of the GNU General Public License //
16 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
18 
19 #ifndef SDRBASE_GUI_GLSCOPENG_H_
20 #define SDRBASE_GUI_GLSCOPENG_H_
21 
22 #include <QGLWidget>
23 #include <QPen>
24 #include <QTimer>
25 #include <QMutex>
26 #include <QFont>
27 #include <QMatrix4x4>
28 #include <QAtomicInt>
29 
30 #include "dsp/dsptypes.h"
31 #include "dsp/scopevis.h"
32 #include "gui/scaleengine.h"
33 #include "gui/glshadersimple.h"
34 #include "gui/glshadertextured.h"
35 #include "export.h"
36 #include "util/bitfieldindex.h"
37 #include "util/incrementalarray.h"
38 
39 class QPainter;
40 
41 class SDRGUI_API GLScope: public QGLWidget {
42  Q_OBJECT
43 
44 public:
45  enum DisplayMode {
50  DisplayPol
51  };
52 
53  GLScope(QWidget* parent = 0);
54  virtual ~GLScope();
55 
56  void connectTimer(const QTimer& timer);
57 
58  void setTraces(std::vector<ScopeVis::TraceData>* tracesData, std::vector<float *>* traces);
59  void newTraces(std::vector<float *>* traces);
60  void newTraces(std::vector<float *>* traces, int traceIndex);
61 
62  int getSampleRate() const { return m_sampleRate; }
63  int getTraceSize() const { return m_traceSize; }
64 
65  void setTriggerPre(uint32_t triggerPre, bool emitSignal = false);
66  void setTimeOfsProMill(int timeOfsProMill);
67  void setSampleRate(int sampleRate);
68  void setTimeBase(int timeBase);
69  void setFocusedTraceIndex(uint32_t traceIndex);
70  void setDisplayMode(DisplayMode displayMode);
71  void setTraceSize(int trceSize, bool emitSignal = false);
72  void updateDisplay();
73  void setDisplayGridIntensity(int intensity);
74  void setDisplayTraceIntensity(int intensity);
75  void setFocusedTriggerData(ScopeVis::TriggerData& triggerData) { m_focusedTriggerData = triggerData; }
76  void setConfigChanged() { m_configChanged = true; }
77  //void incrementTraceCounter() { m_traceCounter++; }
78 
79  bool getDataChanged() const { return m_dataChanged; }
80  DisplayMode getDisplayMode() const { return m_displayMode; }
81  void setDisplayXYPoints(bool value) { m_displayXYPoints = value; }
82  const QAtomicInt& getProcessingTraceIndex() const { return m_processingTraceIndex; }
83 
84 signals:
85  void sampleRateChanged(int);
86  void traceSizeChanged(uint32_t);
87  void preTriggerChanged(uint32_t);
88 
89 private:
90  std::vector<ScopeVis::TraceData> *m_tracesData;
91  std::vector<float *> *m_traces;
94  //int m_traceCounter;
97  QTimer m_timer;
98  QMutex m_mutex;
99  QAtomicInt m_dataChanged;
108 
109  // graphics stuff
112  QMatrix4x4 m_glScopeMatrix1;
113  QMatrix4x4 m_glScopeMatrix2;
119 
126 
130 
135 
137 
144 
150 
151  static const int m_topMargin = 5;
152  static const int m_botMargin = 20;
153  static const int m_leftMargin = 35;
154  static const int m_rightMargin = 5;
155 
156  void initializeGL();
157  void resizeGL(int width, int height);
158  void paintGL();
159 
160  void applyConfig();
161  void setYScale(ScaleEngine& scale, uint32_t highlightedTraceIndex);
162  void setUniqueDisplays();
163  void setVerticalDisplays();
164  void setHorizontalDisplays();
165  void setPolarDisplays();
166 
167  void drawChannelOverlay(
168  const QString& text,
169  const QColor& color,
170  QPixmap& channelOverlayPixmap,
171  const QRectF& glScopeRect);
172 
173 protected slots:
174  void cleanup();
175  void tick();
176 
177 };
178 
179 #endif /* SDRBASE_GUI_GLSCOPENG_H_ */
bool getDataChanged() const
Definition: glscope.h:79
int m_timeOffset
Definition: glscope.h:106
QAtomicInt m_dataChanged
Definition: glscope.h:99
QTimer m_timer
Definition: glscope.h:97
QPixmap m_left1ScalePixmap
Definition: glscope.h:120
QPixmap m_bot2ScalePixmap
Definition: glscope.h:123
QMatrix4x4 m_glBot2ScaleMatrix
Definition: glscope.h:118
ScaleEngine m_x2Scale
Display #2 X scale. Time scale.
Definition: glscope.h:132
uint32_t m_focusedTraceIndex
Definition: glscope.h:107
QPixmap m_channelOverlayPixmap1
Definition: glscope.h:124
ScaleEngine m_y1Scale
Display #1 Y scale. Always connected to trace #0 (X trace)
Definition: glscope.h:133
GLShaderSimple m_glShaderSimple
Definition: glscope.h:138
std::vector< float * > * m_traces
Definition: glscope.h:91
IncrementalArray< GLfloat > m_q3TickY1
Definition: glscope.h:146
int m_traceSize
Definition: glscope.h:104
GLShaderTextured m_glShaderBottom1Scale
Definition: glscope.h:140
int m_displayGridIntensity
Definition: glscope.h:127
DisplayMode m_displayMode
Definition: glscope.h:96
uint32_t m_triggerPre
Definition: glscope.h:103
QMatrix4x4 m_glScopeMatrix1
Definition: glscope.h:112
void setDisplayXYPoints(bool value)
Definition: glscope.h:81
void setFocusedTriggerData(ScopeVis::TriggerData &triggerData)
Definition: glscope.h:75
unsigned int uint32_t
Definition: rtptypes_win.h:46
IncrementalArray< GLfloat > m_q3TickY2
Definition: glscope.h:147
#define SDRGUI_API
Definition: export.h:52
DisplayMode getDisplayMode() const
Definition: glscope.h:80
void setConfigChanged()
Definition: glscope.h:76
bool m_displayXYPoints
Definition: glscope.h:129
QPixmap m_left2ScalePixmap
Definition: glscope.h:121
ScopeVis::TriggerData m_focusedTriggerData
Definition: glscope.h:93
GLShaderTextured m_glShaderLeft1Scale
Definition: glscope.h:139
int m_displayTraceIntensity
Definition: glscope.h:128
QFont m_channelOverlayFont
Definition: glscope.h:136
uint32_t m_bufferIndex
Definition: glscope.h:95
QMatrix4x4 m_glBot1ScaleMatrix
Definition: glscope.h:117
GLShaderTextured m_glShaderLeft2Scale
Definition: glscope.h:141
IncrementalArray< GLfloat > m_q3TickX2
Definition: glscope.h:149
int getTraceSize() const
Definition: glscope.h:63
IncrementalArray< GLfloat > m_q3TickX1
Definition: glscope.h:148
GLShaderTextured m_glShaderPowerOverlay
Definition: glscope.h:143
QMatrix4x4 m_glRight1ScaleMatrix
Definition: glscope.h:115
QAtomicInt m_processingTraceIndex
Definition: glscope.h:92
QPixmap m_channelOverlayPixmap2
Definition: glscope.h:125
QMutex m_mutex
Definition: glscope.h:98
int getSampleRate() const
Definition: glscope.h:62
int m_sampleRate
Definition: glscope.h:101
GLShaderTextured m_glShaderBottom2Scale
Definition: glscope.h:142
int m_timeBase
Definition: glscope.h:105
bool m_configChanged
Definition: glscope.h:100
const QAtomicInt & getProcessingTraceIndex() const
Definition: glscope.h:82
QRectF m_glScopeRect1
Definition: glscope.h:110
QPixmap m_bot1ScalePixmap
Definition: glscope.h:122
int m_timeOfsProMill
Definition: glscope.h:102
std::vector< ScopeVis::TraceData > * m_tracesData
Definition: glscope.h:90
ScaleEngine m_y2Scale
Display #2 Y scale. Connected to highlighted Y trace (#1..n)
Definition: glscope.h:134
QMatrix4x4 m_glScopeMatrix2
Definition: glscope.h:113
QRectF m_glScopeRect2
Definition: glscope.h:111
ScaleEngine m_x1Scale
Display #1 X scale. Time scale.
Definition: glscope.h:131
QMatrix4x4 m_glLeft2ScaleMatrix
Definition: glscope.h:116
QMatrix4x4 m_glLeft1ScaleMatrix
Definition: glscope.h:114
DisplayMode
Definition: glscope.h:45
IncrementalArray< GLfloat > m_q3Polar
Definition: glscope.h:145