Geant4 11.1.1
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)
 
G4int DoIt (G4String parameterList) override
 
G4String ConvertToStringWithBestUnit (const G4ThreeVector &vec)
 
G4String ConvertToStringWithDefaultUnit (const G4ThreeVector &vec)
 
void SetParameterName (const char *theNameX, const char *theNameY, const char *theNameZ, G4bool omittable, G4bool currentAsDefault=false)
 
void SetDefaultValue (const G4ThreeVector &defVal)
 
void SetUnitCategory (const char *unitCategory)
 
void SetUnitCandidates (const char *candidateList)
 
void SetDefaultUnit (const char *defUnit)
 
- Public Member Functions inherited from G4UIcommand
 G4UIcommand ()=default
 
 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 ()
 
CommandType GetCommandType () const
 
void SetCommandType (CommandType)
 
void SetDefaultSortFlag (G4bool val)
 

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 (const G4ThreeVector &vec)
 
static G4String ConvertToString (const 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

- Public Types inherited from G4UIcommand
enum  CommandType {
  BaseClassCmd , WithoutParameterCmd , WithABoolCmd , WithAnIntegerCmd ,
  WithALongIntCmd , WithADoubleCmd , WithADoubleAndUnitCmd , With3VectorCmd ,
  With3VectorAndUnitCmd , WithAStringCmd , CmdDirectory = -1
}
 
- 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 = ""
 
G4bool ifSort = false
 

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 auto* dblParamX = new G4UIparameter('d');
43 SetParameter(dblParamX);
44 auto* dblParamY = new G4UIparameter('d');
45 SetParameter(dblParamY);
46 auto* dblParamZ = new G4UIparameter('d');
47 SetParameter(dblParamZ);
48 auto* untParam = new G4UIparameter('s');
49 untParam->SetParameterName("Unit");
50 SetParameter(untParam);
52}
G4UIcommand()=default
void SetCommandType(CommandType)
Definition: G4UIcommand.cc:89
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:147
@ With3VectorAndUnitCmd
Definition: G4UIcommand.hh:201

Member Function Documentation

◆ ConvertToStringWithBestUnit()

G4String G4UIcmdWith3VectorAndUnit::ConvertToStringWithBestUnit ( const G4ThreeVector vec)

Definition at line 136 of file G4UIcmdWith3VectorAndUnit.cc.

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

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

◆ ConvertToStringWithDefaultUnit()

G4String G4UIcmdWith3VectorAndUnit::ConvertToStringWithDefaultUnit ( const G4ThreeVector vec)

Definition at line 152 of file G4UIcmdWith3VectorAndUnit.cc.

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

◆ DoIt()

G4int G4UIcmdWith3VectorAndUnit::DoIt ( G4String  parameterList)
overridevirtual

Reimplemented from G4UIcommand.

Definition at line 55 of file G4UIcmdWith3VectorAndUnit.cc.

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

◆ GetNew3VectorRawValue()

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

Definition at line 110 of file G4UIcmdWith3VectorAndUnit.cc.

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

◆ GetNew3VectorValue()

◆ GetNewUnitValue()

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

Definition at line 123 of file G4UIcmdWith3VectorAndUnit.cc.

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

◆ SetDefaultUnit()

void G4UIcmdWith3VectorAndUnit::SetDefaultUnit ( const char *  defUnit)

Definition at line 215 of file G4UIcmdWith3VectorAndUnit.cc.

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

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

◆ SetDefaultValue()

void G4UIcmdWith3VectorAndUnit::SetDefaultValue ( const G4ThreeVector defVal)

Definition at line 190 of file G4UIcmdWith3VectorAndUnit.cc.

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

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 169 of file G4UIcmdWith3VectorAndUnit.cc.

174{
175 G4UIparameter* theParamX = GetParameter(0);
176 theParamX->SetParameterName(theNameX);
177 theParamX->SetOmittable(omittable);
178 theParamX->SetCurrentAsDefault(currentAsDefault);
179 G4UIparameter* theParamY = GetParameter(1);
180 theParamY->SetParameterName(theNameY);
181 theParamY->SetOmittable(omittable);
182 theParamY->SetCurrentAsDefault(currentAsDefault);
183 G4UIparameter* theParamZ = GetParameter(2);
184 theParamZ->SetParameterName(theNameZ);
185 theParamZ->SetOmittable(omittable);
186 theParamZ->SetCurrentAsDefault(currentAsDefault);
187}
void SetParameterName(const char *pName)
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 207 of file G4UIcmdWith3VectorAndUnit.cc.

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

Referenced by SetUnitCategory().

◆ SetUnitCategory()

void G4UIcmdWith3VectorAndUnit::SetUnitCategory ( const char *  unitCategory)

Definition at line 201 of file G4UIcmdWith3VectorAndUnit.cc.

202{
203 SetUnitCandidates(UnitsList(unitCategory));
204}
void SetUnitCandidates(const char *candidateList)
static G4String UnitsList(const char *unitCategory)
Definition: G4UIcommand.cc:376

Referenced by G4GlobalMagFieldMessenger::G4GlobalMagFieldMessenger(), G4VisCommandsViewerSet::G4VisCommandsViewerSet(), and SetDefaultUnit().


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