v2.0.0
Loading...
Searching...
No Matches
digitizersettreeitem.cpp
Go to the documentation of this file.
1//=============================================================================================================
12
13//=============================================================================================================
14// INCLUDES
15//=============================================================================================================
16
18#include "digitizertreeitem.h"
19
20#include <fiff/fiff_constants.h>
21
22#include <QVector3D>
23#include <QDebug>
24
25//=============================================================================================================
26// DEFINE MEMBER METHODS
27//=============================================================================================================
28
30 const QList<FIFFLIB::FiffDigPoint> &digitizerPoints)
31 : QStandardItem(text)
32{
33 setCheckable(true);
34 setCheckState(Qt::Checked);
35
36 // Categorize points by kind
37 // Cardinal points are further split by ident (Nasion, LPA, RPA) but grouped together
38 QVector<QVector3D> cardinalPos, hpiPos, eegPos, extraPos;
39 QStringList cardinalNames, hpiNames, eegNames, extraNames;
40
41 int hpiIdx = 0, eegIdx = 0, extraIdx = 0;
42
43 for (const auto &p : digitizerPoints) {
44 QVector3D pos(p.r[0], p.r[1], p.r[2]);
45
46 switch (p.kind) {
48 cardinalPos.append(pos);
49 if (p.ident == FIFFV_POINT_NASION)
50 cardinalNames.append("Nasion");
51 else if (p.ident == FIFFV_POINT_LPA)
52 cardinalNames.append("LPA");
53 else if (p.ident == FIFFV_POINT_RPA)
54 cardinalNames.append("RPA");
55 else
56 cardinalNames.append(QString("Cardinal %1").arg(p.ident));
57 break;
58 }
59 case FIFFV_POINT_HPI:
60 hpiPos.append(pos);
61 hpiNames.append(QString("HPI %1").arg(++hpiIdx));
62 break;
63 case FIFFV_POINT_EEG:
64 eegPos.append(pos);
65 eegNames.append(QString("EEG %1").arg(++eegIdx));
66 break;
68 extraPos.append(pos);
69 extraNames.append(QString("Extra %1").arg(++extraIdx));
70 break;
71 default:
72 extraPos.append(pos);
73 extraNames.append(QString("Unknown %1").arg(extraPos.size()));
74 break;
75 }
76 }
77
78 // Create child items for each non-empty category
79 // Color and size scheme matches disp3D conventions
80 if (!cardinalPos.isEmpty()) {
81 auto *item = new DigitizerTreeItem("Cardinal",
83 cardinalPos,
84 cardinalNames,
85 QColor(0, 255, 0), // Green
86 0.002f); // 2mm
87 appendRow(item);
88 qDebug() << "DigitizerSetTreeItem: Cardinal points:" << cardinalPos.size();
89 }
90
91 if (!hpiPos.isEmpty()) {
92 auto *item = new DigitizerTreeItem("HPI",
94 hpiPos,
95 hpiNames,
96 QColor(128, 0, 0), // DarkRed
97 0.003f); // 3mm - enlarged for better visibility
98 appendRow(item);
99 qDebug() << "DigitizerSetTreeItem: HPI points:" << hpiPos.size();
100 }
101
102 if (!eegPos.isEmpty()) {
103 auto *item = new DigitizerTreeItem("EEG",
105 eegPos,
106 eegNames,
107 QColor(0, 255, 255), // Cyan
108 0.001f); // 1mm
109 appendRow(item);
110 qDebug() << "DigitizerSetTreeItem: EEG dig points:" << eegPos.size();
111 }
112
113 if (!extraPos.isEmpty()) {
114 auto *item = new DigitizerTreeItem("Extra",
116 extraPos,
117 extraNames,
118 QColor(255, 0, 255), // Magenta
119 0.001f); // 1mm
120 appendRow(item);
121 qDebug() << "DigitizerSetTreeItem: Extra/head shape points:" << extraPos.size();
122 }
123}
124
125//=============================================================================================================
126
128{
129 for (int i = 0; i < rowCount(); ++i) {
130 DigitizerTreeItem *item = dynamic_cast<DigitizerTreeItem*>(child(i));
131 if (item && static_cast<int>(item->pointKind()) == kind) {
132 return item;
133 }
134 }
135 return nullptr;
136}
137
138//=============================================================================================================
139
141{
142 int count = 0;
143 for (int i = 0; i < rowCount(); ++i) {
144 DigitizerTreeItem *item = dynamic_cast<DigitizerTreeItem*>(child(i));
145 if (item) {
146 count += item->positions().size();
147 }
148 }
149 return count;
150}
Tree item holding a single category of digitizer points rendered as a batched-sphere mesh.
Container item that groups raw FIFF digitizer points by category (Cardinal, HPI, EEG,...
Symbolic FIFF tag, block, value, unit and channel-type constants shared across FIFFLIB.
#define FIFFV_POINT_EXTRA
#define FIFFV_POINT_CARDINAL
#define FIFFV_POINT_RPA
#define FIFFV_POINT_EEG
#define FIFFV_POINT_LPA
#define FIFFV_POINT_HPI
#define FIFFV_POINT_NASION
DigitizerTreeItem * categoryItem(int kind) const
DigitizerSetTreeItem(const QString &text, const QList< FIFFLIB::FiffDigPoint > &digitizerPoints)
Digitizer point group tree item.
PointKind pointKind() const
const QVector< QVector3D > & positions() const