Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // 26 // >> 27 // $Id: G4OpenGLStoredViewer.cc 85582 2014-10-31 09:07:30Z gcosmo $ 27 // 28 // 28 // 29 // 29 // Andrew Walkden 7th February 1997 30 // Andrew Walkden 7th February 1997 30 // Class G4OpenGLStoredViewer : Encapsulates t 31 // Class G4OpenGLStoredViewer : Encapsulates the `storedness' of 31 // an OpenGL view, 32 // an OpenGL view, for inheritance by 32 // derived (X, Xm.. 33 // derived (X, Xm...) classes. 33 34 >> 35 #ifdef G4VIS_BUILD_OPENGL_DRIVER >> 36 34 #include "G4OpenGLStoredViewer.hh" 37 #include "G4OpenGLStoredViewer.hh" 35 38 36 #include "G4PhysicalConstants.hh" 39 #include "G4PhysicalConstants.hh" 37 #include "G4OpenGLStoredSceneHandler.hh" 40 #include "G4OpenGLStoredSceneHandler.hh" 38 #include "G4Text.hh" 41 #include "G4Text.hh" 39 #include "G4Circle.hh" 42 #include "G4Circle.hh" 40 #include "G4UnitsTable.hh" 43 #include "G4UnitsTable.hh" 41 #include "G4Scene.hh" 44 #include "G4Scene.hh" 42 #include "G4OpenGLTransform3D.hh" 45 #include "G4OpenGLTransform3D.hh" 43 46 44 G4OpenGLStoredViewer::G4OpenGLStoredViewer 47 G4OpenGLStoredViewer::G4OpenGLStoredViewer 45 (G4OpenGLStoredSceneHandler& sceneHandler): 48 (G4OpenGLStoredSceneHandler& sceneHandler): 46 G4VViewer (sceneHandler, -1), 49 G4VViewer (sceneHandler, -1), 47 G4OpenGLViewer (sceneHandler), 50 G4OpenGLViewer (sceneHandler), 48 fG4OpenGLStoredSceneHandler (sceneHandler), << 51 fG4OpenGLStoredSceneHandler (sceneHandler) 49 fDepthTestEnable(true) << 50 { 52 { 51 fLastVP = fDefaultVP; // Update in sub-clas << 53 fLastVP = fDefaultVP; // Not sure if this gets executed before or >> 54 // after G4VViewer::G4VViewer!! Doesn't matter much. 52 } 55 } 53 56 54 G4OpenGLStoredViewer::~G4OpenGLStoredViewer () 57 G4OpenGLStoredViewer::~G4OpenGLStoredViewer () {} 55 58 56 void G4OpenGLStoredViewer::KernelVisitDecision 59 void G4OpenGLStoredViewer::KernelVisitDecision () { 57 60 58 // If there's a significant difference with 61 // If there's a significant difference with the last view parameters 59 // of either the scene handler or this viewe 62 // of either the scene handler or this viewer, trigger a rebuild. 60 63 61 if (!fG4OpenGLStoredSceneHandler.fTopPODL || 64 if (!fG4OpenGLStoredSceneHandler.fTopPODL || 62 CompareForKernelVisit(fLastVP)) { 65 CompareForKernelVisit(fLastVP)) { 63 NeedKernelVisit (); 66 NeedKernelVisit (); 64 } 67 } >> 68 fLastVP = fVP; 65 } 69 } 66 70 67 G4bool G4OpenGLStoredViewer::CompareForKernelV 71 G4bool G4OpenGLStoredViewer::CompareForKernelVisit(G4ViewParameters& lastVP) { 68 72 69 if ( 73 if ( 70 (lastVP.GetDrawingStyle () != fVP.Get 74 (lastVP.GetDrawingStyle () != fVP.GetDrawingStyle ()) || 71 (lastVP.GetNumberOfCloudPoints() != fVP << 72 (lastVP.IsAuxEdgeVisible () != fVP.IsA 75 (lastVP.IsAuxEdgeVisible () != fVP.IsAuxEdgeVisible ()) || 73 (lastVP.IsCulling () != fVP.IsC 76 (lastVP.IsCulling () != fVP.IsCulling ()) || 74 (lastVP.IsCullingInvisible () != fVP.IsC 77 (lastVP.IsCullingInvisible () != fVP.IsCullingInvisible ()) || 75 (lastVP.IsDensityCulling () != fVP.IsD 78 (lastVP.IsDensityCulling () != fVP.IsDensityCulling ()) || 76 (lastVP.IsCullingCovered () != fVP.IsC 79 (lastVP.IsCullingCovered () != fVP.IsCullingCovered ()) || 77 (lastVP.GetCBDAlgorithmNumber() != << 78 fVP.GetCBDAlgorithmNumber()) << 79 // Note: Section and Cutaway can reveal << 80 // backface culling is implemented, the << 81 // the back-facing faces are not there. << 82 // (commented out) backface culling (it << 83 // in fact, performance seems to improve << 84 (lastVP.IsSection () != fVP.IsS 80 (lastVP.IsSection () != fVP.IsSection ()) || 85 // Section (DCUT) is NOT implemented loc << 81 // Section (DCUT) implemented locally. But still need to visit 86 // (lastVP.IsCutaway () != fVP. << 82 // kernel if status changes so that back plane culling can be 87 // Cutaways are implemented locally so w << 83 // switched. >> 84 (lastVP.IsCutaway () != fVP.IsCutaway ()) || >> 85 // Cutaways implemented locally. But still need to visit kernel >> 86 // if status changes so that back plane culling can be switched. 88 (lastVP.IsExplode () != fVP.IsE 87 (lastVP.IsExplode () != fVP.IsExplode ()) || 89 (lastVP.GetNoOfSides () != fVP.Get 88 (lastVP.GetNoOfSides () != fVP.GetNoOfSides ()) || 90 (lastVP.GetGlobalMarkerScale() != fVP << 91 (lastVP.GetGlobalLineWidthScale() != fVP << 92 (lastVP.IsMarkerNotHidden () != fVP.IsM << 93 (lastVP.GetDefaultVisAttributes()->GetCo 89 (lastVP.GetDefaultVisAttributes()->GetColour() != 94 fVP.GetDefaultVisAttributes()->GetColou 90 fVP.GetDefaultVisAttributes()->GetColour()) || 95 (lastVP.GetDefaultTextVisAttributes()->G 91 (lastVP.GetDefaultTextVisAttributes()->GetColour() != 96 fVP.GetDefaultTextVisAttributes()->GetC 92 fVP.GetDefaultTextVisAttributes()->GetColour()) || 97 (lastVP.GetBackgroundColour ()!= fVP.Get 93 (lastVP.GetBackgroundColour ()!= fVP.GetBackgroundColour ())|| 98 (lastVP.IsPicking () != fVP.IsP 94 (lastVP.IsPicking () != fVP.IsPicking ()) || 99 (lastVP.GetVisAttributesModifiers() != << 95 (lastVP.GetVisAttributesModifiers().size() != 100 fVP.GetVisAttributesModifiers()) << 96 fVP.GetVisAttributesModifiers().size()) 101 (lastVP.IsSpecialMeshRendering() != << 102 fVP.IsSpecialMeshRendering()) << 103 (lastVP.GetSpecialMeshRenderingOption() << 104 fVP.GetSpecialMeshRenderingOption()) << 105 ) 97 ) 106 return true; 98 return true; 107 99 108 if (lastVP.IsDensityCulling () && 100 if (lastVP.IsDensityCulling () && 109 (lastVP.GetVisibleDensity () != fVP.GetV 101 (lastVP.GetVisibleDensity () != fVP.GetVisibleDensity ())) 110 return true; 102 return true; 111 103 112 // /***************************************** << 104 /************************************************************** 113 // If section (DCUT) is implemented locally, << 105 Section (DCUT) implemented locally. No need to visit kernel if 114 if (lastVP.IsSection () && << 106 section plane itself changes. 115 (lastVP.GetSectionPlane () != fVP.GetSec << 107 if (lastVP.IsSection () && 116 return true; << 108 (lastVP.GetSectionPlane () != fVP.GetSectionPlane ())) 117 // ***************************************** << 109 return true; >> 110 ***************************************************************/ 118 111 119 /******************************************* 112 /************************************************************** 120 If cutaways are implemented locally, commen << 113 Cutaways implemented locally. No need to visit kernel if cutaway >> 114 planes themselves change. 121 if (lastVP.IsCutaway ()) { 115 if (lastVP.IsCutaway ()) { 122 if (vp.GetCutawayMode() != fVP.GetCutawayMo << 123 if (lastVP.GetCutawayPlanes ().size () != 116 if (lastVP.GetCutawayPlanes ().size () != 124 fVP.GetCutawayPlanes ().size ()) return tru 117 fVP.GetCutawayPlanes ().size ()) return true; 125 for (size_t i = 0; i < lastVP.GetCutawayPla 118 for (size_t i = 0; i < lastVP.GetCutawayPlanes().size(); ++i) 126 if (lastVP.GetCutawayPlanes()[i] != fVP.Get 119 if (lastVP.GetCutawayPlanes()[i] != fVP.GetCutawayPlanes()[i]) 127 return true; 120 return true; 128 } 121 } 129 ******************************************* 122 ***************************************************************/ 130 123 131 if (lastVP.GetCBDAlgorithmNumber() > 0) { << 132 if (lastVP.GetCBDParameters().size() != fV << 133 else if (lastVP.GetCBDParameters() != fVP. << 134 } << 135 << 136 if (lastVP.IsExplode () && 124 if (lastVP.IsExplode () && 137 (lastVP.GetExplodeFactor () != fVP.GetEx 125 (lastVP.GetExplodeFactor () != fVP.GetExplodeFactor ())) 138 return true; << 126 return true; 139 << 140 if (lastVP.IsSpecialMeshRendering() && << 141 (lastVP.GetSpecialMeshVolumes() != fVP.G << 142 return true; << 143 << 144 // Time window parameters operate on the exi << 145 // to rebuild even if they change. << 146 127 147 return false; 128 return false; 148 } 129 } 149 130 150 void G4OpenGLStoredViewer::DrawDisplayLists () 131 void G4OpenGLStoredViewer::DrawDisplayLists () { >> 132 #ifdef G4DEBUG_VIS_OGL >> 133 printf("G4OpenGLStoredViewer::DrawDisplayLists \n"); >> 134 #endif 151 135 152 // We moved these from G4OpenGLViewer to G4V << 153 // editing many lines below we introduce the << 154 #define CONVENIENT_DOUBLE_ALIAS(q) const G4dou << 155 #define CONVENIENT_BOOL_ALIAS(q) const G4bool& << 156 CONVENIENT_DOUBLE_ALIAS(StartTime) << 157 CONVENIENT_DOUBLE_ALIAS(EndTime) << 158 CONVENIENT_DOUBLE_ALIAS(FadeFactor) << 159 CONVENIENT_BOOL_ALIAS(DisplayHeadTime) << 160 CONVENIENT_DOUBLE_ALIAS(DisplayHeadTimeX) << 161 CONVENIENT_DOUBLE_ALIAS(DisplayHeadTimeY) << 162 CONVENIENT_DOUBLE_ALIAS(DisplayHeadTimeSize) << 163 CONVENIENT_DOUBLE_ALIAS(DisplayHeadTimeRed) << 164 CONVENIENT_DOUBLE_ALIAS(DisplayHeadTimeGreen << 165 CONVENIENT_DOUBLE_ALIAS(DisplayHeadTimeBlue) << 166 CONVENIENT_BOOL_ALIAS(DisplayLightFront) << 167 CONVENIENT_DOUBLE_ALIAS(DisplayLightFrontX) << 168 CONVENIENT_DOUBLE_ALIAS(DisplayLightFrontY) << 169 CONVENIENT_DOUBLE_ALIAS(DisplayLightFrontZ) << 170 CONVENIENT_DOUBLE_ALIAS(DisplayLightFrontT) << 171 CONVENIENT_DOUBLE_ALIAS(DisplayLightFrontRed << 172 CONVENIENT_DOUBLE_ALIAS(DisplayLightFrontGre << 173 CONVENIENT_DOUBLE_ALIAS(DisplayLightFrontBlu << 174 << 175 const G4Planes& cutaways = fVP.GetCutawayPla 136 const G4Planes& cutaways = fVP.GetCutawayPlanes(); 176 G4bool cutawayUnion = fVP.IsCutaway() && 137 G4bool cutawayUnion = fVP.IsCutaway() && 177 fVP.GetCutawayMode() == G4ViewParameters::cu 138 fVP.GetCutawayMode() == G4ViewParameters::cutawayUnion; 178 const size_t nCutaways = cutawayUnion? cutaw 139 const size_t nCutaways = cutawayUnion? cutaways.size(): 1; >> 140 #ifdef G4DEBUG_VIS_OGL >> 141 printf("G4OpenGLStoredViewer::DrawDisplayLists"); >> 142 #endif 179 G4int iPass = 1; 143 G4int iPass = 1; 180 G4bool secondPassForTransparencyRequested = 144 G4bool secondPassForTransparencyRequested = false; 181 G4bool thirdPassForNonHiddenMarkersRequested 145 G4bool thirdPassForNonHiddenMarkersRequested = false; 182 fDepthTestEnable = true; 146 fDepthTestEnable = true; 183 glEnable (GL_DEPTH_TEST); glDepthFunc (GL_LE 147 glEnable (GL_DEPTH_TEST); glDepthFunc (GL_LEQUAL); >> 148 fOldDisplayListColor = G4Colour(); 184 do { 149 do { 185 for (size_t iCutaway = 0; iCutaway < nCuta 150 for (size_t iCutaway = 0; iCutaway < nCutaways; ++iCutaway) { 186 151 187 if (cutawayUnion) { 152 if (cutawayUnion) { 188 double a[4]; 153 double a[4]; 189 a[0] = cutaways[iCutaway].a(); 154 a[0] = cutaways[iCutaway].a(); 190 a[1] = cutaways[iCutaway].b(); 155 a[1] = cutaways[iCutaway].b(); 191 a[2] = cutaways[iCutaway].c(); 156 a[2] = cutaways[iCutaway].c(); 192 a[3] = cutaways[iCutaway].d(); 157 a[3] = cutaways[iCutaway].d(); 193 glClipPlane (GL_CLIP_PLANE2, a); 158 glClipPlane (GL_CLIP_PLANE2, a); 194 glEnable (GL_CLIP_PLANE2); 159 glEnable (GL_CLIP_PLANE2); 195 } 160 } 196 161 197 G4bool isPicking = fVP.IsPicking(); 162 G4bool isPicking = fVP.IsPicking(); 198 163 199 for (size_t iPO = 0; 164 for (size_t iPO = 0; 200 iPO < fG4OpenGLStoredSceneHandler.f 165 iPO < fG4OpenGLStoredSceneHandler.fPOList.size(); ++iPO) { 201 if (POSelected(iPO)) { 166 if (POSelected(iPO)) { 202 G4OpenGLStoredSceneHandler::PO& po = 167 G4OpenGLStoredSceneHandler::PO& po = 203 fG4OpenGLStoredSceneHandler.fPOList[ 168 fG4OpenGLStoredSceneHandler.fPOList[iPO]; 204 G4Colour c = po.fColour; 169 G4Colour c = po.fColour; 205 DisplayTimePOColourModification(c,iP 170 DisplayTimePOColourModification(c,iPO); 206 const G4bool isTransparent = c.GetAl 171 const G4bool isTransparent = c.GetAlpha() < 1.; 207 if ( iPass == 1) { 172 if ( iPass == 1) { 208 if (isTransparent && transparency_ 173 if (isTransparent && transparency_enabled) { 209 secondPassForTransparencyRequest 174 secondPassForTransparencyRequested = true; 210 continue; 175 continue; 211 } 176 } 212 if (po.fMarkerOrPolyline && fVP.Is 177 if (po.fMarkerOrPolyline && fVP.IsMarkerNotHidden()) { 213 thirdPassForNonHiddenMarkersRequ 178 thirdPassForNonHiddenMarkersRequested = true; 214 continue; 179 continue; 215 } 180 } 216 } else if (iPass == 2) { // Second 181 } else if (iPass == 2) { // Second pass for transparency. 217 if (!isTransparent) { 182 if (!isTransparent) { 218 continue; 183 continue; 219 } 184 } 220 } else { // Third pass for non-hidd 185 } else { // Third pass for non-hidden markers 221 if (!po.fMarkerOrPolyline) { 186 if (!po.fMarkerOrPolyline) { 222 continue; 187 continue; 223 } 188 } 224 } 189 } 225 if (isPicking) glLoadName(po.fPickNa 190 if (isPicking) glLoadName(po.fPickName); 226 if (transparency_enabled) { << 191 if ((iPO == 0) || (c != fOldDisplayListColor)) { 227 glColor4d(c.GetRed(),c.GetGreen(), << 192 fOldDisplayListColor = c; 228 } else { << 193 if (transparency_enabled) { 229 glColor3d(c.GetRed(),c.GetGreen(), << 194 glColor4d(c.GetRed(),c.GetGreen(),c.GetBlue(),c.GetAlpha()); >> 195 } else { >> 196 glColor3d(c.GetRed(),c.GetGreen(),c.GetBlue()); >> 197 } 230 } 198 } 231 if (po.fMarkerOrPolyline && fVP.IsMa 199 if (po.fMarkerOrPolyline && fVP.IsMarkerNotHidden()) { 232 if (fDepthTestEnable !=false) { 200 if (fDepthTestEnable !=false) { 233 glDisable (GL_DEPTH_TEST); 201 glDisable (GL_DEPTH_TEST); 234 fDepthTestEnable = false; 202 fDepthTestEnable = false; 235 } 203 } 236 } else { 204 } else { 237 if (fDepthTestEnable !=true) { 205 if (fDepthTestEnable !=true) { 238 glEnable (GL_DEPTH_TEST); glDept 206 glEnable (GL_DEPTH_TEST); glDepthFunc (GL_LEQUAL); 239 fDepthTestEnable = true; 207 fDepthTestEnable = true; 240 } 208 } 241 } 209 } 242 if (po.fpG4TextPlus) { 210 if (po.fpG4TextPlus) { 243 if (po.fpG4TextPlus->fProcessing2D 211 if (po.fpG4TextPlus->fProcessing2D) { 244 glMatrixMode (GL_PROJECTION); 212 glMatrixMode (GL_PROJECTION); 245 glPushMatrix(); 213 glPushMatrix(); 246 glLoadIdentity(); 214 glLoadIdentity(); 247 g4GlOrtho (-1., 1., -1., 1., -G4 << 215 glOrtho (-1., 1., -1., 1., -G4OPENGL_FLT_BIG, G4OPENGL_FLT_BIG); 248 glMatrixMode (GL_MODELVIEW); 216 glMatrixMode (GL_MODELVIEW); 249 glPushMatrix(); 217 glPushMatrix(); 250 glLoadIdentity(); 218 glLoadIdentity(); 251 G4OpenGLTransform3D oglt (po.fTr 219 G4OpenGLTransform3D oglt (po.fTransform); 252 glMultMatrixd (oglt.GetGLMatrix 220 glMultMatrixd (oglt.GetGLMatrix ()); 253 // This text is from a PODL. We << 221 fOpenGLSceneHandler.G4OpenGLSceneHandler::AddPrimitive 254 AddPrimitiveForASingleFrame(po.f << 222 (po.fpG4TextPlus->fG4Text); 255 } else { 223 } else { 256 glPushMatrix(); 224 glPushMatrix(); 257 G4OpenGLTransform3D oglt (po.fTr 225 G4OpenGLTransform3D oglt (po.fTransform); 258 glMultMatrixd (oglt.GetGLMatrix 226 glMultMatrixd (oglt.GetGLMatrix ()); 259 // This text is from a PODL. We << 227 fOpenGLSceneHandler.G4OpenGLSceneHandler::AddPrimitive 260 AddPrimitiveForASingleFrame(po.f << 228 (po.fpG4TextPlus->fG4Text); 261 glPopMatrix(); 229 glPopMatrix(); 262 } 230 } 263 231 264 if (po.fpG4TextPlus->fProcessing2D 232 if (po.fpG4TextPlus->fProcessing2D) { 265 glMatrixMode (GL_PROJECTION); 233 glMatrixMode (GL_PROJECTION); 266 glPopMatrix(); 234 glPopMatrix(); 267 glMatrixMode (GL_MODELVIEW); 235 glMatrixMode (GL_MODELVIEW); 268 glPopMatrix(); 236 glPopMatrix(); 269 } 237 } 270 } else { 238 } else { 271 glPushMatrix(); 239 glPushMatrix(); 272 G4OpenGLTransform3D oglt (po.fTran 240 G4OpenGLTransform3D oglt (po.fTransform); 273 glMultMatrixd (oglt.GetGLMatrix () 241 glMultMatrixd (oglt.GetGLMatrix ()); 274 glCallList (po.fDisplayListId); 242 glCallList (po.fDisplayListId); 275 glPopMatrix(); 243 glPopMatrix(); 276 } 244 } 277 } 245 } 278 } 246 } 279 247 280 G4Transform3D lastMatrixTransform; 248 G4Transform3D lastMatrixTransform; 281 G4bool first = true; 249 G4bool first = true; 282 << 250 283 for (size_t iTO = 0; 251 for (size_t iTO = 0; 284 iTO < fG4OpenGLStoredSceneHandler.f 252 iTO < fG4OpenGLStoredSceneHandler.fTOList.size(); ++iTO) { 285 if (TOSelected(iTO)) { 253 if (TOSelected(iTO)) { 286 G4OpenGLStoredSceneHandler::TO& to = 254 G4OpenGLStoredSceneHandler::TO& to = 287 fG4OpenGLStoredSceneHandler.fTOList[ 255 fG4OpenGLStoredSceneHandler.fTOList[iTO]; 288 const G4Colour& c = to.fColour; 256 const G4Colour& c = to.fColour; 289 const G4bool isTransparent = c.GetAl 257 const G4bool isTransparent = c.GetAlpha() < 1.; 290 if ( iPass == 1) { 258 if ( iPass == 1) { 291 if (isTransparent && transparency_ 259 if (isTransparent && transparency_enabled) { 292 secondPassForTransparencyRequest 260 secondPassForTransparencyRequested = true; 293 continue; 261 continue; 294 } 262 } 295 if (to.fMarkerOrPolyline && fVP.Is 263 if (to.fMarkerOrPolyline && fVP.IsMarkerNotHidden()) { 296 thirdPassForNonHiddenMarkersRequ 264 thirdPassForNonHiddenMarkersRequested = true; 297 continue; 265 continue; 298 } 266 } 299 } else if (iPass == 2) { // Second 267 } else if (iPass == 2) { // Second pass for transparency. 300 if (!isTransparent) { 268 if (!isTransparent) { 301 continue; 269 continue; 302 } 270 } 303 } else { // Third pass for non-hidd 271 } else { // Third pass for non-hidden markers 304 if (!to.fMarkerOrPolyline) { 272 if (!to.fMarkerOrPolyline) { 305 continue; 273 continue; 306 } 274 } 307 } 275 } 308 if (to.fMarkerOrPolyline && fVP.IsMa 276 if (to.fMarkerOrPolyline && fVP.IsMarkerNotHidden()) { 309 if (fDepthTestEnable !=false) { 277 if (fDepthTestEnable !=false) { 310 glDisable (GL_DEPTH_TEST); 278 glDisable (GL_DEPTH_TEST); 311 fDepthTestEnable = false; 279 fDepthTestEnable = false; 312 } 280 } 313 } else { 281 } else { 314 if (fDepthTestEnable !=true) { 282 if (fDepthTestEnable !=true) { 315 glEnable (GL_DEPTH_TEST); glDept 283 glEnable (GL_DEPTH_TEST); glDepthFunc (GL_LEQUAL); 316 fDepthTestEnable = true; 284 fDepthTestEnable = true; 317 } 285 } 318 } 286 } 319 if (to.fEndTime >= fStartTime && to. 287 if (to.fEndTime >= fStartTime && to.fStartTime <= fEndTime) { 320 if (fVP.IsPicking()) glLoadName(to 288 if (fVP.IsPicking()) glLoadName(to.fPickName); 321 if (to.fpG4TextPlus) { 289 if (to.fpG4TextPlus) { 322 if (to.fpG4TextPlus->fProcessing 290 if (to.fpG4TextPlus->fProcessing2D) { 323 glMatrixMode (GL_PROJECTION); 291 glMatrixMode (GL_PROJECTION); 324 glPushMatrix(); 292 glPushMatrix(); 325 glLoadIdentity(); 293 glLoadIdentity(); 326 g4GlOrtho (-1., 1., -1., 1., - << 294 glOrtho (-1., 1., -1., 1., -G4OPENGL_FLT_BIG, G4OPENGL_FLT_BIG); 327 glMatrixMode (GL_MODELVIEW); 295 glMatrixMode (GL_MODELVIEW); 328 glPushMatrix(); 296 glPushMatrix(); 329 glLoadIdentity(); 297 glLoadIdentity(); 330 } 298 } 331 G4OpenGLTransform3D oglt (to.fTr 299 G4OpenGLTransform3D oglt (to.fTransform); 332 glMultMatrixd (oglt.GetGLMatrix 300 glMultMatrixd (oglt.GetGLMatrix ()); 333 // This text is from a TODL. We << 301 if (transparency_enabled) { 334 AddPrimitiveForASingleFrame(to.f << 302 glColor4d(c.GetRed(),c.GetGreen(),c.GetBlue(),c.GetAlpha()); >> 303 } else { >> 304 glColor3d(c.GetRed(),c.GetGreen(),c.GetBlue()); >> 305 } >> 306 fOpenGLSceneHandler.G4OpenGLSceneHandler::AddPrimitive >> 307 (to.fpG4TextPlus->fG4Text); 335 if (to.fpG4TextPlus->fProcessing 308 if (to.fpG4TextPlus->fProcessing2D) { 336 glMatrixMode (GL_PROJECTION); 309 glMatrixMode (GL_PROJECTION); 337 glPopMatrix(); 310 glPopMatrix(); 338 glMatrixMode (GL_MODELVIEW); 311 glMatrixMode (GL_MODELVIEW); 339 glPopMatrix(); 312 glPopMatrix(); 340 } 313 } 341 } else { 314 } else { 342 if (to.fTransform != lastMatrixT 315 if (to.fTransform != lastMatrixTransform) { 343 if (! first) { 316 if (! first) { 344 glPopMatrix(); 317 glPopMatrix(); 345 } 318 } 346 first = false; 319 first = false; 347 glPushMatrix(); 320 glPushMatrix(); 348 G4OpenGLTransform3D oglt (to.f 321 G4OpenGLTransform3D oglt (to.fTransform); 349 glMultMatrixd (oglt.GetGLMatri 322 glMultMatrixd (oglt.GetGLMatrix ()); 350 } 323 } 351 const G4Colour& cc = to.fColour; 324 const G4Colour& cc = to.fColour; 352 if (fFadeFactor > 0. && to.fEndT 325 if (fFadeFactor > 0. && to.fEndTime < fEndTime) { 353 // Brightness scaling factor 326 // Brightness scaling factor 354 G4double bsf = 1. - fFadeFacto 327 G4double bsf = 1. - fFadeFactor * 355 ((fEndTime - to.fEndTime) / (f 328 ((fEndTime - to.fEndTime) / (fEndTime - fStartTime)); 356 const G4Colour& bg = fVP.GetBa 329 const G4Colour& bg = fVP.GetBackgroundColour(); 357 if (transparency_enabled) { 330 if (transparency_enabled) { 358 glColor4d 331 glColor4d 359 (bsf * cc.GetRed() + (1. - b 332 (bsf * cc.GetRed() + (1. - bsf) * bg.GetRed(), 360 bsf * cc.GetGreen() + (1. - 333 bsf * cc.GetGreen() + (1. - bsf) * bg.GetGreen(), 361 bsf * cc.GetBlue() + (1. - 334 bsf * cc.GetBlue() + (1. - bsf) * bg.GetBlue(), 362 bsf * cc.GetAlpha() + (1. - 335 bsf * cc.GetAlpha() + (1. - bsf) * bg.GetAlpha()); 363 } else { 336 } else { 364 glColor3d 337 glColor3d 365 (bsf * cc.GetRed() + (1. - b 338 (bsf * cc.GetRed() + (1. - bsf) * bg.GetRed(), 366 bsf * cc.GetGreen() + (1. - 339 bsf * cc.GetGreen() + (1. - bsf) * bg.GetGreen(), 367 bsf * cc.GetBlue() + (1. - 340 bsf * cc.GetBlue() + (1. - bsf) * bg.GetBlue()); 368 } 341 } 369 } else { 342 } else { 370 if (transparency_enabled) { 343 if (transparency_enabled) { 371 glColor4d(cc.GetRed(),cc.Get 344 glColor4d(cc.GetRed(),cc.GetGreen(),cc.GetBlue(),cc.GetAlpha()); 372 } else { 345 } else { 373 glColor3d(cc.GetRed(),cc.Get 346 glColor3d(cc.GetRed(),cc.GetGreen(),cc.GetBlue()); 374 } 347 } 375 } 348 } 376 glCallList (to.fDisplayListId); 349 glCallList (to.fDisplayListId); 377 } 350 } 378 if (to.fTransform != lastMatrixTra 351 if (to.fTransform != lastMatrixTransform) { 379 lastMatrixTransform = to.fTransf 352 lastMatrixTransform = to.fTransform; 380 } 353 } 381 } 354 } 382 } 355 } 383 } 356 } 384 if (! first) { 357 if (! first) { 385 glPopMatrix(); 358 glPopMatrix(); 386 } 359 } 387 360 388 if (cutawayUnion) glDisable (GL_CLIP_PLA 361 if (cutawayUnion) glDisable (GL_CLIP_PLANE2); 389 } // iCutaway 362 } // iCutaway 390 363 391 if (iPass == 2) secondPassForTransparencyR 364 if (iPass == 2) secondPassForTransparencyRequested = false; // Done. 392 if (iPass == 3) thirdPassForNonHiddenMarke 365 if (iPass == 3) thirdPassForNonHiddenMarkersRequested = false; // Done. 393 366 394 if (secondPassForTransparencyRequested) iP 367 if (secondPassForTransparencyRequested) iPass = 2; 395 else if (thirdPassForNonHiddenMarkersReque 368 else if (thirdPassForNonHiddenMarkersRequested) iPass = 3; 396 else break; 369 else break; 397 370 398 } while (true); 371 } while (true); 399 372 400 // Display time at "head" of time range, whi 373 // Display time at "head" of time range, which is fEndTime... 401 if (fDisplayHeadTime && fEndTime < G4VisAttr << 374 if (fDisplayHeadTime && fEndTime < DBL_MAX) { 402 glMatrixMode (GL_PROJECTION); 375 glMatrixMode (GL_PROJECTION); 403 glPushMatrix(); 376 glPushMatrix(); 404 glLoadIdentity(); 377 glLoadIdentity(); 405 g4GlOrtho (-1., 1., -1., 1., -G4OPENGL_FLT << 378 glOrtho (-1., 1., -1., 1., -G4OPENGL_FLT_BIG, G4OPENGL_FLT_BIG); 406 glMatrixMode (GL_MODELVIEW); 379 glMatrixMode (GL_MODELVIEW); 407 glPushMatrix(); 380 glPushMatrix(); 408 glLoadIdentity(); 381 glLoadIdentity(); 409 G4Text headTimeText(G4BestUnit(fEndTime,"T 382 G4Text headTimeText(G4BestUnit(fEndTime,"Time"), 410 G4Point3D(fDisplayHead 383 G4Point3D(fDisplayHeadTimeX, fDisplayHeadTimeY, 0.)); 411 headTimeText.SetScreenSize(fDisplayHeadTim 384 headTimeText.SetScreenSize(fDisplayHeadTimeSize); 412 G4VisAttributes visAtts (G4Colour 385 G4VisAttributes visAtts (G4Colour 413 (fDisplayHeadTime 386 (fDisplayHeadTimeRed, 414 fDisplayHeadTime 387 fDisplayHeadTimeGreen, 415 fDisplayHeadTime 388 fDisplayHeadTimeBlue)); 416 headTimeText.SetVisAttributes(&visAtts); 389 headTimeText.SetVisAttributes(&visAtts); 417 AddPrimitiveForASingleFrame(headTimeText); << 390 fOpenGLSceneHandler.G4OpenGLSceneHandler::AddPrimitive(headTimeText); 418 glMatrixMode (GL_PROJECTION); 391 glMatrixMode (GL_PROJECTION); 419 glPopMatrix(); 392 glPopMatrix(); 420 glMatrixMode (GL_MODELVIEW); 393 glMatrixMode (GL_MODELVIEW); 421 glPopMatrix(); 394 glPopMatrix(); 422 } 395 } 423 396 424 // Display light front... 397 // Display light front... 425 if (fDisplayLightFront && fEndTime < G4VisAt << 398 if (fDisplayLightFront && fEndTime < DBL_MAX) { 426 G4double lightFrontRadius = (fEndTime - fD 399 G4double lightFrontRadius = (fEndTime - fDisplayLightFrontT) * c_light; 427 if (lightFrontRadius > 0.) { 400 if (lightFrontRadius > 0.) { 428 G4Point3D lightFrontCentre(fDisplayLight 401 G4Point3D lightFrontCentre(fDisplayLightFrontX, fDisplayLightFrontY, fDisplayLightFrontZ); 429 G4Point3D circleCentre = lightFrontCentr 402 G4Point3D circleCentre = lightFrontCentre; 430 G4double circleRadius = lightFrontRadius 403 G4double circleRadius = lightFrontRadius; 431 if (fVP.GetFieldHalfAngle() > 0.) { 404 if (fVP.GetFieldHalfAngle() > 0.) { 432 // Perspective view. Find horizon cen 405 // Perspective view. Find horizon centre and radius... 433 G4Point3D targetPoint = fSceneHandler. 406 G4Point3D targetPoint = fSceneHandler.GetScene()->GetStandardTargetPoint() + 434 fVP.GetCurrentTargetPoint(); 407 fVP.GetCurrentTargetPoint(); 435 G4double sceneRadius = fSceneHandler.G 408 G4double sceneRadius = fSceneHandler.GetScene()->GetExtent().GetExtentRadius(); 436 if(sceneRadius <= 0.) sceneRadius = 1. 409 if(sceneRadius <= 0.) sceneRadius = 1.; 437 G4double cameraDistance = fVP.GetCamer 410 G4double cameraDistance = fVP.GetCameraDistance(sceneRadius); 438 G4Point3D cameraPosition = targetPoint 411 G4Point3D cameraPosition = targetPoint + cameraDistance * fVP.GetViewpointDirection().unit(); 439 G4Vector3D lightFrontToCameraDirection 412 G4Vector3D lightFrontToCameraDirection = cameraPosition - lightFrontCentre; 440 G4double lightFrontCentreDistance = li 413 G4double lightFrontCentreDistance = lightFrontToCameraDirection.mag(); 441 /* 414 /* 442 G4cout << "cameraPosition: " << camer 415 G4cout << "cameraPosition: " << cameraPosition 443 << ", lightFrontCentre: " << lightFro 416 << ", lightFrontCentre: " << lightFrontCentre 444 << ", lightFrontRadius: " << lightFro 417 << ", lightFrontRadius: " << lightFrontRadius 445 << ", lightFrontCentreDistance: " << 418 << ", lightFrontCentreDistance: " << lightFrontCentreDistance 446 << ", dot: " << lightFrontToCameraDir 419 << ", dot: " << lightFrontToCameraDirection * fVP.GetViewpointDirection() 447 << G4endl; 420 << G4endl; 448 */ 421 */ 449 if (lightFrontToCameraDirection * fVP. 422 if (lightFrontToCameraDirection * fVP.GetViewpointDirection() > 0. && lightFrontRadius < lightFrontCentreDistance) { 450 // Light front in front of camera... 423 // Light front in front of camera... 451 G4double sineHorizonAngle = lightFro 424 G4double sineHorizonAngle = lightFrontRadius / lightFrontCentreDistance; 452 circleCentre = lightFrontCentre + (l 425 circleCentre = lightFrontCentre + (lightFrontRadius * sineHorizonAngle) * lightFrontToCameraDirection.unit(); 453 circleRadius = lightFrontRadius * st 426 circleRadius = lightFrontRadius * std::sqrt(1. - std::pow(sineHorizonAngle, 2)); 454 /* 427 /* 455 G4cout << "sineHorizonAngle: " << s 428 G4cout << "sineHorizonAngle: " << sineHorizonAngle 456 << ", circleCentre: " << circleCent 429 << ", circleCentre: " << circleCentre 457 << ", circleRadius: " << circleRadi 430 << ", circleRadius: " << circleRadius 458 << G4endl; 431 << G4endl; 459 */ 432 */ 460 } else { 433 } else { 461 circleRadius = -1.; 434 circleRadius = -1.; 462 } 435 } 463 } 436 } 464 if (circleRadius > 0.) { 437 if (circleRadius > 0.) { 465 G4Circle lightFront(circleCentre); 438 G4Circle lightFront(circleCentre); 466 lightFront.SetWorldRadius(circleRadius 439 lightFront.SetWorldRadius(circleRadius); 467 G4VisAttributes visAtts(G4Colour << 440 glColor3d(fDisplayLightFrontRed, 468 (fDisplayLightFrontRed, << 441 fDisplayLightFrontGreen, 469 fDisplayLightFrontGreen, << 442 fDisplayLightFrontBlue); 470 fDisplayLightFrontBlue)); << 443 fOpenGLSceneHandler.G4OpenGLSceneHandler::AddPrimitive(lightFront); 471 lightFront.SetVisAttributes(visAtts); << 472 AddPrimitiveForASingleFrame(lightFront << 473 } 444 } 474 } 445 } 475 } 446 } 476 } 447 } 477 448 478 void G4OpenGLStoredViewer::AddPrimitiveForASin << 449 #endif 479 { << 480 // We don't want this to get into a display << 481 // use the fMemoryForDisplayLists flag. << 482 fG4OpenGLStoredSceneHandler.fDoNotUseDisplay << 483 fG4OpenGLStoredSceneHandler.G4OpenGLStoredSc << 484 fG4OpenGLStoredSceneHandler.fDoNotUseDisplay << 485 } << 486 << 487 void G4OpenGLStoredViewer::AddPrimitiveForASin << 488 { << 489 // We don't want this to get into a display << 490 // use the fMemoryForDisplayLists flag. << 491 fG4OpenGLStoredSceneHandler.fDoNotUseDisplay << 492 fG4OpenGLStoredSceneHandler.G4OpenGLStoredSc << 493 fG4OpenGLStoredSceneHandler.fDoNotUseDisplay << 494 } << 495 450