Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4UIcmdWith3VectorAndUnit Class Reference

#include <G4UIcmdWith3VectorAndUnit.hh>

Inheritance diagram for G4UIcmdWith3VectorAndUnit:
Collaboration 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 ()
 
G4int operator== (const G4UIcommand &right) const
 
G4int operator!= (const G4UIcommand &right) const
 
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
 
void SetToBeBroadcasted (G4bool val)
 
G4bool ToBeBroadcasted () const
 
void SetToBeFlushed (G4bool val)
 
G4bool ToBeFlushed () const
 
void SetWorkerThreadOnly (G4bool val=true)
 
G4bool IsWorkerThreadOnly () 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)
 
- Protected Attributes inherited from G4UIcommand
G4bool toBeBroadcasted
 
G4bool toBeFlushed
 
G4bool workerThreadOnly
 

Detailed Description

Definition at line 42 of file G4UIcmdWith3VectorAndUnit.hh.

Constructor & Destructor Documentation

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

Definition at line 38 of file G4UIcmdWith3VectorAndUnit.cc.

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

Here is the call graph for this function:

Member Function Documentation

G4String G4UIcmdWith3VectorAndUnit::ConvertToStringWithBestUnit ( G4ThreeVector  vec)

Definition at line 120 of file G4UIcmdWith3VectorAndUnit.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

G4String G4UIcmdWith3VectorAndUnit::ConvertToStringWithDefaultUnit ( G4ThreeVector  vec)

Definition at line 134 of file G4UIcmdWith3VectorAndUnit.cc.

135 {
136  G4UIparameter* unitParam = GetParameter(3);
137  G4String st;
138  if(unitParam->IsOmittable())
139  { st = ConvertToString(vec,unitParam->GetDefaultValue()); }
140  else
141  { st = ConvertToStringWithBestUnit(vec); }
142  return st;
143 }
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:372
G4bool IsOmittable() const
G4UIparameter * GetParameter(G4int i) const
Definition: G4UIcommand.hh:145
G4String GetDefaultValue() const
G4String ConvertToStringWithBestUnit(G4ThreeVector vec)

Here is the call graph for this function:

G4int G4UIcmdWith3VectorAndUnit::DoIt ( G4String  parameterList)
virtual

Reimplemented from G4UIcommand.

Definition at line 52 of file G4UIcmdWith3VectorAndUnit.cc.

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

Here is the call graph for this function:

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

Definition at line 97 of file G4UIcmdWith3VectorAndUnit.cc.

98 {
99  G4double vx;
100  G4double vy;
101  G4double vz;
102  char unts[30];
103  std::istringstream is(paramString);
104  is >> vx >> vy >> vz >> unts;
105  return G4ThreeVector(vx,vy,vz);
106 }
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition: G4Types.hh:76

Here is the caller graph for this function:

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

Definition at line 92 of file G4UIcmdWith3VectorAndUnit.cc.

93 {
94  return ConvertToDimensioned3Vector(paramString);
95 }
static G4ThreeVector ConvertToDimensioned3Vector(const char *st)
Definition: G4UIcommand.cc:485

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 108 of file G4UIcmdWith3VectorAndUnit.cc.

109 {
110  G4double vx;
111  G4double vy;
112  G4double vz;
113  char unts[30];
114  std::istringstream is(paramString);
115  is >> vx >> vy >> vz >> unts;
116  G4String unt = unts;
117  return ValueOf(unt);
118 }
static G4double ValueOf(const char *unitName)
Definition: G4UIcommand.cc:309
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

void G4UIcmdWith3VectorAndUnit::SetDefaultUnit ( const char *  defUnit)

Definition at line 185 of file G4UIcmdWith3VectorAndUnit.cc.

186 {
187  G4UIparameter * untParam = GetParameter(3);
188  untParam->SetOmittable(true);
189  untParam->SetDefaultValue(defUnit);
190  SetUnitCategory(CategoryOf(defUnit));
191 }
void SetOmittable(G4bool om)
void SetUnitCategory(const char *unitCategory)
void SetDefaultValue(const char *theDefaultValue)
G4UIparameter * GetParameter(G4int i) const
Definition: G4UIcommand.hh:145
static G4String CategoryOf(const char *unitName)
Definition: G4UIcommand.cc:316

Here is the call graph for this function:

Here is the caller graph for this function:

void G4UIcmdWith3VectorAndUnit::SetDefaultValue ( G4ThreeVector  defVal)

Definition at line 163 of file G4UIcmdWith3VectorAndUnit.cc.

164 {
165  G4UIparameter * theParamX = GetParameter(0);
166  theParamX->SetDefaultValue(vec.x());
167  G4UIparameter * theParamY = GetParameter(1);
168  theParamY->SetDefaultValue(vec.y());
169  G4UIparameter * theParamZ = GetParameter(2);
170  theParamZ->SetDefaultValue(vec.z());
171 }
void SetDefaultValue(const char *theDefaultValue)
G4UIparameter * GetParameter(G4int i) const
Definition: G4UIcommand.hh:145

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 146 of file G4UIcmdWith3VectorAndUnit.cc.

148 {
149  G4UIparameter * theParamX = GetParameter(0);
150  theParamX->SetParameterName(theNameX);
151  theParamX->SetOmittable(omittable);
152  theParamX->SetCurrentAsDefault(currentAsDefault);
153  G4UIparameter * theParamY = GetParameter(1);
154  theParamY->SetParameterName(theNameY);
155  theParamY->SetOmittable(omittable);
156  theParamY->SetCurrentAsDefault(currentAsDefault);
157  G4UIparameter * theParamZ = GetParameter(2);
158  theParamZ->SetParameterName(theNameZ);
159  theParamZ->SetOmittable(omittable);
160  theParamZ->SetCurrentAsDefault(currentAsDefault);
161 }
void SetOmittable(G4bool om)
void SetParameterName(const char *theName)
void SetCurrentAsDefault(G4bool val)
G4UIparameter * GetParameter(G4int i) const
Definition: G4UIcommand.hh:145

Here is the call graph for this function:

Here is the caller graph for this function:

void G4UIcmdWith3VectorAndUnit::SetUnitCandidates ( const char *  candidateList)

Definition at line 178 of file G4UIcmdWith3VectorAndUnit.cc.

179 {
180  G4UIparameter * untParam = GetParameter(3);
181  G4String canList = candidateList;
182  untParam->SetParameterCandidates(canList);
183 }
void SetParameterCandidates(const char *theString)
G4UIparameter * GetParameter(G4int i) const
Definition: G4UIcommand.hh:145

Here is the call graph for this function:

Here is the caller graph for this function:

void G4UIcmdWith3VectorAndUnit::SetUnitCategory ( const char *  unitCategory)

Definition at line 173 of file G4UIcmdWith3VectorAndUnit.cc.

174 {
175  SetUnitCandidates(UnitsList(unitCategory));
176 }
static G4String UnitsList(const char *unitCategory)
Definition: G4UIcommand.cc:321
void SetUnitCandidates(const char *candidateList)

Here is the call graph for this function:

Here is the caller graph for this function:


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