Geant4 9.6.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)
 
virtual ~G4UIcommand ()
 
G4int operator== (const G4UIcommand &right) const
 
G4int 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
 
G4int GetGuidanceEntries () const
 
const G4StringGetGuidanceLine (G4int i) const
 
const G4StringGetCommandPath () const
 
const G4StringGetCommandName () const
 
G4int 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
 

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 (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 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 Member Functions inherited from G4UIcommand
G4int CheckNewValue (const char *newValue)
 

Detailed Description

Definition at line 42 of file G4UIcmdWith3VectorAndUnit.hh.

Constructor & Destructor Documentation

◆ G4UIcmdWith3VectorAndUnit()

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

Definition at line 36 of file G4UIcmdWith3VectorAndUnit.cc.

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

Member Function Documentation

◆ ConvertToStringWithBestUnit()

G4String G4UIcmdWith3VectorAndUnit::ConvertToStringWithBestUnit ( G4ThreeVector  vec)

Definition at line 117 of file G4UIcmdWith3VectorAndUnit.cc.

118{
119 G4UIparameter* unitParam = GetParameter(3);
120 G4String canList = unitParam->GetParameterCandidates();
121 G4Tokenizer candidateTokenizer(canList);
122 G4String aToken = candidateTokenizer();
123
124 std::ostringstream os;
125 os << G4BestUnit(vec,CategoryOf(aToken));
126 G4String st = os.str();
127
128 return st;
129}
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
G4UIparameter * GetParameter(G4int i) const
Definition: G4UIcommand.hh:140
static G4String CategoryOf(const char *unitName)
Definition: G4UIcommand.cc:295
G4String GetParameterCandidates() const

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

◆ ConvertToStringWithDefaultUnit()

G4String G4UIcmdWith3VectorAndUnit::ConvertToStringWithDefaultUnit ( G4ThreeVector  vec)

Definition at line 131 of file G4UIcmdWith3VectorAndUnit.cc.

132{
133 G4UIparameter* unitParam = GetParameter(3);
134 G4String st;
135 if(unitParam->IsOmittable())
136 { st = ConvertToString(vec,unitParam->GetDefaultValue()); }
137 else
138 { st = ConvertToStringWithBestUnit(vec); }
139 return st;
140}
G4String ConvertToStringWithBestUnit(G4ThreeVector vec)
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:349
G4String GetDefaultValue() const
G4bool IsOmittable() const

◆ DoIt()

G4int G4UIcmdWith3VectorAndUnit::DoIt ( G4String  parameterList)
virtual

Reimplemented from G4UIcommand.

Definition at line 51 of file G4UIcmdWith3VectorAndUnit.cc.

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

◆ GetNew3VectorRawValue()

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

Definition at line 94 of file G4UIcmdWith3VectorAndUnit.cc.

95{
96 G4double vx;
97 G4double vy;
98 G4double vz;
99 char unts[30];
100 std::istringstream is(paramString);
101 is >> vx >> vy >> vz >> unts;
102 return G4ThreeVector(vx,vy,vz);
103}
CLHEP::Hep3Vector G4ThreeVector

◆ GetNew3VectorValue()

◆ GetNewUnitValue()

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

Definition at line 105 of file G4UIcmdWith3VectorAndUnit.cc.

106{
107 G4double vx;
108 G4double vy;
109 G4double vz;
110 char unts[30];
111 std::istringstream is(paramString);
112 is >> vx >> vy >> vz >> unts;
113 G4String unt = unts;
114 return ValueOf(unt);
115}

◆ SetDefaultUnit()

void G4UIcmdWith3VectorAndUnit::SetDefaultUnit ( const char *  defUnit)

◆ SetDefaultValue()

void G4UIcmdWith3VectorAndUnit::SetDefaultValue ( G4ThreeVector  defVal)

Definition at line 160 of file G4UIcmdWith3VectorAndUnit.cc.

161{
162 G4UIparameter * theParamX = GetParameter(0);
163 theParamX->SetDefaultValue(vec.x());
164 G4UIparameter * theParamY = GetParameter(1);
165 theParamY->SetDefaultValue(vec.y());
166 G4UIparameter * theParamZ = GetParameter(2);
167 theParamZ->SetDefaultValue(vec.z());
168}

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

145{
146 G4UIparameter * theParamX = GetParameter(0);
147 theParamX->SetParameterName(theNameX);
148 theParamX->SetOmittable(omittable);
149 theParamX->SetCurrentAsDefault(currentAsDefault);
150 G4UIparameter * theParamY = GetParameter(1);
151 theParamY->SetParameterName(theNameY);
152 theParamY->SetOmittable(omittable);
153 theParamY->SetCurrentAsDefault(currentAsDefault);
154 G4UIparameter * theParamZ = GetParameter(2);
155 theParamZ->SetParameterName(theNameZ);
156 theParamZ->SetOmittable(omittable);
157 theParamZ->SetCurrentAsDefault(currentAsDefault);
158}
void SetCurrentAsDefault(G4bool val)

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

◆ SetUnitCandidates()

void G4UIcmdWith3VectorAndUnit::SetUnitCandidates ( const char *  candidateList)

Definition at line 175 of file G4UIcmdWith3VectorAndUnit.cc.

176{
177 G4UIparameter * untParam = GetParameter(3);
178 G4String canList = candidateList;
179 untParam->SetParameterCandidates(canList);
180}
void SetParameterCandidates(const char *theString)

Referenced by SetUnitCategory().

◆ SetUnitCategory()

void G4UIcmdWith3VectorAndUnit::SetUnitCategory ( const char *  unitCategory)

Definition at line 170 of file G4UIcmdWith3VectorAndUnit.cc.

171{
172 SetUnitCandidates(UnitsList(unitCategory));
173}
void SetUnitCandidates(const char *candidateList)
static G4String UnitsList(const char *unitCategory)
Definition: G4UIcommand.cc:300

Referenced by G4VisCommandsViewerSet::G4VisCommandsViewerSet(), SetDefaultUnit(), and G4GenericMessenger::Command::SetUnit().


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