v2.0.0
Loading...
Searching...
No Matches
networkobject.h
Go to the documentation of this file.
1//=============================================================================================================
34
35#ifndef NETWORKOBJECT_H
36#define NETWORKOBJECT_H
37
38//=============================================================================================================
39// INCLUDES
40//=============================================================================================================
41
43
44#include <QMatrix4x4>
45#include <QVector3D>
46#include <QColor>
47#include <vector>
48#include <memory>
49
51
52// Forward-declare QRhi types so that this header stays QRhi-free
53class QRhi;
54class QRhiBuffer;
55class QRhiResourceUpdateBatch;
56
57//=============================================================================================================
65{
66public:
67 //=========================================================================================================
72
73 //=========================================================================================================
78
79 //=========================================================================================================
86 void load(const CONNECTIVITYLIB::Network &network, const QString &sColormap = "Viridis");
87
88 //=========================================================================================================
94 void setThreshold(double dThreshold);
95
96 //=========================================================================================================
102 void setColormap(const QString &sColormap);
103
104 //=========================================================================================================
111 void updateNodeBuffers(QRhi *rhi, QRhiResourceUpdateBatch *u);
112
113 //=========================================================================================================
120 void updateEdgeBuffers(QRhi *rhi, QRhiResourceUpdateBatch *u);
121
122 // ── Node accessors ──────────────────────────────────────────────────
123 QRhiBuffer* nodeVertexBuffer() const;
124 QRhiBuffer* nodeIndexBuffer() const;
125 QRhiBuffer* nodeInstanceBuffer() const;
126 int nodeIndexCount() const { return m_nodeIndexCount; }
127 int nodeInstanceCount() const { return m_nodeInstanceCount; }
128
129 // ── Edge accessors ──────────────────────────────────────────────────
130 QRhiBuffer* edgeVertexBuffer() const;
131 QRhiBuffer* edgeIndexBuffer() const;
132 QRhiBuffer* edgeInstanceBuffer() const;
133 int edgeIndexCount() const { return m_edgeIndexCount; }
134 int edgeInstanceCount() const { return m_edgeInstanceCount; }
135
136 // ── Visibility ──────────────────────────────────────────────────────
137 bool isVisible() const { return m_visible; }
138 void setVisible(bool visible) { m_visible = visible; }
139
140 bool hasData() const { return !m_network.isEmpty(); }
141
142private:
146 // Instance data: identical layout to DipoleObject for shader compatibility
147 // Model Matrix (4x4) + Color (vec4) + isSelected (float)
148 struct InstanceData {
149 float model[16];
150 float color[4];
151 float isSelected; // Always 0.0 for networks
152 };
153
157 struct VertexData {
158 float x, y, z;
159 float nx, ny, nz;
160 };
161
162 void createNodeGeometry();
163 void createEdgeGeometry();
164 void buildNodeInstances();
165 void buildEdgeInstances();
166
167 // ── Network data ────────────────────────────────────────────────────
168 CONNECTIVITYLIB::Network m_network;
169 QString m_colormap = "Viridis";
170
171 // ── Node GPU resources ──────────────────────────────────────────────
173 struct GpuBuffers;
174 std::unique_ptr<GpuBuffers> m_gpu;
175
176 QByteArray m_nodeVertexData;
177 QByteArray m_nodeIndexData;
178 QByteArray m_nodeInstanceData;
179 int m_nodeIndexCount = 0;
180 int m_nodeInstanceCount = 0;
181 bool m_nodeGeometryDirty = false;
182 bool m_nodeInstancesDirty = false;
183
184 // ── Edge GPU resources ──────────────────────────────────────────────
185 QByteArray m_edgeVertexData;
186 QByteArray m_edgeIndexData;
187 QByteArray m_edgeInstanceData;
188 int m_edgeIndexCount = 0;
189 int m_edgeInstanceCount = 0;
190 bool m_edgeGeometryDirty = false;
191 bool m_edgeInstancesDirty = false;
192
193 bool m_visible = true;
194};
195
196#endif // NETWORKOBJECT_H
disp3D_rhi library export/import macros.
#define DISP3DRHISHARED_EXPORT
Network class declaration.
This class holds information about a network, can compute a distance table and provide network metric...
Definition network.h:92
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)