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

#include <G4UIcmdWithADoubleAndUnit.hh>

Inheritance diagram for G4UIcmdWithADoubleAndUnit:
Collaboration diagram for G4UIcmdWithADoubleAndUnit:

Public Member Functions

 G4UIcmdWithADoubleAndUnit (const char *theCommandPath, G4UImessenger *theMessenger)
 
virtual G4int DoIt (G4String parameterList)
 
G4String ConvertToStringWithBestUnit (G4double val)
 
G4String ConvertToStringWithDefaultUnit (G4double val)
 
void SetParameterName (const char *theName, G4bool omittable, G4bool currentAsDefault=false)
 
void SetDefaultValue (G4double 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 G4double GetNewDoubleValue (const char *paramString)
 
static G4double GetNewDoubleRawValue (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 41 of file G4UIcmdWithADoubleAndUnit.hh.

Constructor & Destructor Documentation

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

Definition at line 39 of file G4UIcmdWithADoubleAndUnit.cc.

40 :G4UIcommand(theCommandPath,theMessenger)
41 {
42  G4UIparameter * dblParam = new G4UIparameter('d');
43  SetParameter(dblParam);
44  G4UIparameter * untParam = new G4UIparameter('s');
45  SetParameter(untParam);
46  untParam->SetParameterName("Unit");
47 }
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 G4UIcmdWithADoubleAndUnit::ConvertToStringWithBestUnit ( G4double  val)

Definition at line 111 of file G4UIcmdWithADoubleAndUnit.cc.

112 {
113  G4UIparameter* unitParam = GetParameter(1);
114  G4String canList = unitParam->GetParameterCandidates();
115  G4Tokenizer candidateTokenizer(canList);
116  G4String aToken = candidateTokenizer();
117  std::ostringstream os;
118  os << G4BestUnit(val,CategoryOf(aToken));
119 
120  G4String st = os.str();
121  return st;
122 }
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 G4UIcmdWithADoubleAndUnit::ConvertToStringWithDefaultUnit ( G4double  val)

Definition at line 124 of file G4UIcmdWithADoubleAndUnit.cc.

125 {
126  G4UIparameter* unitParam = GetParameter(1);
127  G4String st;
128  if(unitParam->IsOmittable())
129  { st = ConvertToString(val,unitParam->GetDefaultValue()); }
130  else
131  { st = ConvertToStringWithBestUnit(val); }
132  return st;
133 }
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(G4double val)

Here is the call graph for this function:

G4int G4UIcmdWithADoubleAndUnit::DoIt ( G4String  parameterList)
virtual

Reimplemented from G4UIcommand.

Definition at line 49 of file G4UIcmdWithADoubleAndUnit.cc.

50 {
51  std::vector<G4String> token_vector;
52  G4Tokenizer tkn(parameterList);
53  G4String str;
54  while( (str = tkn()) != "" ) {
55  token_vector.push_back(str);
56  }
57 
58  // convert a value in default unit
59  G4String converted_parameter;
60  G4String default_unit = GetParameter(1)-> GetDefaultValue();
61  if (default_unit != "" && token_vector.size() >= 2) {
62  if(CategoryOf(token_vector[1])!=CategoryOf(default_unit))
63  { return fParameterOutOfCandidates+1; }
64  G4double value_given = ValueOf(token_vector[1]);
65  G4double value_default = ValueOf(default_unit);
66  G4double value = ConvertToDouble(token_vector[0])
67  * value_given / value_default;
68  // reconstruct parameter list
69  converted_parameter += ConvertToString(value);
70  converted_parameter += " ";
71  converted_parameter += default_unit;
72  for ( size_t i=2 ; i< token_vector.size(); i++) {
73  converted_parameter += " ";
74  converted_parameter += token_vector[i];
75  }
76  } else {
77  converted_parameter = parameterList;
78  }
79 
80  return G4UIcommand::DoIt(converted_parameter);
81 }
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:372
const XML_Char int const XML_Char * value
Definition: expat.h:331
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
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:

G4double G4UIcmdWithADoubleAndUnit::GetNewDoubleRawValue ( const char *  paramString)
static

Definition at line 88 of file G4UIcmdWithADoubleAndUnit.cc.

89 {
90  G4double vl;
91  char unts[30];
92 
93  std::istringstream is(paramString);
94  is >> vl >> unts;
95 
96  return vl;
97 }
double G4double
Definition: G4Types.hh:76
G4double G4UIcmdWithADoubleAndUnit::GetNewDoubleValue ( const char *  paramString)
static

Definition at line 83 of file G4UIcmdWithADoubleAndUnit.cc.

84 {
85  return ConvertToDimensionedDouble(paramString);
86 }
static G4double ConvertToDimensionedDouble(const char *st)
Definition: G4UIcommand.cc:463

Here is the call graph for this function:

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

Definition at line 99 of file G4UIcmdWithADoubleAndUnit.cc.

100 {
101  G4double vl;
102  char unts[30];
103 
104  std::istringstream is(paramString);
105  is >> vl >> unts;
106  G4String unt = unts;
107 
108  return ValueOf(unt);
109 }
static G4double ValueOf(const char *unitName)
Definition: G4UIcommand.cc:309
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

Here is the caller graph for this function:

void G4UIcmdWithADoubleAndUnit::SetDefaultUnit ( const char *  defUnit)

Definition at line 162 of file G4UIcmdWithADoubleAndUnit.cc.

163 {
164  G4UIparameter * untParam = GetParameter(1);
165  untParam->SetOmittable(true);
166  untParam->SetDefaultValue(defUnit);
167  SetUnitCategory(CategoryOf(defUnit));
168 }
void SetOmittable(G4bool om)
void SetDefaultValue(const char *theDefaultValue)
void SetUnitCategory(const char *unitCategory)
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 G4UIcmdWithADoubleAndUnit::SetDefaultValue ( G4double  defVal)

Definition at line 144 of file G4UIcmdWithADoubleAndUnit.cc.

145 {
146  G4UIparameter * theParam = GetParameter(0);
147  theParam->SetDefaultValue(defVal);
148 }
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 G4UIcmdWithADoubleAndUnit::SetParameterName ( const char *  theName,
G4bool  omittable,
G4bool  currentAsDefault = false 
)

Definition at line 136 of file G4UIcmdWithADoubleAndUnit.cc.

137 {
138  G4UIparameter * theParam = GetParameter(0);
139  theParam->SetParameterName(theName);
140  theParam->SetOmittable(omittable);
141  theParam->SetCurrentAsDefault(currentAsDefault);
142 }
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:

void G4UIcmdWithADoubleAndUnit::SetUnitCandidates ( const char *  candidateList)

Definition at line 155 of file G4UIcmdWithADoubleAndUnit.cc.

156 {
157  G4UIparameter * untParam = GetParameter(1);
158  G4String canList = candidateList;
159  untParam->SetParameterCandidates(canList);
160 }
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 G4UIcmdWithADoubleAndUnit::SetUnitCategory ( const char *  unitCategory)

Definition at line 150 of file G4UIcmdWithADoubleAndUnit.cc.

151 {
152  SetUnitCandidates(UnitsList(unitCategory));
153 }
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: