Overview Contents Previous Next Geant4 User's Guide
For Application Developers
Visualization
8.7 Enhanced Trajectory Drawing



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.

8.7.1 G4TrajectoryDrawByCharge

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):
	Charge		Colour	
	----------------------
	1		Blue
	-1		Red
	0		Green

8.7.2 G4TrajectoryDrawByParticleID

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.

8.7.3 Controlling from Commands

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.

8.7.3.1 Example commands

#Create a drawByCharge model named drawCharge-0 by default (Subsequent models will be named drawByCharge-1, drawByCharge-2, etc.)
/vis/modeling/trajectories/create/drawByCharge

#Create a drawByCharge model named testChargeModel
/vis/modeling/trajectories/create/drawByCharge 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
/vis/modeling/trajectories/create/drawByParticleID

#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
/vis/modeling/trajectories/list

#select drawByParticleID-0 to be current
/vis/modeling/trajectories/select drawByParticleID-0

8.7.4 Controlling from Compiled Code

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;
  visManager->Initialize();

  G4TrajectoryDrawByParticleID* model = new G4TrajectoryDrawByParticleID;
  G4TrajectoryDrawByParticleID* model2 = new G4TrajectoryDrawByParticleID("test");

  model->SetDefault("cyan");
  model->Set("gamma", "green");
  model->Set("e+", "magenta");
  model->Set("e-", G4Colour(0.3, 0.3, 0.3));

  visManager->RegisterModel(model);
  visManager->RegisterModel(model2);

  visManager->SelectTrajectoryModel(model->Name());


Next section
Back to contents