Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4TrajectoryDrawByEncounteredVolume Class Reference

#include <G4TrajectoryDrawByEncounteredVolume.hh>

Inheritance diagram for G4TrajectoryDrawByEncounteredVolume:
Collaboration diagram for G4TrajectoryDrawByEncounteredVolume:

Public Member Functions

 G4TrajectoryDrawByEncounteredVolume (const G4String &name="Unspecified", G4VisTrajContext *context=0)
 
virtual ~G4TrajectoryDrawByEncounteredVolume ()
 
virtual void Draw (const G4VTrajectory &trajectory, const G4bool &visible=true) const
 
virtual void Print (std::ostream &ostr) const
 
void SetDefault (const G4String &)
 
void SetDefault (const G4Colour &)
 
void Set (const G4String &pvname, const G4String &colour)
 
void Set (const G4String &pvname, const G4Colour &colour)
 
- Public Member Functions inherited from G4VTrajectoryModel
 G4VTrajectoryModel (const G4String &name, G4VisTrajContext *fpContext=0)
 
virtual ~G4VTrajectoryModel ()
 
G4String Name () const
 
const G4VisTrajContextGetContext () const
 
void SetVerbose (const G4bool &)
 
G4bool GetVerbose () const
 

Detailed Description

Definition at line 44 of file G4TrajectoryDrawByEncounteredVolume.hh.

Constructor & Destructor Documentation

G4TrajectoryDrawByEncounteredVolume::G4TrajectoryDrawByEncounteredVolume ( const G4String name = "Unspecified",
G4VisTrajContext context = 0 
)

Definition at line 40 of file G4TrajectoryDrawByEncounteredVolume.cc.

41  :G4VTrajectoryModel(name, context)
42  ,fDefault(G4Colour::Grey())
43 {}
G4VTrajectoryModel(const G4String &name, G4VisTrajContext *fpContext=0)
static G4Colour Grey()
Definition: G4Colour.hh:145
G4TrajectoryDrawByEncounteredVolume::~G4TrajectoryDrawByEncounteredVolume ( )
virtual

Definition at line 45 of file G4TrajectoryDrawByEncounteredVolume.cc.

45 {}

Member Function Documentation

void G4TrajectoryDrawByEncounteredVolume::Draw ( const G4VTrajectory trajectory,
const G4bool visible = true 
) const
virtual

Implements G4VTrajectoryModel.

Definition at line 48 of file G4TrajectoryDrawByEncounteredVolume.cc.

49 {
50  try
51  {
52  const G4RichTrajectory& richTrajectory = dynamic_cast<const G4RichTrajectory&>(traj);
53 
54  G4Colour colour(fDefault);
55  G4String soughtPVName("none");
56 
57  for (const auto& item: fMap.GetBasicMap()) {
58  soughtPVName = item.first;
59  for (G4int iPoint = 0; iPoint < richTrajectory.GetPointEntries(); iPoint++) {
60  G4VTrajectoryPoint* point = richTrajectory.GetPoint(iPoint);
61  if (!point) continue;
62  std::vector<G4AttValue>* attValues = point->CreateAttValues();
63  std::vector<G4AttValue>::const_iterator iAtt;
64  for (iAtt = attValues->begin(); iAtt != attValues->end(); ++iAtt) {
65  if (iAtt->GetName() == "PostVPath" &&
66  iAtt->GetValue().contains(soughtPVName)) break;
67  }
68  if (iAtt != attValues->end()) { // Required value found
69  fMap.GetColour(soughtPVName, colour);
70  break; // First found pvname determines colour.
71  }
72  }
73  }
74 
75  G4VisTrajContext myContext(GetContext());
76 
77  myContext.SetLineColour(colour);
78  myContext.SetVisible(visible);
79 
80  if (GetVerbose()) {
81  G4cout
82  << "G4TrajectoryDrawByEncounteredVolume drawer named " << Name()
83  << ", drawing trajectory touching physical volume " << soughtPVName
84  << ", with configuration:" << G4endl;
85  myContext.Print(G4cout);
86  }
87 
88  G4TrajectoryDrawerUtils::DrawLineAndPoints(richTrajectory, myContext);
89 
90  }
91 
92  catch (std::bad_cast)
93  {
95  ed << "Requires G4RichTrajectory - \"/vis/scene/add/trajectories rich\"";
97  ("G4TrajectoryDrawByEncounteredVolume::Draw(const G4VTrajectory& traj,...",
98  "modeling0125",
99  JustWarning, ed);
100  return;
101  }
102 }
const std::map< T, G4Colour > & GetBasicMap() const
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
int GetPointEntries() const
int G4int
Definition: G4Types.hh:78
G4String Name() const
virtual std::vector< G4AttValue > * CreateAttValues() const
const G4VisTrajContext & GetContext() const
G4GLOB_DLL std::ostream G4cout
bool GetColour(const T &, G4Colour &) const
void DrawLineAndPoints(const G4VTrajectory &traj, const G4VisTrajContext &)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
G4bool GetVerbose() const
G4VTrajectoryPoint * GetPoint(G4int i) const

Here is the call graph for this function:

void G4TrajectoryDrawByEncounteredVolume::Print ( std::ostream &  ostr) const
virtual

Implements G4VTrajectoryModel.

Definition at line 141 of file G4TrajectoryDrawByEncounteredVolume.cc.

142 {
143  ostr
144  << "G4TrajectoryDrawByEncounteredVolume model "<< Name()
145  << ", colour scheme: "
146  << ", Default " << fDefault
147  << std::endl;
148 
149  fMap.Print(ostr);
150 
151  ostr << "Default configuration:" << std::endl;
152  GetContext().Print(ostr);
153 }
G4String Name() const
const G4VisTrajContext & GetContext() const
void Print(std::ostream &ostr) const
void Print(std::ostream &ostr) const

Here is the call graph for this function:

void G4TrajectoryDrawByEncounteredVolume::Set ( const G4String pvname,
const G4String colour 
)

Definition at line 129 of file G4TrajectoryDrawByEncounteredVolume.cc.

130 {
131  fMap.Set(pvname, colour);
132 }
void Set(const T &, const G4Colour &)

Here is the call graph for this function:

void G4TrajectoryDrawByEncounteredVolume::Set ( const G4String pvname,
const G4Colour colour 
)

Definition at line 135 of file G4TrajectoryDrawByEncounteredVolume.cc.

136 {
137  fMap[pvname] = colour;
138 }
void G4TrajectoryDrawByEncounteredVolume::SetDefault ( const G4String colour)

Definition at line 105 of file G4TrajectoryDrawByEncounteredVolume.cc.

106 {
107  G4Colour myColour;
108 
109  // Will not modify default colour if colour key does not exist
110  if (!G4Colour::GetColour(colour, myColour)) {
112  ed << "G4Colour with key "<<colour<<" does not exist ";
114  ("G4TrajectoryDrawByEncounteredParticleID::SetDefault(const G4String& colour)",
115  "modeling0123", JustWarning, ed);
116  return;
117  }
118 
119  SetDefault(myColour);
120 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
static G4bool GetColour(const G4String &key, G4Colour &result)
Definition: G4Colour.cc:126
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Here is the call graph for this function:

void G4TrajectoryDrawByEncounteredVolume::SetDefault ( const G4Colour colour)

Definition at line 123 of file G4TrajectoryDrawByEncounteredVolume.cc.

124 {
125  fDefault = colour;
126 }

The documentation for this class was generated from the following files: