8.7 Enhanced Trajectory Drawing
Geant4 User's Guide
For Application Developers
Visualised trajectories are, by default, coloured according to charge.
Enhanced trajectory drawing makes it possible for the user to configure this charge colouring
model as desired.
Users can also write their own code to create completely new trajectory models.
The models are configurable through both commands and compiled code.
Two trajectory models are currently available: G4TrajectoryDrawByCharge and G4TrajectoryDrawByParticleID.
These will be described briefly below.
This is the default trajectory model which colours trajectories according to charge.
The default colouring scheme is
as follows (but the user can easily change what colour is used for what charge):
This model colours trajectories according to particle type.
All trajectories are coloured grey by default.
The model can be configured to highlight chosen particle types with a chosen colours.
There is no limit on the number of particle types that can highlighted.
Multiple trajectory models can be created and configured using commands in the
"/vis/modeling/trajectories/" directory. It is then possible to list available
models and select one to be current. Two types of model are currently available:
G4TrajectoryDrawByCharge (drawByCharge) and G4TrajectoryDrawByParticleID (drawByParticleID).
Model configuration commands are generated dynamically when a model is instantiated.
These commands apply directly to that instance. This makes it possible to have multiple
instances of the drawByCharge model for example, each independently configurable through
it's own set of commands.
18.104.22.168 Example commands
#Create a drawByCharge model named drawCharge-0 by default
(Subsequent models will be named drawByCharge-1, drawByCharge-2, etc.)
#Create a drawByCharge model named testChargeModel
#Configure drawByCharge-0 model
/vis/modeling/trajectories/drawByCharge-0/set 1 red
/vis/modeling/trajectories/drawByCharge-0/set -1 red
/vis/modeling/trajectories/drawByCharge-0/set 0 white
#Configure testCharge model through G4Colour components
/vis/modeling/trajectories/testChargeModel/setRGBA 1 0 1 1 1
/vis/modeling/trajectories/testChargeModel/setRGBA -1 0.5 0.5 0.5 1
/vis/modeling/trajectories/testChargeModel/setRGBA 0 1 1 0 1
#Create a drawByParticleID model named drawByParticleID-0
#Configure drawByParticleID-0 model
/vis/modeling/trajectories/drawByParticleID-0/set gamma red
/vis/modeling/trajectories/drawByParticleID-0/setRGBA e+ 1 0 1 1
#List available models
#select drawByParticleID-0 to be current
It is possible to use the enhanced trajectory drawing functionality in compiled code
as well as from commands.
Multiple trajectory models can be instantiated, configured and registered with G4VisManager.
Only one model may be current. For example:
G4VisManager* visManager = new G4VisExecutive;
G4TrajectoryDrawByParticleID* model = new G4TrajectoryDrawByParticleID;
G4TrajectoryDrawByParticleID* model2 = new G4TrajectoryDrawByParticleID("test");
model->Set("e-", G4Colour(0.3, 0.3, 0.3));
Back to contents