Geant4-11
Public Member Functions | Private Attributes
G4TrajectoryDrawByEncounteredVolume Class Reference

#include <G4TrajectoryDrawByEncounteredVolume.hh>

Inheritance diagram for G4TrajectoryDrawByEncounteredVolume:
G4VTrajectoryModel

Public Member Functions

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

Private Attributes

G4Colour fDefault
 
G4ModelColourMap< G4StringfMap
 
G4String fName
 
G4VisTrajContextfpContext
 
G4bool fVerbose
 

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.

42{}
static G4Colour Grey()
Definition: G4Colour.hh:158
G4VTrajectoryModel(const G4String &name, G4VisTrajContext *fpContext=0)
const char * name(G4int ptype)
context
Definition: g4zmq.py:11

◆ ~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 G4StrUtil::contains(iAtt->GetValue(), 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
G4bool contains(const G4String &str, std::string_view ss)
Check if a string contains a given substring.
void DrawLineAndPoints(const G4VTrajectory &traj, const G4VisTrajContext &)

References G4StrUtil::contains(), G4VTrajectoryPoint::CreateAttValues(), G4TrajectoryDrawerUtils::DrawLineAndPoints(), fDefault, fMap, G4cout, G4endl, G4Exception(), G4ModelColourMap< T >::GetBasicMap(), G4ModelColourMap< T >::GetColour(), G4VTrajectoryModel::GetContext(), G4RichTrajectory::GetPoint(), G4RichTrajectory::GetPointEntries(), G4VTrajectoryModel::GetVerbose(), JustWarning, G4VTrajectoryModel::Name(), G4VisTrajContext::Print(), and G4VisTrajContext::SetLineColour().

◆ GetContext()

const G4VisTrajContext & G4VTrajectoryModel::GetContext ( ) const
inherited

◆ GetVerbose()

G4bool G4VTrajectoryModel::GetVerbose ( ) const
inherited

◆ Name()

G4String G4VTrajectoryModel::Name ( ) const
inherited

◆ 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

References fDefault, fMap, G4VTrajectoryModel::GetContext(), G4VTrajectoryModel::Name(), G4ModelColourMap< T >::Print(), and G4VisTrajContext::Print().

◆ 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}

References fMap.

◆ 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 &)

References fMap, and G4ModelColourMap< T >::Set().

◆ SetDefault() [1/2]

void G4TrajectoryDrawByEncounteredVolume::SetDefault ( const G4Colour colour)

Definition at line 121 of file G4TrajectoryDrawByEncounteredVolume.cc.

122{
123 fDefault = colour;
124}

References fDefault.

◆ 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:161

References G4Exception(), G4Colour::GetColour(), JustWarning, and SetDefault().

Referenced by SetDefault().

◆ SetVerbose()

void G4VTrajectoryModel::SetVerbose ( const G4bool verbose)
inherited

Definition at line 67 of file G4VTrajectoryModel.cc.

68{
69 fVerbose = verbose;
70}

References G4VTrajectoryModel::fVerbose.

Field Documentation

◆ fDefault

G4Colour G4TrajectoryDrawByEncounteredVolume::fDefault
private

Definition at line 69 of file G4TrajectoryDrawByEncounteredVolume.hh.

Referenced by Draw(), Print(), and SetDefault().

◆ fMap

G4ModelColourMap<G4String> G4TrajectoryDrawByEncounteredVolume::fMap
private

Definition at line 68 of file G4TrajectoryDrawByEncounteredVolume.hh.

Referenced by Draw(), Print(), and Set().

◆ fName

G4String G4VTrajectoryModel::fName
privateinherited

Definition at line 75 of file G4VTrajectoryModel.hh.

Referenced by G4VTrajectoryModel::Name().

◆ fpContext

G4VisTrajContext* G4VTrajectoryModel::fpContext
privateinherited

◆ fVerbose

G4bool G4VTrajectoryModel::fVerbose
privateinherited

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