41 #include "../model/items/common/types.h"
42 #include "../model/data3Dtreemodel.h"
43 #include "../model/3dhelpers/renderable3Dentity.h"
45 #include "../model/3dhelpers/geometrymultiplier.h"
46 #include "../model/materials/geometrymultipliermaterial.h"
53 #include <QPropertyAnimation>
59 #include <Qt3DCore/QTransform>
60 #include <Qt3DCore/QAspectEngine>
61 #include <Qt3DRender/QCamera>
62 #include <Qt3DExtras/QPhongMaterial>
63 #include <Qt3DRender/QPointLight>
64 #include <Qt3DRender/QRenderCaptureReply>
65 #include <Qt3DExtras/QCylinderGeometry>
66 #include <Qt3DExtras/QSphereMesh>
67 #include <Qt3DRender/QRenderSettings>
68 #include <Qt3DRender/QRenderSurfaceSelector>
69 #include <Qt3DRender/QCameraSelector>
70 #include <Qt3DRender/QTechniqueFilter>
71 #include <Qt3DRender/QClearBuffers>
72 #include <Qt3DRender/QNoDraw>
74 #include <QObjectPicker>
75 #include <QPickingSettings>
76 #include <QRenderSettings>
78 #include <QPickTriangleEvent>
84 using namespace MNELIB;
85 using namespace DISP3DLIB;
86 using namespace FSLIB;
87 using namespace CONNECTIVITYLIB;
94 : Qt3DExtras::Qt3DWindow()
95 , m_pRootEntity(new Qt3DCore::QEntity())
96 , m_p3DObjectsEntity(new Qt3DCore::QEntity(m_pRootEntity))
97 , m_pLightEntity(new Qt3DCore::QEntity(m_pRootEntity))
98 , m_pCamera(this->camera())
99 , m_pMultiCam1(new Qt3DRender::QCamera)
100 , m_pMultiCam2(new Qt3DRender::QCamera)
101 , m_pMultiCam3(new Qt3DRender::QCamera)
102 , m_pPicker(new Qt3DRender::QObjectPicker(m_pRootEntity))
104 , m_MultiViewOrientation(
View3D::MultiViewOrientation::Horizontal)
112 this->renderSettings()->setRenderPolicy(Qt3DRender::QRenderSettings::OnDemand);
142 delete m_pMultiFrame;
153 connect(
m_pPicker, &Qt3DRender::QObjectPicker::pressed,
158 this->renderSettings()->pickingSettings()->setPickMethod(Qt3DRender::QPickingSettings::PrimitivePicking);
159 this->renderSettings()->pickingSettings()->setPickResultMode(Qt3DRender::QPickingSettings::NearestPick);
160 this->renderSettings()->pickingSettings()->setWorldSpaceTolerance(0.00000001f);
175 if(qPickEvent->button() == qPickEvent->LeftButton) {
176 emit pickEventOccured(qPickEvent);
185 QList<QVector3D> lLightPositions;
186 const QColor lightColor(255,255,255);
187 const float lightIntensity = 0.4f;
189 lLightPositions << QVector3D(-0.5,0,0) << QVector3D(0.5,0,0);
194 for(
int i = 0; i < lLightPositions.size(); ++i) {
196 Qt3DCore::QEntity* pLightEntity =
new Qt3DCore::QEntity(
m_pLightEntity);
198 Qt3DCore::QTransform* pTransform =
new Qt3DCore::QTransform();
199 pTransform->setTranslation(lLightPositions.at(i));
200 pLightEntity->addComponent(pTransform);
202 Qt3DRender::QPointLight *pPointLight =
new Qt3DRender::QPointLight(pLightEntity);
203 pPointLight->setColor(lightColor);
204 pPointLight->setIntensity(lightIntensity);
205 pLightEntity->addComponent(pPointLight);
209 Qt3DExtras::QSphereMesh* lightSphere =
new Qt3DExtras::QSphereMesh(pLightEntity);
210 lightSphere->setRadius(0.1f);
211 pLightEntity->addComponent(lightSphere);
246 this->Qt3DWindow::showFullScreen();
288 this, &View3D::saveScreenshot);
293 void View3D::saveScreenshot()
300 QString sDate = QDate::currentDate().toString(
"yyyy_MM_dd");
301 QString sTime = QTime::currentTime().toString(
"hh_mm_ss");
303 if(!QDir(
"./Screenshots").exists()) {
304 QDir().mkdir(
"./Screenshots");
307 QString fileName = QString(
"./Screenshots/%1-%2-View3D.bmp").arg(sDate).arg(sTime);
317 if(e->key() == Qt::Key_Escape) {
321 Qt3DWindow::keyPressEvent(e);
331 QSharedPointer<Qt3DExtras::QCylinderGeometry> pAxis = QSharedPointer<Qt3DExtras::QCylinderGeometry>::create();
332 pAxis->setRadius(0.001f);
333 pAxis->setLength(30);
334 pAxis->setRings(100);
335 pAxis->setSlices(20);
339 QVector<QColor> vColors;
341 QVector<QMatrix4x4> vTransforms;
342 vTransforms.reserve(3);
343 QMatrix4x4 transformMat;
346 transformMat.setToIdentity();
347 vTransforms.push_back(transformMat);
348 vColors.push_back(QColor(255, 0, 0));
351 transformMat.setToIdentity();
352 transformMat.rotate(90.0f, QVector3D(0,0,1));
353 vTransforms.push_back(transformMat);
354 vColors.push_back(QColor(0, 0, 255));
357 transformMat.setToIdentity();
358 transformMat.rotate(90.0f, QVector3D(1,0,0));
359 vTransforms.push_back(transformMat);
360 vColors.push_back(QColor(0, 255, 0));
379 m_pCamera->setPosition(QVector3D(0.0f, -0.4f, -0.25f));
380 m_pCamera->setViewCenter(QVector3D(0.0f, 0.0f, 0.0f));
381 m_pCamera->setUpVector(QVector3D(0.0f, 1.0f, 0.0f));
383 QQuaternion quat = QQuaternion::QQuaternion::fromEulerAngles(0,0,fAngle);
419 m_pCamera->lens()->setPerspectiveProjection(45.0f, 16.0f/9.0f, 0.0001f, 100000.0f);
420 m_pCamera->setPosition(QVector3D(0.0f, -0.4f, -0.25f));
421 m_pCamera->setViewCenter(QVector3D(0.0f, 0.0f, 0.0f));
422 m_pCamera->setUpVector(QVector3D(0.0f, 1.0f, 0.0f));
424 m_pCamera->lens()->setPerspectiveProjection(45.0f, this->width()/this->height(), 0.01f, 5000.0f);
434 m_pMultiCam1->lens()->setPerspectiveProjection(45.0f, 16.0f/9.0f, 0.0001f, 100000.0f);
435 m_pMultiCam1->setPosition(QVector3D(0.0f, 0.65f, 0.0f));
436 m_pMultiCam1->setViewCenter(QVector3D(0.0f, 0.0f, 0.0f));
440 m_pMultiCam2->lens()->setPerspectiveProjection(45.0f, 16.0f/9.0f, 0.0001f, 100000.0f);
441 m_pMultiCam2->setPosition(QVector3D(-0.65f, 0.0f, 0.0f));
442 m_pMultiCam2->setViewCenter(QVector3D(0.0f, 0.0f, 0.0f));
446 m_pMultiCam3->lens()->setPerspectiveProjection(45.0f, 16.0f/9.0f, 0.0001f, 100000.0f);
447 m_pMultiCam3->setPosition(QVector3D(0.0f, 0.0f, 0.65f));
448 m_pMultiCam3->setViewCenter(QVector3D(0.0f, 0.0f, 0.0f));
460 m_pFrameGraph->setClearColor(QColor::fromRgbF(0.0, 0.0, 0.0, 1.0));
472 m_pMultiFrame =
new Qt3DRender::QRenderSurfaceSelector();
473 auto mainViewPort =
new Qt3DRender::QViewport(m_pMultiFrame);
476 auto clearBuffers =
new Qt3DRender::QClearBuffers(mainViewPort);
477 clearBuffers->setBuffers(Qt3DRender::QClearBuffers::ColorDepthBuffer);
478 clearBuffers->setClearColor(QColor::fromRgbF(0.0, 0.0, 0.0, 1.0));
497 auto noDraw =
new Qt3DRender::QNoDraw(clearBuffers);
507 Qt3DWindow::resizeEvent(event);
514 float fAspectRatio =
static_cast<float>(this->width())/
static_cast<float>(this->height());
516 if(fAspectRatio > 1.5f ){
568 this->setActiveFrameGraph(m_pMultiFrame);