51 #include "qglbuilder.h"
54 #include <QtCore/qurl.h>
82 , m_surfSet(p_surfSet)
83 , m_qListLabels(p_qListLabels)
84 , m_qListRGBAs(p_qListRGBAs)
86 , m_pSceneNodeBrain(0)
90 m_pCameraFrontal =
new QGLCamera(
this);
91 m_pCameraFrontal->setAdjustForAspectRatio(
false);
94 m_timer =
new QTimer(
this);
95 QObject::connect(m_timer, &QTimer::timeout,
this, &LabelView::updateData);
112 m_curSourceEstimate = p_sourceEstimate;
114 m_nTSteps = m_curSourceEstimate.
times.size();
116 qDebug() <<
"#########" << m_curSourceEstimate.
data.rows() << m_curSourceEstimate.
data.cols() << m_nTSteps;
118 m_vecFirstLabelSourceEstimate = m_curSourceEstimate.
data.block(0,0,3,m_curSourceEstimate.
data.cols()).colwise().sum();
120 m_dMaxSourceEstimate = m_vecFirstLabelSourceEstimate.maxCoeff();
123 m_timer->start(m_curSourceEstimate.
tstep*1000);
136 builder << QGL::Faceted;
137 m_pSceneNodeBrain = builder.currentNode();
143 QSharedPointer<QGLMaterialCollection> palette = builder.sceneNode()->palette();
148 for(qint32 h = 0; h < 2; ++h)
153 MatrixX3f rr = m_surfSet[h].rr();
159 for(qint32 k = 0; k < m_qListLabels.size(); ++k)
162 if(m_qListLabels[k].hemi != h)
166 tris = m_qListLabels[k].selectTris(m_surfSet[h]);
169 if(builder.currentNode()->count() > 0)
173 QGeometryData t_GeometryDataTri;
176 MatrixXf t_TriCoords(3,3*tris.rows());
178 for(qint32 i = 0; i < tris.rows(); ++i)
180 t_TriCoords.col(i*3) = rr.row( tris(i,0) ).transpose();
181 t_TriCoords.col(i*3+1) = rr.row( tris(i,1) ).transpose();
182 t_TriCoords.col(i*3+2) = rr.row( tris(i,2) ).transpose();
186 t_GeometryDataTri.appendVertexArray(QArray<QVector3D>::fromRawData( reinterpret_cast<const QVector3D*>(t_TriCoords.data()), t_TriCoords.cols() ));
191 if (t_GeometryDataTri.count() > 0)
197 builder.addTriangles(t_GeometryDataTri);
202 QGLMaterial *t_pMaterialROI =
new QGLMaterial();
204 r = m_qListRGBAs[k][0];
205 g = m_qListRGBAs[k][1];
206 b = m_qListRGBAs[k][2];
208 t_pMaterialROI->setColor(QColor(r,g,b,200));
213 index = palette->addMaterial(t_pMaterialROI);
214 builder.currentNode()->setMaterialIndex(index);
225 m_pSceneNode = builder.finalizedSceneNode();
226 m_pSceneNode->setParent(
this);
231 m_pLightModel =
new QGLLightModel(
this);
232 m_pLightModel->setAmbientSceneColor(Qt::white);
233 m_pLightModel->setViewerPosition(QGLLightModel::LocalViewer);
235 m_pLightModel =
new QGLLightModel(
this);
237 m_pLightParametersScene =
new QGLLightParameters(
this);
238 m_pLightParametersScene->setPosition(QVector3D(0.0f, 0.0f, 3.0f));
239 painter->setMainLight(m_pLightParametersScene);
249 this->setStereoType(QGLView::RedCyanAnaglyph);
250 camera()->setEyeSeparation(0.4f);
251 m_pCameraFrontal->setEyeSeparation(0.1f);
267 painter->modelViewMatrix().push();
268 painter->projectionMatrix().push();
270 painter->setStandardEffect(QGL::LitMaterial);
272 painter->setLightModel(m_pLightModel);
282 qint32 iVal = (m_vecFirstLabelSourceEstimate[simCount%m_nTSteps]/m_dMaxSourceEstimate) * 255;
283 m_pSceneNode->palette()->material(15)->setSpecularColor(QColor(iVal,iVal,iVal,1));
286 m_pSceneNode->draw(painter);
289 painter->modelViewMatrix().pop();
290 painter->projectionMatrix().pop();
308 void LabelView::updateData()
LabelView class declaration.
LabelView(SurfaceSet &p_surfSet, QList< Label > &p_qListLabels, QList< RowVector4i > &p_qListRGBAs, QWindow *parent=0)
void paintGL(QGLPainter *painter)
void initializeGL(QGLPainter *painter)
A hemisphere set of surfaces.