G4TrajectoryDrawByParticleID.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, John Allison, Joseph Perl November 2005
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   // Will not modify myColour if colour key does not exist  
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 }

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