00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "G4TrajectoryDrawByParticleID.hh"
00031 #include "G4TrajectoryDrawerUtils.hh"
00032 #include "G4VisTrajContext.hh"
00033 #include "G4VTrajectory.hh"
00034
00035 G4TrajectoryDrawByParticleID::G4TrajectoryDrawByParticleID(const G4String& name, G4VisTrajContext* context)
00036 :G4VTrajectoryModel(name, context)
00037 ,fDefault(G4Colour::Grey())
00038 {
00039 Set("gamma", "green");
00040 Set("e-", "red");
00041 Set("e+", "blue");
00042 Set("pi+", "magenta");
00043 Set("pi-", "magenta");
00044 Set("proton", "cyan");
00045 Set("neutron", "yellow");
00046 }
00047
00048 G4TrajectoryDrawByParticleID::~G4TrajectoryDrawByParticleID() {}
00049
00050 void
00051 G4TrajectoryDrawByParticleID::Draw(const G4VTrajectory& object,
00052 const G4int&,
00053 const G4bool& visible) const
00054 {
00055 Draw(object, visible);
00056 }
00057
00058 void
00059 G4TrajectoryDrawByParticleID::Draw(const G4VTrajectory& traj, const G4bool& visible) const
00060 {
00061 G4Colour colour(fDefault);
00062 G4String particle = traj.GetParticleName();
00063
00064 fMap.GetColour(particle, colour);
00065
00066 G4VisTrajContext myContext(GetContext());
00067
00068 myContext.SetLineColour(colour);
00069 myContext.SetVisible(visible);
00070
00071 if (GetVerbose()) {
00072 G4cout<<"G4TrajectoryDrawByParticleID drawer named "<<Name();
00073 G4cout<<", drawing trajectory with particle type, "<<particle<<G4endl;
00074 G4cout<<", with configuration:"<<G4endl;
00075 myContext.Print(G4cout);
00076 }
00077
00078 G4TrajectoryDrawerUtils::DrawLineAndPoints(traj, myContext);
00079 }
00080
00081 void
00082 G4TrajectoryDrawByParticleID::SetDefault(const G4String& colour)
00083 {
00084 G4Colour myColour(G4Colour::White());
00085
00086
00087 if (!G4Colour::GetColour(colour, myColour)) {
00088 G4ExceptionDescription ed;
00089 ed << "G4Colour with key "<<colour<<" does not exist ";
00090 G4Exception
00091 ("G4TrajectoryDrawByParticleID::SetDefault(const G4String& colour)",
00092 "modeling0124", JustWarning, ed);
00093 }
00094
00095 SetDefault(myColour);
00096 }
00097
00098 void
00099 G4TrajectoryDrawByParticleID::SetDefault(const G4Colour& colour)
00100 {
00101 fDefault = colour;
00102 }
00103
00104 void
00105 G4TrajectoryDrawByParticleID::Set(const G4String& particle, const G4String& colour)
00106 {
00107 fMap.Set(particle, colour);
00108 }
00109
00110 void
00111 G4TrajectoryDrawByParticleID::Set(const G4String& particle, const G4Colour& colour)
00112 {
00113 fMap[particle] = colour;
00114 }
00115
00116 void
00117 G4TrajectoryDrawByParticleID::Print(std::ostream& ostr) const
00118 {
00119 ostr<<"G4TrajectoryDrawByParticleID model "<< Name() <<" colour scheme: "<<std::endl;
00120
00121 ostr<<"Default colour: "<<fDefault<<G4endl;
00122
00123 fMap.Print(ostr);
00124
00125 ostr<<"Default configuration:"<<G4endl;
00126 GetContext().Print(G4cout);
00127 }