1256 SoCamera *cam = getCamera();
1257 const SoType type(ev->getTypeId());
1259 if (type.isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) {
1260 SoMouseButtonEvent * me = (SoMouseButtonEvent *) ev;
1262 if (currentState == ANIMATION || currentState == REVERSED_ANIMATION
1263 || currentState == PAUSED_ANIMATION) {
1264 switch (me->getButton()) {
1265 case SoMouseButtonEvent::BUTTON4:
1266 if (me->getState() == SoButtonEvent::DOWN) {
1267 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
1269 ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
1270 ((SoPerspectiveCamera *) cam)->heightAngle = hAngle
1273 }
else if (cam->isOfType(
1274 SoOrthographicCamera::getClassTypeId())) {
1276 ((SoOrthographicCamera *) cam)->height.getValue();
1277 ((SoOrthographicCamera *) cam)->height = height + 5;
1282 case SoMouseButtonEvent::BUTTON5:
1283 if (me->getState() == SoButtonEvent::DOWN) {
1284 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
1286 ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
1288 ((SoPerspectiveCamera *) cam)->heightAngle = hAngle
1291 }
else if (cam->isOfType(
1292 SoOrthographicCamera::getClassTypeId())) {
1294 ((SoOrthographicCamera *) cam)->height.getValue();
1296 ((SoOrthographicCamera *) cam)->height = height - 5;
1305 if (currentState == GENERAL) {
1310 if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) {
1311 SoKeyboardEvent * ke = (SoKeyboardEvent *) ev;
1313 if (SoKeyboardEvent::isKeyPressEvent(ev, ke->getKey())) {
1314 switch (ke->getKey()) {
1315 case SoKeyboardEvent::LEFT_SHIFT:
1316 this->lshiftdown =
true;
1318 case SoKeyboardEvent::RIGHT_SHIFT:
1319 this->rshiftdown =
true;
1321 case SoKeyboardEvent::LEFT_CONTROL:
1322 this->lctrldown =
true;
1324 case SoKeyboardEvent::RIGHT_CONTROL:
1325 this->rctrldown =
true;
1327 case SoKeyboardEvent::SPACE:
1328 if (currentState == ANIMATION
1329 || currentState == REVERSED_ANIMATION) {
1330 beforePausing = currentState;
1331 currentState = PAUSED_ANIMATION;
1332 if (animateSensor->isScheduled())
1333 animateSensor->unschedule();
1335 }
else if (currentState == PAUSED_ANIMATION) {
1337 if ((beforePausing == ANIMATION
1339 < (
int) refParticleTrajectory.size() - 1)
1340 || (beforePausing == REVERSED_ANIMATION
1341 && refParticleIdx > 0)) {
1342 currentState = beforePausing;
1343 animateRefParticle();
1349 case SoKeyboardEvent::ESCAPE:
1350 if (currentState == ANIMATION
1351 || currentState == REVERSED_ANIMATION
1352 || currentState == PAUSED_ANIMATION) {
1354 if (animateSensor->isScheduled())
1355 animateSensor->unschedule();
1356 currentState = prevState;
1357 refParticleIdx = prevRefIdx;
1358 setSuperimpositionEnabled(superimposition,
FALSE);
1363 if (currentState == VIEWPOINT) {
1364 setSuperimpositionEnabled(superimposition,
TRUE);
1365 axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
1366 animSpeedOutlineSwitch->whichChild.setValue(
1368 animSpeedSwitch->whichChild.setValue(SO_SWITCH_NONE);
1376 case SoKeyboardEvent::DELETE:
1377 if (viewPtList.size()
1378 && (currentState != ANIMATION
1379 || currentState != REVERSED_ANIMATION
1380 || currentState != PAUSED_ANIMATION)) {
1381 String dialogName = (
char *)
"Delete Viewpoint";
1382 std::string msg =
"Are you sure you want to delete current viewpoint?";
1387 case SoKeyboardEvent::LEFT_ARROW:
1388 switch (currentState) {
1390 if ((this->lshiftdown) || (this->rshiftdown)){
1391 refParticleIdx -= step;
1394 else if ((this->lctrldown) || (this->rctrldown)){
1395 if (SoXtExaminerViewer::isAnimating())
1397 prevState = currentState;
1398 currentState = ROTATING;
1399 animateBtwPtsPeriod = 0.08f;
1411 if (SoXtExaminerViewer::isAnimating())
1413 prevState = currentState;
1414 currentState = ROTATING;
1415 animateBtwPtsPeriod = 0.08f;
1430 case REVERSED_ANIMATION:
1433 case PAUSED_ANIMATION:
1435 setStartingPtForAnimation();
1436 cam->position = myCam->position;
1440 if ((!this->lshiftdown) && (!this->rshiftdown)) {
1443 this->bottomWheelMotion(
1444 this->getBottomWheelValue() + 0.1f);
1454 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::processSoEvent",
1455 "Unhandled viewer state");
1460 case SoKeyboardEvent::RIGHT_ARROW:
1461 switch(currentState){
1463 if ((this->lshiftdown) || (this->rshiftdown)){
1464 refParticleIdx += step;
1467 else if ((this->lctrldown) || (this->rctrldown)){
1468 if (SoXtExaminerViewer::isAnimating())
1470 prevState = currentState;
1471 currentState = ROTATING;
1472 animateBtwPtsPeriod = 0.08f;
1482 if (SoXtExaminerViewer::isAnimating())
1484 prevState = currentState;
1485 currentState = ROTATING;
1486 animateBtwPtsPeriod = 0.08f;
1498 case REVERSED_ANIMATION:
1501 case PAUSED_ANIMATION:
1503 setStartingPtForAnimation();
1504 cam->position = myCam->position;
1508 if ((!this->lshiftdown) && (!this->rshiftdown)) {
1511 this->bottomWheelMotion(
1512 this->getBottomWheelValue() - 0.1f);
1521 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::processSoEvent",
1522 "Unhandled viewer state");
1527 case SoKeyboardEvent::DOWN_ARROW:
1528 switch(currentState){
1531 if ((this->lshiftdown) || (this->rshiftdown)){
1532 refParticleIdx -= step;
1536 if (SoXtExaminerViewer::isAnimating())
1538 prevState = currentState;
1539 currentState = ROTATING;
1540 animateBtwPtsPeriod = 0.08f;
1553 case REVERSED_ANIMATION:
1556 case PAUSED_ANIMATION:
1558 setStartingPtForAnimation();
1559 cam->position = myCam->position;
1565 if ((!this->lshiftdown) && (!this->rshiftdown)) {
1566 this->leftWheelMotion(this->getLeftWheelValue() - 0.1f);
1575 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::processSoEvent",
1576 "Unhandled viewer state");
1581 case SoKeyboardEvent::UP_ARROW:
1582 switch(currentState){
1584 if ((this->lshiftdown) || (this->rshiftdown)){
1585 refParticleIdx -= step;
1589 if (SoXtExaminerViewer::isAnimating())
1591 prevState = currentState;
1592 currentState = ROTATING;
1593 animateBtwPtsPeriod = 0.08f;
1606 case REVERSED_ANIMATION:
1609 case PAUSED_ANIMATION:
1611 setStartingPtForAnimation();
1612 cam->position = myCam->position;
1618 if ((!this->lshiftdown) && (!this->rshiftdown)) {
1619 this->leftWheelMotion(this->getLeftWheelValue() + 0.1f);
1628 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::processSoEvent",
1629 "Unhandled viewer state");
1634 case SoKeyboardEvent::PAGE_UP:
1635 switch(currentState){
1637 if (step < (
int) refParticleTrajectory.size() / 5)
1648 case REVERSED_ANIMATION:
1649 if(!animateSensor->isScheduled()){
1650 currentState = ANIMATION;
1652 < (
int) refParticleTrajectory.size() - 1) {
1656 animateRefParticle();
1665 case PAUSED_ANIMATION:
1670 if (beforePausing == ANIMATION) {
1675 beforePausing = ANIMATION;
1685 case SoKeyboardEvent::PAGE_DOWN:
1686 switch(currentState){
1692 if(!animateSensor->isScheduled()){
1693 currentState = REVERSED_ANIMATION;
1694 if (refParticleIdx > 1) {
1698 animateRefParticle();
1707 case REVERSED_ANIMATION:
1710 if (maxSpeed < -0.8)
1714 case PAUSED_ANIMATION:
1716 if (maxSpeed < -0.8)
1718 if (beforePausing == REVERSED_ANIMATION) {
1723 beforePausing = REVERSED_ANIMATION;
1733 case SoKeyboardEvent::E:
1734 this->escapeCallback(this->examinerObject);
1741 if (SoKeyboardEvent::isKeyReleaseEvent(ev, ke->getKey())) {
1742 switch (ke->getKey()) {
1743 case SoKeyboardEvent::LEFT_SHIFT:
1744 this->lshiftdown =
false;
1746 case SoKeyboardEvent::RIGHT_SHIFT:
1747 this->rshiftdown =
false;
1749 case SoKeyboardEvent::LEFT_CONTROL:
1750 this->lctrldown =
false;
1752 case SoKeyboardEvent::RIGHT_CONTROL:
1753 this->rctrldown =
false;
1761 if (currentState == ANIMATION || currentState == REVERSED_ANIMATION
1762 || currentState == ROTATING)
1765 return SoXtExaminerViewer::processSoEvent(ev);
#define SPEED_INDICATOR_STEP
void moveCamera(float dist=0, bool lookdown=false)
void warningMsgDialog(std::string, String, XtCallbackProc)
#define MAX_SPEED_INDICATOR