G4TrajectoryDrawByOriginVolume.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 // $Id$
00027 //
00028 // Jane Tinslay March 2006
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   // Logical volumes form basis.
00065   G4LogicalVolume* logicalVolume = volume->GetLogicalVolume();
00066   assert (0 != logicalVolume);
00067 
00068   G4String logicalName = logicalVolume->GetName();
00069   fMap.GetColour(logicalName, colour);
00070 
00071   // Override with physical volume colouring if it exists
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   // Will not modify default colour if colour key does not exist  
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 }

Generated on Mon May 27 17:50:02 2013 for Geant4 by  doxygen 1.4.7