v2.0.0
Loading...
Searching...
No Matches
polylineobject.h
Go to the documentation of this file.
1//=============================================================================================================
22
23#ifndef DISP3DLIB_POLYLINEOBJECT_H
24#define DISP3DLIB_POLYLINEOBJECT_H
25
26//=============================================================================================================
27// INCLUDES
28//=============================================================================================================
29
30#include "../disp3D_global.h"
31
32//=============================================================================================================
33// QT INCLUDES
34//=============================================================================================================
35
36#include <QByteArray>
37#include <QColor>
38#include <QString>
39#include <QVector>
40
41#include <memory>
42
43//=============================================================================================================
44// EIGEN INCLUDES
45//=============================================================================================================
46
47#include <Eigen/Core>
48
49//=============================================================================================================
50// FORWARD DECLARATIONS
51//=============================================================================================================
52
53class QRhi;
54class QRhiBuffer;
55class QRhiResourceUpdateBatch;
56
57//=============================================================================================================
58// DEFINE CLASS
59//=============================================================================================================
60
61// Deliberately at global scope, matching DipoleObject and NetworkObject. The
62// other renderables in this directory are not namespaced either.
63
64namespace DISP3DLIB
65{
66
67//=============================================================================================================
80{
81public:
82 //=========================================================================================================
87
88 //=========================================================================================================
93
94 //=========================================================================================================
103 void setPoints(const QVector<Eigen::Vector3f>& vecPoints);
104
105 //=========================================================================================================
109 void clear();
110
111 //=========================================================================================================
117 void setRadius(float fRadius);
118
119 //=========================================================================================================
129 void setGradient(const QColor& startColor, const QColor& endColor);
130
131 //=========================================================================================================
138 void updateBuffers(QRhi* rhi, QRhiResourceUpdateBatch* u);
139
140 //=========================================================================================================
144 QRhiBuffer* vertexBuffer() const;
145
146 //=========================================================================================================
150 QRhiBuffer* indexBuffer() const;
151
152 //=========================================================================================================
156 QRhiBuffer* instanceBuffer() const;
157
158 //=========================================================================================================
162 int indexCount() const
163 {
164 return m_iIndexCount;
165 }
166
167 //=========================================================================================================
171 int instanceCount() const
172 {
173 return m_iInstanceCount;
174 }
175
176 //=========================================================================================================
180 bool isVisible() const
181 {
182 return m_bVisible;
183 }
184
185 //=========================================================================================================
191 void setVisible(bool bVisible)
192 {
193 m_bVisible = bVisible;
194 }
195
196 //=========================================================================================================
200 bool hasData() const
201 {
202 return m_iInstanceCount > 0;
203 }
204
205private:
206 //=========================================================================================================
210 void createSegmentGeometry();
211
212 //=========================================================================================================
216 void buildInstances();
217
218 // Instance layout shared with DipoleObject and NetworkObject so that the
219 // Dipole pipeline can render this object unchanged.
220 struct InstanceData
221 {
222 float model[16];
223 float color[4];
224 float isSelected;
225 };
226
227 struct VertexData
228 {
229 float x, y, z;
230 float nx, ny, nz;
231 };
232
233 QVector<Eigen::Vector3f> m_vecPoints;
234
235 QByteArray m_vertexData;
236 QByteArray m_indexData;
237 QByteArray m_instanceData;
238
239 int m_iIndexCount;
240 int m_iInstanceCount;
241
242 float m_fRadius;
243 QColor m_startColor;
244 QColor m_endColor;
245
246 bool m_bVisible;
247 bool m_bGeometryDirty;
248 bool m_bInstancesDirty;
249
250 struct GpuResources;
251 std::unique_ptr<GpuResources> m_gpu;
252};
253
254} // namespace DISP3DLIB
255
256#endif // DISP3DLIB_POLYLINEOBJECT_H
Library export/import macros and namespace marker for the disp3D library.
#define DISP3DSHARED_EXPORT
3-D brain visualisation using the Qt RHI rendering backend.
void updateBuffers(QRhi *rhi, QRhiResourceUpdateBatch *u)
QRhiBuffer * instanceBuffer() const
void setVisible(bool bVisible)
QRhiBuffer * indexBuffer() const
void setRadius(float fRadius)
void setGradient(const QColor &startColor, const QColor &endColor)
QRhiBuffer * vertexBuffer() const
void setPoints(const QVector< Eigen::Vector3f > &vecPoints)