Geant4-11
Public Types | Public Member Functions | Private Member Functions | Private Attributes
G4TrajectoryDrawByCharge Class Reference

#include <G4TrajectoryDrawByCharge.hh>

Inheritance diagram for G4TrajectoryDrawByCharge:
G4VTrajectoryModel

Public Types

enum  Charge { Negative =-1 , Neutral =0 , Positive =1 }
 

Public Member Functions

virtual void Draw (const G4VTrajectory &trajectory, const G4bool &visible=true) const
 
 G4TrajectoryDrawByCharge (const G4String &name, const G4Colour &positive, const G4Colour &negative, const G4Colour &neutral)
 
 G4TrajectoryDrawByCharge (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 Charge &charge, const G4Colour &colour)
 
void Set (const Charge &charge, const G4String &colour)
 
void Set (const G4String &charge, const G4Colour &colour)
 
void Set (const G4String &charge, const G4String &colour)
 
void SetVerbose (const G4bool &)
 
virtual ~G4TrajectoryDrawByCharge ()
 

Private Member Functions

G4bool ConvertToCharge (const G4String &, Charge &)
 

Private Attributes

G4ModelColourMap< ChargefMap
 
G4String fName
 
G4VisTrajContextfpContext
 
G4bool fVerbose
 

Detailed Description

Definition at line 42 of file G4TrajectoryDrawByCharge.hh.

Member Enumeration Documentation

◆ Charge

Constructor & Destructor Documentation

◆ G4TrajectoryDrawByCharge() [1/2]

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

Definition at line 34 of file G4TrajectoryDrawByCharge.cc.

36{
37 // Default configuration
41}
static G4Colour Green()
Definition: G4Colour.hh:162
static G4Colour Red()
Definition: G4Colour.hh:161
static G4Colour Blue()
Definition: G4Colour.hh:163
G4ModelColourMap< Charge > fMap
G4VTrajectoryModel(const G4String &name, G4VisTrajContext *fpContext=0)
const char * name(G4int ptype)
context
Definition: g4zmq.py:11

References G4Colour::Blue(), fMap, G4Colour::Green(), Negative, Neutral, Positive, and G4Colour::Red().

◆ G4TrajectoryDrawByCharge() [2/2]

G4TrajectoryDrawByCharge::G4TrajectoryDrawByCharge ( const G4String name,
const G4Colour positive,
const G4Colour negative,
const G4Colour neutral 
)

Definition at line 43 of file G4TrajectoryDrawByCharge.cc.

48{
49 fMap[Positive] = positive;
50 fMap[Negative] = negative;
51 fMap[Neutral] = neutral;
52}

References fMap, Negative, Neutral, and Positive.

◆ ~G4TrajectoryDrawByCharge()

G4TrajectoryDrawByCharge::~G4TrajectoryDrawByCharge ( )
virtual

Definition at line 54 of file G4TrajectoryDrawByCharge.cc.

54{}

Member Function Documentation

◆ ConvertToCharge()

G4bool G4TrajectoryDrawByCharge::ConvertToCharge ( const G4String string,
Charge myCharge 
)
private

Definition at line 134 of file G4TrajectoryDrawByCharge.cc.

135{
136 bool result(true);
137
138 G4int charge;
139 std::istringstream is(string.c_str());
140 is >> charge;
141
142 switch (charge) {
143 case 1:
145 break;
146 case 0:
148 break;
149 case -1:
151 break;
152 default:
153 result = false;
154 }
155
156 return result;
157}
int G4int
Definition: G4Types.hh:85

References Negative, Neutral, and Positive.

Referenced by Set().

◆ Draw()

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

Implements G4VTrajectoryModel.

Definition at line 57 of file G4TrajectoryDrawByCharge.cc.

58{
59 G4Colour colour;
60
61 const G4double charge = traj.GetCharge();
62
63 if(charge>0.) fMap.GetColour(Positive, colour);
64 else if(charge<0.) fMap.GetColour(Negative, colour);
65 else fMap.GetColour(Neutral, colour);
66
67 G4VisTrajContext myContext(GetContext());
68
69 myContext.SetLineColour(colour);
70
71 if (GetVerbose()) {
72 G4cout<<"G4TrajectoryDrawByCharge drawer named "<<Name();
73 G4cout<<", drawing trajectory with charge, "<<charge<<G4endl;
74 G4cout<<", with configuration:"<<G4endl;
75 myContext.Print(G4cout);
76 }
77
79}
double G4double
Definition: G4Types.hh:83
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
bool GetColour(const T &, G4Colour &) const
G4String Name() const
const G4VisTrajContext & GetContext() const
G4bool GetVerbose() const
void DrawLineAndPoints(const G4VTrajectory &traj, const G4VisTrajContext &)

References G4TrajectoryDrawerUtils::DrawLineAndPoints(), fMap, G4cout, G4endl, G4VTrajectory::GetCharge(), G4ModelColourMap< T >::GetColour(), G4VTrajectoryModel::GetContext(), G4VTrajectoryModel::GetVerbose(), G4VTrajectoryModel::Name(), Negative, Neutral, Positive, 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 G4TrajectoryDrawByCharge::Print ( std::ostream &  ostr) const
virtual

Implements G4VTrajectoryModel.

Definition at line 82 of file G4TrajectoryDrawByCharge.cc.

83{
84 ostr<<"G4TrajectoryDrawByCharge model "<< Name() <<" colour scheme: "<<std::endl;
85 fMap.Print(ostr);
86 ostr<<"Default configuration:"<<G4endl;
88}
void Print(std::ostream &ostr) const
void Print(std::ostream &ostr) const

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

◆ Set() [1/4]

void G4TrajectoryDrawByCharge::Set ( const Charge charge,
const G4Colour colour 
)

Definition at line 97 of file G4TrajectoryDrawByCharge.cc.

98{
99 fMap[charge] = colour;
100}

References fMap.

Referenced by Set().

◆ Set() [2/4]

void G4TrajectoryDrawByCharge::Set ( const Charge charge,
const G4String colour 
)

Definition at line 91 of file G4TrajectoryDrawByCharge.cc.

92{
93 fMap.Set(charge, colour);
94}
void Set(const T &, const G4Colour &)

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

◆ Set() [3/4]

void G4TrajectoryDrawByCharge::Set ( const G4String charge,
const G4Colour colour 
)

Definition at line 119 of file G4TrajectoryDrawByCharge.cc.

120{
121 Charge myCharge;
122
123 if (!ConvertToCharge(charge, myCharge)) {
125 ed << "Invalid charge "<<charge;
127 ("G4TrajectoryDrawByCharge::Set(const G4int& charge, const G4Colour& colour)", "modeling0122", JustWarning, ed);
128 }
129
130 return Set(myCharge, colour);
131}
@ 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
void Set(const Charge &charge, const G4Colour &colour)
G4bool ConvertToCharge(const G4String &, Charge &)

References ConvertToCharge(), G4Exception(), JustWarning, and Set().

◆ Set() [4/4]

void G4TrajectoryDrawByCharge::Set ( const G4String charge,
const G4String colour 
)

Definition at line 103 of file G4TrajectoryDrawByCharge.cc.

104{
105 Charge myCharge;
106
107 if (!ConvertToCharge(charge, myCharge)) {
109 ed << "Invalid charge "<<charge;
111 ("G4TrajectoryDrawByCharge::Set(const G4int& charge, const G4String& colour)", "modeling0121", JustWarning, ed);
112 return;
113 }
114
115 return Set(myCharge, colour);
116}

References ConvertToCharge(), G4Exception(), JustWarning, and Set().

◆ 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

◆ fMap

G4ModelColourMap<Charge> G4TrajectoryDrawByCharge::fMap
private

Definition at line 76 of file G4TrajectoryDrawByCharge.hh.

Referenced by Draw(), G4TrajectoryDrawByCharge(), 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: