[834] | 1 | // |
---|
| 2 | // ******************************************************************** |
---|
| 3 | // * License and Disclaimer * |
---|
| 4 | // * * |
---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
| 7 | // * conditions of the Geant4 Software License, included in the file * |
---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
| 9 | // * include a list of copyright holders. * |
---|
| 10 | // * * |
---|
| 11 | // * Neither the authors of this software system, nor their employing * |
---|
| 12 | // * institutes,nor the agencies providing financial support for this * |
---|
| 13 | // * work make any representation or warranty, express or implied, * |
---|
| 14 | // * regarding this software system or assume any liability for its * |
---|
| 15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
| 16 | // * for the full disclaimer and the limitation of liability. * |
---|
| 17 | // * * |
---|
| 18 | // * This code implementation is the result of the scientific and * |
---|
| 19 | // * technical work of the GEANT4 collaboration. * |
---|
| 20 | // * By using, copying, modifying or distributing the software (or * |
---|
| 21 | // * any work based on the software) you agree to acknowledge its * |
---|
| 22 | // * use in resulting scientific publications, and indicate your * |
---|
| 23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
| 24 | // ******************************************************************** |
---|
| 25 | // |
---|
| 26 | // |
---|
| 27 | // $Id: G4TheRayTracer.hh,v 1.3 2006/06/29 21:23:49 gunter Exp $ |
---|
[850] | 28 | // GEANT4 tag $Name: HEAD $ |
---|
[834] | 29 | // |
---|
| 30 | // |
---|
| 31 | |
---|
| 32 | |
---|
| 33 | #ifndef G4TheRayTracer_H |
---|
| 34 | #define G4TheRayTracer_H 1 |
---|
| 35 | |
---|
| 36 | // class description: |
---|
| 37 | // |
---|
| 38 | // G4TheRayTracer |
---|
| 39 | // This is a graphics driver of Geant4 which generates a figure file by |
---|
| 40 | // ray tracing technique. The format of output figure file can be selected |
---|
| 41 | // by assigning a pointer of G4VFigureFileMaker concrete class object. |
---|
| 42 | // The main entry of ray tracing is Trace() method, which is available |
---|
| 43 | // only at Idle state. G4TheRayTracer shoots rays and controls its own event |
---|
| 44 | // loop. It generates G4Event objects used for its own purpose. When ray |
---|
| 45 | // tracing is working, all sensitive detectors are inactivated and all |
---|
| 46 | // user action classes are swapped out. Still, verbosities set to Geant4 |
---|
| 47 | // manager classes are concerned. Thus, it is recommended to set verbosities |
---|
| 48 | // to minimum (usually zero). |
---|
| 49 | // G4TheRayTracer can visualise absolutely all kinds of geometrical shapes |
---|
| 50 | // which G4Navigator can deal with. Instead, it can NOT visualise hits |
---|
| 51 | // nor trajectories generated by usual simulation. |
---|
| 52 | |
---|
| 53 | #include "globals.hh" |
---|
| 54 | #include "G4ThreeVector.hh" |
---|
| 55 | #include "G4Colour.hh" |
---|
| 56 | |
---|
| 57 | class G4Event; |
---|
| 58 | class G4EventManager; |
---|
| 59 | class G4UserEventAction; |
---|
| 60 | class G4UserStackingAction; |
---|
| 61 | class G4UserTrackingAction; |
---|
| 62 | class G4UserSteppingAction; |
---|
| 63 | class G4RTTrackingAction; |
---|
| 64 | class G4RTSteppingAction; |
---|
| 65 | class G4RTMessenger; |
---|
| 66 | class G4RayShooter; |
---|
| 67 | class G4VFigureFileMaker; |
---|
| 68 | class G4RayTrajectoryPoint; |
---|
| 69 | class G4VisAttributes; |
---|
| 70 | class G4VRTScanner; |
---|
| 71 | |
---|
| 72 | |
---|
| 73 | class G4TheRayTracer |
---|
| 74 | { |
---|
| 75 | public: // with description |
---|
| 76 | G4TheRayTracer(G4VFigureFileMaker* figMaker = 0, |
---|
| 77 | G4VRTScanner* scanner = 0); |
---|
| 78 | // Constructor. The argument is the pointer to G4VFigureFileMaker |
---|
| 79 | // concrete class object. If it is not set and |
---|
| 80 | // SetFigureFileMaker() method is not invoked before Trace() |
---|
| 81 | // command is invoked, then G4RTJpegMaker will be used and JPEG |
---|
| 82 | // file will be generated. The second argument is a scanner that |
---|
| 83 | // produces a sequence of window coordinates. If it is not set |
---|
| 84 | // here or if SetScanner is not invoked before Trace(), a default |
---|
| 85 | // G4RTSimpleScanner will be used. |
---|
| 86 | |
---|
| 87 | public: |
---|
| 88 | ~G4TheRayTracer(); |
---|
| 89 | |
---|
| 90 | public: // with description |
---|
| 91 | void Trace(G4String fileName); |
---|
| 92 | // The main entry point which triggers ray tracing. "fileName" is output |
---|
| 93 | // file name, and it must contain extention (e.g. myFigure.jpg). This |
---|
| 94 | // method is available only if Geant4 is at Idle state. |
---|
| 95 | |
---|
| 96 | protected: |
---|
| 97 | G4bool CreateBitMap(); |
---|
| 98 | // Event loop |
---|
| 99 | void CreateFigureFile(G4String fileName); |
---|
| 100 | // Create figure file after an event loop |
---|
| 101 | G4bool GenerateColour(G4Event* anEvent); |
---|
| 102 | // Calcurate RGB for one trajectory |
---|
| 103 | void StoreUserActions(); |
---|
| 104 | void RestoreUserActions(); |
---|
| 105 | // Store and restore user action classes if defined |
---|
| 106 | |
---|
| 107 | G4Colour GetSurfaceColour(G4RayTrajectoryPoint* point); |
---|
| 108 | G4Colour GetMixedColour(G4Colour surfCol,G4Colour transCol,G4double weight=0.5); |
---|
| 109 | G4Colour Attenuate(G4RayTrajectoryPoint* point, G4Colour sourceCol); |
---|
| 110 | G4bool ValidColour(const G4VisAttributes* visAtt); |
---|
| 111 | |
---|
| 112 | public: // with description |
---|
| 113 | inline void SetFigureFileMaker(G4VFigureFileMaker* figMaker) |
---|
| 114 | // Set a concrete class of G4VFigureFileMaker for assigning the format of |
---|
| 115 | // output figure file. |
---|
| 116 | { theFigMaker = figMaker; } |
---|
| 117 | inline G4VFigureFileMaker* GetFigureFileMaker() {return theFigMaker;} |
---|
| 118 | inline void SetScanner(G4VRTScanner* scanner) |
---|
| 119 | // Set a concrete class of G4VRTScanner for producing a sequence |
---|
| 120 | // of window coordinates. |
---|
| 121 | { theScanner = scanner; } |
---|
| 122 | inline G4VRTScanner* GetScanner() {return theScanner;} |
---|
| 123 | |
---|
| 124 | protected: |
---|
| 125 | G4RayShooter * theRayShooter; |
---|
| 126 | G4VFigureFileMaker * theFigMaker; |
---|
| 127 | G4RTMessenger * theMessenger; |
---|
| 128 | G4VRTScanner * theScanner; |
---|
| 129 | |
---|
| 130 | G4EventManager * theEventManager; |
---|
| 131 | |
---|
| 132 | G4UserEventAction * theUserEventAction; |
---|
| 133 | G4UserStackingAction * theUserStackingAction; |
---|
| 134 | G4UserTrackingAction * theUserTrackingAction; |
---|
| 135 | G4UserSteppingAction * theUserSteppingAction; |
---|
| 136 | |
---|
| 137 | G4UserEventAction * theRayTracerEventAction; |
---|
| 138 | G4UserStackingAction * theRayTracerStackingAction; |
---|
| 139 | G4RTTrackingAction * theRayTracerTrackingAction; |
---|
| 140 | G4RTSteppingAction * theRayTracerSteppingAction; |
---|
| 141 | |
---|
| 142 | unsigned char* colorR; |
---|
| 143 | unsigned char* colorG; |
---|
| 144 | unsigned char* colorB; |
---|
| 145 | |
---|
| 146 | G4int nColumn; |
---|
| 147 | G4int nRow; |
---|
| 148 | |
---|
| 149 | G4ThreeVector eyePosition; |
---|
| 150 | G4ThreeVector targetPosition; |
---|
| 151 | G4ThreeVector eyeDirection; |
---|
| 152 | G4ThreeVector lightDirection; |
---|
| 153 | G4double headAngle; |
---|
| 154 | G4double viewSpan; // Angle per 100 pixels |
---|
| 155 | G4double attenuationLength; |
---|
| 156 | |
---|
| 157 | G4bool distortionOn; |
---|
| 158 | G4bool antialiasingOn; |
---|
| 159 | |
---|
| 160 | G4Colour rayColour; |
---|
| 161 | G4Colour backgroundColour; |
---|
| 162 | |
---|
| 163 | public: |
---|
| 164 | inline void SetNColumn(G4int val) { nColumn = val; } |
---|
| 165 | inline G4int GetNColumn() const { return nColumn; } |
---|
| 166 | inline void SetNRow(G4int val) { nRow = val; } |
---|
| 167 | inline G4int GetNRow() const { return nRow; } |
---|
| 168 | inline void SetEyePosition(const G4ThreeVector& val) { eyePosition = val; } |
---|
| 169 | inline G4ThreeVector GetEyePosition() const { return eyePosition; } |
---|
| 170 | inline void SetTargetPosition(const G4ThreeVector& val) { targetPosition = val; } |
---|
| 171 | inline G4ThreeVector GetTargetPosition() const { return targetPosition; } |
---|
| 172 | inline void SetLightDirection(const G4ThreeVector& val) { lightDirection = val.unit(); } |
---|
| 173 | inline G4ThreeVector GetLightDirection() const { return lightDirection; } |
---|
| 174 | inline void SetHeadAngle(G4double val) { headAngle = val; } |
---|
| 175 | inline G4double GetHeadAngle() const { return headAngle; } |
---|
| 176 | inline void SetViewSpan(G4double val) { viewSpan = val; } |
---|
| 177 | inline G4double GetViewSpan() const { return viewSpan; } |
---|
| 178 | inline void SetAttenuationLength(G4double val) { attenuationLength = val; } |
---|
| 179 | inline G4double GetAttenuationLength() const { return attenuationLength; } |
---|
| 180 | inline void SetDistortion(G4bool val) { distortionOn = val; } |
---|
| 181 | inline G4bool GetDistortion() const { return distortionOn; } |
---|
| 182 | inline void SetBackgroundColour(G4Colour val) { backgroundColour = val; } |
---|
| 183 | inline G4Colour GetBackgroundColour() const { return backgroundColour; } |
---|
| 184 | }; |
---|
| 185 | |
---|
| 186 | #endif |
---|