41 #include "../common/metatreeitem.h"
42 #include "../../workers/rtSensorData/rtsensordatacontroller.h"
43 #include "../common/gpuinterpolationitem.h"
44 #include "../common/abstractmeshtreeitem.h"
45 #include "../../3dhelpers/custommesh.h"
46 #include "../../materials/pervertexphongalphamaterial.h"
55 #include <QGeometryRenderer>
56 #include <Qt3DCore/QTransform>
68 using namespace Eigen;
69 using namespace FIFFLIB;
70 using namespace DISP3DLIB;
71 using namespace MNELIB;
81 SensorDataTreeItem::SensorDataTreeItem(
int iType,
85 , m_bIsDataInit(false)
103 const QString &sSensorType,
104 Qt3DCore::QEntity* p3DEntityParent)
107 qDebug(
"SensorDataTreeItem::initData - Item is already initialized");
110 this->
setData(0, Data3DTreeModelItemRoles::Data);
113 fiff_int_t sensorTypeFiffConstant;
114 if (sSensorType.toStdString() ==
"MEG") {
115 sensorTypeFiffConstant = FIFFV_MEG_CH;
116 }
else if (sSensorType.toStdString() ==
"EEG") {
117 sensorTypeFiffConstant = FIFFV_EEG_CH;
119 qDebug() <<
"SensorDataTreeItem::initData - unknown sensor type. Returning ...";
125 QVector<Vector3f> vecSensorPos;
129 if(info.
kind == sensorTypeFiffConstant &&
130 (info.
unit == FIFF_UNIT_T || info.
unit == FIFF_UNIT_V)) {
131 vecSensorPos.push_back(info.
chpos.
r0);
140 for(
const QString &bad : fiffInfo.
bads) {
148 Data3DTreeModelItemTypes::GpuInterpolationItem,
149 QStringLiteral(
"3D Plot"));
155 QList<QStandardItem*> list;
158 this->appendRow(list);
171 Data3DTreeModelItemTypes::AbstractMeshItem,
172 QStringLiteral(
"3D Plot"));
181 Qt3DRender::QGeometryRenderer::Triangles);
183 QList<QStandardItem*> list;
186 this->appendRow(list);
202 sensorTypeFiffConstant);
213 qDebug() <<
"SensorDataTreeItem::addData - item has not been initialized yet!";
219 if(tSensorData.rows() > iSensorSize)
221 MatrixXd dSmallSensorData(iSensorSize, tSensorData.cols());
222 for(
int i = 0 ; i < iSensorSize; ++i)
226 dSmallSensorData.row(i).setZero();
233 data.setValue(dSmallSensorData);
234 this->
setData(data, Data3DTreeModelItemRoles::Data);
242 MatrixXd dSmallSensorData = tSensorData;
243 for(
int i = 0 ; i < dSmallSensorData.rows(); ++i)
246 dSmallSensorData.row(i).setZero();
252 data.setValue(dSmallSensorData);
253 this->
setData(data, Data3DTreeModelItemRoles::Data);
264 QList<QStandardItem*> lItems = this->
findChildren(MetaTreeItemTypes::LoopedStreaming);
266 for(
int i = 0; i < lItems.size(); i++) {
268 pAbstractItem->setCheckState(bState ==
true ? Qt::Checked : Qt::Unchecked);
270 data.setValue(bState);
271 pAbstractItem->setData(data, MetaTreeItemRoles::LoopedStreaming);
280 QList<QStandardItem*> lItems = this->
findChildren(MetaTreeItemTypes::StreamStatus);
282 for(
int i = 0; i < lItems.size(); i++) {
284 pAbstractItem->setCheckState(bState ==
true ? Qt::Checked : Qt::Unchecked);
286 data.setValue(bState);
287 pAbstractItem->setData(data, MetaTreeItemRoles::StreamStatus);
296 QList<QStandardItem*> lItems = this->
findChildren(MetaTreeItemTypes::StreamingTimeInterval);
298 for(
int i = 0; i < lItems.size(); i++) {
301 data.setValue(iMSec);
302 pAbstractItem->setData(data, MetaTreeItemRoles::StreamingTimeInterval);
303 pAbstractItem->setData(data, Qt::DisplayRole);
312 QList<QStandardItem*> lItems = this->
findChildren(MetaTreeItemTypes::NumberAverages);
314 for(
int i = 0; i < lItems.size(); i++) {
317 data.setValue(iNumberAverages);
318 pAbstractItem->setData(data, MetaTreeItemRoles::NumberAverages);
319 pAbstractItem->setData(data, Qt::DisplayRole);
328 QList<QStandardItem*> lItems = this->
findChildren(MetaTreeItemTypes::ColormapType);
330 for(
int i = 0; i < lItems.size(); i++) {
333 data.setValue(sColormap);
334 pAbstractItem->setData(data, MetaTreeItemRoles::ColormapType);
335 pAbstractItem->setData(data, Qt::DisplayRole);
344 QList<QStandardItem*> lItems = this->
findChildren(MetaTreeItemTypes::DataThreshold);
346 for(
int i = 0; i < lItems.size(); i++) {
349 data.setValue(vecThresholds);
350 pAbstractItem->setData(data, MetaTreeItemRoles::DataThreshold);
352 QString sTemp = QString(
"%1,%2,%3").arg(vecThresholds.x()).arg(vecThresholds.y()).arg(vecThresholds.z());
353 data.setValue(sTemp);
354 pAbstractItem->setData(data, Qt::DisplayRole);
363 QList<QStandardItem*> lItems = this->
findChildren(MetaTreeItemTypes::CancelDistance);
365 for(
int i = 0; i < lItems.size(); i++) {
368 data.setValue(dCancelDist);
369 pAbstractItem->setData(data, MetaTreeItemRoles::CancelDistance);
370 pAbstractItem->setData(data, Qt::DisplayRole);
379 QList<QStandardItem*> lItems = this->
findChildren(MetaTreeItemTypes::InterpolationFunction);
381 for(
int i = 0; i < lItems.size(); i++) {
384 data.setValue(sInterpolationFunction);
385 pAbstractItem->setData(data, MetaTreeItemRoles::InterpolationFunction);
386 pAbstractItem->setData(data, Qt::DisplayRole);
407 for(
const QString &bad : info.
bads) {
472 this->setEditable(
false);
473 this->setCheckable(
true);
474 this->setCheckState(Qt::Checked);
475 this->setToolTip(
"Sensor Data item");
478 QList<QStandardItem*> list;
482 list << pItemStreamStatus;
483 list <<
new QStandardItem(pItemStreamStatus->toolTip());
484 this->appendRow(list);
485 pItemStreamStatus->setCheckable(
true);
486 pItemStreamStatus->setEditable(
false);
487 pItemStreamStatus->setCheckState(Qt::Unchecked);
491 data.setValue(
false);
492 pItemStreamStatus->setData(data, MetaTreeItemRoles::StreamStatus);
496 list << pItemColormapType;
497 list <<
new QStandardItem(pItemColormapType->toolTip());
498 this->appendRow(list);
499 data.setValue(QString(
"Hot"));
500 pItemColormapType->setData(data, MetaTreeItemRoles::ColormapType);
506 list << pItemThreshold;
507 list <<
new QStandardItem(pItemThreshold->toolTip());
508 this->appendRow(list);
509 data.setValue(QVector3D(0.0,5.5,15));
510 pItemThreshold->setData(data, MetaTreeItemRoles::DataThreshold);
516 list << pItemStreamingInterval;
517 list <<
new QStandardItem(pItemStreamingInterval->toolTip());
518 this->appendRow(list);
520 pItemStreamingInterval->setData(data, MetaTreeItemRoles::StreamingTimeInterval);
525 pItemLoopedStreaming->setCheckable(
true);
526 pItemLoopedStreaming->setCheckState(Qt::Checked);
528 list << pItemLoopedStreaming;
529 list <<
new QStandardItem(pItemLoopedStreaming->toolTip());
530 this->appendRow(list);
536 list << pItemAveragedStreaming;
537 list <<
new QStandardItem(pItemAveragedStreaming->toolTip());
538 this->appendRow(list);
540 pItemAveragedStreaming->setData(data, MetaTreeItemRoles::NumberAverages);
546 list << pItemCancelDistance;
547 list <<
new QStandardItem(pItemCancelDistance->toolTip());
548 this->appendRow(list);
550 pItemCancelDistance->setData(data, MetaTreeItemRoles::CancelDistance);
556 list << pInterpolationFunction;
557 list <<
new QStandardItem(pInterpolationFunction->toolTip());
558 this->appendRow(list);
559 data.setValue(QString(
"Cubic"));
560 pInterpolationFunction->setData(data, MetaTreeItemRoles::InterpolationFunction);
600 if(checkState == Qt::Checked) {
602 }
else if(checkState == Qt::Unchecked) {
612 if(sColormapType.canConvert<QString>()) {
629 if(iMSec.canConvert<
int>()) {
640 if(vecThresholds.canConvert<QVector3D>()) {
658 if(checkState == Qt::Checked) {
660 }
else if(checkState == Qt::Unchecked) {
670 if(iNumAvr.canConvert<
int>()) {
681 if(dCancelDist.canConvert<
double>())
693 if(sInterpolationFunction.canConvert<QString>())