Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-05-30 08:06:03

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 //
0028 //
0029 
0030 
0031 #ifndef G4TheRayTracer_H
0032 #define G4TheRayTracer_H 1
0033 
0034 // class description:
0035 //
0036 // G4TheRayTracer
0037 //   This is a graphics driver of Geant4 which generates a figure file by
0038 // ray tracing technique. The format of output figure file can be selected
0039 // by assigning a pointer of G4VFigureFileMaker concrete class object.
0040 //   The main entry of ray tracing is Trace() method, which is available
0041 // only at Idle state. G4TheRayTracer shoots rays and controls its own event
0042 // loop. It generates G4Event objects used for its own purpose. When ray
0043 // tracing is working, all sensitive detectors are inactivated and all
0044 // user action classes are swapped out. Still, verbosities set to Geant4
0045 // manager classes are concerned. Thus, it is recommended to set verbosities
0046 // to minimum (usually zero).
0047 //   G4TheRayTracer can visualise absolutely all kinds of geometrical shapes
0048 // which G4Navigator can deal with. Instead, it can NOT visualise hits
0049 // nor trajectories generated by usual simulation.
0050 
0051 #include "globals.hh"
0052 #include "G4ThreeVector.hh"
0053 #include "G4Colour.hh"
0054 
0055 class G4Event;
0056 class G4EventManager;
0057 class G4UserEventAction;
0058 class G4UserStackingAction;
0059 class G4UserTrackingAction;
0060 class G4UserSteppingAction;
0061 class G4RTTrackingAction;
0062 class G4RTSteppingAction;
0063 class G4RTMessenger;
0064 class G4RayShooter;
0065 class G4VFigureFileMaker;
0066 class G4RayTrajectoryPoint;
0067 class G4VisAttributes;
0068 class G4VRTScanner;
0069 
0070 
0071 class G4TheRayTracer
0072 {
0073   public: // with description
0074     G4TheRayTracer(G4VFigureFileMaker* figMaker = 0,
0075            G4VRTScanner* scanner = 0);
0076     // Constructor. The argument is the pointer to G4VFigureFileMaker
0077     // concrete class object. If it is not set and
0078     // SetFigureFileMaker() method is not invoked before Trace()
0079     // command is invoked, then G4RTJpegMaker will be used and JPEG
0080     // file will be generated.  The second argument is a scanner that
0081     // produces a sequence of window coordinates.  If it is not set
0082     // here or if SetScanner is not invoked before Trace(), a default
0083     // G4RTSimpleScanner will be used.
0084 
0085   public:
0086     virtual ~G4TheRayTracer();
0087 
0088   public: // with description
0089     virtual void Trace(const G4String& fileName);
0090     // The main entry point which triggers ray tracing. "fileName" is output
0091     // file name, and it must contain extention (e.g. myFigure.jpg). This
0092     // method is available only if Geant4 is at Idle state.
0093 
0094   protected:
0095     virtual G4bool CreateBitMap();
0096     // Event loop
0097     void CreateFigureFile(const G4String& fileName);
0098     // Create figure file after an event loop
0099     G4bool GenerateColour(G4Event* anEvent);
0100     // Calcurate RGB for one trajectory
0101     virtual void StoreUserActions();
0102     virtual void RestoreUserActions();
0103     // Store and restore user action classes if defined
0104 
0105     G4Colour GetSurfaceColour(G4RayTrajectoryPoint* point);
0106     G4Colour GetMixedColour
0107     (const G4Colour& surfCol,const G4Colour& transCol,G4double weight=0.5);
0108     G4Colour Attenuate(G4RayTrajectoryPoint* point,const G4Colour& sourceCol);
0109     G4bool ValidColour(const G4VisAttributes* visAtt);
0110 
0111   public: // with description
0112     inline void SetFigureFileMaker(G4VFigureFileMaker* figMaker)
0113     // Set a concrete class of G4VFigureFileMaker for assigning the format of
0114     // output figure file.
0115     { theFigMaker = figMaker; }
0116     inline G4VFigureFileMaker* GetFigureFileMaker() {return theFigMaker;}
0117     inline void SetScanner(G4VRTScanner* scanner)
0118     // Set a concrete class of G4VRTScanner for producing a sequence
0119     // of window coordinates.
0120     { theScanner = scanner; }
0121     inline G4VRTScanner* GetScanner() {return theScanner;}
0122 
0123   protected:
0124     G4RayShooter * theRayShooter;
0125     static G4VFigureFileMaker * theFigMaker;
0126     G4RTMessenger * theMessenger;
0127     static G4VRTScanner * theScanner;
0128 
0129     G4EventManager * theEventManager;
0130 
0131     G4UserEventAction * theUserEventAction;
0132     G4UserStackingAction * theUserStackingAction;
0133     G4UserTrackingAction * theUserTrackingAction;
0134     G4UserSteppingAction * theUserSteppingAction;
0135 
0136     G4UserEventAction * theRayTracerEventAction;
0137     G4UserStackingAction * theRayTracerStackingAction;
0138     G4RTTrackingAction * theRayTracerTrackingAction;
0139     G4RTSteppingAction * theRayTracerSteppingAction;
0140 
0141     unsigned char* colorR;
0142     unsigned char* colorG;
0143     unsigned char* colorB;
0144 
0145     G4int nColumn;
0146     G4int nRow;
0147 
0148     G4ThreeVector eyePosition;
0149     G4ThreeVector targetPosition;
0150     G4ThreeVector eyeDirection;
0151     G4ThreeVector lightDirection;
0152     G4ThreeVector up;
0153     G4double headAngle;
0154     G4double viewSpan; // Angle per 100 pixels
0155     G4double attenuationLength;
0156 
0157     G4bool distortionOn;
0158     G4bool antialiasingOn;
0159 
0160     G4Colour rayColour;
0161     G4Colour backgroundColour;
0162 
0163   public:
0164     inline void SetNColumn(G4int val) { nColumn = val; }
0165     inline G4int GetNColumn() const { return nColumn; }
0166     inline void SetNRow(G4int val) { nRow = val; }
0167     inline G4int GetNRow() const { return nRow; }
0168     inline void SetEyePosition(const G4ThreeVector& val) { eyePosition = val; }
0169     inline G4ThreeVector GetEyePosition() const { return eyePosition; }
0170     inline void SetTargetPosition(const G4ThreeVector& val) { targetPosition = val; }
0171     inline G4ThreeVector GetTargetPosition() const { return targetPosition; }
0172     inline void SetLightDirection(const G4ThreeVector& val) { lightDirection = val.unit(); }
0173     inline G4ThreeVector GetLightDirection() const { return lightDirection; }
0174     inline void SetUpVector(const G4ThreeVector& val) { up = val; }
0175     inline G4ThreeVector GetUpVector() const { return up; }
0176     inline void SetHeadAngle(G4double val) { headAngle = val; }
0177     inline G4double GetHeadAngle() const { return headAngle; }
0178     inline void SetViewSpan(G4double val) { viewSpan = val; }
0179     inline G4double GetViewSpan() const { return viewSpan; }
0180     inline void SetAttenuationLength(G4double val) { attenuationLength = val; }
0181     inline G4double GetAttenuationLength() const { return attenuationLength; }
0182     inline void SetDistortion(G4bool val) { distortionOn = val; }
0183     inline G4bool GetDistortion() const { return distortionOn; }
0184     inline void SetBackgroundColour(const G4Colour& val) { backgroundColour = val; }
0185     inline G4Colour GetBackgroundColour() const { return backgroundColour; }
0186 };
0187 
0188 #endif