G4TheRayTracer.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 //
00030 
00031 
00032 #ifndef G4TheRayTracer_H
00033 #define G4TheRayTracer_H 1
00034 
00035 // class description:
00036 //
00037 // G4TheRayTracer
00038 //   This is a graphics driver of Geant4 which generates a figure file by
00039 // ray tracing technique. The format of output figure file can be selected
00040 // by assigning a pointer of G4VFigureFileMaker concrete class object.
00041 //   The main entry of ray tracing is Trace() method, which is available
00042 // only at Idle state. G4TheRayTracer shoots rays and controls its own event
00043 // loop. It generates G4Event objects used for its own purpose. When ray
00044 // tracing is working, all sensitive detectors are inactivated and all
00045 // user action classes are swapped out. Still, verbosities set to Geant4
00046 // manager classes are concerned. Thus, it is recommended to set verbosities
00047 // to minimum (usually zero).
00048 //   G4TheRayTracer can visualise absolutely all kinds of geometrical shapes
00049 // which G4Navigator can deal with. Instead, it can NOT visualise hits
00050 // nor trajectories generated by usual simulation.
00051 
00052 #include "globals.hh"
00053 #include "G4ThreeVector.hh"
00054 #include "G4Colour.hh"
00055 
00056 class G4Event;
00057 class G4EventManager;
00058 class G4UserEventAction;
00059 class G4UserStackingAction;
00060 class G4UserTrackingAction;
00061 class G4UserSteppingAction;
00062 class G4RTTrackingAction;
00063 class G4RTSteppingAction;
00064 class G4RTMessenger;
00065 class G4RayShooter;
00066 class G4VFigureFileMaker;
00067 class G4RayTrajectoryPoint;
00068 class G4VisAttributes;
00069 class G4VRTScanner;
00070 
00071 
00072 class G4TheRayTracer
00073 {
00074   public: // with description
00075     G4TheRayTracer(G4VFigureFileMaker* figMaker = 0,
00076                    G4VRTScanner* scanner = 0);
00077     // Constructor. The argument is the pointer to G4VFigureFileMaker
00078     // concrete class object. If it is not set and
00079     // SetFigureFileMaker() method is not invoked before Trace()
00080     // command is invoked, then G4RTJpegMaker will be used and JPEG
00081     // file will be generated.  The second argument is a scanner that
00082     // produces a sequence of window coordinates.  If it is not set
00083     // here or if SetScanner is not invoked before Trace(), a default
00084     // G4RTSimpleScanner will be used.
00085 
00086   public:
00087     ~G4TheRayTracer();
00088 
00089   public: // with description
00090     void Trace(G4String fileName);
00091     // The main entry point which triggers ray tracing. "fileName" is output
00092     // file name, and it must contain extention (e.g. myFigure.jpg). This
00093     // method is available only if Geant4 is at Idle state.
00094 
00095   protected:
00096     G4bool CreateBitMap();
00097     // Event loop
00098     void CreateFigureFile(G4String fileName);
00099     // Create figure file after an event loop
00100     G4bool GenerateColour(G4Event* anEvent);
00101     // Calcurate RGB for one trajectory
00102     void StoreUserActions();
00103     void RestoreUserActions();
00104     // Store and restore user action classes if defined
00105 
00106     G4Colour GetSurfaceColour(G4RayTrajectoryPoint* point);
00107     G4Colour GetMixedColour(G4Colour surfCol,G4Colour transCol,G4double weight=0.5);
00108     G4Colour Attenuate(G4RayTrajectoryPoint* point, G4Colour sourceCol);
00109     G4bool ValidColour(const G4VisAttributes* visAtt);
00110 
00111   public: // with description
00112     inline void SetFigureFileMaker(G4VFigureFileMaker* figMaker)
00113     // Set a concrete class of G4VFigureFileMaker for assigning the format of
00114     // output figure file.
00115     { theFigMaker = figMaker; }
00116     inline G4VFigureFileMaker* GetFigureFileMaker() {return theFigMaker;}
00117     inline void SetScanner(G4VRTScanner* scanner)
00118     // Set a concrete class of G4VRTScanner for producing a sequence
00119     // of window coordinates.
00120     { theScanner = scanner; }
00121     inline G4VRTScanner* GetScanner() {return theScanner;}
00122 
00123   protected:
00124     G4RayShooter * theRayShooter;
00125     G4VFigureFileMaker * theFigMaker;
00126     G4RTMessenger * theMessenger;
00127     G4VRTScanner * theScanner;
00128 
00129     G4EventManager * theEventManager;
00130 
00131     G4UserEventAction * theUserEventAction;
00132     G4UserStackingAction * theUserStackingAction;
00133     G4UserTrackingAction * theUserTrackingAction;
00134     G4UserSteppingAction * theUserSteppingAction;
00135 
00136     G4UserEventAction * theRayTracerEventAction;
00137     G4UserStackingAction * theRayTracerStackingAction;
00138     G4RTTrackingAction * theRayTracerTrackingAction;
00139     G4RTSteppingAction * theRayTracerSteppingAction;
00140 
00141     unsigned char* colorR;
00142     unsigned char* colorG;
00143     unsigned char* colorB;
00144 
00145     G4int nColumn;
00146     G4int nRow;
00147 
00148     G4ThreeVector eyePosition;
00149     G4ThreeVector targetPosition;
00150     G4ThreeVector eyeDirection;
00151     G4ThreeVector lightDirection;
00152     G4ThreeVector up;
00153     G4double headAngle;
00154     G4double viewSpan; // Angle per 100 pixels
00155     G4double attenuationLength;
00156 
00157     G4bool distortionOn;
00158     G4bool antialiasingOn;
00159 
00160     G4Colour rayColour;
00161     G4Colour backgroundColour;
00162 
00163   public:
00164     inline void SetNColumn(G4int val) { nColumn = val; }
00165     inline G4int GetNColumn() const { return nColumn; }
00166     inline void SetNRow(G4int val) { nRow = val; }
00167     inline G4int GetNRow() const { return nRow; }
00168     inline void SetEyePosition(const G4ThreeVector& val) { eyePosition = val; }
00169     inline G4ThreeVector GetEyePosition() const { return eyePosition; }
00170     inline void SetTargetPosition(const G4ThreeVector& val) { targetPosition = val; }
00171     inline G4ThreeVector GetTargetPosition() const { return targetPosition; }
00172     inline void SetLightDirection(const G4ThreeVector& val) { lightDirection = val.unit(); }
00173     inline G4ThreeVector GetLightDirection() const { return lightDirection; }
00174     inline void SetUpVector(const G4ThreeVector& val) { up = val; }
00175     inline G4ThreeVector GetUpVector() const { return up; }
00176     inline void SetHeadAngle(G4double val) { headAngle = val; }
00177     inline G4double GetHeadAngle() const { return headAngle; }
00178     inline void SetViewSpan(G4double val) { viewSpan = val; }
00179     inline G4double GetViewSpan() const { return viewSpan; }
00180     inline void SetAttenuationLength(G4double val) { attenuationLength = val; }
00181     inline G4double GetAttenuationLength() const { return attenuationLength; }
00182     inline void SetDistortion(G4bool val) { distortionOn = val; }
00183     inline G4bool GetDistortion() const { return distortionOn; }
00184     inline void SetBackgroundColour(G4Colour val) { backgroundColour = val; }
00185     inline G4Colour GetBackgroundColour() const { return backgroundColour; }
00186 };
00187 
00188 #endif

Generated on Mon May 27 17:50:00 2013 for Geant4 by  doxygen 1.4.7