MNE-CPP 0.1.9
A Framework for Electrophysiology
Loading...
Searching...
No Matches
orbitalcameracontroller.cpp
Go to the documentation of this file.
1//=============================================================================================================
35//=============================================================================================================
36// INCLUDES
37//=============================================================================================================
38
40
41//=============================================================================================================
42// QT INCLUDES
43//=============================================================================================================
44
45#include <Qt3DRender/QCamera>
46#include <Qt3DCore/qtransform.h>
47
48//=============================================================================================================
49// EIGEN INCLUDES
50//=============================================================================================================
51
52//=============================================================================================================
53// USED NAMESPACES
54//=============================================================================================================
55
56using namespace DISP3DLIB;
57
58//=============================================================================================================
59// DEFINE GLOBAL METHODS
60//=============================================================================================================
61
62//=============================================================================================================
63// DEFINE MEMBER METHODS
64//=============================================================================================================
65
67 :QAbstractCameraController(pParent)
68 , m_iRotating(0.0f)
69{
70 initController();
71}
72
73//=============================================================================================================
74
76{
77 if(newStatusFlag == true) {
78 m_fRotationInverseFactor = -1.0f;
79 }
80 else {
81 m_fRotationInverseFactor = 1.0f;
82 }
83}
84
85//=============================================================================================================
86
87void OrbitalCameraController::moveCamera(const Qt3DExtras::QAbstractCameraController::InputState &state, float dt)
88{
89 Qt3DRender::QCamera *pCamera = this->camera();
90
91 if(pCamera == nullptr) {
92 return;
93 }
94
95 //Mouse input
96 if(state.rightMouseButtonActive) {
97 if(state.altKeyActive) {
98 //translate camera in x/y direction
99 pCamera->translate(QVector3D(state.rxAxisValue * this->linearSpeed() * dt * 0.2f,
100 state.ryAxisValue * this->linearSpeed() * dt * 0.2f,
101 0.0f));
102 }
103 else {
104 // orbit around view center
105 pCamera->panAboutViewCenter(state.rxAxisValue * this->lookSpeed() * dt * m_fRotationInverseFactor,
106 QVector3D(0.0f, 0.0f, 1.0f));
107 pCamera->tiltAboutViewCenter(state.ryAxisValue * this->lookSpeed() * dt * m_fRotationInverseFactor);
108 }
109 }
110
111 if(state.middleMouseButtonActive) {
112 //translate the cameras view center
113 pCamera->translate(QVector3D(state.rxAxisValue * this->linearSpeed() * dt * 0.2f,
114 state.ryAxisValue * this->linearSpeed() * dt * 0.2f,
115 0.0f));
116 }
117
118 //zoom with mouse wheel and page up and down
119 if(distance(pCamera->position(), pCamera->viewCenter()) > m_fZoomInLimit) {
120 pCamera->translate(QVector3D(0.0f, 0.0f, state.tzAxisValue * this->linearSpeed() * dt),
121 pCamera->DontTranslateViewCenter);
122 }
123 else {
124 pCamera->translate(QVector3D(0.0f, 0.0f, -m_fZoomInLimit), pCamera->DontTranslateViewCenter);
125 }
126
127 //Keyboard input: orbit around view center
128 pCamera->panAboutViewCenter(state.txAxisValue * this->lookSpeed() * dt * 0.8f * m_fRotationInverseFactor,
129 QVector3D(0.0f, 0.0f, 1.0f));
130 pCamera->tiltAboutViewCenter(state.tyAxisValue * this->lookSpeed()* dt * 0.8f * m_fRotationInverseFactor);
131}
132
133//=============================================================================================================
134
135void OrbitalCameraController::initController()
136{
137 this->setLinearSpeed(0.55f);
138 this->setLookSpeed(143.f);
140}
141
142//=============================================================================================================
143
145{
146 Qt3DRender::QCamera *pCamera = this->camera();
147
148 m_iRotating = count;
149 QQuaternion quat = QQuaternion::QQuaternion::fromEulerAngles(0,0,m_fAutoRotationSpeed);
150 pCamera->rotateAboutViewCenter(quat);
151}
152
153//=============================================================================================================
154
156{
157 return m_iRotating;
158}
OrbitalCameraController class declaration.
OrbitalCameraController(Qt3DCore::QNode *pParent=nullptr)