Ignore:
Timestamp:
Feb 11, 2008, 3:07:12 PM (16 years ago)
Author:
garnier
Message:

mise a jour des shortcuts qui ne se displaient pas comme il faut. Ajout d un shortcut pour accelerer/relantir les mvt automatiques

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc

    r720 r721  
    292292  ,fDeltaDepth(0.01)
    293293  ,fDeltaZoom(0.1)
    294   ,holdKeyEvent(false)
     294  ,fDeltaMove(0.2)
     295  ,fHoldKeyEvent(false)
    295296  ,fAutoMove(false)
    296297{
     
    330331  fMoveAction =  new QAction("&Move","&Move",CTRL+Key_M,mMouseAction,0,true);
    331332  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);
    333334#else
    334335  fRotateAction =  new QAction("&Rotate",CTRL+Key_R,mMouseAction);
    335336  fMoveAction =  new QAction("&Move",CTRL+Key_M,mMouseAction);
    336337  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);
    338339#endif
    339340  fRotateAction->addTo(mMouseAction);
    340341  fMoveAction->addTo(mMouseAction);
    341342  fPickAction->addTo(mMouseAction);
    342   fShortcutsAction->addTo(mMouseAction);
     343  shortcutsAction->addTo(mMouseAction);
    343344
    344345  fRotateAction->setToggleAction(true);
    345346  fMoveAction->setToggleAction(true);
    346347  fPickAction->setToggleAction(true);
    347   fShortcutsAction->setToggleAction(true);
     348  shortcutsAction->setToggleAction(true);
    348349
    349350  fRotateAction->setOn(true);
    350351  fMoveAction->setOn(false);
    351352  fPickAction->setOn(false);
    352   fShortcutsAction->setOn(false);
     353  shortcutsAction->setOn(false);
    353354
    354355
     
    368369                    SLOT(actionMousePick()));
    369370
    370   QObject ::connect(fShortcutsAction,
     371  QObject ::connect(shortcutsAction,
    371372                    SIGNAL(activated()),
    372373                    this,
    373                     SLOT(actionMouseShortcuts()));
     374                    SLOT(showShortcuts()));
    374375
    375376#else
     
    379380  fMoveAction = mMouseAction->addAction("Move");
    380381  fPickAction = mMouseAction->addAction("Pick");
    381   fShortcutsAction = mMouseAction->addAction("Show shortcuts");
     382  QAction *shortcutsAction = mMouseAction->addAction("Show shortcuts");
    382383
    383384  fRotateAction->setCheckable(true);
    384385  fMoveAction->setCheckable(false);
    385386  fPickAction->setCheckable(false);
    386   fShortcutsAction->setCheckable(false);
     387  shortcutsAction->setCheckable(false);
    387388
    388389  fRotateAction->setChecked(true);
    389390  fMoveAction->setChecked(false);
    390391  fPickAction->setChecked(false);
    391   fShortcutsAction->setChecked(false);
     392  shortcutsAction->setChecked(false);
    392393
    393394  QObject ::connect(fRotateAction,
     
    406407                    SLOT(actionMousePick()));
    407408
    408   QObject ::connect(fShortcutsAction,
     409  QObject ::connect(shortcutsAction,
    409410                    SIGNAL(triggered(bool)),
    410411                    this,
    411                     SLOT(actionMouseShortcuts()));
     412                    SLOT(showShortcuts()));
    412413#endif
    413414
     
    893894}
    894895
    895 /**
    896    Slot activate when mouseAction->zoom menu is set
    897  */
    898 void G4OpenGLQtViewer::actionMouseShortcuts() {
    899 #ifdef GEANT4_QT_DEBUG
    900   printf("G4OpenGLQtViewer::actionMouseShortcuts \n");
    901 #endif
    902   emit toggleMouseAction(STYLE4);
    903 }
    904896
    905897/**
     
    940932  if ((aAction == STYLE1) || //initialize all
    941933      (aAction == STYLE2) ||
    942       (aAction == STYLE3) ||
    943       (aAction == STYLE4))  {
     934      (aAction == STYLE3))  {
    944935#if QT_VERSION < 0x040000
    945936    fRotateAction->setOn (false);
    946937    fMoveAction->setOn (false);
    947938    fPickAction->setOn (false);
    948     fShortcutsAction->setOn (false);
    949939#else
    950940    fRotateAction->setChecked (false);
    951941    fMoveAction->setChecked (false);
    952942    fPickAction->setChecked (false);
    953     fShortcutsAction->setChecked (false);
    954943#endif
    955944    fVP.SetPicking(false);
     
    958947  // rotate
    959948  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 */
     974void G4OpenGLQtViewer::showShortcuts() {
     975  if (fMouseAction == STYLE1) {  // rotate
    960976    G4cout << "Click and move mouse to rotate volume \n" << G4endl;
    961977    G4cout << "Press left/right arrows to move volume left/right\n" << G4endl;
     
    964980    G4cout << "Press SHIFT+left/right arrows to rotate volume left/right\n" << G4endl;
    965981    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
    973984    G4cout << "Move camera point of view with mouse\n" << G4endl;
    974 #if QT_VERSION < 0x040000
    975     fMoveAction->setOn (true);
    976 #else
    977     fMoveAction->setChecked (true);
    978 #endif
    979   } else  if (aAction == STYLE3) { //pick
    980     G4cout << "Click and pick \n" << G4endl;
    981 #if QT_VERSION < 0x040000
    982     fPickAction->setOn (true);
    983 #else
    984     fPickAction->setChecked (true);
    985 #endif
    986     fVP.SetPicking(true);
    987   } else  if (aAction == STYLE4) {  // display shortcuts
    988 #if QT_VERSION < 0x040000
    989     //    fShortcutsAction->setOn (true);
    990 #else
    991     //    fShortcutsAction->setChecked (true);
    992 #endif
    993 
    994     G4cout << "Click and move mouse to rotate volume \n" << G4endl;
    995985    G4cout << "Press left/right arrows to move volume left/right\n" << G4endl;
    996986    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;
    998988    G4cout << "Press SHIFT+left/right arrows to rotate volume left/right\n" << G4endl;
    999989    G4cout << "Press SHIFT+up/down arrows to rotate volume up/down\n" << G4endl;
    1000990    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
    10041000/**
    10051001   Slot activated when drawing menu is toggle
     
    14491445
    14501446  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)) {
    14551452    fAutoMove = false;
    14561453  }
     
    14601457      if (fAutoMove) {
    14611458        while (fAutoMove) {
    1462           rotateScene(fDeltaPos.x(),fDeltaPos.y());
     1459          rotateScene(fDeltaPosX,fDeltaPosY);
    14631460#ifdef GEANT4_QT_DEBUG
    1464           printf("                   Processiongevent %d %d\n",fDeltaPos.x(),fDeltaPos.y());
     1461          printf("                   Processiongevent %d %d\n",fDeltaPosX,fDeltaPosY);
    14651462#endif
    14661463          ((QApplication*)G4Qt::getInstance ())->processEvents();
    14671464        }
    14681465      } else {
    1469         rotateScene(fDeltaPos.x(),fDeltaPos.y());
     1466        rotateScene(fDeltaPosX,fDeltaPosY);
    14701467      }
    14711468    }
     
    14741471      if (fAutoMove) {
    14751472        while (fAutoMove) {
    1476           moveScene(-fDeltaPos.x(),-fDeltaPos.y(),0,true);
     1473          moveScene(-fDeltaPosX,-fDeltaPosY,0,true);
    14771474        }
    14781475      } else {
    1479         moveScene(-fDeltaPos.x(),-fDeltaPos.y(),0,true);
     1476        moveScene(-fDeltaPosX,-fDeltaPosY,0,true);
    14801477      }
    14811478    }
     
    14841481#ifdef GEANT4_QT_DEBUG
    14851482  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);
    14891486  }
    14901487#endif
     
    18741871void G4OpenGLQtViewer::G4keyPressEvent (QKeyEvent * event)
    18751872{
    1876   if (holdKeyEvent)
     1873  if (fHoldKeyEvent)
    18771874    return;
    18781875
    1879   holdKeyEvent = true;
     1876  fHoldKeyEvent = true;
    18801877
    18811878#if QT_VERSION < 0x040000
     
    19221919    rotateScene(-1,0);
    19231920  }
     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
    19241940  if (event->key() == Qt::Key_Escape) { // escaped from full screen
    19251941#if QT_VERSION >= 0x030200
     
    19601976    }
    19611977  }
    1962   holdKeyEvent = false;
     1978  fHoldKeyEvent = false;
    19631979}
    19641980
Note: See TracChangeset for help on using the changeset viewer.