Changeset 712 for trunk


Ignore:
Timestamp:
Feb 5, 2008, 3:17:36 PM (16 years ago)
Author:
garnier
Message:

correction du ticket #119

Location:
trunk/geant4
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/geant4/specific-geant4-dev.sh

    r709 r712  
    103103
    104104export DISTCC_COMPILER="gcc version 4.0.1 (Apple Computer, Inc. build 5370)"
    105 export DISTCC_HOSTS="mac-ens14/3,lzo mac-ens15/3,lzo  mac-ens13/3,lzo localhost/1 mac-ens7/3,lzo mac-ens2.local./3,lzo mac-ens8.local./3,lzo mac-ens12.local./3,lzo mac-ens3.local./3,lzo mac-ens4/3,lzo mac-ens13/3,lzo mac-ens9/3,lzo"
     105export DISTCC_HOSTS="mac-ens4/3,lzo mac-ens5/3,lzo  mac-ens3/3,lzo localhost/1 mac-ens7/3,lzo mac-ens2.local./3,lzo mac-ens8.local./3,lzo mac-ens12.local./3,lzo mac-ens3.local./3,lzo mac-ens4/3,lzo mac-ens13/3,lzo mac-ens9/3,lzo"
    106106export DISTCC_SYSTEM="10.4.11 (8S165, ppc)"
    107107
  • trunk/geant4/visualization/OpenGL/include/G4OpenGLQtViewer.hh

    r711 r712  
    112112  QPoint fLastPos;
    113113  /** delta of scene translation. This delta is put in % of the scene view */
    114   float fDeltaSceneTranslation;
    115   /** delta of left right move. This delta is put in % of the scene view */
    116   float fDeltaZoom;
     114  G4double fDeltaSceneTranslation;
     115  /** delta of depth move. This delta is put in % of the scene view */
     116  G4double fDeltaDepth;
     117  /** delta of zoom move. This delta is put in % of the scene view */
     118  G4double fDeltaZoom;
    117119  /** To ensure key event are keep one by one */
    118120  bool holdKeyEvent;
  • trunk/geant4/visualization/OpenGL/include/G4OpenGLViewer.hh

    r606 r712  
    7373  void spewWireframeEPS (FILE*, GLint, GLfloat*, const char*);
    7474  void print3DcolorVertex(GLint, GLint*, GLfloat*);
     75  GLdouble getSceneNearWidth();
     76  GLdouble getSceneFarWidth();
     77  GLdouble getSceneDepth();
    7578  G4float                           pointSize;
    7679  char                              print_string[50];
  • trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc

    r711 r712  
    287287  ,fContextMenu(0)
    288288  ,fMouseAction(STYLE1)
    289   ,fDeltaSceneTranslation(1/100)
    290   ,fDeltaZoom(1.1)
     289  ,fDeltaSceneTranslation(0.01)
     290  ,fDeltaDepth(0.01)
     291  ,fDeltaZoom(0.1)
    291292  ,holdKeyEvent(false)
    292293{
     
    13951396void G4OpenGLQtViewer::G4MouseMoveEvent(int dx, int dy, int dz)
    13961397{
    1397 //               2
    1398 //         ------------       0              0              tx
    1399 //         right - left
    1400 //                            2
    1401 //             0         ------------        0              ty
    1402 //                       top - bottom
    1403 //                                           -2
    1404 //             0              0         ------------        tz
    1405 //                                       zFar-zNear
    1406 //             0              0              0              1
    1407 //        where
    1408 //                        tx = - (right + left) / (right - left)
    1409 //                        ty = - (top + bottom) / (top - bottom)
    1410 //                        tz = - (zFar + zNear) / (zFar - zNear)
    1411  double              projection_view[16];
    1412  glGetDoublev (GL_PROJECTION_MATRIX, projection_view);
    1413  printf("%f\t%f\t%f\t%f\n",projection_view[0],projection_view[1],projection_view[2],projection_view[3]);
    1414  printf("%f\t%f\t%f\t%f\n",projection_view[4],projection_view[5],projection_view[6],projection_view[7]);
    1415  printf("%f\t%f\t%f\t%f\n",projection_view[8],projection_view[9],projection_view[10],projection_view[11]);
    1416  printf("%f\t%f\t%f\t%f\n",projection_view[12],projection_view[13],projection_view[14],projection_view[15]);
    1417 //   int deltaX =
    1418 // GLenum clip = glGet(GL_CLIP_PLANE);
    1419 //   int deltaY = ;
    1420 
    1421 
    1422   G4Point3D stp = GetSceneHandler()->GetScene()->GetStandardTargetPoint();
    1423  
    1424   G4Point3D tp = stp + fVP.GetCurrentTargetPoint ();
    1425  
    1426   const G4Vector3D& upVector = fVP.GetUpVector ();
    1427   const G4Vector3D& vpVector = fVP.GetViewpointDirection ();
    1428  
    1429   G4Vector3D unitRight = (upVector.cross (vpVector)).unit();
    1430   G4Vector3D unitUp    = (vpVector.cross (unitRight)).unit();
    1431  
    1432 #ifdef GEANT4_QT_DEBUG
    1433   G4cout << fVP<<G4endl;
    1434   printf("Mouse event Target Point : %f %f %f\n",tp.x(),tp.y(),tp.z());
    1435   printf("Mouse event upVector : %f %f %f\n",upVector.x(),upVector.y(),upVector.z());
    1436   printf("Mouse event vpVector Point : %f %f %f\n",vpVector.x(),vpVector.y(),vpVector.z());
    1437   printf("Mouse event unitRight Point : %f %f %f\n",unitRight.x(),unitRight.y(),unitRight.z());
    1438   printf("Mouse event unitUp Point : %f %f %f\n",unitUp.x(),unitUp.y(),unitUp.z());
    1439 #endif
    1440   tp += -dx * unitRight + dy * unitUp + dz * vpVector;
    1441   fVP.SetCurrentTargetPoint (tp - stp);
    1442  
    1443   updateQWidget();
     1398  GLdouble coefTrans = getSceneNearWidth()*fDeltaSceneTranslation;
     1399  GLdouble coefDepth = getSceneDepth()*fDeltaDepth;
     1400
     1401  printf("Increment : %f %f\n",getSceneNearWidth(),getSceneDepth());
     1402  printf("Increment : %f %f %f \n",-dx*coefTrans,dy*coefTrans,dz*coefDepth);
     1403 fVP.IncrementPan(-dx*coefTrans,dy*coefTrans,dz*coefDepth);
     1404 
     1405 updateQWidget();
    14441406}
    14451407
     
    18071769  if ((event->key() == Qt::Key_Down) && (event->modifiers() & Qt::AltModifier )) { // go backward
    18081770#endif
     1771#ifdef GEANT4_QT_DEBUG
     1772    printf("Alt + Down!!\n");
     1773#endif
     1774   
    18091775    G4MouseMoveEvent(0,0,1);
    18101776  }
     
    18131779#else
    18141780  else if ((event->key() == Qt::Key_Up) && (event->modifiers() & Qt::AltModifier)) { // go forward
     1781#endif
     1782#ifdef GEANT4_QT_DEBUG
     1783    printf("Alt + Up!!\n");
    18151784#endif
    18161785    G4MouseMoveEvent(0,0,-1);
     
    18481817  }
    18491818  if (event->key() == Qt::Key_Plus) { // zoom in
    1850     fVP.SetZoomFactor(fVP.GetZoomFactor()*fDeltaZoom);
     1819    fVP.SetZoomFactor(fVP.GetZoomFactor()*(1+fDeltaZoom));
    18511820    updateQWidget();
    18521821  }
    18531822  else if (event->key() == Qt::Key_Minus) { // zoom out
    1854     fVP.SetZoomFactor(fVP.GetZoomFactor()/fDeltaZoom);
     1823    fVP.SetZoomFactor(fVP.GetZoomFactor()*(1-fDeltaZoom));
    18551824    updateQWidget();
    18561825  }
    18571826  // with no modifiers
    18581827  if (!event->modifiers()) {
     1828#ifdef GEANT4_QT_DEBUG
     1829    printf("No modifier !!\n");
     1830#endif
    18591831    if (event->key() == Qt::Key_Down) { // go down
    18601832      G4MouseMoveEvent(0,1,0);
  • trunk/geant4/visualization/OpenGL/src/G4OpenGLViewer.cc

    r688 r712  
    196196  }
    197197 
     198  printf("Set view to : %f %f %f %f %f %f \n",left, right, bottom, top, pnear, pfar);
    198199  glMatrixMode (GL_MODELVIEW); // apply further transformations to scene.
    199200  glLoadIdentity();
     
    724725}
    725726
     727GLdouble G4OpenGLViewer::getSceneNearWidth()
     728{
     729  const G4Point3D targetPoint
     730    = fSceneHandler.GetScene()->GetStandardTargetPoint()
     731    + fVP.GetCurrentTargetPoint ();
     732  G4double radius = fSceneHandler.GetScene()->GetExtent().GetExtentRadius();
     733  if(radius<=0.) radius = 1.;
     734  const G4double cameraDistance = fVP.GetCameraDistance (radius);
     735  const GLdouble pnear   = fVP.GetNearDistance (cameraDistance, radius);
     736  return 2 * fVP.GetFrontHalfHeight (pnear, radius);
     737}
     738
     739GLdouble G4OpenGLViewer::getSceneFarWidth()
     740{
     741  const G4Point3D targetPoint
     742    = fSceneHandler.GetScene()->GetStandardTargetPoint()
     743    + fVP.GetCurrentTargetPoint ();
     744  G4double radius = fSceneHandler.GetScene()->GetExtent().GetExtentRadius();
     745  if(radius<=0.) radius = 1.;
     746  const G4double cameraDistance = fVP.GetCameraDistance (radius);
     747  const GLdouble pnear   = fVP.GetNearDistance (cameraDistance, radius);
     748  const GLdouble pfar    = fVP.GetFarDistance  (cameraDistance, pnear, radius);
     749  return 2 * fVP.GetFrontHalfHeight (pfar, radius);
     750}
     751
     752
     753GLdouble G4OpenGLViewer::getSceneDepth()
     754{
     755  const G4Point3D targetPoint
     756    = fSceneHandler.GetScene()->GetStandardTargetPoint()
     757    + fVP.GetCurrentTargetPoint ();
     758  G4double radius = fSceneHandler.GetScene()->GetExtent().GetExtentRadius();
     759  if(radius<=0.) radius = 1.;
     760  const G4double cameraDistance = fVP.GetCameraDistance (radius);
     761  const GLdouble pnear   = fVP.GetNearDistance (cameraDistance, radius);
     762  return fVP.GetFarDistance  (cameraDistance, pnear, radius)- pnear;
     763}
     764
     765
    726766void G4OpenGLViewer::spewSortedFeedback(FILE * file, GLint size, GLfloat * buffer)
    727767{
  • trunk/geant4/visualization/management/include/G4ViewParameters.hh

    r593 r712  
    210210  void SetLightsMoveWithCamera (G4bool moves);
    211211  void SetPan                  (G4double right, G4double up);
     212  /** Increment currentTarget point by following X,Y values
     213   */
    212214  void IncrementPan            (G4double right, G4double up);
     215  /** Increment currentTarget point by following X,Y,Z values
     216   */
     217  void IncrementPan            (G4double right, G4double up, G4double distance);
    213218  void SetDefaultVisAttributes (const G4VisAttributes&);
    214219  void SetDefaultTextVisAttributes (const G4VisAttributes&);
  • trunk/geant4/visualization/management/src/G4ViewParameters.cc

    r593 r712  
    233233
    234234void G4ViewParameters::IncrementPan (G4double right, G4double up) {
     235  IncrementPan (right,up, 0);
     236}
     237
     238void G4ViewParameters::IncrementPan (G4double right, G4double up, G4double distance) {
    235239  G4Vector3D unitRight = (fUpVector.cross (fViewpointDirection)).unit();
    236240  G4Vector3D unitUp    = (fViewpointDirection.cross (unitRight)).unit();
    237   fCurrentTargetPoint += right * unitRight + up * unitUp;
     241  fCurrentTargetPoint += right * unitRight + up * unitUp + distance * fViewpointDirection;
    238242}
    239243
Note: See TracChangeset for help on using the changeset viewer.