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

#include <G4UIcmdWith3VectorAndUnit.hh>

+ Inheritance diagram for G4UIcmdWith3VectorAndUnit:

Public Member Functions

 G4UIcmdWith3VectorAndUnit (const char *theCommandPath, G4UImessenger *theMessenger)
 
virtual G4int DoIt (G4String parameterList)
 
G4String ConvertToStringWithBestUnit (G4ThreeVector vec)
 
G4String ConvertToStringWithDefaultUnit (G4ThreeVector vec)
 
void SetParameterName (const char *theNameX, const char *theNameY, const char *theNameZ, G4bool omittable, G4bool currentAsDefault=false)
 
void SetDefaultValue (G4ThreeVector defVal)
 
void SetUnitCategory (const char *unitCategory)
 
void SetUnitCandidates (const char *candidateList)
 
void SetDefaultUnit (const char *defUnit)
 
- Public Member Functions inherited from G4UIcommand
 G4UIcommand ()
 
 G4UIcommand (const char *theCommandPath, G4UImessenger *theMessenger, G4bool tBB=true)
 
virtual ~G4UIcommand ()
 
G4bool operator== (const G4UIcommand &right) const
 
G4bool operator!= (const G4UIcommand &right) const
 
virtual G4int DoIt (G4String parameterList)
 
G4String GetCurrentValue ()
 
void AvailableForStates (G4ApplicationState s1)
 
void AvailableForStates (G4ApplicationState s1, G4ApplicationState s2)
 
void AvailableForStates (G4ApplicationState s1, G4ApplicationState s2, G4ApplicationState s3)
 
void AvailableForStates (G4ApplicationState s1, G4ApplicationState s2, G4ApplicationState s3, G4ApplicationState s4)
 
void AvailableForStates (G4ApplicationState s1, G4ApplicationState s2, G4ApplicationState s3, G4ApplicationState s4, G4ApplicationState s5)
 
G4bool IsAvailable ()
 
virtual void List ()
 
void SetRange (const char *rs)
 
const G4StringGetRange () const
 
std::size_t GetGuidanceEntries () const
 
const G4StringGetGuidanceLine (G4int i) const
 
const G4StringGetCommandPath () const
 
const G4StringGetCommandName () const
 
std::size_t GetParameterEntries () const
 
G4UIparameterGetParameter (G4int i) const
 
std::vector< G4ApplicationState > * GetStateList ()
 
G4UImessengerGetMessenger () const
 
void SetParameter (G4UIparameter *const newParameter)
 
void SetGuidance (const char *aGuidance)
 
const G4String GetTitle () const
 
void SetToBeBroadcasted (G4bool val)
 
G4bool ToBeBroadcasted () const
 
void SetToBeFlushed (G4bool val)
 
G4bool ToBeFlushed () const
 
void SetWorkerThreadOnly (G4bool val=true)
 
G4bool IsWorkerThreadOnly () const
 
void CommandFailed (G4int errCode, G4ExceptionDescription &ed)
 
void CommandFailed (G4ExceptionDescription &ed)
 
G4int IfCommandFailed ()
 
const G4StringGetFailureDescription ()
 
void ResetFailure ()
 

Static Public Member Functions

static G4ThreeVector GetNew3VectorValue (const char *paramString)
 
static G4ThreeVector GetNew3VectorRawValue (const char *paramString)
 
static G4double GetNewUnitValue (const char *paramString)
 
- Static Public Member Functions inherited from G4UIcommand
static G4String ConvertToString (G4bool boolVal)
 
static G4String ConvertToString (G4int intValue)
 
static G4String ConvertToString (G4long longValue)
 
static G4String ConvertToString (G4double doubleValue)
 
static G4String ConvertToString (G4double doubleValue, const char *unitName)
 
static G4String ConvertToString (G4ThreeVector vec)
 
static G4String ConvertToString (G4ThreeVector vec, const char *unitName)
 
static G4bool ConvertToBool (const char *st)
 
static G4int ConvertToInt (const char *st)
 
static G4long ConvertToLongInt (const char *st)
 
static G4double ConvertToDouble (const char *st)
 
static G4double ConvertToDimensionedDouble (const char *st)
 
static G4ThreeVector ConvertTo3Vector (const char *st)
 
static G4ThreeVector ConvertToDimensioned3Vector (const char *st)
 
static G4double ValueOf (const char *unitName)
 
static G4String CategoryOf (const char *unitName)
 
static G4String UnitsList (const char *unitCategory)
 

Additional Inherited Members

- Protected Types inherited from G4UIcommand
using yystype = G4UItokenNum::yystype
 
using tokenNum = G4UItokenNum::tokenNum
 
- Protected Member Functions inherited from G4UIcommand
G4int CheckNewValue (const char *newValue)
 
- Protected Attributes inherited from G4UIcommand
G4bool toBeBroadcasted = false
 
G4bool toBeFlushed = false
 
G4bool workerThreadOnly = false
 
G4int commandFailureCode = 0
 
G4String failureDescription = ""
 

Detailed Description

Definition at line 42 of file G4UIcmdWith3VectorAndUnit.hh.

Constructor & Destructor Documentation

◆ G4UIcmdWith3VectorAndUnit()

G4UIcmdWith3VectorAndUnit::G4UIcmdWith3VectorAndUnit ( const char *  theCommandPath,
G4UImessenger theMessenger 
)

Definition at line 38 of file G4UIcmdWith3VectorAndUnit.cc.

40 : G4UIcommand(theCommandPath, theMessenger)
41{
42 G4UIparameter* dblParamX = new G4UIparameter('d');
43 SetParameter(dblParamX);
44 G4UIparameter* dblParamY = new G4UIparameter('d');
45 SetParameter(dblParamY);
46 G4UIparameter* dblParamZ = new G4UIparameter('d');
47 SetParameter(dblParamZ);
48 G4UIparameter* untParam = new G4UIparameter('s');
49 SetParameter(untParam);
50 untParam->SetParameterName("Unit");
51}
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:146
void SetParameterName(const char *pName)

Member Function Documentation

◆ ConvertToStringWithBestUnit()

G4String G4UIcmdWith3VectorAndUnit::ConvertToStringWithBestUnit ( G4ThreeVector  vec)

Definition at line 135 of file G4UIcmdWith3VectorAndUnit.cc.

137{
138 G4UIparameter* unitParam = GetParameter(3);
139 G4String canList = unitParam->GetParameterCandidates();
140 G4Tokenizer candidateTokenizer(canList);
141 G4String aToken = candidateTokenizer();
142
143 std::ostringstream os;
144 os << G4BestUnit(vec, CategoryOf(aToken));
145 G4String st = os.str();
146
147 return st;
148}
#define G4BestUnit(a, b)
G4UIparameter * GetParameter(G4int i) const
Definition: G4UIcommand.hh:139
static G4String CategoryOf(const char *unitName)
Definition: G4UIcommand.cc:356
const G4String & GetParameterCandidates() const

Referenced by ConvertToStringWithDefaultUnit(), G4MoleculeShootMessenger::GetCurrentValue(), and G4VisCommandsViewerSet::SetNewValue().

◆ ConvertToStringWithDefaultUnit()

G4String G4UIcmdWith3VectorAndUnit::ConvertToStringWithDefaultUnit ( G4ThreeVector  vec)

Definition at line 151 of file G4UIcmdWith3VectorAndUnit.cc.

153{
154 G4UIparameter* unitParam = GetParameter(3);
155 G4String st;
156 if(unitParam->IsOmittable())
157 {
158 st = ConvertToString(vec, unitParam->GetDefaultValue());
159 }
160 else
161 {
163 }
164 return st;
165}
G4String ConvertToStringWithBestUnit(G4ThreeVector vec)
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:430
G4bool IsOmittable() const
const G4String & GetDefaultValue() const

◆ DoIt()

G4int G4UIcmdWith3VectorAndUnit::DoIt ( G4String  parameterList)
virtual

Reimplemented from G4UIcommand.

Definition at line 54 of file G4UIcmdWith3VectorAndUnit.cc.

55{
56 std::vector<G4String> token_vector;
57 G4Tokenizer tkn(parameterList);
58 G4String str;
59 while((str = tkn()) != "")
60 {
61 token_vector.push_back(str);
62 }
63
64 // convert a value in default unit
65 G4String converted_parameter;
66 G4String default_unit = GetParameter(3)->GetDefaultValue();
67 if(default_unit != "" && token_vector.size() >= 4)
68 {
69 if(CategoryOf(token_vector[3]) != CategoryOf(default_unit))
70 {
72 }
73 G4double value_given = ValueOf(token_vector[3]);
74 G4double value_default = ValueOf(default_unit);
75 G4double x = ConvertToDouble(token_vector[0]) * value_given / value_default;
76 G4double y = ConvertToDouble(token_vector[1]) * value_given / value_default;
77 G4double z = ConvertToDouble(token_vector[2]) * value_given / value_default;
78
79 // reconstruct parameter list
80 converted_parameter += ConvertToString(x);
81 converted_parameter += " ";
82 converted_parameter += ConvertToString(y);
83 converted_parameter += " ";
84 converted_parameter += ConvertToString(z);
85 converted_parameter += " ";
86 converted_parameter += default_unit;
87 for(std::size_t i = 4; i < token_vector.size(); ++i)
88 {
89 converted_parameter += " ";
90 converted_parameter += token_vector[i];
91 }
92 }
93 else
94 {
95 converted_parameter = parameterList;
96 }
97
98 return G4UIcommand::DoIt(converted_parameter);
99}
double G4double
Definition: G4Types.hh:83
@ fParameterOutOfCandidates
static G4double ValueOf(const char *unitName)
Definition: G4UIcommand.cc:348
virtual G4int DoIt(G4String parameterList)
Definition: G4UIcommand.cc:135
static G4double ConvertToDouble(const char *st)
Definition: G4UIcommand.cc:561

◆ GetNew3VectorRawValue()

G4ThreeVector G4UIcmdWith3VectorAndUnit::GetNew3VectorRawValue ( const char *  paramString)
static

Definition at line 109 of file G4UIcmdWith3VectorAndUnit.cc.

111{
112 G4double vx;
113 G4double vy;
114 G4double vz;
115 char unts[30];
116 std::istringstream is(paramString);
117 is >> vx >> vy >> vz >> unts;
118 return G4ThreeVector(vx, vy, vz);
119}
CLHEP::Hep3Vector G4ThreeVector

◆ GetNew3VectorValue()

◆ GetNewUnitValue()

G4double G4UIcmdWith3VectorAndUnit::GetNewUnitValue ( const char *  paramString)
static

Definition at line 122 of file G4UIcmdWith3VectorAndUnit.cc.

123{
124 G4double vx;
125 G4double vy;
126 G4double vz;
127 char unts[30];
128 std::istringstream is(paramString);
129 is >> vx >> vy >> vz >> unts;
130 G4String unt = unts;
131 return ValueOf(unt);
132}

◆ SetDefaultUnit()

void G4UIcmdWith3VectorAndUnit::SetDefaultUnit ( const char *  defUnit)

Definition at line 214 of file G4UIcmdWith3VectorAndUnit.cc.

215{
216 G4UIparameter* untParam = GetParameter(3);
217 untParam->SetOmittable(true);
218 untParam->SetDefaultValue(defUnit);
219 SetUnitCategory(CategoryOf(defUnit));
220}
void SetUnitCategory(const char *unitCategory)
void SetDefaultValue(const char *theDefaultValue)
void SetOmittable(G4bool om)

Referenced by G4MatScanMessenger::G4MatScanMessenger(), G4ParticleGunMessenger::G4ParticleGunMessenger(), G4ScoringMessenger::G4ScoringMessenger(), and G4GenericMessenger::Command::SetUnit().

◆ SetDefaultValue()

void G4UIcmdWith3VectorAndUnit::SetDefaultValue ( G4ThreeVector  defVal)

Definition at line 189 of file G4UIcmdWith3VectorAndUnit.cc.

190{
191 G4UIparameter* theParamX = GetParameter(0);
192 theParamX->SetDefaultValue(vec.x());
193 G4UIparameter* theParamY = GetParameter(1);
194 theParamY->SetDefaultValue(vec.y());
195 G4UIparameter* theParamZ = GetParameter(2);
196 theParamZ->SetDefaultValue(vec.z());
197}

Referenced by G4MatScanMessenger::G4MatScanMessenger().

◆ SetParameterName()

void G4UIcmdWith3VectorAndUnit::SetParameterName ( const char *  theNameX,
const char *  theNameY,
const char *  theNameZ,
G4bool  omittable,
G4bool  currentAsDefault = false 
)

Definition at line 168 of file G4UIcmdWith3VectorAndUnit.cc.

173{
174 G4UIparameter* theParamX = GetParameter(0);
175 theParamX->SetParameterName(theNameX);
176 theParamX->SetOmittable(omittable);
177 theParamX->SetCurrentAsDefault(currentAsDefault);
178 G4UIparameter* theParamY = GetParameter(1);
179 theParamY->SetParameterName(theNameY);
180 theParamY->SetOmittable(omittable);
181 theParamY->SetCurrentAsDefault(currentAsDefault);
182 G4UIparameter* theParamZ = GetParameter(2);
183 theParamZ->SetParameterName(theNameZ);
184 theParamZ->SetOmittable(omittable);
185 theParamZ->SetCurrentAsDefault(currentAsDefault);
186}
void SetCurrentAsDefault(G4bool val)

Referenced by G4GlobalMagFieldMessenger::G4GlobalMagFieldMessenger(), G4MatScanMessenger::G4MatScanMessenger(), G4ParticleGunMessenger::G4ParticleGunMessenger(), G4ScoringMessenger::G4ScoringMessenger(), and G4VisCommandsViewerSet::G4VisCommandsViewerSet().

◆ SetUnitCandidates()

void G4UIcmdWith3VectorAndUnit::SetUnitCandidates ( const char *  candidateList)

Definition at line 206 of file G4UIcmdWith3VectorAndUnit.cc.

207{
208 G4UIparameter* untParam = GetParameter(3);
209 G4String canList = candidateList;
210 untParam->SetParameterCandidates(canList);
211}
void SetParameterCandidates(const char *theString)

Referenced by SetUnitCategory().

◆ SetUnitCategory()

void G4UIcmdWith3VectorAndUnit::SetUnitCategory ( const char *  unitCategory)

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