Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes | Friends
G4TheMTRayTracer Class Reference

#include <G4TheMTRayTracer.hh>

Inheritance diagram for G4TheMTRayTracer:
G4TheRayTracer

Public Member Functions

 G4TheMTRayTracer (G4VFigureFileMaker *figMaker=0, G4VRTScanner *scanner=0)
 
virtual ~G4TheMTRayTracer ()
 
virtual void Trace (const G4String &fileName)
 
- Public Member Functions inherited from G4TheRayTracer
 G4TheRayTracer (G4VFigureFileMaker *figMaker=0, G4VRTScanner *scanner=0)
 
virtual ~G4TheRayTracer ()
 
void SetFigureFileMaker (G4VFigureFileMaker *figMaker)
 
G4VFigureFileMakerGetFigureFileMaker ()
 
void SetScanner (G4VRTScanner *scanner)
 
G4VRTScannerGetScanner ()
 
void SetNColumn (G4int val)
 
G4int GetNColumn () const
 
void SetNRow (G4int val)
 
G4int GetNRow () const
 
void SetEyePosition (const G4ThreeVector &val)
 
G4ThreeVector GetEyePosition () const
 
void SetTargetPosition (const G4ThreeVector &val)
 
G4ThreeVector GetTargetPosition () const
 
void SetLightDirection (const G4ThreeVector &val)
 
G4ThreeVector GetLightDirection () const
 
void SetUpVector (const G4ThreeVector &val)
 
G4ThreeVector GetUpVector () const
 
void SetHeadAngle (G4double val)
 
G4double GetHeadAngle () const
 
void SetViewSpan (G4double val)
 
G4double GetViewSpan () const
 
void SetAttenuationLength (G4double val)
 
G4double GetAttenuationLength () const
 
void SetDistortion (G4bool val)
 
G4bool GetDistortion () const
 
void SetBackgroundColour (const G4Colour &val)
 
G4Colour GetBackgroundColour () const
 

Protected Member Functions

virtual G4bool CreateBitMap ()
 
virtual void StoreUserActions ()
 
virtual void RestoreUserActions ()
 
- Protected Member Functions inherited from G4TheRayTracer
void CreateFigureFile (const G4String &fileName)
 
G4bool GenerateColour (G4Event *anEvent)
 
G4Colour GetSurfaceColour (G4RayTrajectoryPoint *point)
 
G4Colour GetMixedColour (const G4Colour &surfCol, const G4Colour &transCol, G4double weight=0.5)
 
G4Colour Attenuate (G4RayTrajectoryPoint *point, const G4Colour &sourceCol)
 
G4bool ValidColour (const G4VisAttributes *visAtt)
 

Protected Attributes

const G4UserWorkerInitializationtheUserWorkerInitialization
 
G4RTWorkerInitializationtheRTWorkerInitialization
 
const G4UserRunActiontheUserRunAction
 
G4RTRunActiontheRTRunAction
 
- Protected Attributes inherited from G4TheRayTracer
G4RayShootertheRayShooter
 
G4VFigureFileMakertheFigMaker
 
G4RTMessengertheMessenger
 
G4VRTScannertheScanner
 
G4EventManagertheEventManager
 
G4UserEventActiontheUserEventAction
 
G4UserStackingActiontheUserStackingAction
 
G4UserTrackingActiontheUserTrackingAction
 
G4UserSteppingActiontheUserSteppingAction
 
G4UserEventActiontheRayTracerEventAction
 
G4UserStackingActiontheRayTracerStackingAction
 
G4RTTrackingActiontheRayTracerTrackingAction
 
G4RTSteppingActiontheRayTracerSteppingAction
 
unsigned char * colorR
 
unsigned char * colorG
 
unsigned char * colorB
 
G4int nColumn
 
G4int nRow
 
G4ThreeVector eyePosition
 
G4ThreeVector targetPosition
 
G4ThreeVector eyeDirection
 
G4ThreeVector lightDirection
 
G4ThreeVector up
 
G4double headAngle
 
G4double viewSpan
 
G4double attenuationLength
 
G4bool distortionOn
 
G4bool antialiasingOn
 
G4Colour rayColour
 
G4Colour backgroundColour
 

Friends

class G4RTPrimaryGeneratorAction
 
class G4RTRun
 
class G4RayTracerViewer
 

Detailed Description

Definition at line 71 of file G4TheMTRayTracer.hh.

Constructor & Destructor Documentation

G4TheMTRayTracer::G4TheMTRayTracer ( G4VFigureFileMaker figMaker = 0,
G4VRTScanner scanner = 0 
)

Definition at line 51 of file G4TheMTRayTracer.cc.

References FatalException, G4Exception(), theRTRunAction, theRTWorkerInitialization, theUserRunAction, and theUserWorkerInitialization.

53 : G4TheRayTracer(figMaker,scanner)
54 {
55  if(!theInstance)
56  { theInstance = this; }
57  else
58  { G4Exception("G4TheMTRayTracer::G4TheMTRayTracer","VisRayTracer00100",
59  FatalException,"G4TheMTRayTracer has to be a singleton.");}
62  theUserRunAction = 0;
63  theRTRunAction = 0;
64 }
G4RTRunAction * theRTRunAction
const G4UserWorkerInitialization * theUserWorkerInitialization
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
const G4UserRunAction * theUserRunAction
G4RTWorkerInitialization * theRTWorkerInitialization
G4TheRayTracer(G4VFigureFileMaker *figMaker=0, G4VRTScanner *scanner=0)
G4TheMTRayTracer::~G4TheMTRayTracer ( )
virtual

Definition at line 66 of file G4TheMTRayTracer.cc.

References theRTRunAction, and theRTWorkerInitialization.

67 {
69  {
72  }
73  if(theRTRunAction)
74  {
75  delete theRTRunAction;
76  theRTRunAction = 0;
77  }
78 }
G4RTRunAction * theRTRunAction
G4RTWorkerInitialization * theRTWorkerInitialization

Member Function Documentation

G4bool G4TheMTRayTracer::CreateBitMap ( )
protectedvirtual

Reimplemented from G4TheRayTracer.

Definition at line 152 of file G4TheMTRayTracer.cc.

References G4UImanager::ApplyCommand(), G4TheRayTracer::colorB, G4TheRayTracer::colorG, G4TheRayTracer::colorR, G4UIcommand::ConvertToString(), G4VRTScanner::Coords(), G4VRTScanner::Draw(), G4Colour::GetBlue(), G4VVisManager::GetConcreteInstance(), G4RunManager::GetCurrentRun(), G4Colour::GetGreen(), G4RTRun::GetMap(), G4THitsMap< T >::GetMap(), G4MTRunManager::GetMasterRunManager(), G4Colour::GetRed(), G4UImanager::GetUIpointer(), G4VVisManager::IgnoreStateChanges(), G4VRTScanner::Initialize(), G4TheRayTracer::nColumn, G4TheRayTracer::nRow, RestoreUserActions(), StoreUserActions(), and G4TheRayTracer::theScanner.

Referenced by Trace().

153 {
155  visMan->IgnoreStateChanges(true);
157 
158 // Event loop
160  G4int nEvent = nRow*nColumn;
161 //// mrm->BeamOn(nEvent);
162 //// Temporary work-around until direct invokation of G4RunManager::BeamOn() works.
163  G4String str = "/run/beamOn " + G4UIcommand::ConvertToString(nEvent);
165 
167  visMan->IgnoreStateChanges(false);
168 
169  const G4RTRun* theRun = static_cast<const G4RTRun*>(mrm->GetCurrentRun());
170  if(!theRun) return false;
171 
172  G4THitsMap<G4Colour>* colMap = theRun->GetMap();
173  std::map<G4int,G4Colour*>::iterator itr = colMap->GetMap()->begin();
174  for(;itr!=colMap->GetMap()->end();itr++)
175  {
176  G4int key = itr->first;
177  G4Colour* col = itr->second;
178  colorR[key] = (unsigned char)(int(255*col->GetRed()));
179  colorG[key] = (unsigned char)(int(255*col->GetGreen()));
180  colorB[key] = (unsigned char)(int(255*col->GetBlue()));
181  }
182 
183  theScanner->Initialize(nRow,nColumn);
184  G4int iRow, iColumn;
185  while (theScanner->Coords(iRow,iColumn))
186  {
187  G4int iCoord = iRow * nColumn + iColumn;
188  theScanner->Draw(colorR[iCoord],colorG[iCoord],colorB[iCoord]);
189  }
190 
191  return true;
192 }
static G4VVisManager * GetConcreteInstance()
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:357
virtual G4bool Coords(G4int &iRow, G4int &iColumn)=0
G4double GetBlue() const
Definition: G4Colour.hh:141
G4VRTScanner * theScanner
int G4int
Definition: G4Types.hh:78
const G4Run * GetCurrentRun() const
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
unsigned char * colorR
virtual void Draw(unsigned char red, unsigned char green, unsigned char blue)
Definition: G4VRTScanner.hh:71
G4double GetRed() const
Definition: G4Colour.hh:139
virtual void IgnoreStateChanges(G4bool)
virtual void Initialize(G4int nRow, G4int nColumn)=0
G4double GetGreen() const
Definition: G4Colour.hh:140
static G4MTRunManager * GetMasterRunManager()
G4THitsMap< G4Colour > * GetMap() const
Definition: G4RTRun.hh:64
virtual void StoreUserActions()
unsigned char * colorB
std::map< G4int, T * > * GetMap() const
Definition: G4THitsMap.hh:68
virtual void RestoreUserActions()
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:419
unsigned char * colorG
void G4TheMTRayTracer::RestoreUserActions ( )
protectedvirtual

Reimplemented from G4TheRayTracer.

Definition at line 145 of file G4TheMTRayTracer.cc.

References G4MTRunManager::GetMasterRunManager(), G4MTRunManager::SetUserAction(), G4MTRunManager::SetUserInitialization(), theUserRunAction, and theUserWorkerInitialization.

Referenced by CreateBitMap().

146 {
148  mrm->SetUserInitialization(const_cast<G4UserWorkerInitialization*>(theUserWorkerInitialization));
149  mrm->SetUserAction(const_cast<G4UserRunAction*>(theUserRunAction));
150 }
virtual void SetUserAction(G4UserRunAction *userAction)
static G4MTRunManager * GetMasterRunManager()
virtual void SetUserInitialization(G4VUserPhysicsList *userPL)
const G4UserWorkerInitialization * theUserWorkerInitialization
const G4UserRunAction * theUserRunAction
void G4TheMTRayTracer::StoreUserActions ( )
protectedvirtual

Reimplemented from G4TheRayTracer.

Definition at line 132 of file G4TheMTRayTracer.cc.

References G4MTRunManager::GetMasterRunManager(), G4RunManager::GetUserRunAction(), G4RunManager::GetUserWorkerInitialization(), G4MTRunManager::SetUserAction(), G4MTRunManager::SetUserInitialization(), theRTRunAction, theRTWorkerInitialization, theUserRunAction, and theUserWorkerInitialization.

Referenced by CreateBitMap().

133 {
137 
140 
143 }
G4RTRunAction * theRTRunAction
const G4UserWorkerInitialization * GetUserWorkerInitialization() const
virtual void SetUserAction(G4UserRunAction *userAction)
static G4MTRunManager * GetMasterRunManager()
virtual void SetUserInitialization(G4VUserPhysicsList *userPL)
const G4UserWorkerInitialization * theUserWorkerInitialization
const G4UserRunAction * theUserRunAction
G4RTWorkerInitialization * theRTWorkerInitialization
const G4UserRunAction * GetUserRunAction() const
void G4TheMTRayTracer::Trace ( const G4String fileName)
virtual

Reimplemented from G4TheRayTracer.

Definition at line 80 of file G4TheMTRayTracer.cc.

References G4UImanager::ApplyCommand(), G4TheRayTracer::backgroundColour, G4TheRayTracer::colorB, G4TheRayTracer::colorG, G4TheRayTracer::colorR, G4UIcommand::ConvertToString(), CreateBitMap(), G4TheRayTracer::CreateFigureFile(), G4TheRayTracer::eyeDirection, G4TheRayTracer::eyePosition, G4cerr, G4endl, G4State_Idle, G4Colour::GetBlue(), G4UImanager::GetCurrentIntValue(), G4StateManager::GetCurrentState(), G4Colour::GetGreen(), G4Colour::GetRed(), G4StateManager::GetStateManager(), G4StateManager::GetStateString(), G4UImanager::GetUIpointer(), G4TheRayTracer::nColumn, G4TheRayTracer::nRow, G4TheRayTracer::targetPosition, G4TheRayTracer::theFigMaker, and CLHEP::Hep3Vector::unit().

81 {
83  G4ApplicationState currentState = theStateMan->GetCurrentState();
84  if(currentState!=G4State_Idle)
85  {
86  G4cerr << "Illegal application state <" << theStateMan->GetStateString(currentState)
87  << "> - Trace() ignored. " << G4endl;
88  return;
89  }
90 
91  if(!theFigMaker)
92  {
93  G4cerr << "Figure file maker class is not specified - Trace() ignored." << G4endl;
94  return;
95  }
96 
98  G4int storeTrajectory = UI->GetCurrentIntValue("/tracking/storeTrajectory");
99  UI->ApplyCommand("/tracking/storeTrajectory 1");
100 
102  eyeDirection = tmpVec.unit();
103  G4int nPixel = nColumn*nRow;
104  colorR = new unsigned char[nPixel];
105  colorG = new unsigned char[nPixel];
106  colorB = new unsigned char[nPixel];
107  unsigned char defR = (unsigned char)(int(255*backgroundColour.GetRed()));
108  unsigned char defG = (unsigned char)(int(255*backgroundColour.GetGreen()));
109  unsigned char defB = (unsigned char)(int(255*backgroundColour.GetBlue()));
110  for(G4int ii=0;ii<nPixel;ii++)
111  {
112  colorR[ii] = defR;
113  colorG[ii] = defG;
114  colorB[ii] = defB;
115  }
116 
117  G4bool succeeded = CreateBitMap();
118  if(succeeded)
119  { CreateFigureFile(fileName); }
120  else
121  { G4cerr << "Could not create figure file" << G4endl;
122  G4cerr << "You might set the eye position outside of the world volume" << G4endl; }
123 
124  G4String str = "/tracking/storeTrajectory " + G4UIcommand::ConvertToString(storeTrajectory);
125  UI->ApplyCommand(str);
126 
127  delete [] colorR;
128  delete [] colorG;
129  delete [] colorB;
130 }
G4ThreeVector targetPosition
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:357
void CreateFigureFile(const G4String &fileName)
G4double GetBlue() const
Definition: G4Colour.hh:141
G4ThreeVector eyeDirection
int G4int
Definition: G4Types.hh:78
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
unsigned char * colorR
static G4StateManager * GetStateManager()
G4double GetRed() const
Definition: G4Colour.hh:139
bool G4bool
Definition: G4Types.hh:79
G4double GetGreen() const
Definition: G4Colour.hh:140
G4ApplicationState GetCurrentState() const
G4int GetCurrentIntValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
Definition: G4UImanager.cc:218
G4VFigureFileMaker * theFigMaker
virtual G4bool CreateBitMap()
Hep3Vector unit() const
unsigned char * colorB
#define G4endl
Definition: G4ios.hh:61
G4Colour backgroundColour
G4ThreeVector eyePosition
G4ApplicationState
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:419
G4GLOB_DLL std::ostream G4cerr
G4String GetStateString(G4ApplicationState aState) const
unsigned char * colorG

Friends And Related Function Documentation

friend class G4RayTracerViewer
friend

Definition at line 75 of file G4TheMTRayTracer.hh.

friend class G4RTPrimaryGeneratorAction
friend

Definition at line 73 of file G4TheMTRayTracer.hh.

friend class G4RTRun
friend

Definition at line 74 of file G4TheMTRayTracer.hh.

Field Documentation

G4RTRunAction* G4TheMTRayTracer::theRTRunAction
protected

Definition at line 113 of file G4TheMTRayTracer.hh.

Referenced by G4TheMTRayTracer(), StoreUserActions(), and ~G4TheMTRayTracer().

G4RTWorkerInitialization* G4TheMTRayTracer::theRTWorkerInitialization
protected

Definition at line 111 of file G4TheMTRayTracer.hh.

Referenced by G4TheMTRayTracer(), StoreUserActions(), and ~G4TheMTRayTracer().

const G4UserRunAction* G4TheMTRayTracer::theUserRunAction
protected

Definition at line 112 of file G4TheMTRayTracer.hh.

Referenced by G4TheMTRayTracer(), RestoreUserActions(), and StoreUserActions().

const G4UserWorkerInitialization* G4TheMTRayTracer::theUserWorkerInitialization
protected

Definition at line 110 of file G4TheMTRayTracer.hh.

Referenced by G4TheMTRayTracer(), RestoreUserActions(), and StoreUserActions().


The documentation for this class was generated from the following files: