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

#include <G4UIcmdWithADoubleAndUnit.hh>

+ Inheritance 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)
 
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 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)
 

Detailed Description

Definition at line 41 of file G4UIcmdWithADoubleAndUnit.hh.

Constructor & Destructor Documentation

◆ G4UIcmdWithADoubleAndUnit()

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

Definition at line 37 of file G4UIcmdWithADoubleAndUnit.cc.

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

Member Function Documentation

◆ ConvertToStringWithBestUnit()

G4String G4UIcmdWithADoubleAndUnit::ConvertToStringWithBestUnit ( G4double  val)

Definition at line 108 of file G4UIcmdWithADoubleAndUnit.cc.

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

◆ ConvertToStringWithDefaultUnit()

G4String G4UIcmdWithADoubleAndUnit::ConvertToStringWithDefaultUnit ( G4double  val)

Definition at line 121 of file G4UIcmdWithADoubleAndUnit.cc.

122{
123 G4UIparameter* unitParam = GetParameter(1);
124 G4String st;
125 if(unitParam->IsOmittable())
126 { st = ConvertToString(val,unitParam->GetDefaultValue()); }
127 else
128 { st = ConvertToStringWithBestUnit(val); }
129 return st;
130}
G4String ConvertToStringWithBestUnit(G4double val)
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:349
G4String GetDefaultValue() const
G4bool IsOmittable() const

◆ DoIt()

G4int G4UIcmdWithADoubleAndUnit::DoIt ( G4String  parameterList)
virtual

Reimplemented from G4UIcommand.

Definition at line 48 of file G4UIcmdWithADoubleAndUnit.cc.

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

◆ GetNewDoubleRawValue()

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

Definition at line 85 of file G4UIcmdWithADoubleAndUnit.cc.

86{
87 G4double vl;
88 char unts[30];
89
90 std::istringstream is(paramString);
91 is >> vl >> unts;
92
93 return vl;
94}

◆ GetNewDoubleValue()

◆ GetNewUnitValue()

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

Definition at line 96 of file G4UIcmdWithADoubleAndUnit.cc.

97{
98 G4double vl;
99 char unts[30];
100
101 std::istringstream is(paramString);
102 is >> vl >> unts;
103 G4String unt = unts;
104
105 return ValueOf(unt);
106}

◆ SetDefaultUnit()

◆ SetDefaultValue()

◆ SetParameterName()

◆ SetUnitCandidates()

void G4UIcmdWithADoubleAndUnit::SetUnitCandidates ( const char *  candidateList)

Definition at line 152 of file G4UIcmdWithADoubleAndUnit.cc.

153{
154 G4UIparameter * untParam = GetParameter(1);
155 G4String canList = candidateList;
156 untParam->SetParameterCandidates(canList);
157}
void SetParameterCandidates(const char *theString)

Referenced by SetUnitCategory().

◆ SetUnitCategory()


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