Geant4 10.7.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 ()
 
virtual void Draw (const G4VTrajectory &trajectory, const G4bool &visible=true) const =0
 
virtual void Print (std::ostream &ostr) const =0
 
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:156

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

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

◆ Set() [1/2]

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

Definition at line 133 of file G4TrajectoryDrawByEncounteredVolume.cc.

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

◆ Set() [2/2]

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

Definition at line 127 of file G4TrajectoryDrawByEncounteredVolume.cc.

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

◆ SetDefault() [1/2]

void G4TrajectoryDrawByEncounteredVolume::SetDefault ( const G4Colour colour)

Definition at line 121 of file G4TrajectoryDrawByEncounteredVolume.cc.

122{
123 fDefault = colour;
124}

◆ SetDefault() [2/2]

void G4TrajectoryDrawByEncounteredVolume::SetDefault ( const G4String colour)

Definition at line 103 of file G4TrajectoryDrawByEncounteredVolume.cc.

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

Referenced by SetDefault().


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