1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-11 19:24:10 +01:00

Ground/ModelView: Added camera switching through keyboard (numbers: 1 to 0).

Also, fixed wrong rotation of pitch and yaw.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1874 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
muralha 2010-10-04 10:17:59 +00:00 committed by muralha
parent abba162dca
commit 114956a514
2 changed files with 63 additions and 2 deletions

View File

@ -101,6 +101,7 @@ void ModelViewGadgetWidget::initializeGL()
glEnable(GL_MULTISAMPLE); glEnable(GL_MULTISAMPLE);
m_MotionTimer.start(100); m_MotionTimer.start(100);
setFocusPolicy(Qt::StrongFocus); // keyboard capture for camera switching
} }
void ModelViewGadgetWidget::paintGL() void ModelViewGadgetWidget::paintGL()
@ -217,6 +218,65 @@ void ModelViewGadgetWidget::mouseReleaseEvent(QMouseEvent*)
updateGL(); updateGL();
} }
void ModelViewGadgetWidget::keyPressEvent(QKeyEvent * e) // switch between camera
{
if (e->key() == Qt::Key_1)
{
m_GlView.cameraHandle()->setIsoView();
updateGL();
}
if (e->key() == Qt::Key_2)
{
m_GlView.cameraHandle()->setFrontView();
updateGL();
}
if (e->key() == Qt::Key_3)
{
m_GlView.cameraHandle()->setIsoView();
m_GlView.cameraHandle()->rotateAroundTarget(glc::Z_AXIS,glc::toRadian(90));
updateGL();
}
if (e->key() == Qt::Key_4)
{
m_GlView.cameraHandle()->setLeftView();
updateGL();
}
if (e->key() == Qt::Key_5)
{
m_GlView.cameraHandle()->setTopView();
m_GlView.cameraHandle()->rotateAroundTarget(glc::Z_AXIS,glc::toRadian(180));
updateGL();
}
if (e->key() == Qt::Key_6)
{
m_GlView.cameraHandle()->setRightView();;
updateGL();
}
if (e->key() == Qt::Key_7)
{
m_GlView.cameraHandle()->setIsoView();
m_GlView.cameraHandle()->rotateAroundTarget(glc::Z_AXIS,glc::toRadian(-90));
updateGL();
}
if (e->key() == Qt::Key_8)
{
m_GlView.cameraHandle()->setRearView();;
updateGL();
}
if (e->key() == Qt::Key_9)
{
m_GlView.cameraHandle()->setIsoView();
m_GlView.cameraHandle()->rotateAroundTarget(glc::Z_AXIS,glc::toRadian(180));
updateGL();
}
if (e->key() == Qt::Key_0)
{
m_GlView.cameraHandle()->setBottomView();
m_GlView.cameraHandle()->rotateAroundTarget(glc::Z_AXIS,glc::toRadian(180));
updateGL();
}
}
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// Private slots Functions // Private slots Functions
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
@ -225,9 +285,9 @@ void ModelViewGadgetWidget::updateAttitude()
AttitudeActual::DataFields data = attActual->getData(); AttitudeActual::DataFields data = attActual->getData();
GLC_StructOccurence* rootObject= m_World.rootOccurence(); GLC_StructOccurence* rootObject= m_World.rootOccurence();
GLC_Matrix4x4 rootObjectPosition(0, 0, 0); // will be changed when the acceleration movement is tested GLC_Matrix4x4 rootObjectPosition(0, 0, 0); // will be changed when the acceleration movement is tested
double pitch= glc::toRadian(data.Pitch); double pitch= glc::toRadian(-data.Pitch);
double roll= glc::toRadian(data.Roll); double roll= glc::toRadian(data.Roll);
double yaw= glc::toRadian(data.Yaw); double yaw= glc::toRadian(-data.Yaw);
GLC_Matrix4x4 rootObjectRotation(GLC_Matrix4x4().fromEuler(pitch, roll, yaw)); GLC_Matrix4x4 rootObjectRotation(GLC_Matrix4x4().fromEuler(pitch, roll, yaw));
rootObject->structInstance()->setMatrix(rootObjectPosition * rootObjectRotation); rootObject->structInstance()->setMatrix(rootObjectPosition * rootObjectRotation);
rootObject->updateChildrenAbsoluteMatrix(); rootObject->updateChildrenAbsoluteMatrix();

View File

@ -68,6 +68,7 @@ private:
void mouseMoveEvent(QMouseEvent * e); void mouseMoveEvent(QMouseEvent * e);
void mouseReleaseEvent(QMouseEvent * e); void mouseReleaseEvent(QMouseEvent * e);
void wheelEvent(QWheelEvent * e); void wheelEvent(QWheelEvent * e);
void keyPressEvent(QKeyEvent * e);
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// Private slots Functions // Private slots Functions