35 #ifdef G4VIS_BUILD_OPENGL_DRIVER 
   47 G4OpenGLStoredViewer::G4OpenGLStoredViewer
 
   48 (G4OpenGLStoredSceneHandler& sceneHandler):
 
   50 G4OpenGLViewer (sceneHandler), 
 
   51 fG4OpenGLStoredSceneHandler (sceneHandler)
 
   57 G4OpenGLStoredViewer::~G4OpenGLStoredViewer () {}
 
   59 void G4OpenGLStoredViewer::KernelVisitDecision () {
 
   64   if (!fG4OpenGLStoredSceneHandler.fTopPODL ||
 
   65       CompareForKernelVisit(fLastVP)) {
 
   76       (lastVP.
IsCulling ()          != fVP.IsCulling ())          ||
 
   80       (lastVP.
IsSection ()          != fVP.IsSection ())          ||
 
   84       (lastVP.
IsCutaway ()          != fVP.IsCutaway ())          ||
 
   87       (lastVP.
IsExplode ()          != fVP.IsExplode ())          ||
 
   90        fVP.GetDefaultVisAttributes()->
GetColour())                ||
 
   92        fVP.GetDefaultTextVisAttributes()->
GetColour())            ||
 
   94       (lastVP.
IsPicking ()          != fVP.IsPicking ())          ||
 
   96        fVP.GetVisAttributesModifiers().size())
 
  131 void G4OpenGLStoredViewer::DrawDisplayLists () {
 
  132 #ifdef G4DEBUG_VIS_OGL 
  133   printf(
"G4OpenGLStoredViewer::DrawDisplayLists \n");
 
  136   const G4Planes& cutaways = fVP.GetCutawayPlanes();
 
  137   G4bool cutawayUnion = fVP.IsCutaway() &&
 
  139   const size_t nCutaways = cutawayUnion? cutaways.size(): 1;
 
  140 #ifdef G4DEBUG_VIS_OGL 
  141   printf(
"G4OpenGLStoredViewer::DrawDisplayLists");
 
  144   G4bool secondPassForTransparencyRequested = 
false;
 
  145   G4bool thirdPassForNonHiddenMarkersRequested = 
false;
 
  147     for (
size_t iCutaway = 0; iCutaway < nCutaways; ++iCutaway) {
 
  151     a[0] = cutaways[iCutaway].a();
 
  152     a[1] = cutaways[iCutaway].b();
 
  153     a[2] = cutaways[iCutaway].c();
 
  154     a[3] = cutaways[iCutaway].d();
 
  155     glClipPlane (GL_CLIP_PLANE2, a);
 
  156     glEnable (GL_CLIP_PLANE2);
 
  159       G4bool isPicking = fVP.IsPicking();
 
  162        iPO < fG4OpenGLStoredSceneHandler.fPOList.size(); ++iPO) {
 
  163     if (POSelected(iPO)) {
 
  164       G4OpenGLStoredSceneHandler::PO& po =
 
  165         fG4OpenGLStoredSceneHandler.fPOList[iPO];
 
  167       DisplayTimePOColourModification(c,iPO);
 
  170         if (isTransparent && transparency_enabled) {
 
  171           secondPassForTransparencyRequested = 
true;
 
  174         if (po.fMarkerOrPolyline && fVP.IsMarkerNotHidden()) {
 
  175           thirdPassForNonHiddenMarkersRequested = 
true;
 
  178       } 
else if (iPass == 2) {  
 
  179         if (!isTransparent) {
 
  183         if (!po.fMarkerOrPolyline) {
 
  187       if (isPicking) glLoadName(po.fPickName);
 
  188           if (transparency_enabled) {
 
  193           if (po.fMarkerOrPolyline && fVP.IsMarkerNotHidden())
 
  194             glDisable (GL_DEPTH_TEST);
 
  195           else {glEnable (GL_DEPTH_TEST); glDepthFunc (GL_LEQUAL);}
 
  196       if (po.fpG4TextPlus) {
 
  197         if (po.fpG4TextPlus->fProcessing2D) {
 
  198           glMatrixMode (GL_PROJECTION);
 
  201           glOrtho (-1., 1., -1., 1., -G4OPENGL_FLT_BIG, G4OPENGL_FLT_BIG);
 
  202           glMatrixMode (GL_MODELVIEW);
 
  205         G4OpenGLTransform3D oglt (po.fTransform);
 
  206         glMultMatrixd (oglt.GetGLMatrix ());
 
  207         fOpenGLSceneHandler.G4OpenGLSceneHandler::AddPrimitive
 
  208           (po.fpG4TextPlus->fG4Text);
 
  211         G4OpenGLTransform3D oglt (po.fTransform);
 
  212         glMultMatrixd (oglt.GetGLMatrix ());
 
  213         fOpenGLSceneHandler.G4OpenGLSceneHandler::AddPrimitive
 
  214           (po.fpG4TextPlus->fG4Text);
 
  218         if (po.fpG4TextPlus->fProcessing2D) {
 
  219           glMatrixMode (GL_PROJECTION);
 
  221           glMatrixMode (GL_MODELVIEW);
 
  226         G4OpenGLTransform3D oglt (po.fTransform);
 
  227         glMultMatrixd (oglt.GetGLMatrix ());
 
  228         glCallList (po.fDisplayListId);
 
  238        iTO < fG4OpenGLStoredSceneHandler.fTOList.size(); ++iTO) {
 
  239     if (TOSelected(iTO)) {
 
  240       G4OpenGLStoredSceneHandler::TO& to =
 
  241         fG4OpenGLStoredSceneHandler.fTOList[iTO];
 
  245         if (isTransparent && transparency_enabled) {
 
  246           secondPassForTransparencyRequested = 
true;
 
  249         if (to.fMarkerOrPolyline && fVP.IsMarkerNotHidden()) {
 
  250           thirdPassForNonHiddenMarkersRequested = 
true;
 
  253       } 
else if (iPass == 2) {  
 
  254         if (!isTransparent) {
 
  258         if (!to.fMarkerOrPolyline) {
 
  262           if (to.fMarkerOrPolyline && fVP.IsMarkerNotHidden())
 
  263             glDisable (GL_DEPTH_TEST);
 
  264           else {glEnable (GL_DEPTH_TEST); glDepthFunc (GL_LEQUAL);}
 
  265       if (to.fEndTime >= fStartTime && to.fStartTime <= fEndTime) {
 
  266         if (fVP.IsPicking()) glLoadName(to.fPickName);
 
  267         if (to.fpG4TextPlus) {
 
  268           if (to.fpG4TextPlus->fProcessing2D) {
 
  269         glMatrixMode (GL_PROJECTION);
 
  272         glOrtho (-1., 1., -1., 1., -G4OPENGL_FLT_BIG, G4OPENGL_FLT_BIG);
 
  273         glMatrixMode (GL_MODELVIEW);
 
  277           G4OpenGLTransform3D oglt (to.fTransform);
 
  278           glMultMatrixd (oglt.GetGLMatrix ());
 
  279               if (transparency_enabled) {
 
  284           fOpenGLSceneHandler.G4OpenGLSceneHandler::AddPrimitive
 
  285         (to.fpG4TextPlus->fG4Text);
 
  286           if (to.fpG4TextPlus->fProcessing2D) {
 
  287         glMatrixMode (GL_PROJECTION);
 
  289         glMatrixMode (GL_MODELVIEW);
 
  293           if (to.fTransform != lastMatrixTransform) {
 
  299         G4OpenGLTransform3D oglt (to.fTransform);
 
  300         glMultMatrixd (oglt.GetGLMatrix ());
 
  303           if (fFadeFactor > 0. && to.fEndTime < fEndTime) {
 
  306           ((fEndTime - to.fEndTime) / (fEndTime - fStartTime));
 
  307         const G4Colour& bg = fVP.GetBackgroundColour();
 
  308                 if (transparency_enabled) {
 
  310           (bsf * cc.
GetRed() + (1. - bsf) * bg.GetRed(),
 
  311            bsf * cc.
GetGreen() + (1. - bsf) * bg.GetGreen(),
 
  312            bsf * cc.
GetBlue() + (1. - bsf) * bg.GetBlue(),
 
  313                    bsf * cc.
GetAlpha() + (1. - bsf) * bg.GetAlpha());
 
  316           (bsf * cc.
GetRed() + (1. - bsf) * bg.GetRed(),
 
  317            bsf * cc.
GetGreen() + (1. - bsf) * bg.GetGreen(),
 
  318            bsf * cc.
GetBlue() + (1. - bsf) * bg.GetBlue());
 
  321                 if (transparency_enabled) {
 
  327           glCallList (to.fDisplayListId);
 
  329         if (to.fTransform != lastMatrixTransform) {
 
  330           lastMatrixTransform = to.fTransform;
 
  339       if (cutawayUnion) glDisable (GL_CLIP_PLANE2);
 
  342     if (iPass == 2) secondPassForTransparencyRequested = 
false;  
 
  343     if (iPass == 3) thirdPassForNonHiddenMarkersRequested = 
false;  
 
  345     if (secondPassForTransparencyRequested) iPass = 2;
 
  346     else if (thirdPassForNonHiddenMarkersRequested) iPass = 3;
 
  352   if (fDisplayHeadTime && fEndTime < 
DBL_MAX) {
 
  353     glMatrixMode (GL_PROJECTION);
 
  356     glOrtho (-1., 1., -1., 1., -G4OPENGL_FLT_BIG, G4OPENGL_FLT_BIG);
 
  357     glMatrixMode (GL_MODELVIEW);
 
  361             G4Point3D(fDisplayHeadTimeX, fDisplayHeadTimeY, 0.));
 
  362     headTimeText.SetScreenSize(fDisplayHeadTimeSize);
 
  364                  (fDisplayHeadTimeRed,
 
  365                   fDisplayHeadTimeGreen,
 
  366                   fDisplayHeadTimeBlue));
 
  367     headTimeText.SetVisAttributes(&visAtts);
 
  368     fOpenGLSceneHandler.G4OpenGLSceneHandler::AddPrimitive(headTimeText);
 
  369     glMatrixMode (GL_PROJECTION);
 
  371     glMatrixMode (GL_MODELVIEW);
 
  376   if (fDisplayLightFront && fEndTime < 
DBL_MAX) {
 
  377     G4double lightFrontRadius = (fEndTime - fDisplayLightFrontT) * 
c_light;
 
  378     if (lightFrontRadius > 0.) {
 
  379       G4Point3D lightFrontCentre(fDisplayLightFrontX, fDisplayLightFrontY, fDisplayLightFrontZ);
 
  380       G4Point3D circleCentre = lightFrontCentre;
 
  381       G4double circleRadius = lightFrontRadius;
 
  382       if (fVP.GetFieldHalfAngle() > 0.) {
 
  384     G4Point3D targetPoint = fSceneHandler.GetScene()->GetStandardTargetPoint() +
 
  385       fVP.GetCurrentTargetPoint();
 
  386     G4double sceneRadius = fSceneHandler.GetScene()->GetExtent().GetExtentRadius();
 
  387     if(sceneRadius <= 0.) sceneRadius = 1.;
 
  388     G4double cameraDistance = fVP.GetCameraDistance(sceneRadius);
 
  389     G4Point3D cameraPosition = targetPoint + cameraDistance * fVP.GetViewpointDirection().
unit();
 
  390     G4Vector3D lightFrontToCameraDirection = cameraPosition - lightFrontCentre;
 
  391     G4double lightFrontCentreDistance = lightFrontToCameraDirection.
mag();
 
  400     if (lightFrontToCameraDirection * fVP.GetViewpointDirection() > 0. && lightFrontRadius < lightFrontCentreDistance) {
 
  402       G4double sineHorizonAngle = lightFrontRadius / lightFrontCentreDistance;
 
  403       circleCentre = lightFrontCentre + (lightFrontRadius * sineHorizonAngle) * lightFrontToCameraDirection.
unit();
 
  404       circleRadius = lightFrontRadius * std::sqrt(1. - std::pow(sineHorizonAngle, 2));
 
  415       if (circleRadius > 0.) {
 
  417     lightFront.SetWorldRadius(circleRadius);
 
  418     glColor3d(fDisplayLightFrontRed,
 
  419           fDisplayLightFrontGreen,
 
  420           fDisplayLightFrontBlue);
 
  421     fOpenGLSceneHandler.G4OpenGLSceneHandler::AddPrimitive(lightFront);
 
const G4Colour & GetBackgroundColour() const 
 
G4double GetAlpha() const 
 
G4double GetVisibleDensity() const 
 
G4bool IsCullingInvisible() const 
 
G4double GetExplodeFactor() const 
 
BasicVector3D< T > unit() const 
 
static G4bool GetColour(const G4String &key, G4Colour &result)
 
const G4Colour & GetColour() const 
 
G4bool IsDensityCulling() const 
 
HepGeom::Point3D< G4double > G4Point3D
 
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1 
 
const std::vector< G4ModelingParameters::VisAttributesModifier > & GetVisAttributesModifiers() const 
 
G4bool IsAuxEdgeVisible() const 
 
G4double GetGreen() const 
 
std::vector< G4Plane3D > G4Planes
 
G4bool IsCullingCovered() const 
 
const G4VisAttributes * GetDefaultTextVisAttributes() const 
 
G4int GetNoOfSides() const 
 
DrawingStyle GetDrawingStyle() const 
 
printf("%d Experimental points found\n", nlines)
 
const G4VisAttributes * GetDefaultVisAttributes() const