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 <QVector3D>
36#include <vector>
37#include <memory>
39
40// Forward-declare QRhi types so that this header stays QRhi-free
41class QRhi;
42class QRhiBuffer;
43class QRhiResourceUpdateBatch;
44
45//=============================================================================================================
53{
54public:
57
58 void load(const INVLIB::InvEcdSet &ecdSet);
59
60 // Apply a transformation matrix to all dipoles
61 void applyTransform(const QMatrix4x4 &trans);
62
63 void updateBuffers(QRhi *rhi, QRhiResourceUpdateBatch *u);
64
65 QRhiBuffer* vertexBuffer() const;
66 QRhiBuffer* indexBuffer() const;
67 QRhiBuffer* instanceBuffer() const;
68
69 int indexCount() const { return m_indexCount; }
70 int instanceCount() const { return m_instanceCount; }
71
72 bool isVisible() const { return m_visible; }
73 void setVisible(bool visible) { m_visible = visible; }
74
75 QVector3D debugFirstDipolePosition() const; // For debugging
76
77 void setSelected(int index, bool selected);
78
79 //=========================================================================================================
88 int intersect(const QVector3D &rayOrigin, const QVector3D &rayDir, float &dist) const;
89
90private:
91 void createGeometry();
92
94 struct GpuBuffers;
95 std::unique_ptr<GpuBuffers> m_gpu;
96
97 int m_indexCount = 0;
98 int m_instanceCount = 0;
99 bool m_visible = true;
100
104 struct VertexData {
105 float x, y, z;
106 float nx, ny, nz;
107 };
108
112 // Instance data: Model Matrix (4x4) + Color (vec4)
113 struct InstanceData {
114 float model[16];
115 float color[4];
116 float isSelected; // 1.0 = selected, 0.0 = not
117 };
118
119 QByteArray m_vertexData;
120 QByteArray m_indexData;
121 QByteArray m_instanceData;
122
123 bool m_geometryDirty = false;
124 bool m_instancesDirty = false;
125
126 std::vector<QVector4D> m_originalColors;
127};
128
129#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.
Interleaved vertex attributes (position, normal, color, curvature) for brain surface GPU upload.
QRhiBuffer * instanceBuffer() const
int instanceCount() const
void updateBuffers(QRhi *rhi, QRhiResourceUpdateBatch *u)
int indexCount() const
void setVisible(bool visible)
void load(const INVLIB::InvEcdSet &ecdSet)
QRhiBuffer * indexBuffer() const
QRhiBuffer * vertexBuffer() const
void applyTransform(const QMatrix4x4 &trans)
bool isVisible() const
Holds a set of Electric Current Dipoles.
Definition inv_ecd_set.h:64