Geant4 11.3.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4TrajectoryDrawByEncounteredVolume Class Reference

#include <G4TrajectoryDrawByEncounteredVolume.hh>

+ Inheritance 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 43 of file G4TrajectoryDrawByEncounteredVolume.hh.

Constructor & Destructor Documentation

◆ G4TrajectoryDrawByEncounteredVolume()

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

Definition at line 38 of file G4TrajectoryDrawByEncounteredVolume.cc.

40 :G4VTrajectoryModel(name, context)
41 ,fDefault(G4Colour::Grey())
42{}
static G4Colour Grey()
Definition G4Colour.hh:176
G4VTrajectoryModel(const G4String &name, G4VisTrajContext *fpContext=0)

◆ ~G4TrajectoryDrawByEncounteredVolume()

G4TrajectoryDrawByEncounteredVolume::~G4TrajectoryDrawByEncounteredVolume ( )
virtual

Definition at line 44 of file G4TrajectoryDrawByEncounteredVolume.cc.

44{}

Member Function Documentation

◆ Draw()

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

Implements G4VTrajectoryModel.

Definition at line 47 of file G4TrajectoryDrawByEncounteredVolume.cc.

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

◆ Print()

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

Implements G4VTrajectoryModel.

Definition at line 140 of file G4TrajectoryDrawByEncounteredVolume.cc.

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

◆ Set() [1/2]

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

Definition at line 134 of file G4TrajectoryDrawByEncounteredVolume.cc.

135{
136 fMap[pvname] = colour;
137}

◆ Set() [2/2]

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

Definition at line 128 of file G4TrajectoryDrawByEncounteredVolume.cc.

129{
130 fMap.Set(pvname, colour);
131}

◆ SetDefault() [1/2]

void G4TrajectoryDrawByEncounteredVolume::SetDefault ( const G4Colour & colour)

Definition at line 122 of file G4TrajectoryDrawByEncounteredVolume.cc.

123{
124 fDefault = colour;
125}

◆ SetDefault() [2/2]

void G4TrajectoryDrawByEncounteredVolume::SetDefault ( const G4String & colour)

Definition at line 104 of file G4TrajectoryDrawByEncounteredVolume.cc.

105{
106 G4Colour myColour;
107
108 // Will not modify default colour if colour key does not exist
109 if (!G4Colour::GetColour(colour, myColour)) {
111 ed << "G4Colour with key "<<colour<<" does not exist ";
113 ("G4TrajectoryDrawByEncounteredParticleID::SetDefault(const G4String& colour)",
114 "modeling0123", JustWarning, ed);
115 return;
116 }
117
118 SetDefault(myColour);
119}
static G4bool GetColour(const G4String &key, G4Colour &result)
Definition G4Colour.cc:158

Referenced by SetDefault().


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