Changeset 844 for trunk/source


Ignore:
Timestamp:
Jun 20, 2008, 3:51:39 PM (16 years ago)
Author:
garnier
Message:

update before commit to cvs

Location:
trunk/source/visualization/OpenGL
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/visualization/OpenGL/include/G4OpenGLQtViewer.hh

    r843 r844  
    7272  virtual ~G4OpenGLQtViewer ();
    7373  void SetView ();
    74   void ClearView ();
    7574  void ShowView ();
    7675  virtual void updateQWidget()=0;
  • trunk/source/visualization/OpenGL/src/G4OpenGLQtViewer.cc

    r843 r844  
    3636#ifdef G4VIS_BUILD_OPENGLQT_DRIVER
    3737
    38 #define GEANT4_QT_DEBUG
    39 #define ROTATEGL
     38//#define GEANT4_QT_DEBUG
    4039
    4140#include "G4OpenGLQtViewer.hh"
    4241
    43 #include <cmath>
    4442#include "G4ios.hh"
    4543#include "G4VisExtent.hh"
     
    7977#include <qdialog.h>
    8078#include <qevent.h> //include <qcontextmenuevent.h>
    81 #include <qdatetime.h>
     79
    8280
    8381//////////////////////////////////////////////////////////////////////////////
     
    9088//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
    9189{
     90#ifdef GEANT4_QT_DEBUG
     91  printf("G4OpenGLQtViewer::SetView ++++++++++++++++++++\n");
     92#endif
    9293  //   if(!fHDC) return;
    9394  //   if(!fHGLRC) return;
    9495  //   ::wglMakeCurrent(fHDC,fHGLRC);
    9596  //  fWindow->makeCurrent();
    96   //  G4OpenGLViewer::SetView ();
    97  
    98   // Calculates view representation based on extent of object being
    99   // viewed and (initial) viewpoint.  (Note: it can change later due
    100   // to user interaction via visualization system's GUI.)
    101  
    102   // Lighting.
    103   GLfloat lightPosition [4];
    104   lightPosition [0] = fVP.GetActualLightpointDirection().x();
    105   lightPosition [1] = fVP.GetActualLightpointDirection().y();
    106   lightPosition [2] = fVP.GetActualLightpointDirection().z();
    107   lightPosition [3] = 0.;
    108   // Light position is "true" light direction, so must come after gluLookAt.
    109   GLfloat ambient [] = { 0.2, 0.2, 0.2, 1.};
    110   GLfloat diffuse [] = { 0.8, 0.8, 0.8, 1.};
    111   glEnable (GL_LIGHT0);
    112   glLightfv (GL_LIGHT0, GL_AMBIENT, ambient);
    113   glLightfv (GL_LIGHT0, GL_DIFFUSE, diffuse);
    114  
    115   // Get radius of scene, etc.
    116   // Note that this procedure properly takes into account zoom, dolly and pan.
    117   const G4Point3D targetPoint
    118     = fSceneHandler.GetScene()->GetStandardTargetPoint()
    119     + fVP.GetCurrentTargetPoint ();
    120   G4double radius = fSceneHandler.GetScene()->GetExtent().GetExtentRadius();
    121   if(radius<=0.) radius = 1.;
    122   const G4double cameraDistance = fVP.GetCameraDistance (radius);
    123   const G4Point3D cameraPosition =
    124     targetPoint + cameraDistance * fVP.GetViewpointDirection().unit();
    125   const GLdouble pnear   = fVP.GetNearDistance (cameraDistance, radius);
    126   const GLdouble pfar    = fVP.GetFarDistance  (cameraDistance, pnear, radius);
    127   const GLdouble right  = fVP.GetFrontHalfHeight (pnear, radius);
    128   const GLdouble left   = -right;
    129   const GLdouble bottom = left;
    130   const GLdouble top    = right;
    131  
    132   glMatrixMode (GL_PROJECTION); // set up Frustum.
    133   glLoadIdentity();
    134 
    135   const G4Vector3D scale = fVP.GetScaleFactor();
    136   glScaled(scale.x(),scale.y(),scale.z());
    137  
    138   if (fVP.GetFieldHalfAngle() == 0.) {
    139     glOrtho (left, right, bottom, top, pnear, pfar);
    140   }
    141   else {
    142     glFrustum (left, right, bottom, top, pnear, pfar);
    143   }
    144  
    145   glMatrixMode (GL_MODELVIEW); // apply further transformations to scene.
    146   glLoadIdentity();
    147  
    148   const G4Normal3D& upVector = fVP.GetUpVector (); 
    149   G4Point3D gltarget;
    150   if (cameraDistance > 1.e-6 * radius) {
    151     gltarget = targetPoint;
    152   }
    153   else {
    154     gltarget = targetPoint - radius * fVP.GetViewpointDirection().unit();
    155   }
    156 
    157   const G4Point3D& pCamera = cameraPosition;  // An alias for brevity.
    158   gluLookAt (pCamera.x(),  pCamera.y(),  pCamera.z(),       // Viewpoint.
    159              gltarget.x(), gltarget.y(), gltarget.z(),      // Target point.
    160              upVector.x(), upVector.y(), upVector.z());     // Up vector.
    161  
    162   // Light position is "true" light direction, so must come after gluLookAt.
    163   glLightfv (GL_LIGHT0, GL_POSITION, lightPosition);
    164 
    165   // OpenGL no longer seems to reconstruct clipped edges, so, when the
    166   // BooleanProcessor is up to it, abandon this and use generic
    167   // clipping in G4OpenGLSceneHandler::CreateSectionPolyhedron.  Also,
    168   // force kernel visit on change of clipping plane in
    169   // G4OpenGLStoredViewer::CompareForKernelVisit.
    170   if (fVP.IsSection () ) {  // pair of back to back clip planes.
    171     const G4Plane3D& s = fVP.GetSectionPlane ();
    172     double sArray[4];
    173     sArray[0] = s.a();
    174     sArray[1] = s.b();
    175     sArray[2] = s.c();
    176     sArray[3] = s.d() + radius * 1.e-05;
    177     glClipPlane (GL_CLIP_PLANE0, sArray);
    178     glEnable (GL_CLIP_PLANE0);
    179     sArray[0] = -s.a();
    180     sArray[1] = -s.b();
    181     sArray[2] = -s.c();
    182     sArray[3] = -s.d() + radius * 1.e-05;
    183     glClipPlane (GL_CLIP_PLANE1, sArray);
    184     glEnable (GL_CLIP_PLANE1);
    185   } else {
    186     glDisable (GL_CLIP_PLANE0);
    187     glDisable (GL_CLIP_PLANE1);
    188   }
    189 
    190   const G4Planes& cutaways = fVP.GetCutawayPlanes();
    191   size_t nPlanes = cutaways.size();
    192   if (fVP.IsCutaway() &&
    193       fVP.GetCutawayMode() == G4ViewParameters::cutawayIntersection &&
    194       nPlanes > 0) {
    195     double a[4];
    196     a[0] = cutaways[0].a();
    197     a[1] = cutaways[0].b();
    198     a[2] = cutaways[0].c();
    199     a[3] = cutaways[0].d();
    200     glClipPlane (GL_CLIP_PLANE2, a);
    201     glEnable (GL_CLIP_PLANE2);
    202     if (nPlanes > 1) {
    203       a[0] = cutaways[1].a();
    204       a[1] = cutaways[1].b();
    205       a[2] = cutaways[1].c();
    206       a[3] = cutaways[1].d();
    207       glClipPlane (GL_CLIP_PLANE3, a);
    208       glEnable (GL_CLIP_PLANE3);
    209     }
    210     if (nPlanes > 2) {
    211       a[0] = cutaways[2].a();
    212       a[1] = cutaways[2].b();
    213       a[2] = cutaways[2].c();
    214       a[3] = cutaways[2].d();
    215       glClipPlane (GL_CLIP_PLANE4, a);
    216       glEnable (GL_CLIP_PLANE4);
    217     }
    218   } else {
    219     glDisable (GL_CLIP_PLANE2);
    220     glDisable (GL_CLIP_PLANE3);
    221     glDisable (GL_CLIP_PLANE4);
    222   }
    223 
    224   // Background.
    225   background = fVP.GetBackgroundColour ();
    226 }
    227 
    228 void G4OpenGLQtViewer::ClearView (
    229 )
    230 //////////////////////////////////////////////////////////////////////////////
    231 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
    232 {
    233   G4OpenGLViewer::ClearView ();
    234   // glLoadIdentity();
    235 #ifdef ROTATEGL
    236   glRotatef(fRotationAngleY, 1.0, 0.0, 0.0);
    237   glRotatef(fRotationAngleX, 0.0, 1.0, 0.0);
    238   glRotatef(fRotationAngleZ, 0.0, 0.0, 1.0);
     97  G4OpenGLViewer::SetView ();
     98#ifdef GEANT4_QT_DEBUG
     99  printf("G4OpenGLQtViewer::SetView --------------------\n");
    239100#endif
    240101}
     
    429290  ,fWindow(0)
    430291  ,fRecordFrameNumber(0)
     292  ,fRotationAngleX(0)
     293  ,fRotationAngleY(0)
     294  ,fDeltaRotationAngleX(0)
     295  ,fDeltaRotationAngleY(0)
    431296  ,fContextMenu(0)
    432297  ,fMouseAction(STYLE1)
     
    449314  ,fProcess(NULL)
    450315  ,fLaunchSpinDelay(100)
    451   ,fRotationAngleX(0)
    452   ,fRotationAngleY(0)
    453   ,fDeltaRotationAngleX(0)
    454   ,fDeltaRotationAngleY(0)
    455316{
    456317
     
    17991660    return;
    18001661  fHoldRotateEvent = true;
    1801 
    1802 #ifndef ROTATEGL
     1662 
    18031663  if( dx != 0) {
    18041664    rotateScene(dx,0,fDeltaRotation);
     
    18091669    emit rotatePhi(dy);
    18101670  }
    1811 #else
    1812   fDeltaRotationAngleX = -50*dx*3.14/180;
    1813   fDeltaRotationAngleY = 50*dy*3.14/180;
    1814   fRotationAngleZ +=fDeltaRotationAngleZ;
    1815   fRotationAngleY +=fDeltaRotationAngleY;
    1816   fRotationAngleX +=fDeltaRotationAngleX;
    1817 #endif
    18181671  updateQWidget();
    18191672 
  • trunk/source/visualization/OpenGL/src/G4OpenGLStoredQtViewer.cc

    r804 r844  
    123123#ifdef GEANT4_QT_DEBUG
    124124  printf("G4OpenGLQtViewer::setupViewport\n");
    125 #endif
    126 #ifdef GEANT4_QT_DEBUG
    127125  printf("G4OpenGLStoredQtViewer::DrawView %d %d   VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",WinSize_x, WinSize_y);
    128126#endif
  • trunk/source/visualization/OpenGL/src/G4OpenGLViewer.cc

    r801 r844  
    3434#ifdef G4VIS_BUILD_OPENGL_DRIVER
    3535
    36 #define GEANT4_QT_DEBUG
     36//#define GEANT4_QT_DEBUG
    3737
    3838#include "G4ios.hh"
Note: See TracChangeset for help on using the changeset viewer.