Changeset 721 for trunk/geant4
- Timestamp:
- Feb 11, 2008, 3:07:12 PM (17 years ago)
- Location:
- trunk/geant4/visualization/OpenGL
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/geant4/visualization/OpenGL/include/G4OpenGLQtViewer.hh
r720 r721 115 115 mouseActions fMouseAction; // 1: rotate 2:move 3:pick 4:shortcuts 116 116 QPoint fLastPos; 117 /** delta of move event */ 118 QPoint fDeltaPos; 117 /** delta X of move event */ 118 G4double fDeltaPosX; 119 /** delta Y of move event */ 120 G4double fDeltaPosY; 119 121 /** delta of scene rotation. This delta is put in degree */ 120 122 G4double fDeltaRotation; … … 125 127 /** delta of zoom move. This delta is put in % of the scene view */ 126 128 G4double fDeltaZoom; 129 /** delta of auto move/rotation. This delta is put in % of the move/rotation param */ 130 G4double fDeltaMove; 127 131 /** To ensure key event are keep one by one */ 128 bool holdKeyEvent;132 bool fHoldKeyEvent; 129 133 bool fAutoMove; 130 134 QAction *fRotateAction; 131 135 QAction *fMoveAction; 132 136 QAction *fPickAction; 133 QAction *fShortcutsAction;134 137 QAction *fFullScreenOn; 135 138 QAction *fFullScreenOff; … … 143 146 void actionMouseMove(); 144 147 void actionMousePick(); 145 void actionMouseShortcuts();146 148 void actionDrawingWireframe(); 147 149 void actionDrawingLineRemoval(); … … 150 152 void actionCreateEPS(); 151 153 154 void showShortcuts(); 152 155 void toggleDrawingAction(int); 153 156 void toggleMouseAction(mouseActions); -
trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc
r720 r721 292 292 ,fDeltaDepth(0.01) 293 293 ,fDeltaZoom(0.1) 294 ,holdKeyEvent(false) 294 ,fDeltaMove(0.2) 295 ,fHoldKeyEvent(false) 295 296 ,fAutoMove(false) 296 297 { … … 330 331 fMoveAction = new QAction("&Move","&Move",CTRL+Key_M,mMouseAction,0,true); 331 332 fPickAction = new QAction("&Pick","&Pick",CTRL+Key_P,mMouseAction,0,true); 332 fShortcutsAction = new QAction("&Show shortcuts","&Show shortcuts",CTRL+Key_S,mMouseAction,0,true);333 QAction * shortcutsAction = new QAction("&Show shortcuts","&Show shortcuts",CTRL+Key_S,mMouseAction,0,true); 333 334 #else 334 335 fRotateAction = new QAction("&Rotate",CTRL+Key_R,mMouseAction); 335 336 fMoveAction = new QAction("&Move",CTRL+Key_M,mMouseAction); 336 337 fPickAction = new QAction("&Pick",CTRL+Key_P,mMouseAction); 337 fShortcutsAction = new QAction("&Show shortcuts",CTRL+Key_S,mMouseAction);338 QAction *shortcutsAction = new QAction("&Show shortcuts",CTRL+Key_S,mMouseAction); 338 339 #endif 339 340 fRotateAction->addTo(mMouseAction); 340 341 fMoveAction->addTo(mMouseAction); 341 342 fPickAction->addTo(mMouseAction); 342 fShortcutsAction->addTo(mMouseAction);343 shortcutsAction->addTo(mMouseAction); 343 344 344 345 fRotateAction->setToggleAction(true); 345 346 fMoveAction->setToggleAction(true); 346 347 fPickAction->setToggleAction(true); 347 fShortcutsAction->setToggleAction(true);348 shortcutsAction->setToggleAction(true); 348 349 349 350 fRotateAction->setOn(true); 350 351 fMoveAction->setOn(false); 351 352 fPickAction->setOn(false); 352 fShortcutsAction->setOn(false);353 shortcutsAction->setOn(false); 353 354 354 355 … … 368 369 SLOT(actionMousePick())); 369 370 370 QObject ::connect( fShortcutsAction,371 QObject ::connect(shortcutsAction, 371 372 SIGNAL(activated()), 372 373 this, 373 SLOT( actionMouseShortcuts()));374 SLOT(showShortcuts())); 374 375 375 376 #else … … 379 380 fMoveAction = mMouseAction->addAction("Move"); 380 381 fPickAction = mMouseAction->addAction("Pick"); 381 fShortcutsAction = mMouseAction->addAction("Show shortcuts");382 QAction *shortcutsAction = mMouseAction->addAction("Show shortcuts"); 382 383 383 384 fRotateAction->setCheckable(true); 384 385 fMoveAction->setCheckable(false); 385 386 fPickAction->setCheckable(false); 386 fShortcutsAction->setCheckable(false);387 shortcutsAction->setCheckable(false); 387 388 388 389 fRotateAction->setChecked(true); 389 390 fMoveAction->setChecked(false); 390 391 fPickAction->setChecked(false); 391 fShortcutsAction->setChecked(false);392 shortcutsAction->setChecked(false); 392 393 393 394 QObject ::connect(fRotateAction, … … 406 407 SLOT(actionMousePick())); 407 408 408 QObject ::connect( fShortcutsAction,409 QObject ::connect(shortcutsAction, 409 410 SIGNAL(triggered(bool)), 410 411 this, 411 SLOT( actionMouseShortcuts()));412 SLOT(showShortcuts())); 412 413 #endif 413 414 … … 893 894 } 894 895 895 /**896 Slot activate when mouseAction->zoom menu is set897 */898 void G4OpenGLQtViewer::actionMouseShortcuts() {899 #ifdef GEANT4_QT_DEBUG900 printf("G4OpenGLQtViewer::actionMouseShortcuts \n");901 #endif902 emit toggleMouseAction(STYLE4);903 }904 896 905 897 /** … … 940 932 if ((aAction == STYLE1) || //initialize all 941 933 (aAction == STYLE2) || 942 (aAction == STYLE3) || 943 (aAction == STYLE4)) { 934 (aAction == STYLE3)) { 944 935 #if QT_VERSION < 0x040000 945 936 fRotateAction->setOn (false); 946 937 fMoveAction->setOn (false); 947 938 fPickAction->setOn (false); 948 fShortcutsAction->setOn (false);949 939 #else 950 940 fRotateAction->setChecked (false); 951 941 fMoveAction->setChecked (false); 952 942 fPickAction->setChecked (false); 953 fShortcutsAction->setChecked (false);954 943 #endif 955 944 fVP.SetPicking(false); … … 958 947 // rotate 959 948 if (aAction == STYLE1) { // rotate 949 showShortcuts(); 950 #if QT_VERSION < 0x040000 951 fRotateAction->setOn (true); 952 #else 953 fRotateAction->setChecked (true); 954 #endif 955 } else if (aAction == STYLE2) { //move 956 #if QT_VERSION < 0x040000 957 fMoveAction->setOn (true); 958 #else 959 fMoveAction->setChecked (true); 960 #endif 961 } else if (aAction == STYLE3) { //pick 962 #if QT_VERSION < 0x040000 963 fPickAction->setOn (true); 964 #else 965 fPickAction->setChecked (true); 966 #endif 967 fVP.SetPicking(true); 968 } 969 } 970 971 /** 972 Show shortcuts for this mouse action 973 */ 974 void G4OpenGLQtViewer::showShortcuts() { 975 if (fMouseAction == STYLE1) { // rotate 960 976 G4cout << "Click and move mouse to rotate volume \n" << G4endl; 961 977 G4cout << "Press left/right arrows to move volume left/right\n" << G4endl; … … 964 980 G4cout << "Press SHIFT+left/right arrows to rotate volume left/right\n" << G4endl; 965 981 G4cout << "Press SHIFT+up/down arrows to rotate volume up/down\n" << G4endl; 966 G4cout << "Press +/- to zoom into volume\n" << G4endl; 967 #if QT_VERSION < 0x040000 968 fRotateAction->setOn (true); 969 #else 970 fRotateAction->setChecked (true); 971 #endif 972 } else if (aAction == STYLE2) { //move 982 G4cout << "Press ALT+/- to slow/speed auto rotation/move\n" << G4endl; 983 } else if (fMouseAction == STYLE2) { //move 973 984 G4cout << "Move camera point of view with mouse\n" << G4endl; 974 #if QT_VERSION < 0x040000975 fMoveAction->setOn (true);976 #else977 fMoveAction->setChecked (true);978 #endif979 } else if (aAction == STYLE3) { //pick980 G4cout << "Click and pick \n" << G4endl;981 #if QT_VERSION < 0x040000982 fPickAction->setOn (true);983 #else984 fPickAction->setChecked (true);985 #endif986 fVP.SetPicking(true);987 } else if (aAction == STYLE4) { // display shortcuts988 #if QT_VERSION < 0x040000989 // fShortcutsAction->setOn (true);990 #else991 // fShortcutsAction->setChecked (true);992 #endif993 994 G4cout << "Click and move mouse to rotate volume \n" << G4endl;995 985 G4cout << "Press left/right arrows to move volume left/right\n" << G4endl; 996 986 G4cout << "Press up/down arrows to move volume up/down\n" << G4endl; 997 G4cout << "Press CONTROL+up/down arrows to move volume toward/forward\n" << G4endl;987 G4cout << "Press ALT+up/down arrows to move volume toward/forward\n" << G4endl; 998 988 G4cout << "Press SHIFT+left/right arrows to rotate volume left/right\n" << G4endl; 999 989 G4cout << "Press SHIFT+up/down arrows to rotate volume up/down\n" << G4endl; 1000 990 G4cout << "Press +/- to zoom into volume\n" << G4endl; 1001 } 1002 1003 } 991 G4cout << "Press ALT+/- to slow/speed auto rotation/move\n" << G4endl; 992 } else if (fMouseAction == STYLE3) { //pick 993 G4cout << "Click and pick \n" << G4endl; 994 } 995 996 } 997 998 999 1004 1000 /** 1005 1001 Slot activated when drawing menu is toggle … … 1449 1445 1450 1446 if (!fAutoMove) { // keep old delta if automove 1451 fDeltaPos = QPoint(fLastPos.x() - pos_x, fLastPos.y() - pos_y); 1452 } 1453 1454 if ((fDeltaPos.x() == 0) && (fDeltaPos.y() == 0)) { 1447 fDeltaPosX = fLastPos.x() - pos_x; 1448 fDeltaPosY = fLastPos.y() - pos_y; 1449 } 1450 1451 if ((fDeltaPosX == 0) && (fDeltaPosY == 0)) { 1455 1452 fAutoMove = false; 1456 1453 } … … 1460 1457 if (fAutoMove) { 1461 1458 while (fAutoMove) { 1462 rotateScene(fDeltaPos .x(),fDeltaPos.y());1459 rotateScene(fDeltaPosX,fDeltaPosY); 1463 1460 #ifdef GEANT4_QT_DEBUG 1464 printf(" Processiongevent %d %d\n",fDeltaPos .x(),fDeltaPos.y());1461 printf(" Processiongevent %d %d\n",fDeltaPosX,fDeltaPosY); 1465 1462 #endif 1466 1463 ((QApplication*)G4Qt::getInstance ())->processEvents(); 1467 1464 } 1468 1465 } else { 1469 rotateScene(fDeltaPos .x(),fDeltaPos.y());1466 rotateScene(fDeltaPosX,fDeltaPosY); 1470 1467 } 1471 1468 } … … 1474 1471 if (fAutoMove) { 1475 1472 while (fAutoMove) { 1476 moveScene(-fDeltaPos .x(),-fDeltaPos.y(),0,true);1473 moveScene(-fDeltaPosX,-fDeltaPosY,0,true); 1477 1474 } 1478 1475 } else { 1479 moveScene(-fDeltaPos .x(),-fDeltaPos.y(),0,true);1476 moveScene(-fDeltaPosX,-fDeltaPosY,0,true); 1480 1477 } 1481 1478 } … … 1484 1481 #ifdef GEANT4_QT_DEBUG 1485 1482 if (mButtons & Qt::LeftButton) { 1486 printf(" end of mouse move event %d %d delta:%d %d\n",pos_x,pos_y,fDeltaPos .x(),fDeltaPos.y());1487 } else { 1488 printf(" end of mouse move event %d %d delta:%d %d --------------NO BUTTON\n",pos_x,pos_y,fDeltaPos .x(),fDeltaPos.y());1483 printf(" end of mouse move event %d %d delta:%d %d\n",pos_x,pos_y,fDeltaPosX,fDeltaPosY); 1484 } else { 1485 printf(" end of mouse move event %d %d delta:%d %d --------------NO BUTTON\n",pos_x,pos_y,fDeltaPosX,fDeltaPosY); 1489 1486 } 1490 1487 #endif … … 1874 1871 void G4OpenGLQtViewer::G4keyPressEvent (QKeyEvent * event) 1875 1872 { 1876 if ( holdKeyEvent)1873 if (fHoldKeyEvent) 1877 1874 return; 1878 1875 1879 holdKeyEvent = true;1876 fHoldKeyEvent = true; 1880 1877 1881 1878 #if QT_VERSION < 0x040000 … … 1922 1919 rotateScene(-1,0); 1923 1920 } 1921 1922 #if QT_VERSION < 0x040000 1923 if ((event->key() == Qt::Key_Plus) && (event->state() & Qt::AltButton)) { // rotate theta 1924 #else 1925 if ((event->key() == Qt::Key_Plus) && (event->modifiers() & Qt::AltModifier)) { // rotate theta 1926 #endif 1927 fDeltaPosX =fDeltaPosX*(1+fDeltaMove); 1928 fDeltaPosY =fDeltaPosY*(1+fDeltaMove); 1929 } 1930 #if QT_VERSION < 0x040000 1931 else if ((event->key() == Qt::Key_Minus) && (event->state() & Qt::AltButton)) { // rotate theta 1932 #else 1933 else if ((event->key() == Qt::Key_Minus) && (event->modifiers() & Qt::AltModifier)) { // rotate theta 1934 #endif 1935 fDeltaPosX =fDeltaPosX*(1-fDeltaMove); 1936 fDeltaPosY =fDeltaPosY*(1-fDeltaMove); 1937 } 1938 1939 1924 1940 if (event->key() == Qt::Key_Escape) { // escaped from full screen 1925 1941 #if QT_VERSION >= 0x030200 … … 1960 1976 } 1961 1977 } 1962 holdKeyEvent = false;1978 fHoldKeyEvent = false; 1963 1979 } 1964 1980
Note: See TracChangeset
for help on using the changeset viewer.