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 {
55};
56
57//=============================================================================================================
64enum class FiducialId {
65 LPA = 1,
66 NAS = 2,
67 RPA = 3
68};
69
70//=============================================================================================================
81
82//=============================================================================================================
89class UTILSSHARED_EXPORT AcquiredPoints : public QObject
90{
91 Q_OBJECT
92public:
93 explicit AcquiredPoints(QObject* parent = nullptr) : QObject(parent) {}
94
95 const QVector<DigitizedPoint>& points() const { return m_points; }
96
98 void append(const DigitizedPoint& p) {
99 m_points.append(p);
100 emit pointsChanged();
101 }
102
104 void undoLast(PointKind kind) {
105 for (int i = m_points.size() - 1; i >= 0; --i) {
106 if (m_points[i].kind == kind) {
107 m_points.removeAt(i);
108 emit pointsChanged();
109 return;
110 }
111 }
112 }
113
115 void clear() {
116 if (m_points.isEmpty()) return;
117 m_points.clear();
118 emit pointsChanged();
119 }
120
123 QVector3D fiducial(FiducialId id) const {
124 for (const auto& p : m_points) {
125 if (p.kind == PointKind::Fiducial && p.identNumber == static_cast<int>(id)) {
126 return p.position;
127 }
128 }
129 return {};
130 }
131
133 bool hasFiducial(FiducialId id) const {
134 for (const auto& p : m_points) {
135 if (p.kind == PointKind::Fiducial && p.identNumber == static_cast<int>(id)) {
136 return true;
137 }
138 }
139 return false;
140 }
141
144 for (int i = m_points.size() - 1; i >= 0; --i) {
145 if (m_points[i].kind == PointKind::Fiducial
146 && m_points[i].identNumber == static_cast<int>(id)) {
147 m_points.removeAt(i);
148 }
149 }
150 emit pointsChanged();
151 }
152
159
160 int countOf(PointKind kind) const {
161 int n = 0;
162 for (const auto& p : m_points) if (p.kind == kind) ++n;
163 return n;
164 }
165
166 void setPosition(int index, const QVector3D& pos) {
167 if (index >= 0 && index < m_points.size())
168 m_points[index].position = pos;
169 }
170
171 void emitChanged() { emit pointsChanged(); }
172
173 // ── Twin (BEM-space) fiducials — clicked on digital twin surface ──
174
175 void setTwinFiducial(FiducialId id, const QVector3D& pos) {
176 m_twinFiducials[static_cast<int>(id)] = pos;
177 emit pointsChanged();
178 }
179
181 m_twinFiducials.remove(static_cast<int>(id));
182 emit pointsChanged();
183 }
184
186 return m_twinFiducials.contains(static_cast<int>(id));
187 }
188
189 QVector3D twinFiducial(FiducialId id) const {
190 return m_twinFiducials.value(static_cast<int>(id));
191 }
192
198
199signals:
201
202private:
203 QVector<DigitizedPoint> m_points;
204 QMap<int, QVector3D> m_twinFiducials;
205};
206
207} // namespace UTILSLIB
208
209#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)