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
25namespace DISP3DLIB
26{
27
28//=============================================================================================================
29// DEFINE MEMBER METHODS
30//=============================================================================================================
31
33 const QList<FIFFLIB::FiffDigPoint>& digitizerPoints)
34: QStandardItem(text)
35{
36 setCheckable(true);
37 setCheckState(Qt::Checked);
38
39 // Categorize points by kind
40 // Cardinal points are further split by ident (Nasion, LPA, RPA) but grouped together
41 QVector<QVector3D> cardinalPos, hpiPos, eegPos, extraPos;
42 QStringList cardinalNames, hpiNames, eegNames, extraNames;
43
44 int hpiIdx = 0, eegIdx = 0, extraIdx = 0;
45
46 for (const auto& p : digitizerPoints) {
47 QVector3D pos(p.r[0], p.r[1], p.r[2]);
48
49 switch (p.kind) {
51 cardinalPos.append(pos);
52 if (p.ident == FIFFV_POINT_NASION)
53 cardinalNames.append("Nasion");
54 else if (p.ident == FIFFV_POINT_LPA)
55 cardinalNames.append("LPA");
56 else if (p.ident == FIFFV_POINT_RPA)
57 cardinalNames.append("RPA");
58 else
59 cardinalNames.append(QString("Cardinal %1").arg(p.ident));
60 break;
61 }
62 case FIFFV_POINT_HPI:
63 hpiPos.append(pos);
64 hpiNames.append(QString("HPI %1").arg(++hpiIdx));
65 break;
66 case FIFFV_POINT_EEG:
67 eegPos.append(pos);
68 eegNames.append(QString("EEG %1").arg(++eegIdx));
69 break;
71 extraPos.append(pos);
72 extraNames.append(QString("Extra %1").arg(++extraIdx));
73 break;
74 default:
75 extraPos.append(pos);
76 extraNames.append(QString("Unknown %1").arg(extraPos.size()));
77 break;
78 }
79 }
80
81 // Create child items for each non-empty category
82 // Color and size scheme matches disp3D conventions
83 if (!cardinalPos.isEmpty()) {
84 auto* item = new DigitizerTreeItem("Cardinal",
86 cardinalPos,
87 cardinalNames,
88 QColor(0, 255, 0), // Green
89 0.002f); // 2mm
90 appendRow(item);
91 qDebug() << "DigitizerSetTreeItem: Cardinal points:" << cardinalPos.size();
92 }
93
94 if (!hpiPos.isEmpty()) {
95 auto* item = new DigitizerTreeItem("HPI",
97 hpiPos,
98 hpiNames,
99 QColor(128, 0, 0), // DarkRed
100 0.003f); // 3mm - enlarged for better visibility
101 appendRow(item);
102 qDebug() << "DigitizerSetTreeItem: HPI points:" << hpiPos.size();
103 }
104
105 if (!eegPos.isEmpty()) {
106 auto* item = new DigitizerTreeItem("EEG",
108 eegPos,
109 eegNames,
110 QColor(0, 255, 255), // Cyan
111 0.001f); // 1mm
112 appendRow(item);
113 qDebug() << "DigitizerSetTreeItem: EEG dig points:" << eegPos.size();
114 }
115
116 if (!extraPos.isEmpty()) {
117 auto* item = new DigitizerTreeItem("Extra",
119 extraPos,
120 extraNames,
121 QColor(255, 0, 255), // Magenta
122 0.001f); // 1mm
123 appendRow(item);
124 qDebug() << "DigitizerSetTreeItem: Extra/head shape points:" << extraPos.size();
125 }
126}
127
128//=============================================================================================================
129
131{
132 for (int i = 0; i < rowCount(); ++i) {
133 DigitizerTreeItem* item = dynamic_cast<DigitizerTreeItem*>(child(i));
134 if (item && static_cast<int>(item->pointKind()) == kind) {
135 return item;
136 }
137 }
138 return nullptr;
139}
140
141//=============================================================================================================
142
144{
145 int count = 0;
146 for (int i = 0; i < rowCount(); ++i) {
147 DigitizerTreeItem* item = dynamic_cast<DigitizerTreeItem*>(child(i));
148 if (item) {
149 count += item->positions().size();
150 }
151 }
152 return count;
153}
154
155} // namespace DISP3DLIB
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
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,...
3-D brain visualisation using the Qt RHI rendering backend.
DigitizerSetTreeItem(const QString &text, const QList< FIFFLIB::FiffDigPoint > &digitizerPoints)
DigitizerTreeItem * categoryItem(int kind) const
Digitizer point group tree item.
const QVector< QVector3D > & positions() const