v2.0.0
Loading...
Searching...
No Matches
dipoleobject.h
Go to the documentation of this file.
1//=============================================================================================================
24
25#ifndef DIPOLEOBJECT_H
26#define DIPOLEOBJECT_H
27
28//=============================================================================================================
29// INCLUDES
30//=============================================================================================================
31
32#include "../disp3D_global.h"
33
34#include <QMatrix4x4>
35#include <QVector>
36#include <QVector3D>
37#include <vector>
38#include <memory>
40
41// Forward-declare QRhi types so that this header stays QRhi-free
42class QRhi;
43class QRhiBuffer;
44class QRhiResourceUpdateBatch;
45
46namespace DISP3DLIB
47{
48
49//=============================================================================================================
59{
60public:
63
64 void load(const INVLIB::InvEcdSet& ecdSet);
65
66 // Place all loaded dipoles with this transform (replaces any previous one)
67 void applyTransform(const QMatrix4x4& trans);
68
69 void updateBuffers(QRhi* rhi, QRhiResourceUpdateBatch* u);
70
71 QRhiBuffer* vertexBuffer() const;
72 QRhiBuffer* indexBuffer() const;
73 QRhiBuffer* instanceBuffer() const;
74
75 int indexCount() const
76 {
77 return m_indexCount;
78 }
79 int instanceCount() const
80 {
81 return m_instanceCount;
82 }
83
84 bool isVisible() const
85 {
86 return m_visible;
87 }
88 void setVisible(bool visible)
89 {
90 m_visible = visible;
91 }
92
93 //=========================================================================================================
101 bool boundingBox(QVector3D& min, QVector3D& max) const;
102
103 void setSelected(int index, bool selected);
104
105 //=========================================================================================================
114 int intersect(const QVector3D& rayOrigin, const QVector3D& rayDir, float& dist) const;
115
116private:
117 void createGeometry();
118
120 struct GpuBuffers;
121 std::unique_ptr<GpuBuffers> m_gpu;
122
123 int m_indexCount = 0;
124 int m_instanceCount = 0;
125 bool m_visible = true;
126
130 struct VertexData
131 {
132 float x, y, z;
133 float nx, ny, nz;
134 };
135
139 // Instance data: Model Matrix (4x4) + Color (vec4)
140 struct InstanceData
141 {
142 float model[16];
143 float color[4];
144 float isSelected; // 1.0 = selected, 0.0 = not
145 };
146
147 QByteArray m_vertexData;
148 QByteArray m_indexData;
149 QByteArray m_instanceData;
150 QVector<QMatrix4x4> m_loadedModels;
151
152 bool m_geometryDirty = false;
153 bool m_instancesDirty = false;
154
155 std::vector<QVector4D> m_originalColors;
156};
157
158} // namespace DISP3DLIB
159
160#endif // DIPOLEOBJECT_H
Library export/import macros and namespace marker for the disp3D library.
#define DISP3DSHARED_EXPORT
Ordered set of INVLIB::InvEcd records — the result of a sequential dipole-fit run.
3-D brain visualisation using the Qt RHI rendering backend.
Interleaved vertex attributes (position, normal, color, curvature) for brain surface GPU upload.
QRhiBuffer * indexBuffer() const
void load(const INVLIB::InvEcdSet &ecdSet)
void updateBuffers(QRhi *rhi, QRhiResourceUpdateBatch *u)
void applyTransform(const QMatrix4x4 &trans)
void setVisible(bool visible)
QRhiBuffer * vertexBuffer() const
QRhiBuffer * instanceBuffer() const
Holds a set of Electric Current Dipoles.
Definition inv_ecd_set.h:67