Import Geant4 8.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 14:44:26 +02:00
parent 8a51e0bc40
commit 216a75eeb1
8717 changed files with 360418 additions and 141343 deletions
+27 -2
View File
@@ -1,4 +1,4 @@
$Id: History,v 1.39 2005/12/05 06:44:10 perl Exp $
$Id: History,v 1.46 2006/05/12 12:43:43 allison Exp $
-------------------------------------------------------------------
=========================================================
@@ -21,9 +21,34 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
History file for visualization category
History file for Ray Tracer category
---------------------------------------
12th May 2006 John Allison (raytracer-V08-00-04)
- SetRecomputeTransients(false).
10th May 2006 Makoto Asai (raytracer-V08-00-03)
- Remove G4RayShooter class to Event category.
21st April 2006 John Allison (raytracer-V08-00-02)
- Relies on improved protection for null models and parameters.
26th January 2006 John Allison (raytracer-V08-00-01)
- G4RayTracerSceneHandler: Improved handling of dummy scene.
- G4TheRayTracer: Advance work for possible inclusion of
anti-aliasing. Currently no change of functionality.
11th January 2006 John Allison (raytracer-V08-00-00)
- Reorganisation (needs visman-V08-00-02):
o Allowed multiple ray tracers.
o Separated out the original ray tracer into G4TheRayTracer, to be
used by viewers.
o Made G4RTMessenger a smart singleton that queries the vis manager
for tracers.
o Caused G4RayTracer to instantiate a default ray tracer if the user
wants to use /vis/rayTracer commands without the benefit of the
vis system (scene handlers and viewers).
4th December 2005 Makoto Asai (raytracer-V07-01-08)
- Correct initialization of G4RTTrackingAction and G4RTSteppingAction
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RTJpeg.hh,v 1.5 2001/07/11 10:09:01 gunter Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4RTJpeg.hh,v 1.6 2006/06/29 21:23:13 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RTJpegCoder.hh,v 1.5 2001/07/11 10:09:01 gunter Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4RTJpegCoder.hh,v 1.6 2006/06/29 21:23:15 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RTJpegCoderTables.hh,v 1.5 2001/07/11 10:09:01 gunter Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4RTJpegCoderTables.hh,v 1.6 2006/06/29 21:23:17 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
// class description:
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RTJpegMaker.hh,v 1.5 2001/07/11 10:09:02 gunter Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4RTJpegMaker.hh,v 1.6 2006/06/29 21:23:19 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RTMessenger.hh,v 1.5 2003/09/18 11:13:24 johna Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4RTMessenger.hh,v 1.7 2006/06/29 21:23:21 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//
@@ -44,20 +47,25 @@ class G4UIcmdWith3VectorAndUnit;
class G4UIcmdWithADoubleAndUnit;
class G4UIcmdWithAnInteger;
class G4UIcmdWithAString;
class G4RayTracer;
class G4TheRayTracer;
class G4RTSteppingAction;
class G4RTMessenger : public G4UImessenger
{
public:
G4RTMessenger(G4RayTracer* p1,G4RTSteppingAction* p2);
static G4RTMessenger* GetInstance
(G4TheRayTracer* p1,G4RTSteppingAction* p2); // Singleton constructor.
virtual ~G4RTMessenger();
virtual G4String GetCurrentValue(G4UIcommand * command);
virtual void SetNewValue(G4UIcommand * command,G4String newValue);
private:
G4RayTracer* theTracer;
G4RTMessenger(G4TheRayTracer* p1,G4RTSteppingAction* p2);
static G4RTMessenger* fpInstance;
G4TheRayTracer* theDefaultTracer; // The first tracer to
// instantiate this messenger.
G4TheRayTracer* theTracer; // The current tracer.
G4RTSteppingAction* theSteppingAction;
G4UIdirectory* rayDirectory;
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RTOutBitStream.hh,v 1.6 2001/07/11 10:09:02 gunter Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4RTOutBitStream.hh,v 1.7 2006/06/29 21:23:23 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RTSimpleScanner.hh,v 1.2 2005/07/17 13:59:24 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4RTSimpleScanner.hh,v 1.3 2006/06/29 21:23:25 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RTSteppingAction.hh,v 1.4 2001/07/11 10:09:02 gunter Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4RTSteppingAction.hh,v 1.5 2006/06/29 21:23:27 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RTTrackingAction.hh,v 1.5 2003/05/30 13:01:20 johna Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4RTTrackingAction.hh,v 1.6 2006/06/29 21:23:29 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RTXScanner.hh,v 1.2 2005/07/20 20:39:02 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4RTXScanner.hh,v 1.4 2006/06/29 21:23:31 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//
@@ -39,7 +42,10 @@
#include "G4VRTScanner.hh"
class G4RayTracer;
#include <X11/Xlib.h>
#include <X11/Xutil.h>
class G4ViewParameters;
class G4RTXScanner: public G4VRTScanner {
@@ -67,13 +73,19 @@ public: // with description
// last valid coordinate.
virtual void Draw
(unsigned char red, unsigned char green, unsigned char blue,
G4RayTracer*);
(unsigned char red, unsigned char green, unsigned char blue);
// Draw coloured square at current position.
G4bool GetXWindow(const G4String& name, G4ViewParameters&);
protected:
G4String theGSName, theGSNickname;
G4int theNRow, theNColumn, theStep, theIRow, theIColumn;
// X Window variables...
Display* display;
Window win;
GC gc;
XStandardColormap *scmap;
};
#endif
@@ -1,78 +0,0 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: G4RayShooter.hh,v 1.3 2001/07/11 10:09:02 gunter Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
// class description:
//
// the object of this class shoots a ray (actually geantino) primary particle
// associated with a G4Event object. This slass must be used exclusively by
// G4RayTracer.
//
#ifndef G4RayShooter_h
#define G4RayShooter_h 1
#include "globals.hh"
#include "G4ThreeVector.hh"
#include "G4ParticleDefinition.hh"
#include "G4PrimaryVertex.hh"
#include "G4ParticleMomentum.hh"
class G4Event;
class G4RayShooter
{
public:
G4RayShooter();
public:
virtual ~G4RayShooter();
public: // with description
void Shoot(G4Event* evt,G4ThreeVector vtx,G4ThreeVector direc);
// This method generates a primary vertex and a primary particle at the
// given vertex point and with the given direction. This method is invoked
// by G4RayTracer.
private:
void SetInitialValues();
G4ParticleDefinition* particle_definition;
G4ParticleMomentum particle_momentum_direction;
G4double particle_energy;
G4ThreeVector particle_position;
G4double particle_time;
G4ThreeVector particle_polarization;
};
#endif
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RayTracer.hh,v 1.9 2003/09/18 11:14:03 johna Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4RayTracer.hh,v 1.11 2006/06/29 21:23:33 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//
@@ -33,159 +36,19 @@
// class description:
//
// G4RayTracer
// This is a graphics driver of Geant4 which generates a figure file by
// ray tracing technique. The format of output figure file can be selected
// by assigning a pointer of G4VFigureFileMaker concrete class object.
// The main entry of ray tracing is Trace() method, which is available
// only at Idle state. G4RayTracer shoots rays and controls its own event
// loop. It generates G4Event objects used for its own purpose. When ray
// tracing is working, all sensitive detectors are inactivated and all
// user action classes are swapped out. Still, verbosities set to Geant4
// manager classes are concerned. Thus, it is recommended to set verbosities
// to minimum (usually zero).
// G4RayTracer can visualise absolutely all kinds of geometrical shapes
// which G4Navigator can deal with. Instead, it can NOT visualise hits
// nor trajectories generated by usual simulation.
// To make G4RayTracer library, G4VIS_BUILD_RAYTRACER_DRIVER environment
// variable must be set before compiling visualization category. To use
// G4RayTracer with your program, G4VIS_USE_RAYTRACER environment variable
// must be set before compiling your program and your VisManager concrete
// implementation must contain
// RegisterGraphicsSystem (new G4RayTracer);
//
// This is a factory for G4RayTracerSceneHandler and G4RayTracerViewer
// objects. The viewer uses the original G4RayTracer, which has now
// been renamed G4TheRayTracer.
#include "globals.hh"
#include "G4ThreeVector.hh"
#include "G4VGraphicsSystem.hh"
#include "G4Colour.hh"
class G4Event;
class G4EventManager;
class G4UserEventAction;
class G4UserStackingAction;
class G4UserTrackingAction;
class G4UserSteppingAction;
class G4RTTrackingAction;
class G4RTSteppingAction;
class G4RTMessenger;
class G4RayShooter;
class G4VFigureFileMaker;
class G4RayTrajectoryPoint;
class G4VisAttributes;
class G4VRTScanner;
class G4RayTracer : public G4VGraphicsSystem
{
public: // with description
G4RayTracer(G4VFigureFileMaker* figMaker = 0,
G4VRTScanner* scanner = 0);
// Constructor. The argument is the pointer to G4VFigureFileMaker
// concrete class object. If it is not set and
// SetFigureFileMaker() method is not invoked before Trace()
// command is invoked, then G4RTJpegMaker will be used and JPEG
// file will be generated. The second argument is a scanner that
// produces a sequence of window coordinates. If it is not set
// here or if SetScanner is not invoked before Trace(), a default
// G4RTSimpleScanner will be used.
public:
G4RayTracer();
~G4RayTracer();
public: // with description
void Trace(G4String fileName);
// The main entry point which triggers ray tracing. "fileName" is output
// file name, and it must contain extention (e.g. myFigure.jpg). This
// method is available only if Geant4 is at Idle state.
public:
virtual G4VSceneHandler* CreateSceneHandler (const G4String& );
virtual G4VViewer* CreateViewer (G4VSceneHandler&, const G4String& );
protected:
G4bool CreateBitMap();
// Event loop
void CreateFigureFile(G4String fileName);
// Create figure file after an event loop
G4bool GenerateColour(G4Event* anEvent, G4int iCoord);
// Calcurate RGB for one trajectory stored at location iCoord
void StoreUserActions();
void RestoreUserActions();
// Store and restore user action classes if defined
G4Colour GetSurfaceColour(G4RayTrajectoryPoint* point);
G4Colour GetMixedColour(G4Colour surfCol,G4Colour transCol,G4double weight=0.5);
G4Colour Attenuate(G4RayTrajectoryPoint* point, G4Colour sourceCol);
G4bool ValidColour(const G4VisAttributes* visAtt);
public: // with description
inline void SetFigureFileMaker(G4VFigureFileMaker* figMaker)
// Set a concrete class of G4VFigureFileMaker for assigning the format of
// output figure file.
{ theFigMaker = figMaker; }
inline void SetScanner(G4VRTScanner* scanner)
// Set a concrete class of G4VRTScanner for producing a sequence
// of window coordinates.
{ theScanner = scanner; }
protected:
G4RayShooter * theRayShooter;
G4VFigureFileMaker * theFigMaker;
G4RTMessenger * theMessenger;
G4VRTScanner * theScanner;
G4EventManager * theEventManager;
G4UserEventAction * theUserEventAction;
G4UserStackingAction * theUserStackingAction;
G4UserTrackingAction * theUserTrackingAction;
G4UserSteppingAction * theUserSteppingAction;
G4UserEventAction * theRayTracerEventAction;
G4UserStackingAction * theRayTracerStackingAction;
G4RTTrackingAction * theRayTracerTrackingAction;
G4RTSteppingAction * theRayTracerSteppingAction;
unsigned char* colorR;
unsigned char* colorG;
unsigned char* colorB;
G4int nColumn;
G4int nRow;
G4ThreeVector eyePosition;
G4ThreeVector targetPosition;
G4ThreeVector eyeDirection;
G4ThreeVector lightDirection;
G4double headAngle;
G4double viewSpan; // Angle per 100 pixels
G4double attenuationLength;
G4bool distortionOn;
G4Colour backgroundColour;
public:
inline void SetNColumn(G4int val) { nColumn = val; }
inline G4int GetNColumn() const { return nColumn; }
inline void SetNRow(G4int val) { nRow = val; }
inline G4int GetNRow() const { return nRow; }
inline void SetEyePosition(const G4ThreeVector& val) { eyePosition = val; }
inline G4ThreeVector GetEyePosition() const { return eyePosition; }
inline void SetTargetPosition(const G4ThreeVector& val) { targetPosition = val; }
inline G4ThreeVector GetTargetPosition() const { return targetPosition; }
inline void SetLightDirection(const G4ThreeVector& val) { lightDirection = val.unit(); }
inline G4ThreeVector GetLightDirection() const { return lightDirection; }
inline void SetHeadAngle(G4double val) { headAngle = val; }
inline G4double GetHeadAngle() const { return headAngle; }
inline void SetViewSpan(G4double val) { viewSpan = val; }
inline G4double GetViewSpan() const { return viewSpan; }
inline void SetAttenuationLength(G4double val) { attenuationLength = val; }
inline G4double GetAttenuationLength() const { return attenuationLength; }
inline void SetDistortion(G4bool val) { distortionOn = val; }
inline G4bool GetDistortion() const { return distortionOn; }
inline void SetBackgroundColour(G4Colour val) { backgroundColour = val; }
inline G4Colour GetBackgroundColour() const { return backgroundColour; }
G4VSceneHandler* CreateSceneHandler (const G4String& );
G4VViewer* CreateViewer (G4VSceneHandler&, const G4String& );
};
#endif
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RayTracerFeatures.hh,v 1.3 2001/07/11 10:09:02 gunter Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4RayTracerFeatures.hh,v 1.4 2006/06/29 21:23:35 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RayTracerSceneHandler.hh,v 1.8 2005/06/02 17:43:46 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4RayTracerSceneHandler.hh,v 1.11 2006/06/29 21:23:37 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
// John Allison 17th March 2000
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RayTracerViewer.hh,v 1.5 2005/07/17 13:59:24 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4RayTracerViewer.hh,v 1.7 2006/06/29 21:23:39 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
// John Allison 17th March 2000
@@ -31,15 +34,21 @@
#include "G4VViewer.hh"
class G4TheRayTracer;
class G4RayTracerViewer: public G4VViewer {
public:
G4RayTracerViewer(G4VSceneHandler&,const G4String& name);
G4RayTracerViewer(G4VSceneHandler&,
const G4String& name,
G4TheRayTracer* = 0);
virtual ~G4RayTracerViewer();
void SetView();
void ClearView();
void DrawView();
G4TheRayTracer* GetTracer() {return theTracer;}
protected:
G4int fFileCount;
G4TheRayTracer* theTracer;
};
#endif
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RayTracerX.hh,v 1.2 2005/07/20 20:39:02 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4RayTracerX.hh,v 1.4 2006/06/29 21:23:41 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//
// John Allison 11th September 2003
@@ -35,28 +38,19 @@
// class description:
//
// G4RayTracerX
// X window version of RayTracer (also produces jpeg file - see class
// description for G4RayTracer).
// X window version of RayTracer - opens X window for viewing as well
// as producing jpeg file just like G4RayTracer.
#include "G4RayTracer.hh"
#include "G4VGraphicsSystem.hh"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
class G4RayTracerX : public G4RayTracer
class G4RayTracerX : public G4VGraphicsSystem
{
public:
G4RayTracerX();
G4VSceneHandler* CreateSceneHandler (const G4String& );
G4VViewer* CreateViewer (G4VSceneHandler&, const G4String& );
// X Window variables...
Display* display;
Window win;
GC gc;
XStandardColormap *scmap;
public: // with description
G4RayTracerX();
~G4RayTracerX();
G4VSceneHandler* CreateSceneHandler (const G4String& );
G4VViewer* CreateViewer (G4VSceneHandler&, const G4String& );
};
#endif
#endif
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RayTracerXViewer.hh,v 1.2 2005/07/20 20:39:02 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4RayTracerXViewer.hh,v 1.3 2006/06/29 21:23:43 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
// John Allison 17th March 2000
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RayTrajectory.hh,v 1.14 2004/06/11 14:30:49 gcosmo Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4RayTrajectory.hh,v 1.15 2006/06/29 21:23:45 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RayTrajectoryPoint.hh,v 1.8 2004/06/11 14:30:50 gcosmo Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4RayTrajectoryPoint.hh,v 1.9 2006/06/29 21:23:47 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//
@@ -0,0 +1,186 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4TheRayTracer.hh,v 1.3 2006/06/29 21:23:49 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//
#ifndef G4TheRayTracer_H
#define G4TheRayTracer_H 1
// class description:
//
// G4TheRayTracer
// This is a graphics driver of Geant4 which generates a figure file by
// ray tracing technique. The format of output figure file can be selected
// by assigning a pointer of G4VFigureFileMaker concrete class object.
// The main entry of ray tracing is Trace() method, which is available
// only at Idle state. G4TheRayTracer shoots rays and controls its own event
// loop. It generates G4Event objects used for its own purpose. When ray
// tracing is working, all sensitive detectors are inactivated and all
// user action classes are swapped out. Still, verbosities set to Geant4
// manager classes are concerned. Thus, it is recommended to set verbosities
// to minimum (usually zero).
// G4TheRayTracer can visualise absolutely all kinds of geometrical shapes
// which G4Navigator can deal with. Instead, it can NOT visualise hits
// nor trajectories generated by usual simulation.
#include "globals.hh"
#include "G4ThreeVector.hh"
#include "G4Colour.hh"
class G4Event;
class G4EventManager;
class G4UserEventAction;
class G4UserStackingAction;
class G4UserTrackingAction;
class G4UserSteppingAction;
class G4RTTrackingAction;
class G4RTSteppingAction;
class G4RTMessenger;
class G4RayShooter;
class G4VFigureFileMaker;
class G4RayTrajectoryPoint;
class G4VisAttributes;
class G4VRTScanner;
class G4TheRayTracer
{
public: // with description
G4TheRayTracer(G4VFigureFileMaker* figMaker = 0,
G4VRTScanner* scanner = 0);
// Constructor. The argument is the pointer to G4VFigureFileMaker
// concrete class object. If it is not set and
// SetFigureFileMaker() method is not invoked before Trace()
// command is invoked, then G4RTJpegMaker will be used and JPEG
// file will be generated. The second argument is a scanner that
// produces a sequence of window coordinates. If it is not set
// here or if SetScanner is not invoked before Trace(), a default
// G4RTSimpleScanner will be used.
public:
~G4TheRayTracer();
public: // with description
void Trace(G4String fileName);
// The main entry point which triggers ray tracing. "fileName" is output
// file name, and it must contain extention (e.g. myFigure.jpg). This
// method is available only if Geant4 is at Idle state.
protected:
G4bool CreateBitMap();
// Event loop
void CreateFigureFile(G4String fileName);
// Create figure file after an event loop
G4bool GenerateColour(G4Event* anEvent);
// Calcurate RGB for one trajectory
void StoreUserActions();
void RestoreUserActions();
// Store and restore user action classes if defined
G4Colour GetSurfaceColour(G4RayTrajectoryPoint* point);
G4Colour GetMixedColour(G4Colour surfCol,G4Colour transCol,G4double weight=0.5);
G4Colour Attenuate(G4RayTrajectoryPoint* point, G4Colour sourceCol);
G4bool ValidColour(const G4VisAttributes* visAtt);
public: // with description
inline void SetFigureFileMaker(G4VFigureFileMaker* figMaker)
// Set a concrete class of G4VFigureFileMaker for assigning the format of
// output figure file.
{ theFigMaker = figMaker; }
inline G4VFigureFileMaker* GetFigureFileMaker() {return theFigMaker;}
inline void SetScanner(G4VRTScanner* scanner)
// Set a concrete class of G4VRTScanner for producing a sequence
// of window coordinates.
{ theScanner = scanner; }
inline G4VRTScanner* GetScanner() {return theScanner;}
protected:
G4RayShooter * theRayShooter;
G4VFigureFileMaker * theFigMaker;
G4RTMessenger * theMessenger;
G4VRTScanner * theScanner;
G4EventManager * theEventManager;
G4UserEventAction * theUserEventAction;
G4UserStackingAction * theUserStackingAction;
G4UserTrackingAction * theUserTrackingAction;
G4UserSteppingAction * theUserSteppingAction;
G4UserEventAction * theRayTracerEventAction;
G4UserStackingAction * theRayTracerStackingAction;
G4RTTrackingAction * theRayTracerTrackingAction;
G4RTSteppingAction * theRayTracerSteppingAction;
unsigned char* colorR;
unsigned char* colorG;
unsigned char* colorB;
G4int nColumn;
G4int nRow;
G4ThreeVector eyePosition;
G4ThreeVector targetPosition;
G4ThreeVector eyeDirection;
G4ThreeVector lightDirection;
G4double headAngle;
G4double viewSpan; // Angle per 100 pixels
G4double attenuationLength;
G4bool distortionOn;
G4bool antialiasingOn;
G4Colour rayColour;
G4Colour backgroundColour;
public:
inline void SetNColumn(G4int val) { nColumn = val; }
inline G4int GetNColumn() const { return nColumn; }
inline void SetNRow(G4int val) { nRow = val; }
inline G4int GetNRow() const { return nRow; }
inline void SetEyePosition(const G4ThreeVector& val) { eyePosition = val; }
inline G4ThreeVector GetEyePosition() const { return eyePosition; }
inline void SetTargetPosition(const G4ThreeVector& val) { targetPosition = val; }
inline G4ThreeVector GetTargetPosition() const { return targetPosition; }
inline void SetLightDirection(const G4ThreeVector& val) { lightDirection = val.unit(); }
inline G4ThreeVector GetLightDirection() const { return lightDirection; }
inline void SetHeadAngle(G4double val) { headAngle = val; }
inline G4double GetHeadAngle() const { return headAngle; }
inline void SetViewSpan(G4double val) { viewSpan = val; }
inline G4double GetViewSpan() const { return viewSpan; }
inline void SetAttenuationLength(G4double val) { attenuationLength = val; }
inline G4double GetAttenuationLength() const { return attenuationLength; }
inline void SetDistortion(G4bool val) { distortionOn = val; }
inline G4bool GetDistortion() const { return distortionOn; }
inline void SetBackgroundColour(G4Colour val) { backgroundColour = val; }
inline G4Colour GetBackgroundColour() const { return backgroundColour; }
};
#endif
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4VFigureFileMaker.hh,v 1.4 2001/07/11 10:09:03 gunter Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4VFigureFileMaker.hh,v 1.5 2006/06/29 21:23:51 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4VRTScanner.hh,v 1.3 2005/11/28 20:07:44 tinslay Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4VRTScanner.hh,v 1.5 2006/06/29 21:23:53 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//
@@ -36,8 +39,6 @@
#include "globals.hh"
class G4RayTracer;
class G4VRTScanner {
public: // with description
@@ -59,10 +60,13 @@ public: // with description
// last valid coordinate.
virtual void Draw
(unsigned char, unsigned char, unsigned char,
G4RayTracer*) {}
(unsigned char red, unsigned char green, unsigned char blue);
// Draw coloured square at current position.
};
inline void G4VRTScanner::Draw
(unsigned char, unsigned char, unsigned char)
{}
#endif
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RTJpegCoder.cc,v 1.5 2004/12/07 23:41:00 perl Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4RTJpegCoder.cc,v 1.6 2006/06/29 21:23:55 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//
//
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RTJpegMaker.cc,v 1.9 2003/06/18 08:23:02 gcosmo Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4RTJpegMaker.cc,v 1.10 2006/06/29 21:23:57 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//
//
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RTMessenger.cc,v 1.7 2003/09/18 11:13:25 johna Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4RTMessenger.cc,v 1.9 2006/06/29 21:23:59 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//
//
@@ -37,13 +40,24 @@
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4UIcmdWithAString.hh"
#include "G4RayTracer.hh"
#include "G4TheRayTracer.hh"
#include "G4RTSteppingAction.hh"
#include "G4ThreeVector.hh"
#include "G4VisManager.hh"
#include "G4RayTracerViewer.hh"
G4RTMessenger::G4RTMessenger(G4RayTracer* p1,G4RTSteppingAction* p2)
G4RTMessenger* G4RTMessenger::fpInstance = 0;
G4RTMessenger* G4RTMessenger::GetInstance
(G4TheRayTracer* p1,G4RTSteppingAction* p2)
{
theTracer = p1;
if (!fpInstance) fpInstance = new G4RTMessenger(p1, p2);
return fpInstance;
}
G4RTMessenger::G4RTMessenger(G4TheRayTracer* p1,G4RTSteppingAction* p2)
{
theDefaultTracer = p1;
theSteppingAction = p2;
rayDirectory = new G4UIdirectory("/vis/rayTracer/");
@@ -171,6 +185,29 @@ G4String G4RTMessenger::GetCurrentValue(G4UIcommand * command)
void G4RTMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
{
G4VisManager* pVisManager = G4VisManager::GetInstance();
theTracer = theDefaultTracer;
G4VViewer* pVViewer = pVisManager->GetCurrentViewer();
if (pVViewer) {
G4RayTracerViewer* pViewer = dynamic_cast<G4RayTracerViewer*>(pVViewer);
if (pViewer) {
theTracer = pViewer->GetTracer();
} else {
G4cout <<
"G4RTMessenger::SetNewValue: Current viewer is not of type RayTracer."
"\n Use \"/vis/viewer/select\" or \"/vis/open\"."
<< G4endl;
}
}
if (theTracer == theDefaultTracer) {
G4cout <<
"G4RTMessenger::SetNewValue: No valid current viewer. Using default RayTracer."
<< G4endl;
}
if(command==columnCmd)
{ theTracer->SetNColumn(columnCmd->GetNewIntValue(newValue)); }
else if(command==rowCmd)
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RTOutBitStream.cc,v 1.4 2001/07/11 10:09:04 gunter Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4RTOutBitStream.cc,v 1.5 2006/06/29 21:24:01 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//
//
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RTSimpleScanner.cc,v 1.2 2005/07/17 13:59:24 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4RTSimpleScanner.cc,v 1.3 2006/06/29 21:24:03 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RTSteppingAction.cc,v 1.6 2001/07/11 10:09:04 gunter Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4RTSteppingAction.cc,v 1.7 2006/06/29 21:24:05 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//
//
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RTTrackingAction.cc,v 1.4 2003/05/30 13:01:21 johna Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4RTTrackingAction.cc,v 1.5 2006/06/29 21:24:07 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//
//
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RTXScanner.cc,v 1.2 2005/07/20 20:39:02 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4RTXScanner.cc,v 1.4 2006/06/29 21:24:09 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//
@@ -30,10 +33,18 @@
#include "G4RTXScanner.hh"
#include "G4RayTracerX.hh"
#include "G4TheRayTracer.hh"
#include "G4RayTracerXViewer.hh"
#include "G4ViewParameters.hh"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
extern "C" {
Bool G4RayTracerXScannerWaitForNotify (Display*, XEvent* e, char* arg) {
return (e->type == MapNotify) && (e->xmap.window == (Window) arg);
}
}
G4RTXScanner::G4RTXScanner():
theGSName("RayTracerX"), theGSNickname("RayTracerX"),
@@ -92,17 +103,110 @@ G4bool G4RTXScanner::Coords(G4int& iRow, G4int& iColumn)
return true;
}
G4bool G4RTXScanner::GetXWindow(const G4String& name, G4ViewParameters& vp)
{
display = XOpenDisplay(0); // Use display defined by DISPLAY environment.
if (!display) {
G4cerr << "G4RTXScanner::Initialize(): cannot get display."
<< G4endl;
return false;
}
int screen_num = DefaultScreen(display);
// Window size and position...
int xOffset = 0, yOffset = 0;
unsigned int width, height;
XSizeHints* size_hints = XAllocSizeHints();
const G4String& XGeometryString = vp.GetXGeometryString();
if (!XGeometryString.empty()) {
G4int geometryResultMask = XParseGeometry
((char*)XGeometryString.c_str(),
&xOffset, &yOffset, &width, &height);
if (geometryResultMask & (WidthValue | HeightValue)) {
if (geometryResultMask & XValue) {
if (geometryResultMask & XNegative) {
xOffset = DisplayWidth(display, screen_num) + xOffset - width;
}
size_hints->flags |= PPosition;
size_hints->x = xOffset;
}
if (geometryResultMask & YValue) {
if (geometryResultMask & YNegative) {
yOffset = DisplayHeight(display, screen_num) + yOffset - height;
}
size_hints->flags |= PPosition;
size_hints->y = yOffset;
}
} else {
G4cout << "ERROR: Geometry string \""
<< XGeometryString
<< "\" invalid. Using \"600x600\"."
<< G4endl;
width = 600;
height = 600;
}
}
size_hints->width = width;
size_hints->height = height;
size_hints->flags |= PSize;
win = XCreateSimpleWindow
(display, RootWindow(display, screen_num),
xOffset, yOffset, width, height,
0, // Border width.
WhitePixel(display, screen_num), // Border colour.
BlackPixel(display, screen_num)); // Background colour.
XGCValues values;
gc = XCreateGC(display, win, 0, &values);
int nMaps;
Status status = XGetRGBColormaps
(display, RootWindow(display, screen_num),
&scmap, &nMaps, XA_RGB_BEST_MAP);
if (!status) {
system("xstdcmap -best"); // ...and try again...
Status status = XGetRGBColormaps
(display, RootWindow(display, screen_num),
&scmap, &nMaps, XA_RGB_BEST_MAP);
if (!status) {
G4cerr <<
"G4RTXScanner::Initialize(): cannot get color map."
"\n Perhaps your system does not support RGB_BEST_MAP."
<< G4endl;
return false;
}
}
if (!scmap->colormap) {
G4cerr << "G4RTXScanner::Initialize(): color map empty."
<< G4endl;
return false;
}
XWMHints* wm_hints = XAllocWMHints();
XClassHint* class_hint = XAllocClassHint();
const char* window_name = name.c_str();
XTextProperty windowName;
XStringListToTextProperty((char**)&window_name, 1, &windowName);
XSetWMProperties(display, win, &windowName, &windowName,
0, 0, size_hints, wm_hints, class_hint);
XMapWindow(display, win);
// Wait for window to appear (wait for an "map notify" event).
XSelectInput(display, win, StructureNotifyMask);
XEvent event;
XIfEvent (display, &event, G4RayTracerXScannerWaitForNotify, (char*) win);
return true;
}
void G4RTXScanner::Draw
(unsigned char red, unsigned char green, unsigned char blue,
G4RayTracer* aTracer)
(unsigned char red, unsigned char green, unsigned char blue)
// Draw coloured square at current position.
{
G4RayTracerX* theTracer = (G4RayTracerX*) aTracer;
Display*& display = theTracer->display;
Window& win = theTracer->win;
GC& gc = theTracer->gc;
XStandardColormap*& scmap = theTracer->scmap;
unsigned long pixel_value = scmap->base_pixel +
((unsigned long) ((red * scmap->red_max) / 256.) * scmap->red_mult) +
((unsigned long) ((green * scmap->green_max) / 256.) * scmap->green_mult) +
@@ -119,7 +223,6 @@ void G4RTXScanner::Draw
}
XFlush(display);
}
#endif
@@ -1,93 +0,0 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: G4RayShooter.cc,v 1.4 2005/12/05 04:13:50 asaim Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
#include "G4RayShooter.hh"
#include "G4PrimaryParticle.hh"
#include "G4Event.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
#include "globals.hh"
G4RayShooter::G4RayShooter()
{
SetInitialValues();
}
void G4RayShooter::SetInitialValues()
{
particle_definition = 0;
G4ThreeVector zero;
particle_momentum_direction = (G4ParticleMomentum)zero;
particle_energy = 1.0*GeV;
particle_position = zero;
particle_time = 0.0;
particle_polarization = zero;
}
G4RayShooter::~G4RayShooter()
{
}
void G4RayShooter::Shoot(G4Event* evt,G4ThreeVector vtx,G4ThreeVector direc)
{
if(!particle_definition)
{
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
G4String particleName;
particle_definition = particleTable->FindParticle(particleName="geantino");
if(!particle_definition)
{
G4String msg;
msg = " G4RayTracer uses geantino to trace the ray, but your physics list does not\n";
msg += "define G4Geantino. Please add G4Geantino in your physics list.";
G4Exception("G4RayShooter::Shoot","RayTracer001",FatalException,msg);
}
}
// create a new vertex
G4PrimaryVertex* vertex = new G4PrimaryVertex(vtx,particle_time);
// create new primaries and set them to the vertex
G4double mass = particle_definition->GetPDGMass();
G4double energy = particle_energy + mass;
G4double pmom = std::sqrt(energy*energy-mass*mass);
G4double px = pmom*direc.x();
G4double py = pmom*direc.y();
G4double pz = pmom*direc.z();
G4PrimaryParticle* particle =
new G4PrimaryParticle(particle_definition,px,py,pz);
particle->SetMass( mass );
particle->SetPolarization(particle_polarization.x(),
particle_polarization.y(),
particle_polarization.z());
vertex->SetPrimary( particle );
evt->AddPrimaryVertex( vertex );
}
+40 -390
View File
@@ -1,146 +1,49 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RayTracer.cc,v 1.19 2005/12/05 03:51:22 asaim Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
//
//
// $Id: G4RayTracer.cc,v 1.21 2006/06/29 21:24:11 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
#include "G4RayTracer.hh"
#include "G4RayTracerFeatures.hh"
#include "G4RayTracerSceneHandler.hh"
#include "G4RayTracerViewer.hh"
#include "G4EventManager.hh"
#include "G4RTMessenger.hh"
#include "G4RayShooter.hh"
#include "G4VFigureFileMaker.hh"
#include "G4RTTrackingAction.hh"
#include "G4RTSteppingAction.hh"
#include "G4RayTrajectory.hh"
#include "G4RayTrajectoryPoint.hh"
#include "G4RTJpegMaker.hh"
#include "G4RTSimpleScanner.hh"
#include "G4GeometryManager.hh"
#include "G4SDManager.hh"
#include "G4StateManager.hh"
#include "G4Event.hh"
#include "G4TrajectoryContainer.hh"
#include "G4Colour.hh"
#include "G4VisAttributes.hh"
#include "G4UImanager.hh"
#include "G4TransportationManager.hh"
#include "G4RegionStore.hh"
#include "G4ProductionCutsTable.hh"
#include "G4TheRayTracer.hh"
G4RayTracer::G4RayTracer(G4VFigureFileMaker* figMaker,
G4VRTScanner* scanner)
:G4VGraphicsSystem
(scanner ? scanner->GetGSName() : "RayTracer",
scanner ? scanner->GetGSNickname() : "RayTracer",
RAYTRACER_FEATURES,
G4VGraphicsSystem::threeD)
G4RayTracer::G4RayTracer():
G4VGraphicsSystem("RayTracer",
"RayTracer",
RAYTRACER_FEATURES,
G4VGraphicsSystem::threeD)
{
theFigMaker = figMaker;
if(!theFigMaker) theFigMaker = new G4RTJpegMaker();
theScanner = scanner;
if(!theScanner) theScanner = new G4RTSimpleScanner;
theRayShooter = new G4RayShooter();
theRayTracerEventAction = 0;
theRayTracerStackingAction = 0;
theRayTracerTrackingAction = 0;
theRayTracerSteppingAction = 0;
theMessenger = new G4RTMessenger(this,theRayTracerSteppingAction);
theEventManager = G4EventManager::GetEventManager();
nColumn = 640;
nRow = 640;
eyePosition = G4ThreeVector(1.*m,1.*m,1.*m);
targetPosition = G4ThreeVector(0.,0.,0.);
lightDirection = G4ThreeVector(-0.1,-0.2,-0.3).unit();
viewSpan = 5.0*deg;
headAngle = 270.*deg;
attenuationLength = 1.0*m;
distortionOn = false;
backgroundColour = G4Colour(1.,1.,1.);
new G4TheRayTracer; // Establish default ray tracer.
}
G4RayTracer::~G4RayTracer()
{
delete theRayShooter;
if(theRayTracerTrackingAction) delete theRayTracerTrackingAction;
if(theRayTracerSteppingAction) delete theRayTracerSteppingAction;
delete theMessenger;
delete theScanner;
delete theFigMaker;
}
void G4RayTracer::Trace(G4String fileName)
{
G4StateManager* theStateMan = G4StateManager::GetStateManager();
G4ApplicationState currentState = theStateMan->GetCurrentState();
if(currentState!=G4State_Idle)
{
G4cerr << "Illegal application state - Trace() ignored." << G4endl;
return;
}
if(!theFigMaker)
{
G4cerr << "Figure file maker class is not specified - Trace() ignored." << G4endl;
return;
}
G4UImanager* UI = G4UImanager::GetUIpointer();
G4int storeTrajectory = UI->GetCurrentIntValue("/tracking/storeTrajectory");
if(storeTrajectory==0) UI->ApplyCommand("/tracking/storeTrajectory 1");
G4ThreeVector tmpVec = targetPosition - eyePosition;
eyeDirection = tmpVec.unit();
colorR = new unsigned char[nColumn*nRow];
colorG = new unsigned char[nColumn*nRow];
colorB = new unsigned char[nColumn*nRow];
StoreUserActions();
G4bool succeeded = CreateBitMap();
if(succeeded)
{ CreateFigureFile(fileName); }
else
{ G4cerr << "Could not create figure file" << G4endl;
G4cerr << "You might set the eye position outside of the world volume" << G4endl; }
RestoreUserActions();
if(storeTrajectory==0) UI->ApplyCommand("/tracking/storeTrajectory 0");
delete [] colorR;
delete [] colorG;
delete [] colorB;
}
{}
G4VSceneHandler* G4RayTracer::CreateSceneHandler (const G4String& name) {
G4VSceneHandler* pScene = new G4RayTracerSceneHandler (*this, name);
@@ -149,275 +52,22 @@ G4VSceneHandler* G4RayTracer::CreateSceneHandler (const G4String& name) {
G4VViewer* G4RayTracer::CreateViewer (G4VSceneHandler& sceneHandler,
const G4String& name) {
G4VViewer* pView = new G4RayTracerViewer (sceneHandler, name);
return pView;
}
void G4RayTracer::StoreUserActions()
{
theUserEventAction = theEventManager->GetUserEventAction();
theUserStackingAction = theEventManager->GetUserStackingAction();
theUserTrackingAction = theEventManager->GetUserTrackingAction();
theUserSteppingAction = theEventManager->GetUserSteppingAction();
if(!theRayTracerTrackingAction) theRayTracerTrackingAction = new G4RTTrackingAction();
if(!theRayTracerSteppingAction) theRayTracerSteppingAction = new G4RTSteppingAction();
theEventManager->SetUserAction(theRayTracerEventAction);
theEventManager->SetUserAction(theRayTracerStackingAction);
theEventManager->SetUserAction(theRayTracerTrackingAction);
theEventManager->SetUserAction(theRayTracerSteppingAction);
G4SDManager* theSDMan = G4SDManager::GetSDMpointerIfExist();
if(theSDMan)
{ theSDMan->Activate("/",false); }
G4GeometryManager* theGeomMan = G4GeometryManager::GetInstance();
theGeomMan->OpenGeometry();
theGeomMan->CloseGeometry(true);
}
void G4RayTracer::RestoreUserActions()
{
theEventManager->SetUserAction(theUserEventAction);
theEventManager->SetUserAction(theUserStackingAction);
theEventManager->SetUserAction(theUserTrackingAction);
theEventManager->SetUserAction(theUserSteppingAction);
G4SDManager* theSDMan = G4SDManager::GetSDMpointerIfExist();
if(theSDMan)
{ theSDMan->Activate("/",true); }
}
#include "G4ProcessManager.hh"
#include "G4ProcessVector.hh"
#include "G4Geantino.hh"
G4bool G4RayTracer::CreateBitMap()
{
G4int iEvent = 0;
G4double stepAngle = viewSpan/100.;
G4double viewSpanX = stepAngle*nColumn;
G4double viewSpanY = stepAngle*nRow;
G4bool succeeded;
// Confirm process(es) of Geantino is initialized
G4VPhysicalVolume* pWorld =
G4TransportationManager::GetTransportationManager()->
GetNavigatorForTracking()->GetWorldVolume();
G4RegionStore::GetInstance()->UpdateMaterialList(pWorld);
G4ProductionCutsTable::GetProductionCutsTable()->UpdateCoupleTable(pWorld);
G4ProcessVector* pVector
= G4Geantino::GeantinoDefinition()->GetProcessManager()->GetProcessList();
for (G4int j=0; j < pVector->size(); ++j) {
(*pVector)[j]->BuildPhysicsTable(*(G4Geantino::GeantinoDefinition()));
G4VViewer* pViewer = new G4RayTracerViewer (sceneHandler, name);
if (pViewer) {
if (pViewer->GetViewId() < 0) {
G4cout <<
"G4RayTracer::CreateViewer: ERROR flagged by negative"
" view id in G4RayTracerViewer creation."
"\n Destroying view and returning null pointer."
<< G4endl;
delete pViewer;
pViewer = 0;
}
}
// Close geometry and set the application state
G4GeometryManager* geomManager = G4GeometryManager::GetInstance();
geomManager->OpenGeometry();
geomManager->CloseGeometry(1,0);
G4ThreeVector center(0,0,0);
G4Navigator* navigator =
G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
navigator->LocateGlobalPointAndSetup(center,0,false);
G4StateManager* theStateMan = G4StateManager::GetStateManager();
theStateMan->SetNewState(G4State_GeomClosed);
// Event loop
theScanner->Initialize(nRow,nColumn);
G4int iRow, iColumn;
while (theScanner->Coords(iRow,iColumn)) {
G4int iCoord = iRow * nColumn + iColumn;
G4Event* anEvent = new G4Event(iEvent++);
G4double angleX = -(viewSpanX/2. - iColumn*stepAngle);
G4double angleY = viewSpanY/2. - iRow*stepAngle;
G4ThreeVector rayDirection;
if(distortionOn)
{
rayDirection = G4ThreeVector(std::tan(angleX)/std::cos(angleY),-std::tan(angleY)/std::cos(angleX),1.0);
}
else
{
rayDirection = G4ThreeVector(std::tan(angleX),-std::tan(angleY),1.0);
}
rayDirection.rotateZ(headAngle);
rayDirection.rotateUz(eyeDirection);
G4ThreeVector rayPosition(eyePosition);
G4bool interceptable = true;
// Check if rayPosition is in the world.
EInside whereisit =
pWorld->GetLogicalVolume()->GetSolid()->Inside(rayPosition);
if (whereisit != kInside) {
// It's outside the world, so move it inside.
G4double outsideDistance =
pWorld->GetLogicalVolume()->GetSolid()->
DistanceToIn(rayPosition,rayDirection);
if (outsideDistance != kInfinity) {
// Borrowing form geometry, where 1e-8 < epsilon < 1e-3, in
// absolute/internal length units, is used for ensuring good
// nehaviour, choose to add 0.001 to ensure rayPosition is
// definitely inside the world volume (JA 16/9/2005)...
rayPosition = rayPosition+(outsideDistance+0.001)*rayDirection;
}
else {
interceptable = false;
}
}
if (interceptable) {
theRayShooter->Shoot(anEvent,rayPosition,rayDirection);
theEventManager->ProcessOneEvent(anEvent);
succeeded = GenerateColour(anEvent,iCoord);
}
else { // Ray does not intercept world at all.
// Store background colour...
colorR[iCoord] = (unsigned char)(int(255*backgroundColour.GetRed()));
colorG[iCoord] = (unsigned char)(int(255*backgroundColour.GetGreen()));
colorB[iCoord] = (unsigned char)(int(255*backgroundColour.GetBlue()));
theScanner->Draw(colorR[iCoord],colorG[iCoord],colorB[iCoord],this);
succeeded = true;
}
delete anEvent;
if(!succeeded) return false;
else {
G4cout <<
"G4RayTracer::CreateViewer: ERROR: null pointer on new G4RayTracerViewer."
<< G4endl;
}
theStateMan->SetNewState(G4State_Idle);
return true;
return pViewer;
}
void G4RayTracer::CreateFigureFile(G4String fileName)
{
//G4cout << nColumn << " " << nRow << G4endl;
theFigMaker->CreateFigureFile(fileName,nColumn,nRow,colorR,colorG,colorB);
}
G4bool G4RayTracer::GenerateColour(G4Event* anEvent, G4int iCoord)
{
G4TrajectoryContainer * trajectoryContainer = anEvent->GetTrajectoryContainer();
G4RayTrajectory* trajectory = (G4RayTrajectory*)( (*trajectoryContainer)[0] );
if(!trajectory) return false;
G4int nPoint = trajectory->GetPointEntries();
if(nPoint==0) return false;
G4Colour rayColour;
G4Colour initialColour(backgroundColour);
if( trajectory->GetPointC(nPoint-1)->GetPostStepAtt() )
{ initialColour = GetSurfaceColour(trajectory->GetPointC(nPoint-1)); }
rayColour = Attenuate(trajectory->GetPointC(nPoint-1),initialColour);
for(int i=nPoint-2;i>=0;i--)
{
G4Colour surfaceColour = GetSurfaceColour(trajectory->GetPointC(i));
G4double weight = 1.0 - surfaceColour.GetAlpha();
G4Colour mixedColour = GetMixedColour(rayColour,surfaceColour,weight);
rayColour = Attenuate(trajectory->GetPointC(i),mixedColour);
}
colorR[iCoord] = (unsigned char)(int(255*rayColour.GetRed()));
colorG[iCoord] = (unsigned char)(int(255*rayColour.GetGreen()));
colorB[iCoord] = (unsigned char)(int(255*rayColour.GetBlue()));
theScanner->Draw(colorR[iCoord],colorG[iCoord],colorB[iCoord],this);
return true;
}
G4Colour G4RayTracer::GetMixedColour(G4Colour surfCol,G4Colour transCol,G4double weight)
{
G4double r = weight*surfCol.GetRed() + (1.-weight)*transCol.GetRed();
G4double g = weight*surfCol.GetGreen() + (1.-weight)*transCol.GetGreen();
G4double b = weight*surfCol.GetBlue() + (1.-weight)*transCol.GetBlue();
G4double a = weight*surfCol.GetAlpha() + (1.-weight)*transCol.GetAlpha();
return G4Colour(r,g,b,a);
}
G4Colour G4RayTracer::GetSurfaceColour(G4RayTrajectoryPoint* point)
{
const G4VisAttributes* preAtt = point->GetPreStepAtt();
const G4VisAttributes* postAtt = point->GetPostStepAtt();
G4bool preVis = ValidColour(preAtt);
G4bool postVis = ValidColour(postAtt);
G4Colour transparent(1.,1.,1.,0.);
if(!preVis&&!postVis) return transparent;
G4ThreeVector normal = point->GetSurfaceNormal();
G4Colour preCol(1.,1.,1.);
G4Colour postCol(1.,1.,1.);
if(preVis)
{
G4double brill = (1.0-(-lightDirection).dot(normal))/2.0;
G4double r = preAtt->GetColour().GetRed();
G4double g = preAtt->GetColour().GetGreen();
G4double b = preAtt->GetColour().GetBlue();
preCol = G4Colour(r*brill,g*brill,b*brill,preAtt->GetColour().GetAlpha());
}
else
{ preCol = transparent; }
if(postVis)
{
G4double brill = (1.0-(-lightDirection).dot(-normal))/2.0;
G4double r = postAtt->GetColour().GetRed();
G4double g = postAtt->GetColour().GetGreen();
G4double b = postAtt->GetColour().GetBlue();
postCol = G4Colour(r*brill,g*brill,b*brill,postAtt->GetColour().GetAlpha());
}
else
{ postCol = transparent; }
if(!preVis) return postCol;
if(!postVis) return preCol;
G4double weight = 0.5;
return GetMixedColour(preCol,postCol,weight);
}
G4Colour G4RayTracer::Attenuate(G4RayTrajectoryPoint* point, G4Colour sourceCol)
{
const G4VisAttributes* preAtt = point->GetPreStepAtt();
G4bool visible = ValidColour(preAtt);
if(!visible) return sourceCol;
G4Colour objCol = preAtt->GetColour();
G4double stepRed = objCol.GetRed();
G4double stepGreen = objCol.GetGreen();
G4double stepBlue = objCol.GetBlue();
G4double stepAlpha = objCol.GetAlpha();
G4double stepLength = point->GetStepLength();
G4double attenuationFuctor;
if(stepAlpha > 0.9999999){ stepAlpha = 0.9999999; } // patch to the next line
attenuationFuctor = -stepAlpha/(1.0-stepAlpha)*stepLength/attenuationLength;
G4double KtRed = std::exp((1.0-stepRed)*attenuationFuctor);
G4double KtGreen = std::exp((1.0-stepGreen)*attenuationFuctor);
G4double KtBlue = std::exp((1.0-stepBlue)*attenuationFuctor);
if(KtRed>1.0){KtRed=1.0;}
if(KtGreen>1.0){KtGreen=1.0;}
if(KtBlue>1.0){KtBlue=1.0;}
return G4Colour(sourceCol.GetRed()*KtRed,
sourceCol.GetGreen()*KtGreen,sourceCol.GetBlue()*KtBlue);
}
G4bool G4RayTracer::ValidColour(const G4VisAttributes* visAtt)
{
G4bool val = true;
if(!visAtt)
{ val = false; }
else if(!(visAtt->IsVisible()))
{ val = false; }
else if(visAtt->IsForceDrawingStyle()
&&(visAtt->GetForcedDrawingStyle()==G4VisAttributes::wireframe))
{ val = false; }
return val;
}
@@ -1,35 +1,61 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RayTracerSceneHandler.cc,v 1.3 2005/06/02 17:43:46 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4RayTracerSceneHandler.cc,v 1.8 2006/06/29 21:24:13 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
#include "G4RayTracerSceneHandler.hh"
#include "G4VisManager.hh"
G4RayTracerSceneHandler::G4RayTracerSceneHandler(G4VGraphicsSystem& system,
const G4String& name):
G4VSceneHandler(system, fSceneIdCount++, name)
{}
{
// Ray Tracer does not use the vis concept of scene (G4Scene) - keep
// vis manager happy when someone opens a ray tracer with "/vis/open
// RayTracer" but uses the ray tracer with "/vis/rayTracer" commands
// before creating any scenes, for example, instead of using
// "/vis/drawVolume"...
G4VisManager* visManager = G4VisManager::GetInstance();
if(visManager) {
G4Scene* pScene = visManager->GetCurrentScene();
if (!pScene) {
// Create new scene like /vis/scene/create...
fpScene = new G4Scene("dummy-ray-tracer-scene");
// Avoid code triggered at end of events...
fpScene->SetRefreshAtEndOfEvent(false);
// Avoid re-computing transients.
fpScene->SetRecomputeTransients(false);
// Add to vis manager list; ownership thereby passes to vis manager...
visManager->SetSceneList().push_back(fpScene);
// ...and make current...
visManager->SetCurrentScene(fpScene);
}
}
}
G4RayTracerSceneHandler::~G4RayTracerSceneHandler()
{}
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RayTracerViewer.cc,v 1.14 2005/11/18 23:07:04 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4RayTracerViewer.cc,v 1.16 2006/06/29 21:24:15 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
#include "G4RayTracerViewer.hh"
@@ -31,26 +34,26 @@
#include "G4VSceneHandler.hh"
#include "G4Scene.hh"
#include "G4RayTracer.hh"
#include "G4TheRayTracer.hh"
#include "G4UImanager.hh"
G4RayTracerViewer::G4RayTracerViewer
(G4VSceneHandler& sceneHandler, const G4String& name):
(G4VSceneHandler& sceneHandler,
const G4String& name,
G4TheRayTracer* aTracer):
G4VViewer(sceneHandler, sceneHandler.IncrementViewCount(), name),
fFileCount(0)
{
G4RayTracer* theTracer =
(G4RayTracer*) fSceneHandler.GetGraphicsSystem();
theTracer = aTracer;
if (!aTracer) theTracer = new G4TheRayTracer;
theTracer->SetNColumn(fVP.GetWindowSizeHintX());
theTracer->SetNRow(fVP.GetWindowSizeHintY());
}
G4RayTracerViewer::~G4RayTracerViewer() {}
void G4RayTracerViewer::SetView() {
G4RayTracer* theTracer =
(G4RayTracer*) fSceneHandler.GetGraphicsSystem();
void G4RayTracerViewer::SetView()
{
// Get radius of scene, etc. (See G4OpenGLViewer::SetView().)
// Note that this procedure properly takes into account zoom, dolly and pan.
const G4Point3D& targetPoint
@@ -81,7 +84,8 @@ void G4RayTracerViewer::SetView() {
void G4RayTracerViewer::ClearView() {}
void G4RayTracerViewer::DrawView() {
void G4RayTracerViewer::DrawView()
{
if (fVP.GetFieldHalfAngle() == 0.) { // Orthogonal (parallel) projection.
G4double fieldHalfAngle = perMillion;
fVP.SetFieldHalfAngle(fieldHalfAngle);
@@ -98,8 +102,6 @@ void G4RayTracerViewer::DrawView() {
else {
SetView(); // Special graphics system - bypass ProcessView().
}
G4RayTracer* theTracer =
(G4RayTracer*) fSceneHandler.GetGraphicsSystem();
std::ostringstream filename;
filename << "g4RayTracer." << fShortName << '_' << fFileCount++ << ".jpeg";
theTracer->Trace(filename.str());
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RayTracerX.cc,v 1.3 2005/11/18 23:07:04 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4RayTracerX.cc,v 1.5 2006/06/29 21:24:17 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//
//
@@ -30,13 +33,18 @@
#ifdef G4VIS_BUILD_RAYTRACERX_DRIVER
#include "G4RayTracerX.hh"
#include "G4RayTracerFeatures.hh"
#include "G4RayTracerSceneHandler.hh"
#include "G4RayTracerXViewer.hh"
#include "G4RTXScanner.hh"
G4RayTracerX::G4RayTracerX():
G4RayTracer(0, new G4RTXScanner)
G4VGraphicsSystem("RayTracerX",
"RayTracerX",
RAYTRACER_FEATURES,
G4VGraphicsSystem::threeD)
{}
G4RayTracerX::~G4RayTracerX()
{}
G4VSceneHandler* G4RayTracerX::CreateSceneHandler (const G4String& name) {
@@ -49,14 +57,20 @@ G4VViewer* G4RayTracerX::CreateViewer (G4VSceneHandler& sceneHandler,
G4VViewer* pViewer = new G4RayTracerXViewer (sceneHandler, name);
if (pViewer) {
if (pViewer->GetViewId() < 0) {
G4cerr << "G4RayTracerX::CreateViewer: error flagged by negative"
"\n view id in G4RayTracerXViewer creation."
G4cout <<
"G4RayTracerX::CreateViewer: ERROR flagged by negative"
" view id in G4RayTracerXViewer creation."
"\n Destroying view and returning null pointer."
<< G4endl;
<< G4endl;
delete pViewer;
pViewer = 0;
}
}
else {
G4cout <<
"G4RayTracerX::CreateViewer: ERROR: null pointer on new G4RayTracerXViewer."
<< G4endl;
}
return pViewer;
}
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RayTracerXViewer.cc,v 1.3 2005/11/18 23:05:04 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4RayTracerXViewer.cc,v 1.5 2006/06/29 21:24:19 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
#ifdef G4VIS_BUILD_RAYTRACERX_DRIVER
@@ -30,131 +33,25 @@
#include "G4VSceneHandler.hh"
#include "G4Scene.hh"
#include "G4RayTracerX.hh"
#include "G4TheRayTracer.hh"
#include "G4RTJpegMaker.hh"
#include "G4RTXScanner.hh"
#include "G4UImanager.hh"
#include <cstdlib>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
extern "C" {
Bool G4RayTracerXViewerWaitForNotify (Display*, XEvent* e, char* arg) {
return (e->type == MapNotify) && (e->xmap.window == (Window) arg);
}
}
G4RayTracerXViewer::G4RayTracerXViewer
(G4VSceneHandler& sceneHandler, const G4String& name):
G4RayTracerViewer(sceneHandler, name)
G4RayTracerViewer(sceneHandler,
name,
new G4TheRayTracer(new G4RTJpegMaker, new G4RTXScanner))
{
G4RayTracerX* theTracer =
(G4RayTracerX*) fSceneHandler.GetGraphicsSystem();
Display*& display = theTracer->display;
Window& win = theTracer->win;
GC& gc = theTracer->gc;
XStandardColormap*& scmap = theTracer->scmap;
display = XOpenDisplay(0); // Use display defined by DISPLAY environment.
if (!display) {
// Set up X Window...
G4RTXScanner* theXScanner = (G4RTXScanner*)theTracer->GetScanner();
if (!theXScanner->GetXWindow(fName,fVP)) {
fViewId = -1; // This flags an error.
G4cerr << "G4RayTracerXViewer::G4RayTracerXViewer: cannot get display."
<< G4endl;
return;
}
int screen_num = DefaultScreen(display);
// Window size and position...
int xOffset = 0, yOffset = 0;
unsigned int width, height;
XSizeHints* size_hints = XAllocSizeHints();
const G4String& XGeometryString = fVP.GetXGeometryString();
if (!XGeometryString.empty()) {
G4int geometryResultMask = XParseGeometry
((char*)XGeometryString.c_str(),
&xOffset, &yOffset, &width, &height);
if (geometryResultMask & (WidthValue | HeightValue)) {
if (geometryResultMask & XValue) {
if (geometryResultMask & XNegative) {
xOffset = DisplayWidth(display, screen_num) + xOffset - width;
}
size_hints->flags |= PPosition;
size_hints->x = xOffset;
}
if (geometryResultMask & YValue) {
if (geometryResultMask & YNegative) {
yOffset = DisplayHeight(display, screen_num) + yOffset - height;
}
size_hints->flags |= PPosition;
size_hints->y = yOffset;
}
} else {
G4cout << "ERROR: Geometry string \""
<< XGeometryString
<< "\" invalid. Using \"600x600\"."
<< G4endl;
width = 600;
height = 600;
}
}
size_hints->width = width;
size_hints->height = height;
size_hints->flags |= PSize;
win = XCreateSimpleWindow
(display, RootWindow(display, screen_num),
xOffset, yOffset, width, height,
0, // Border width.
WhitePixel(display, screen_num), // Border colour.
BlackPixel(display, screen_num)); // Background colour.
XGCValues values;
gc = XCreateGC(display, win, 0, &values);
int nMaps;
Status status = XGetRGBColormaps
(display, RootWindow(display, screen_num),
&scmap, &nMaps, XA_RGB_BEST_MAP);
if (!status) {
system("xstdcmap -best"); // ...and try again...
Status status = XGetRGBColormaps
(display, RootWindow(display, screen_num),
&scmap, &nMaps, XA_RGB_BEST_MAP);
if (!status) {
fViewId = -1; // This flags an error.
G4cerr <<
"G4RayTracerXViewer::G4RayTracerXViewer: cannot get color map."
"\n Perhaps your system does not support RGB_BEST_MAP."
<< G4endl;
return;
}
}
if (!scmap->colormap) {
fViewId = -1; // This flags an error.
G4cerr << "G4RayTracerXViewer::G4RayTracerXViewer: color map empty."
<< G4endl;
return;
}
XWMHints* wm_hints = XAllocWMHints();
XClassHint* class_hint = XAllocClassHint();
const char* window_name = fName.c_str();
XTextProperty windowName;
XStringListToTextProperty((char**)&window_name, 1, &windowName);
XSetWMProperties(display, win, &windowName, &windowName,
0, 0, size_hints, wm_hints, class_hint);
XMapWindow(display, win);
// Wait for window to appear (wait for an "map notify" event).
XSelectInput(display, win, StructureNotifyMask);
XEvent event;
XIfEvent (display, &event, G4RayTracerXViewerWaitForNotify, (char*) win);
}
G4RayTracerXViewer::~G4RayTracerXViewer() {}
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RayTrajectory.cc,v 1.14 2004/06/11 14:30:51 gcosmo Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4RayTrajectory.cc,v 1.15 2006/06/29 21:24:21 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//
//
@@ -1,28 +1,31 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4RayTrajectoryPoint.cc,v 1.5 2004/06/11 14:30:51 gcosmo Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4RayTrajectoryPoint.cc,v 1.6 2006/06/29 21:24:23 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//
//
@@ -0,0 +1,407 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4TheRayTracer.cc,v 1.3 2006/06/29 21:24:25 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//
//
#include "G4TheRayTracer.hh"
#include "G4EventManager.hh"
#include "G4RTMessenger.hh"
#include "G4RayShooter.hh"
#include "G4VFigureFileMaker.hh"
#include "G4RTTrackingAction.hh"
#include "G4RTSteppingAction.hh"
#include "G4RayTrajectory.hh"
#include "G4RayTrajectoryPoint.hh"
#include "G4RTJpegMaker.hh"
#include "G4RTSimpleScanner.hh"
#include "G4GeometryManager.hh"
#include "G4SDManager.hh"
#include "G4StateManager.hh"
#include "G4Event.hh"
#include "G4TrajectoryContainer.hh"
#include "G4Colour.hh"
#include "G4VisAttributes.hh"
#include "G4UImanager.hh"
#include "G4TransportationManager.hh"
#include "G4RegionStore.hh"
#include "G4ProductionCutsTable.hh"
G4TheRayTracer::G4TheRayTracer(G4VFigureFileMaker* figMaker,
G4VRTScanner* scanner)
{
theFigMaker = figMaker;
if(!theFigMaker) theFigMaker = new G4RTJpegMaker;
theScanner = scanner;
if(!theScanner) theScanner = new G4RTSimpleScanner;
theRayShooter = new G4RayShooter();
theRayTracerEventAction = 0;
theRayTracerStackingAction = 0;
theRayTracerTrackingAction = 0;
theRayTracerSteppingAction = 0;
theMessenger = G4RTMessenger::GetInstance(this,theRayTracerSteppingAction);
theEventManager = G4EventManager::GetEventManager();
nColumn = 640;
nRow = 640;
eyePosition = G4ThreeVector(1.*m,1.*m,1.*m);
targetPosition = G4ThreeVector(0.,0.,0.);
lightDirection = G4ThreeVector(-0.1,-0.2,-0.3).unit();
viewSpan = 5.0*deg;
headAngle = 270.*deg;
attenuationLength = 1.0*m;
distortionOn = false;
antialiasingOn = false;
backgroundColour = G4Colour(1.,1.,1.);
}
G4TheRayTracer::~G4TheRayTracer()
{
delete theRayShooter;
if(theRayTracerTrackingAction) delete theRayTracerTrackingAction;
if(theRayTracerSteppingAction) delete theRayTracerSteppingAction;
delete theMessenger;
delete theScanner;
delete theFigMaker;
}
void G4TheRayTracer::Trace(G4String fileName)
{
G4StateManager* theStateMan = G4StateManager::GetStateManager();
G4ApplicationState currentState = theStateMan->GetCurrentState();
if(currentState!=G4State_Idle)
{
G4cerr << "Illegal application state - Trace() ignored." << G4endl;
return;
}
if(!theFigMaker)
{
G4cerr << "Figure file maker class is not specified - Trace() ignored." << G4endl;
return;
}
G4UImanager* UI = G4UImanager::GetUIpointer();
G4int storeTrajectory = UI->GetCurrentIntValue("/tracking/storeTrajectory");
if(storeTrajectory==0) UI->ApplyCommand("/tracking/storeTrajectory 1");
G4ThreeVector tmpVec = targetPosition - eyePosition;
eyeDirection = tmpVec.unit();
colorR = new unsigned char[nColumn*nRow];
colorG = new unsigned char[nColumn*nRow];
colorB = new unsigned char[nColumn*nRow];
StoreUserActions();
G4bool succeeded = CreateBitMap();
if(succeeded)
{ CreateFigureFile(fileName); }
else
{ G4cerr << "Could not create figure file" << G4endl;
G4cerr << "You might set the eye position outside of the world volume" << G4endl; }
RestoreUserActions();
if(storeTrajectory==0) UI->ApplyCommand("/tracking/storeTrajectory 0");
delete [] colorR;
delete [] colorG;
delete [] colorB;
}
void G4TheRayTracer::StoreUserActions()
{
theUserEventAction = theEventManager->GetUserEventAction();
theUserStackingAction = theEventManager->GetUserStackingAction();
theUserTrackingAction = theEventManager->GetUserTrackingAction();
theUserSteppingAction = theEventManager->GetUserSteppingAction();
if(!theRayTracerTrackingAction) theRayTracerTrackingAction = new G4RTTrackingAction();
if(!theRayTracerSteppingAction) theRayTracerSteppingAction = new G4RTSteppingAction();
theEventManager->SetUserAction(theRayTracerEventAction);
theEventManager->SetUserAction(theRayTracerStackingAction);
theEventManager->SetUserAction(theRayTracerTrackingAction);
theEventManager->SetUserAction(theRayTracerSteppingAction);
G4SDManager* theSDMan = G4SDManager::GetSDMpointerIfExist();
if(theSDMan)
{ theSDMan->Activate("/",false); }
G4GeometryManager* theGeomMan = G4GeometryManager::GetInstance();
theGeomMan->OpenGeometry();
theGeomMan->CloseGeometry(true);
}
void G4TheRayTracer::RestoreUserActions()
{
theEventManager->SetUserAction(theUserEventAction);
theEventManager->SetUserAction(theUserStackingAction);
theEventManager->SetUserAction(theUserTrackingAction);
theEventManager->SetUserAction(theUserSteppingAction);
G4SDManager* theSDMan = G4SDManager::GetSDMpointerIfExist();
if(theSDMan)
{ theSDMan->Activate("/",true); }
}
#include "G4ProcessManager.hh"
#include "G4ProcessVector.hh"
#include "G4Geantino.hh"
G4bool G4TheRayTracer::CreateBitMap()
{
G4int iEvent = 0;
G4double stepAngle = viewSpan/100.;
G4double viewSpanX = stepAngle*nColumn;
G4double viewSpanY = stepAngle*nRow;
G4bool succeeded;
// Confirm process(es) of Geantino is initialized
G4VPhysicalVolume* pWorld =
G4TransportationManager::GetTransportationManager()->
GetNavigatorForTracking()->GetWorldVolume();
G4RegionStore::GetInstance()->UpdateMaterialList(pWorld);
G4ProductionCutsTable::GetProductionCutsTable()->UpdateCoupleTable(pWorld);
G4ProcessVector* pVector
= G4Geantino::GeantinoDefinition()->GetProcessManager()->GetProcessList();
for (G4int j=0; j < pVector->size(); ++j) {
(*pVector)[j]->BuildPhysicsTable(*(G4Geantino::GeantinoDefinition()));
}
// Close geometry and set the application state
G4GeometryManager* geomManager = G4GeometryManager::GetInstance();
geomManager->OpenGeometry();
geomManager->CloseGeometry(1,0);
G4ThreeVector center(0,0,0);
G4Navigator* navigator =
G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
navigator->LocateGlobalPointAndSetup(center,0,false);
G4StateManager* theStateMan = G4StateManager::GetStateManager();
theStateMan->SetNewState(G4State_GeomClosed);
// Event loop
theScanner->Initialize(nRow,nColumn);
G4int iRow, iColumn;
while (theScanner->Coords(iRow,iColumn)) {
G4int iCoord = iRow * nColumn + iColumn;
G4double dRow = 0, dColumn = 0; // Antialiasing increments.
G4Event* anEvent = new G4Event(iEvent++);
G4double angleX = -(viewSpanX/2. - (iColumn+dColumn)*stepAngle);
G4double angleY = viewSpanY/2. - (iRow+dRow)*stepAngle;
G4ThreeVector rayDirection;
if(distortionOn)
{
rayDirection = G4ThreeVector(std::tan(angleX)/std::cos(angleY),-std::tan(angleY)/std::cos(angleX),1.0);
}
else
{
rayDirection = G4ThreeVector(std::tan(angleX),-std::tan(angleY),1.0);
}
rayDirection.rotateZ(headAngle);
rayDirection.rotateUz(eyeDirection);
G4ThreeVector rayPosition(eyePosition);
G4bool interceptable = true;
// Check if rayPosition is in the world.
EInside whereisit =
pWorld->GetLogicalVolume()->GetSolid()->Inside(rayPosition);
if (whereisit != kInside) {
// It's outside the world, so move it inside.
G4double outsideDistance =
pWorld->GetLogicalVolume()->GetSolid()->
DistanceToIn(rayPosition,rayDirection);
if (outsideDistance != kInfinity) {
// Borrowing from geometry, where 1e-8 < epsilon < 1e-3, in
// absolute/internal length units, is used for ensuring good
// behaviour, choose to add 0.001 to ensure rayPosition is
// definitely inside the world volume (JA 16/9/2005)...
rayPosition = rayPosition+(outsideDistance+0.001)*rayDirection;
}
else {
interceptable = false;
}
}
if (interceptable) {
theRayShooter->Shoot(anEvent,rayPosition,rayDirection);
theEventManager->ProcessOneEvent(anEvent);
succeeded = GenerateColour(anEvent);
colorR[iCoord] = (unsigned char)(int(255*rayColour.GetRed()));
colorG[iCoord] = (unsigned char)(int(255*rayColour.GetGreen()));
colorB[iCoord] = (unsigned char)(int(255*rayColour.GetBlue()));
} else { // Ray does not intercept world at all.
// Store background colour...
colorR[iCoord] = (unsigned char)(int(255*backgroundColour.GetRed()));
colorG[iCoord] = (unsigned char)(int(255*backgroundColour.GetGreen()));
colorB[iCoord] = (unsigned char)(int(255*backgroundColour.GetBlue()));
succeeded = true;
}
theScanner->Draw(colorR[iCoord],colorG[iCoord],colorB[iCoord]);
delete anEvent;
if(!succeeded) return false;
}
theStateMan->SetNewState(G4State_Idle);
return true;
}
void G4TheRayTracer::CreateFigureFile(G4String fileName)
{
//G4cout << nColumn << " " << nRow << G4endl;
theFigMaker->CreateFigureFile(fileName,nColumn,nRow,colorR,colorG,colorB);
}
G4bool G4TheRayTracer::GenerateColour(G4Event* anEvent)
{
G4TrajectoryContainer * trajectoryContainer = anEvent->GetTrajectoryContainer();
G4RayTrajectory* trajectory = (G4RayTrajectory*)( (*trajectoryContainer)[0] );
if(!trajectory) return false;
G4int nPoint = trajectory->GetPointEntries();
if(nPoint==0) return false;
G4Colour initialColour(backgroundColour);
if( trajectory->GetPointC(nPoint-1)->GetPostStepAtt() )
{ initialColour = GetSurfaceColour(trajectory->GetPointC(nPoint-1)); }
rayColour = Attenuate(trajectory->GetPointC(nPoint-1),initialColour);
for(int i=nPoint-2;i>=0;i--)
{
G4Colour surfaceColour = GetSurfaceColour(trajectory->GetPointC(i));
G4double weight = 1.0 - surfaceColour.GetAlpha();
G4Colour mixedColour = GetMixedColour(rayColour,surfaceColour,weight);
rayColour = Attenuate(trajectory->GetPointC(i),mixedColour);
}
return true;
}
G4Colour G4TheRayTracer::GetMixedColour(G4Colour surfCol,G4Colour transCol,G4double weight)
{
G4double r = weight*surfCol.GetRed() + (1.-weight)*transCol.GetRed();
G4double g = weight*surfCol.GetGreen() + (1.-weight)*transCol.GetGreen();
G4double b = weight*surfCol.GetBlue() + (1.-weight)*transCol.GetBlue();
G4double a = weight*surfCol.GetAlpha() + (1.-weight)*transCol.GetAlpha();
return G4Colour(r,g,b,a);
}
G4Colour G4TheRayTracer::GetSurfaceColour(G4RayTrajectoryPoint* point)
{
const G4VisAttributes* preAtt = point->GetPreStepAtt();
const G4VisAttributes* postAtt = point->GetPostStepAtt();
G4bool preVis = ValidColour(preAtt);
G4bool postVis = ValidColour(postAtt);
G4Colour transparent(1.,1.,1.,0.);
if(!preVis&&!postVis) return transparent;
G4ThreeVector normal = point->GetSurfaceNormal();
G4Colour preCol(1.,1.,1.);
G4Colour postCol(1.,1.,1.);
if(preVis)
{
G4double brill = (1.0-(-lightDirection).dot(normal))/2.0;
G4double r = preAtt->GetColour().GetRed();
G4double g = preAtt->GetColour().GetGreen();
G4double b = preAtt->GetColour().GetBlue();
preCol = G4Colour(r*brill,g*brill,b*brill,preAtt->GetColour().GetAlpha());
}
else
{ preCol = transparent; }
if(postVis)
{
G4double brill = (1.0-(-lightDirection).dot(-normal))/2.0;
G4double r = postAtt->GetColour().GetRed();
G4double g = postAtt->GetColour().GetGreen();
G4double b = postAtt->GetColour().GetBlue();
postCol = G4Colour(r*brill,g*brill,b*brill,postAtt->GetColour().GetAlpha());
}
else
{ postCol = transparent; }
if(!preVis) return postCol;
if(!postVis) return preCol;
G4double weight = 0.5;
return GetMixedColour(preCol,postCol,weight);
}
G4Colour G4TheRayTracer::Attenuate(G4RayTrajectoryPoint* point, G4Colour sourceCol)
{
const G4VisAttributes* preAtt = point->GetPreStepAtt();
G4bool visible = ValidColour(preAtt);
if(!visible) return sourceCol;
G4Colour objCol = preAtt->GetColour();
G4double stepRed = objCol.GetRed();
G4double stepGreen = objCol.GetGreen();
G4double stepBlue = objCol.GetBlue();
G4double stepAlpha = objCol.GetAlpha();
G4double stepLength = point->GetStepLength();
G4double attenuationFuctor;
if(stepAlpha > 0.9999999){ stepAlpha = 0.9999999; } // patch to the next line
attenuationFuctor = -stepAlpha/(1.0-stepAlpha)*stepLength/attenuationLength;
G4double KtRed = std::exp((1.0-stepRed)*attenuationFuctor);
G4double KtGreen = std::exp((1.0-stepGreen)*attenuationFuctor);
G4double KtBlue = std::exp((1.0-stepBlue)*attenuationFuctor);
if(KtRed>1.0){KtRed=1.0;}
if(KtGreen>1.0){KtGreen=1.0;}
if(KtBlue>1.0){KtBlue=1.0;}
return G4Colour(sourceCol.GetRed()*KtRed,
sourceCol.GetGreen()*KtGreen,sourceCol.GetBlue()*KtBlue);
}
G4bool G4TheRayTracer::ValidColour(const G4VisAttributes* visAtt)
{
G4bool val = true;
if(!visAtt)
{ val = false; }
else if(!(visAtt->IsVisible()))
{ val = false; }
else if(visAtt->IsForceDrawingStyle()
&&(visAtt->GetForcedDrawingStyle()==G4VisAttributes::wireframe))
{ val = false; }
return val;
}