Geant4-11
G4TheRayTracer.hh
Go to the documentation of this file.
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//
28//
29
30
31#ifndef G4TheRayTracer_H
32#define G4TheRayTracer_H 1
33
34// class description:
35//
36// G4TheRayTracer
37// This is a graphics driver of Geant4 which generates a figure file by
38// ray tracing technique. The format of output figure file can be selected
39// by assigning a pointer of G4VFigureFileMaker concrete class object.
40// The main entry of ray tracing is Trace() method, which is available
41// only at Idle state. G4TheRayTracer shoots rays and controls its own event
42// loop. It generates G4Event objects used for its own purpose. When ray
43// tracing is working, all sensitive detectors are inactivated and all
44// user action classes are swapped out. Still, verbosities set to Geant4
45// manager classes are concerned. Thus, it is recommended to set verbosities
46// to minimum (usually zero).
47// G4TheRayTracer can visualise absolutely all kinds of geometrical shapes
48// which G4Navigator can deal with. Instead, it can NOT visualise hits
49// nor trajectories generated by usual simulation.
50
51#include "globals.hh"
52#include "G4ThreeVector.hh"
53#include "G4Colour.hh"
54
55class G4Event;
56class G4EventManager;
63class G4RTMessenger;
64class G4RayShooter;
67class G4VisAttributes;
68class G4VRTScanner;
69
70
72{
73 public: // with description
75 G4VRTScanner* scanner = 0);
76 // Constructor. The argument is the pointer to G4VFigureFileMaker
77 // concrete class object. If it is not set and
78 // SetFigureFileMaker() method is not invoked before Trace()
79 // command is invoked, then G4RTJpegMaker will be used and JPEG
80 // file will be generated. The second argument is a scanner that
81 // produces a sequence of window coordinates. If it is not set
82 // here or if SetScanner is not invoked before Trace(), a default
83 // G4RTSimpleScanner will be used.
84
85 public:
86 virtual ~G4TheRayTracer();
87
88 public: // with description
89 virtual void Trace(const G4String& fileName);
90 // The main entry point which triggers ray tracing. "fileName" is output
91 // file name, and it must contain extention (e.g. myFigure.jpg). This
92 // method is available only if Geant4 is at Idle state.
93
94 protected:
95 virtual G4bool CreateBitMap();
96 // Event loop
97 void CreateFigureFile(const G4String& fileName);
98 // Create figure file after an event loop
100 // Calcurate RGB for one trajectory
101 virtual void StoreUserActions();
102 virtual void RestoreUserActions();
103 // Store and restore user action classes if defined
104
107 (const G4Colour& surfCol,const G4Colour& transCol,G4double weight=0.5);
108 G4Colour Attenuate(G4RayTrajectoryPoint* point,const G4Colour& sourceCol);
109 G4bool ValidColour(const G4VisAttributes* visAtt);
110
111 public: // with description
113 // Set a concrete class of G4VFigureFileMaker for assigning the format of
114 // output figure file.
115 { theFigMaker = figMaker; }
117 inline void SetScanner(G4VRTScanner* scanner)
118 // Set a concrete class of G4VRTScanner for producing a sequence
119 // of window coordinates.
120 { theScanner = scanner; }
122
123 protected:
128
130
135
140
141 unsigned char* colorR;
142 unsigned char* colorG;
143 unsigned char* colorB;
144
147
154 G4double viewSpan; // Angle per 100 pixels
156
159
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; }
172 inline void SetLightDirection(const G4ThreeVector& val) { lightDirection = val.unit(); }
174 inline void SetUpVector(const G4ThreeVector& val) { up = val; }
175 inline G4ThreeVector GetUpVector() const { return up; }
176 inline void SetHeadAngle(G4double val) { headAngle = val; }
177 inline G4double GetHeadAngle() const { return headAngle; }
178 inline void SetViewSpan(G4double val) { viewSpan = val; }
179 inline G4double GetViewSpan() const { return viewSpan; }
182 inline void SetDistortion(G4bool val) { distortionOn = val; }
183 inline G4bool GetDistortion() const { return distortionOn; }
184 inline void SetBackgroundColour(const G4Colour& val) { backgroundColour = val; }
186};
187
188#endif
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
Hep3Vector unit() const
G4ThreeVector eyeDirection
void SetTargetPosition(const G4ThreeVector &val)
G4RTTrackingAction * theRayTracerTrackingAction
G4double GetViewSpan() const
G4UserTrackingAction * theUserTrackingAction
G4bool GenerateColour(G4Event *anEvent)
void SetUpVector(const G4ThreeVector &val)
G4RTSteppingAction * theRayTracerSteppingAction
virtual void StoreUserActions()
G4int GetNColumn() const
static G4VRTScanner * theScanner
void SetViewSpan(G4double val)
G4ThreeVector lightDirection
G4EventManager * theEventManager
static G4VFigureFileMaker * theFigMaker
G4UserStackingAction * theRayTracerStackingAction
G4UserEventAction * theUserEventAction
void SetNRow(G4int val)
unsigned char * colorG
G4double GetHeadAngle() const
virtual void Trace(const G4String &fileName)
G4UserSteppingAction * theUserSteppingAction
G4Colour Attenuate(G4RayTrajectoryPoint *point, const G4Colour &sourceCol)
G4bool GetDistortion() const
virtual ~G4TheRayTracer()
G4Colour backgroundColour
unsigned char * colorR
G4double attenuationLength
void SetNColumn(G4int val)
virtual G4bool CreateBitMap()
void SetLightDirection(const G4ThreeVector &val)
void SetDistortion(G4bool val)
void SetBackgroundColour(const G4Colour &val)
G4ThreeVector GetTargetPosition() const
G4Colour GetSurfaceColour(G4RayTrajectoryPoint *point)
G4ThreeVector targetPosition
void CreateFigureFile(const G4String &fileName)
void SetAttenuationLength(G4double val)
G4UserEventAction * theRayTracerEventAction
G4Colour GetBackgroundColour() const
void SetFigureFileMaker(G4VFigureFileMaker *figMaker)
G4ThreeVector GetUpVector() const
G4UserStackingAction * theUserStackingAction
G4ThreeVector GetLightDirection() const
G4ThreeVector GetEyePosition() const
G4ThreeVector eyePosition
void SetHeadAngle(G4double val)
virtual void RestoreUserActions()
G4TheRayTracer(G4VFigureFileMaker *figMaker=0, G4VRTScanner *scanner=0)
void SetScanner(G4VRTScanner *scanner)
unsigned char * colorB
G4VRTScanner * GetScanner()
G4VFigureFileMaker * GetFigureFileMaker()
G4RTMessenger * theMessenger
G4RayShooter * theRayShooter
G4double GetAttenuationLength() const
G4ThreeVector up
G4int GetNRow() const
G4bool ValidColour(const G4VisAttributes *visAtt)
void SetEyePosition(const G4ThreeVector &val)
G4Colour GetMixedColour(const G4Colour &surfCol, const G4Colour &transCol, G4double weight=0.5)