v2.0.0
Loading...
Searching...
No Matches
acquired_points.h
Go to the documentation of this file.
1//=============================================================================================================
17
18#ifndef UTILS_ACQUIRED_POINTS_H
19#define UTILS_ACQUIRED_POINTS_H
20
21//=============================================================================================================
22// INCLUDES
23//=============================================================================================================
24
25#include "../utils_global.h"
26
27//=============================================================================================================
28// QT INCLUDES
29//=============================================================================================================
30
31#include <QMap>
32#include <QObject>
33#include <QString>
34#include <QVector>
35#include <QVector3D>
36
37//=============================================================================================================
38// DEFINE NAMESPACE UTILSLIB
39//=============================================================================================================
40
41namespace UTILSLIB
42{
43
44//=============================================================================================================
51enum class PointKind
52{
56};
57
58//=============================================================================================================
65enum class FiducialId
66{
67 LPA = 1,
68 NAS = 2,
69 RPA = 3
70};
71
72//=============================================================================================================
85
86//=============================================================================================================
95class UTILSSHARED_EXPORT AcquiredPoints : public QObject
96{
97 Q_OBJECT
98public:
99 explicit AcquiredPoints(QObject* parent = nullptr)
100 : QObject(parent)
101 {
102 }
103
104 const QVector<DigitizedPoint>& points() const
105 {
106 return m_points;
107 }
108
114 void append(const DigitizedPoint& p)
115 {
116 m_points.append(p);
117 emit pointsChanged();
118 }
119
126 {
127 for (int i = m_points.size() - 1; i >= 0; --i) {
128 if (m_points[i].kind == kind) {
129 m_points.removeAt(i);
130 emit pointsChanged();
131 return;
132 }
133 }
134 }
135
137 void clear()
138 {
139 if (m_points.isEmpty())
140 return;
141 m_points.clear();
142 emit pointsChanged();
143 }
144
152 QVector3D fiducial(FiducialId id) const
153 {
154 for (const auto& p : m_points) {
155 if (p.kind == PointKind::Fiducial && p.identNumber == static_cast<int>(id)) {
156 return p.position;
157 }
158 }
159 return {};
160 }
161
169 bool hasFiducial(FiducialId id) const
170 {
171 for (const auto& p : m_points) {
172 if (p.kind == PointKind::Fiducial && p.identNumber == static_cast<int>(id)) {
173 return true;
174 }
175 }
176 return false;
177 }
178
185 {
186 for (int i = m_points.size() - 1; i >= 0; --i) {
187 if (m_points[i].kind == PointKind::Fiducial && m_points[i].identNumber == static_cast<int>(id)) {
188 m_points.removeAt(i);
189 }
190 }
191 emit pointsChanged();
192 }
193
203
204 int countOf(PointKind kind) const
205 {
206 int n = 0;
207 for (const auto& p : m_points)
208 if (p.kind == kind)
209 ++n;
210 return n;
211 }
212
213 void setPosition(int index, const QVector3D& pos)
214 {
215 if (index >= 0 && index < m_points.size())
216 m_points[index].position = pos;
217 }
218
220 {
221 emit pointsChanged();
222 }
223
224 // ── Twin (BEM-space) fiducials — clicked on digital twin surface ──
225
226 void setTwinFiducial(FiducialId id, const QVector3D& pos)
227 {
228 m_twinFiducials[static_cast<int>(id)] = pos;
229 emit pointsChanged();
230 }
231
233 {
234 m_twinFiducials.remove(static_cast<int>(id));
235 emit pointsChanged();
236 }
237
239 {
240 return m_twinFiducials.contains(static_cast<int>(id));
241 }
242
243 QVector3D twinFiducial(FiducialId id) const
244 {
245 return m_twinFiducials.value(static_cast<int>(id));
246 }
247
252
253signals:
255
256private:
257 QVector<DigitizedPoint> m_points;
258 QMap<int, QVector3D> m_twinFiducials;
259};
260
261} // namespace UTILSLIB
262
263#endif // UTILS_ACQUIRED_POINTS_H
Public umbrella header for UTILSLIB exposing the UTILSSHARED_EXPORT macro and build-info accessors.
#define UTILSSHARED_EXPORT
Shared utilities (I/O helpers, spectral analysis, layout management, warp algorithms).
FiducialId
Identifier for the three cardinal fiducials.
PointKind
Logical category of a captured point.
@ HeadShape
Free head-shape point (continuous mode).
@ Eeg
Named EEG electrode contact.
@ Fiducial
Anatomical landmark (NAS / LPA / RPA).
A single digitised point captured during the alignment session.
QString label
Human label ("NAS", "Cz", "HSP-42", …).
QVector3D position
Position in metres, sensor frame.
int identNumber
1-based id used by FIFF on export.
bool hasFiducial(FiducialId id) const
void setPosition(int index, const QVector3D &pos)
bool hasTwinFiducial(FiducialId id) const
void append(const DigitizedPoint &p)
QVector3D fiducial(FiducialId id) const
void undoLast(PointKind kind)
int countOf(PointKind kind) const
void setTwinFiducial(FiducialId id, const QVector3D &pos)
QVector3D twinFiducial(FiducialId id) const
const QVector< DigitizedPoint > & points() const
void clearTwinFiducial(FiducialId id)
void removeFiducial(FiducialId id)
AcquiredPoints(QObject *parent=nullptr)