+/*!
+ Set the rotation axis and start automatic rotation
+*/
+void OCCViewer_ViewPort3d::setRotationAxis(const gp_Vec& theAxis, double theAngle, double theZAngle)
+{
+ myRotAxis.SetLocation(activeView()->GravityPoint());
+ if (zRotation) {
+ gp_Dir anAxisDir = activeView()->Camera()->Direction();
+ myRotAxis.SetDirection(anAxisDir.Reversed());
+ myRotAngle = theZAngle;
+ }
+ else {
+ myRotAxis.SetDirection(gp_Dir(theAxis));
+ myRotAngle = theAngle;
+ }
+ if (!myRotTimer) {
+ myRotTimer = new QTimer(this);
+ myRotTimer->setSingleShot(true);
+ connect(myRotTimer, SIGNAL(timeout()), this, SLOT(updateRotation()));
+ }
+ else
+ myRotTimer->stop();
+
+ myIsRotating = true;
+ myLastRender = QDateTime::currentMSecsSinceEpoch();
+ Handle(Graphic3d_Camera) aCamera = activeView()->Camera();
+ gp_Trsf trsfRot;
+ trsfRot.SetRotation (myRotAxis, myRotAngle);
+ aCamera->Transform(trsfRot);
+ activeView()->SetCamera(aCamera);
+ myRotTimer->start(20);
+}
+
+/*!
+ Stop the automatic rotation
+*/
+void OCCViewer_ViewPort3d::stopRotation()
+{
+ myIsRotating = false;
+ if (myRotTimer)
+ myRotTimer->stop();
+}
+
+/*!
+ Update the automatic rotation animation
+*/
+void OCCViewer_ViewPort3d::updateRotation()
+{
+ if (!myIsRotating)
+ return;
+
+ qint64 curTime = QDateTime::currentMSecsSinceEpoch();
+ double angle = myRotAngle * (curTime - myLastRender) / 100.;
+ Handle(Graphic3d_Camera) aCamera = activeView()->Camera();
+ gp_Trsf trsfRot;
+ trsfRot.SetRotation(myRotAxis, angle);
+ aCamera->Transform(trsfRot);
+ activeView()->SetCamera(aCamera);
+
+ myLastRender = curTime;
+ if (myRotTimer)
+ myRotTimer->start(20);
+}
+