Skip to content

Commit

Permalink
Removed most perspectives in animation and added two camera rotation …
Browse files Browse the repository at this point in the history
…buttons instead.
  • Loading branch information
Robert Braun authored and adeas31 committed Dec 21, 2016
1 parent acdc742 commit 774de79
Show file tree
Hide file tree
Showing 10 changed files with 1,538 additions and 427 deletions.
191 changes: 125 additions & 66 deletions OMEdit/OMEditGUI/Animation/AnimationWindow.cpp
Expand Up @@ -118,22 +118,26 @@ AnimationWindow::AnimationWindow(PlotWindowContainer *pPlotWindowContainer)
mpSpeedComboBox->setCompleter(0);
mpPerspectiveDropDownBox = new QComboBox(this);
mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective0.svg"), QString("Isometric"));
mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective1.svg"),QString("Left 1"));
mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective2.svg"),QString("Left 2"));
mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective3.svg"),QString("Right 1"));
mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective4.svg"),QString("Right 2"));
mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective5.svg"),QString("Front 1"));
mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective6.svg"),QString("Front 2"));
mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective7.svg"),QString("Front 3"));
mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective8.svg"),QString("Back 1"));
mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective9.svg"),QString("Back 2"));
mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective10.svg"),QString("Back 3"));
mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective11.svg"),QString("Top 1"));
mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective12.svg"),QString("Top 2"));
mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective13.svg"),QString("Top 3"));
mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective14.svg"),QString("Bottom 1"));
mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective15.svg"),QString("Bottom 2"));
mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective16.svg"),QString("Bottom 3"));
// mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective1.svg"),QString("Left 1"));
// mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective2.svg"),QString("Left 2"));
// mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective3.svg"),QString("Right 1"));
mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective1.svg"),QString("Side"));
mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective2.svg"),QString("Front"));
// mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective6.svg"),QString("Front 2"));
// mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective7.svg"),QString("Front 3"));
// mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective8.svg"),QString("Back 1"));
// mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective9.svg"),QString("Back 2"));
// mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective10.svg"),QString("Back 3"));
mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective3.svg"),QString("Top"));
// mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective12.svg"),QString("Top 2"));
// mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective13.svg"),QString("Top 3"));
// mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective14.svg"),QString("Bottom 1"));
// mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective15.svg"),QString("Bottom 2"));
// mpPerspectiveDropDownBox->addItem(QIcon(":/Resources/icons/perspective16.svg"),QString("Bottom 3"));
mpRotateCameraLeftButton = new QToolButton(this);
mpRotateCameraLeftButton->setIcon(QIcon(":/Resources/icons/rotateCameraLeft.svg"));
mpRotateCameraRightButton = new QToolButton(this);
mpRotateCameraRightButton->setIcon(QIcon(":/Resources/icons/rotateCameraRight.svg"));
//assemble the animation toolbar
mpAnimationToolBar->addAction(mpAnimationChooseFileAction);
mpAnimationToolBar->addSeparator();
Expand All @@ -152,6 +156,8 @@ AnimationWindow::AnimationWindow(PlotWindowContainer *pPlotWindowContainer)
mpAnimationToolBar->addWidget(mpSpeedComboBox);
mpAnimationToolBar->addSeparator();
mpAnimationToolBar->addWidget(mpPerspectiveDropDownBox);
mpAnimationToolBar->addWidget(mpRotateCameraLeftButton);
mpAnimationToolBar->addWidget(mpRotateCameraRightButton);
mpAnimationToolBar->setIconSize(QSize(toolbarIconSize, toolbarIconSize));
addToolBar(Qt::TopToolBarArea,mpAnimationToolBar);
// Viewer layout
Expand All @@ -169,6 +175,8 @@ AnimationWindow::AnimationWindow(PlotWindowContainer *pPlotWindowContainer)
connect(mpAnimationPlayAction, SIGNAL(triggered()),this, SLOT(playSlotFunction()));
connect(mpAnimationPauseAction, SIGNAL(triggered()),this, SLOT(pauseSlotFunction()));
connect(mpPerspectiveDropDownBox, SIGNAL(activated(int)), this, SLOT(setPerspective(int)));
connect(mpRotateCameraLeftButton, SIGNAL(clicked()), this, SLOT(rotateCameraLeft()));
connect(mpRotateCameraRightButton, SIGNAL(clicked()), this, SLOT(rotateCameraRight()));
connect(mpAnimationSlider, SIGNAL(valueChanged(int)),this, SLOT(sliderSetTimeSlotFunction(int)));
connect(mpSpeedComboBox, SIGNAL(currentIndexChanged(int)),this, SLOT(setSpeedSlotFunction()));
connect(mpSpeedComboBox->lineEdit(), SIGNAL(textChanged(QString)),this, SLOT(setSpeedSlotFunction()));
Expand Down Expand Up @@ -495,9 +503,9 @@ void AnimationWindow::openAnimationFile(QString fileName)
void AnimationWindow::cameraPositionIsometric()
{
double d = computeDistanceToOrigin();
osg::Matrixd mat = osg::Matrixd(0, -0.7071, 0.7071, 0,
0.816, -0.409, -0.409, 0,
0.57735, 0.57735, 0.57735, 0,
osg::Matrixd mat = osg::Matrixd(0.7071, 0, -0.7071, 0,
-0.409, 0.816, -0.409, 0,
0.57735, 0.57735, 0.57735, 0,
0.57735*d, 0.57735*d, 0.57735*d, 1);
mpSceneView->getCameraManipulator()->setByMatrix(mat);
}
Expand Down Expand Up @@ -719,12 +727,63 @@ void AnimationWindow::cameraPositionBottom2()
*/
void AnimationWindow::cameraPositionBottom3()
{
double d = computeDistanceToOrigin();
osg::Matrixd mat = osg::Matrixd(0, 1, 0, 0,
0, 0,-1, 0,
-1,0, 0, 0,
-d,0, 0, 1);
mpSceneView->getCameraManipulator()->setByMatrix(mat);
// double d = computeDistanceToOrigin();
// osg::Matrixd mat = osg::Matrixd(0, 1, 0, 0,
// 0, 0,-1, 0,
// -1,0, 0, 0,
// -d,0, 0, 1);
// mpSceneView->getCameraManipulator()->setByMatrix(mat);

osg::ref_ptr<osgGA::CameraManipulator> manipulator = mpSceneView->getCameraManipulator();
osg::Matrixd mat = manipulator->getMatrix();

osg::Camera *pCamera = mpSceneView->getCamera();

osg::Vec3d eye, center, up;
pCamera->getViewMatrixAsLookAt(eye, center, up);
osg::Vec3d rotationAxis = center-eye;

std::stringstream ss;
ss << "rotationAxis: " << rotationAxis.x() << "," << rotationAxis.y() << "," << rotationAxis.z();
MessagesWidget::instance()->addGUIMessage(MessageItem(MessageItem::MetaModel, "", false, 0, 0, 0, 0, QString(ss.str().c_str()),
Helper::scriptingKind, Helper::errorLevel));

osg::Matrixd rotMatrix;
rotMatrix.makeRotate(3.1415/2.0, rotationAxis);

mpSceneView->getCameraManipulator()->setByMatrix(mat*rotMatrix);
}

void AnimationWindow::rotateCameraLeft()
{
osg::ref_ptr<osgGA::CameraManipulator> manipulator = mpSceneView->getCameraManipulator();
osg::Matrixd mat = manipulator->getMatrix();
osg::Camera *pCamera = mpSceneView->getCamera();

osg::Vec3d eye, center, up;
pCamera->getViewMatrixAsLookAt(eye, center, up);
osg::Vec3d rotationAxis = center-eye;

osg::Matrixd rotMatrix;
rotMatrix.makeRotate(3.1415/2.0, rotationAxis);

mpSceneView->getCameraManipulator()->setByMatrix(mat*rotMatrix);
}

void AnimationWindow::rotateCameraRight()
{
osg::ref_ptr<osgGA::CameraManipulator> manipulator = mpSceneView->getCameraManipulator();
osg::Matrixd mat = manipulator->getMatrix();
osg::Camera *pCamera = mpSceneView->getCamera();

osg::Vec3d eye, center, up;
pCamera->getViewMatrixAsLookAt(eye, center, up);
osg::Vec3d rotationAxis = center-eye;

osg::Matrixd rotMatrix;
rotMatrix.makeRotate(-3.1415/2.0, rotationAxis);

mpSceneView->getCameraManipulator()->setByMatrix(mat*rotMatrix);
}


Expand Down Expand Up @@ -773,54 +832,54 @@ void AnimationWindow::setPerspective(int value)
case 0:
cameraPositionIsometric();
break;
// case 1:
// cameraPositionLeft1();
// break;
// case 2:
// cameraPositionLeft2();
// break;
// case 3:
// cameraPositionRight1();
// break;
case 1:
cameraPositionLeft1();
cameraPositionRight2();
break;
case 2:
cameraPositionLeft2();
cameraPositionTop1();
break;
// case 6:
// cameraPositionFront2();
// break;
// case 7:
// cameraPositionFront3();
// break;
// case 8:
// cameraPositionBack1();
// break;
// case 9:
// cameraPositionBack2();
// break;
// case 10:
// cameraPositionBack3();
// break;
case 3:
cameraPositionRight1();
break;
case 4:
cameraPositionRight2();
break;
case 5:
cameraPositionFront1();
break;
case 6:
cameraPositionFront2();
break;
case 7:
cameraPositionFront3();
break;
case 8:
cameraPositionBack1();
break;
case 9:
cameraPositionBack2();
break;
case 10:
cameraPositionBack3();
break;
case 11:
cameraPositionTop1();
break;
case 12:
cameraPositionTop2();
break;
case 13:
cameraPositionTop3();
break;
case 14:
cameraPositionBottom1();
break;
case 15:
cameraPositionBottom2();
break;
case 16:
cameraPositionBottom3();
break;
// case 12:
// cameraPositionTop2();
// break;
// case 13:
// cameraPositionTop3();
// break;
// case 14:
// cameraPositionBottom1();
// break;
// case 15:
// cameraPositionBottom2();
// break;
// case 16:
// cameraPositionBottom3();
// break;
}
}

Expand Down

0 comments on commit 774de79

Please sign in to comment.