42 #include "../common/metatreeitem.h"
45 #include "../../3dhelpers/geometrymultiplier.h"
46 #include "../../materials/geometrymultipliermaterial.h"
54 #include <QStringList>
57 #include <QStandardItem>
58 #include <QStandardItemModel>
59 #include <Qt3DRender/qshaderprogram.h>
60 #include <QQuaternion>
61 #include <Qt3DExtras/QConeGeometry>
63 #include <QRandomGenerator>
75 using namespace Eigen;
76 using namespace INVERSELIB;
77 using namespace DISP3DLIB;
83 EcdDataTreeItem::EcdDataTreeItem(Qt3DCore::QEntity *p3DEntityParent,
int iType,
const QString &text)
93 this->setEditable(
false);
94 this->setCheckable(
true);
95 this->setCheckState(Qt::Checked);
96 this->setToolTip(
"Dipole fit data");
103 if(!m_pItemNumDipoles){
105 QList<QStandardItem*> list;
106 m_pItemNumDipoles =
new MetaTreeItem(MetaTreeItemTypes::NumberDipoles, QString::number(pECDSet.
size()));
107 m_pItemNumDipoles->setEditable(
false);
109 list << m_pItemNumDipoles;
110 list <<
new QStandardItem(m_pItemNumDipoles->toolTip());
111 this->appendRow(list);
113 m_pItemNumDipoles->setText(QString::number(pECDSet.
size()));
125 QVector3D pos, to, from;
128 from = QVector3D(0.0, 1.0, 0.0);
131 QVector<QColor> vColors;
132 vColors.reserve(tECDSet.
size());
133 QVector<QMatrix4x4> vTransforms;
134 vTransforms.reserve(tECDSet.
size());
136 for(
int i = 0; i < tECDSet.
size(); ++i) {
137 pos.setX(tECDSet[i].rd(0));
138 pos.setY(tECDSet[i].rd(1));
139 pos.setZ(tECDSet[i].rd(2));
141 norm = sqrt(pow(tECDSet[i].Q(0),2)+pow(tECDSet[i].Q(1),2)+pow(tECDSet[i].Q(2),2));
143 to.setX(tECDSet[i].Q(0)/norm);
144 to.setY(tECDSet[i].Q(1)/norm);
145 to.setZ(tECDSet[i].Q(2)/norm);
150 QQuaternion
final = QQuaternion::rotationTo(from, to);
156 vTransforms.push_back(m);
159 vColors.push_back(QColor(QRandomGenerator::global()->bounded(0 , 255),
160 QRandomGenerator::global()->bounded(0 , 255),
161 QRandomGenerator::global()->bounded(0 , 255)));
166 QSharedPointer<Qt3DExtras::QConeGeometry> pDipolGeometry = QSharedPointer<Qt3DExtras::QConeGeometry>::create();
167 pDipolGeometry->setBottomRadius(0.001f);
168 pDipolGeometry->setLength(0.003f);
173 m_pDipolMesh->setTransforms(vTransforms);
175 m_pDipolMesh->setColors(vColors);
177 this->addComponent(m_pDipolMesh);
183 this->addComponent(pMaterial);
186 m_pDipolMesh->setTransforms(vTransforms);
188 m_pDipolMesh->setColors(vColors);