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 "G4TrajectoryDrawByOriginVolume.hh"
00031 #include "G4TrajectoryDrawerUtils.hh"
00032 #include "G4VTrajectory.hh"
00033 #include "G4TransportationManager.hh"
00034 #include "G4VisTrajContext.hh"
00035 #include "G4VTrajectoryPoint.hh"
00036
00037 G4TrajectoryDrawByOriginVolume::G4TrajectoryDrawByOriginVolume(const G4String& name, G4VisTrajContext* context)
00038 :G4VTrajectoryModel(name, context)
00039 ,fDefault(G4Colour::Grey())
00040 {}
00041
00042 G4TrajectoryDrawByOriginVolume::~G4TrajectoryDrawByOriginVolume() {}
00043
00044 void
00045 G4TrajectoryDrawByOriginVolume::Draw(const G4VTrajectory& object,
00046 const G4int&,
00047 const G4bool& visible) const
00048 {
00049 Draw(object, visible);
00050 }
00051
00052 void
00053 G4TrajectoryDrawByOriginVolume::Draw(const G4VTrajectory& traj, const G4bool& visible) const
00054 {
00055 G4Colour colour(fDefault);
00056
00057 G4Navigator* navigator = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
00058
00059 G4VTrajectoryPoint* aTrajectoryPoint = traj.GetPoint(0);
00060 assert (0 != aTrajectoryPoint);
00061
00062 G4VPhysicalVolume* volume = navigator->LocateGlobalPointAndSetup(aTrajectoryPoint->GetPosition());
00063
00064
00065 G4LogicalVolume* logicalVolume = volume->GetLogicalVolume();
00066 assert (0 != logicalVolume);
00067
00068 G4String logicalName = logicalVolume->GetName();
00069 fMap.GetColour(logicalName, colour);
00070
00071
00072 G4String physicalName = volume->GetName();
00073 fMap.GetColour(physicalName, colour);
00074
00075 G4VisTrajContext myContext(GetContext());
00076
00077 myContext.SetLineColour(colour);
00078 myContext.SetVisible(visible);
00079
00080 if (GetVerbose()) {
00081 G4cout<<"G4TrajectoryDrawByOriginVolume drawer named "<<Name();
00082 G4cout<<", drawing trajectory originating in logical volume, "<<logicalName;
00083 G4cout<<", physical volumed "<<physicalName<<", with configuration:"<<G4endl;
00084 myContext.Print(G4cout);
00085 }
00086
00087 G4TrajectoryDrawerUtils::DrawLineAndPoints(traj, myContext);
00088 }
00089
00090 void
00091 G4TrajectoryDrawByOriginVolume::SetDefault(const G4String& colour)
00092 {
00093 G4Colour myColour;
00094
00095
00096 if (!G4Colour::GetColour(colour, myColour)) {
00097 G4ExceptionDescription ed;
00098 ed << "G4Colour with key "<<colour<<" does not exist ";
00099 G4Exception
00100 ("G4TrajectoryDrawByOriginParticleID::SetDefault(const G4String& colour)", "modeling0123", JustWarning, ed);
00101 return;
00102 }
00103
00104 SetDefault(myColour);
00105 }
00106
00107 void
00108 G4TrajectoryDrawByOriginVolume::SetDefault(const G4Colour& colour)
00109 {
00110 fDefault = colour;
00111 }
00112
00113 void
00114 G4TrajectoryDrawByOriginVolume::Set(const G4String& particle, const G4String& colour)
00115 {
00116 fMap.Set(particle, colour);
00117 }
00118
00119 void
00120 G4TrajectoryDrawByOriginVolume::Set(const G4String& particle, const G4Colour& colour)
00121 {
00122 fMap[particle] = colour;
00123 }
00124
00125 void
00126 G4TrajectoryDrawByOriginVolume::Print(std::ostream& ostr) const
00127 {
00128 ostr<<"G4TrajectoryDrawByOriginVolume model "<< Name() <<" colour scheme: "<<std::endl;
00129 ostr<<"Default : "<<fDefault<<G4endl;
00130
00131 fMap.Print(ostr);
00132
00133 ostr<<"Default configuration:"<<G4endl;
00134 GetContext().Print(G4cout);
00135 }