v2.0.0
Loading...
Searching...
No Matches
networkobject.h
Go to the documentation of this file.
1//=============================================================================================================
24
25#ifndef NETWORKOBJECT_H
26#define NETWORKOBJECT_H
27
28//=============================================================================================================
29// INCLUDES
30//=============================================================================================================
31
32#include "../disp3D_global.h"
33
34#include <QMatrix4x4>
35#include <QVector3D>
36#include <QColor>
37#include <vector>
38#include <memory>
39
41
42// Forward-declare QRhi types so that this header stays QRhi-free
43class QRhi;
44class QRhiBuffer;
45class QRhiResourceUpdateBatch;
46
47//=============================================================================================================
55{
56public:
57 //=========================================================================================================
62
63 //=========================================================================================================
68
69 //=========================================================================================================
76 void load(const CONNECTIVITYLIB::Network &network, const QString &sColormap = "Viridis");
77
78 //=========================================================================================================
84 void setThreshold(double dThreshold);
85
86 //=========================================================================================================
92 void setColormap(const QString &sColormap);
93
94 //=========================================================================================================
101 void updateNodeBuffers(QRhi *rhi, QRhiResourceUpdateBatch *u);
102
103 //=========================================================================================================
110 void updateEdgeBuffers(QRhi *rhi, QRhiResourceUpdateBatch *u);
111
112 // ── Node accessors ──────────────────────────────────────────────────
113 QRhiBuffer* nodeVertexBuffer() const;
114 QRhiBuffer* nodeIndexBuffer() const;
115 QRhiBuffer* nodeInstanceBuffer() const;
116 int nodeIndexCount() const { return m_nodeIndexCount; }
117 int nodeInstanceCount() const { return m_nodeInstanceCount; }
118
119 // ── Edge accessors ──────────────────────────────────────────────────
120 QRhiBuffer* edgeVertexBuffer() const;
121 QRhiBuffer* edgeIndexBuffer() const;
122 QRhiBuffer* edgeInstanceBuffer() const;
123 int edgeIndexCount() const { return m_edgeIndexCount; }
124 int edgeInstanceCount() const { return m_edgeInstanceCount; }
125
126 // ── Visibility ──────────────────────────────────────────────────────
127 bool isVisible() const { return m_visible; }
128 void setVisible(bool visible) { m_visible = visible; }
129
130 bool hasData() const { return !m_network.isEmpty(); }
131
132private:
136 // Instance data: identical layout to DipoleObject for shader compatibility
137 // Model Matrix (4x4) + Color (vec4) + isSelected (float)
138 struct InstanceData {
139 float model[16];
140 float color[4];
141 float isSelected; // Always 0.0 for networks
142 };
143
147 struct VertexData {
148 float x, y, z;
149 float nx, ny, nz;
150 };
151
152 void createNodeGeometry();
153 void createEdgeGeometry();
154 void buildNodeInstances();
155 void buildEdgeInstances();
156
157 // ── Network data ────────────────────────────────────────────────────
158 CONNECTIVITYLIB::Network m_network;
159 QString m_colormap = "Viridis";
160
161 // ── Node GPU resources ──────────────────────────────────────────────
163 struct GpuBuffers;
164 std::unique_ptr<GpuBuffers> m_gpu;
165
166 QByteArray m_nodeVertexData;
167 QByteArray m_nodeIndexData;
168 QByteArray m_nodeInstanceData;
169 int m_nodeIndexCount = 0;
170 int m_nodeInstanceCount = 0;
171 bool m_nodeGeometryDirty = false;
172 bool m_nodeInstancesDirty = false;
173
174 // ── Edge GPU resources ──────────────────────────────────────────────
175 QByteArray m_edgeVertexData;
176 QByteArray m_edgeIndexData;
177 QByteArray m_edgeInstanceData;
178 int m_edgeIndexCount = 0;
179 int m_edgeInstanceCount = 0;
180 bool m_edgeGeometryDirty = false;
181 bool m_edgeInstancesDirty = false;
182
183 bool m_visible = true;
184};
185
186#endif // NETWORKOBJECT_H
Library export/import macros and namespace marker for the disp3D library.
#define DISP3DSHARED_EXPORT
Graph container that stores the result of one functional-connectivity metric as nodes (sources/sensor...
Graph container for one connectivity metric; nodes + weighted edges + threshold/visualisation state.
Definition network.h:98
QRhiBuffer * nodeIndexBuffer() const
int nodeInstanceCount() const
int edgeIndexCount() const
void setColormap(const QString &sColormap)
void updateNodeBuffers(QRhi *rhi, QRhiResourceUpdateBatch *u)
void setVisible(bool visible)
bool isVisible() const
void setThreshold(double dThreshold)
void load(const CONNECTIVITYLIB::Network &network, const QString &sColormap="Viridis")
QRhiBuffer * nodeInstanceBuffer() const
int edgeInstanceCount() const
bool hasData() const
int nodeIndexCount() const
QRhiBuffer * nodeVertexBuffer() const
void updateEdgeBuffers(QRhi *rhi, QRhiResourceUpdateBatch *u)