QWT API (English) 7.3.0
Qt Widget Library for Technical Applications - English API Documentation
Loading...
Searching...
No Matches
qwt3d_waterfall_p.h
1#ifndef QWT3D_WATERFALL_P_H
2#define QWT3D_WATERFALL_P_H
3
4#include "qwt3d_waterfall.h"
5#include "qwt3d_types.h"
6#include "qwt3d_color.h"
7
8#include <QOpenGLBuffer>
9#include <QOpenGLVertexArrayObject>
10#include <QOpenGLShaderProgram>
11#include <QVector3D>
12#include <QVector4D>
13
14#include <vector>
15
16#include <cfloat>
17
24{
25 QVector3D position;
26 QVector4D color;
27};
28
35{
36 QVector3D position;
37 QVector3D normal;
38 QVector4D color;
39};
40
41class Qwt3DWaterfall::PrivateData
42{
43 QWT_DECLARE_PUBLIC(Qwt3DWaterfall)
44
45public:
46 explicit PrivateData(Qwt3DWaterfall* q);
47 ~PrivateData();
48
49 // Data / sliding window
50 //
51 // Traces are stored at the front indices [0, m_count), ordered oldest to
52 // newest. When the window is full a push rotates all slots down by one
53 // (O(capacity) cheap QVector moves, no deep copy) and writes the new trace
54 // into the last slot. The depth y of a trace is its slot index (possibly
55 // mirrored by the depth order), so the hull y-range only grows; the
56 // amplitude lives on z (3D module convention: value axis up).
57 std::vector< QVector<double> > m_traces;
58 int m_capacity;
59 int m_count;
60 int m_samplesPerTrace;
61 QVector<double> m_bins;
62
63 // Cached amplitude range over the stored traces
64 double m_dataMin;
65 double m_dataMax;
66
67 Qwt3DWaterfall::DepthOrder m_depthOrder;
68
69 // Style
71 Qwt3DWaterfall::ColorMode m_colorMode;
72 double m_opacity;
73 bool m_fixedBaseline;
74 double m_baseline;
75 RGBA m_solidColor;
76 RGBA m_outlineColor;
77 double m_outlineWidth;
78
79 // Fixed color range (ByAmplitude mode)
80 bool m_fixedColorRange;
81 double m_colorRangeMin;
82 double m_colorRangeMax;
83
84 // Color functor (owned)
85 Qwt3DColor* m_dataColor;
86
87 // GL resources (created lazily in draw())
88 bool m_ribbonDirty;
89 bool m_outlineDirty;
90 bool m_tubeDirty;
91 bool m_tubeShaderInitialized;
92 QOpenGLBuffer m_ribbonBuffer;
93 QOpenGLVertexArrayObject m_ribbonVAO;
94 int m_ribbonVertexCount; // total vertices, 2 * bins per slot
95 QOpenGLBuffer m_outlineBuffer;
96 QOpenGLVertexArrayObject m_outlineVAO;
97 int m_outlineVertexCount; // total vertices, bins per slot
98 QOpenGLBuffer m_tubeVertexBuffer;
99 QOpenGLBuffer m_tubeIndexBuffer;
100 QOpenGLVertexArrayObject m_tubeVAO;
101 QOpenGLShaderProgram m_tubeShader; // Tube style reuses the surface shader
102 int m_tubeIndexCount;
103
104 // Cached hull
105 ParallelEpiped m_hull;
106
107 // Recomputes m_dataMin/m_dataMax and m_hull from the stored traces
108 void recalculateRanges();
109};
110
111inline Qwt3DWaterfall::PrivateData::PrivateData(Qwt3DWaterfall* q)
112 : q_ptr(q)
113 , m_capacity(64)
114 , m_count(0)
115 , m_samplesPerTrace(0)
116 , m_dataMin(0.0)
117 , m_dataMax(0.0)
118 , m_depthOrder(Qwt3DWaterfall::NewestInFront)
119 , m_style(Qwt3DWaterfall::Ribbon)
120 , m_colorMode(Qwt3DWaterfall::ByDepth)
121 , m_opacity(1.0)
122 , m_fixedBaseline(false)
123 , m_baseline(0.0)
124 , m_solidColor(RGBA(0.65, 0.65, 0.75, 1.0))
125 , m_outlineColor(RGBA(0.15, 0.15, 0.15, 1.0))
126 , m_outlineWidth(1.0)
127 , m_fixedColorRange(false)
128 , m_colorRangeMin(0.0)
129 , m_colorRangeMax(1.0)
130 , m_dataColor(nullptr)
131 , m_ribbonDirty(true)
132 , m_outlineDirty(true)
133 , m_tubeDirty(true)
134 , m_tubeShaderInitialized(false)
135 , m_ribbonVertexCount(0)
136 , m_outlineVertexCount(0)
137 , m_tubeIndexCount(0)
138 , m_hull(Triple(0, 0, 0), Triple(0, 0, 0))
139{
140 m_traces.resize(m_capacity);
141 m_tubeIndexBuffer = QOpenGLBuffer(QOpenGLBuffer::IndexBuffer);
142}
143
144inline Qwt3DWaterfall::PrivateData::~PrivateData()
145{
146 m_ribbonBuffer.destroy();
147 m_ribbonVAO.destroy();
148 m_outlineBuffer.destroy();
149 m_outlineVAO.destroy();
150 m_tubeVertexBuffer.destroy();
151 m_tubeIndexBuffer.destroy();
152 m_tubeVAO.destroy();
153
154 if (m_dataColor)
155 m_dataColor->destroy();
156}
157
158#endif // QWT3D_WATERFALL_P_H
Definition qwt_clipper.h:41
Abstract base class for color functors.
Definition qwt3d_color.h:25
3D waterfall plot item with a built-in sliding window
Definition qwt3d_waterfall.h:42
ColorMode
Where the per-vertex color comes from.
Definition qwt3d_waterfall.h:57
PlotStyle
Geometry style of a trace.
Definition qwt3d_waterfall.h:48
DepthOrder
Depth direction of the sliding window.
Definition qwt3d_waterfall.h:65
Parallelepiped spanned by 2 Triples.
Definition qwt3d_types.h:334
Red-Green-Blue-Alpha value.
Definition qwt3d_types.h:395
Triple [x,y,z].
Definition qwt3d_types.h:201
Vertex for the Tube style (position + normal + color, 40 bytes)
Definition qwt3d_waterfall_p.h:35
Vertex for the Ribbon/RibbonMesh/Wireframe styles (position + color, 28 bytes)
Definition qwt3d_waterfall_p.h:24