G4UIcmdWith3VectorAndUnit Class Reference

#include <G4UIcmdWith3VectorAndUnit.hh>

Inheritance diagram for G4UIcmdWith3VectorAndUnit:

G4UIcommand

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)

Static Public Member Functions

static G4ThreeVector GetNew3VectorValue (const char *paramString)
static G4ThreeVector GetNew3VectorRawValue (const char *paramString)
static G4double GetNewUnitValue (const char *paramString)

Detailed Description

Definition at line 42 of file G4UIcmdWith3VectorAndUnit.hh.


Constructor & Destructor Documentation

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

Definition at line 37 of file G4UIcmdWith3VectorAndUnit.cc.

References G4UIparameter::SetParameterName().

00038 :G4UIcommand(theCommandPath,theMessenger)
00039 {
00040   G4UIparameter * dblParamX = new G4UIparameter('d');
00041   SetParameter(dblParamX);
00042   G4UIparameter * dblParamY = new G4UIparameter('d');
00043   SetParameter(dblParamY);
00044   G4UIparameter * dblParamZ = new G4UIparameter('d');
00045   SetParameter(dblParamZ);
00046   G4UIparameter * untParam = new G4UIparameter('s');
00047   SetParameter(untParam);
00048   untParam->SetParameterName("Unit");
00049 }


Member Function Documentation

G4String G4UIcmdWith3VectorAndUnit::ConvertToStringWithBestUnit ( G4ThreeVector  vec  ) 

Definition at line 117 of file G4UIcmdWith3VectorAndUnit.cc.

References G4UIcommand::CategoryOf(), G4BestUnit, G4UIcommand::GetParameter(), and G4UIparameter::GetParameterCandidates().

Referenced by ConvertToStringWithDefaultUnit().

00118 {
00119   G4UIparameter* unitParam = GetParameter(3);
00120   G4String canList = unitParam->GetParameterCandidates();
00121   G4Tokenizer candidateTokenizer(canList);
00122   G4String aToken = candidateTokenizer();
00123 
00124   std::ostringstream os;
00125   os << G4BestUnit(vec,CategoryOf(aToken));
00126   G4String st = os.str();
00127 
00128   return st;
00129 }

G4String G4UIcmdWith3VectorAndUnit::ConvertToStringWithDefaultUnit ( G4ThreeVector  vec  ) 

Definition at line 131 of file G4UIcmdWith3VectorAndUnit.cc.

References G4UIcommand::ConvertToString(), ConvertToStringWithBestUnit(), G4UIparameter::GetDefaultValue(), G4UIcommand::GetParameter(), and G4UIparameter::IsOmittable().

00132 {
00133   G4UIparameter* unitParam = GetParameter(3);
00134   G4String st;
00135   if(unitParam->IsOmittable())
00136   { st = ConvertToString(vec,unitParam->GetDefaultValue()); }
00137   else
00138   { st = ConvertToStringWithBestUnit(vec); }
00139   return st;
00140 }

G4int G4UIcmdWith3VectorAndUnit::DoIt ( G4String  parameterList  )  [virtual]

Reimplemented from G4UIcommand.

Definition at line 51 of file G4UIcmdWith3VectorAndUnit.cc.

References G4UIcommand::ConvertToDouble(), G4UIcommand::ConvertToString(), G4UIcommand::DoIt(), G4UIcommand::GetParameter(), and G4UIcommand::ValueOf().

00052 {
00053   std::vector<G4String> token_vector;
00054   G4Tokenizer tkn(parameterList);
00055   G4String str;
00056   while( (str = tkn()) != "" ) {
00057     token_vector.push_back(str);
00058   }
00059 
00060   // convert a value in default unit
00061   G4String converted_parameter;
00062   G4String default_unit = GetParameter(3)-> GetDefaultValue();
00063   if (default_unit != "" && token_vector.size() >= 4) {
00064     G4double value_given = ValueOf(token_vector[3]);
00065     G4double value_default = ValueOf(default_unit);
00066     G4double x = ConvertToDouble(token_vector[0]) * value_given / value_default;
00067     G4double y = ConvertToDouble(token_vector[1]) * value_given / value_default;
00068     G4double z = ConvertToDouble(token_vector[2]) * value_given / value_default;
00069 
00070     // reconstruct parameter list
00071     converted_parameter += ConvertToString(x);
00072     converted_parameter += " ";
00073     converted_parameter += ConvertToString(y);
00074     converted_parameter += " ";
00075     converted_parameter += ConvertToString(z);
00076     converted_parameter += " ";
00077     converted_parameter += default_unit;
00078     for ( size_t i=4 ; i< token_vector.size(); i++) {
00079       converted_parameter += " ";
00080       converted_parameter += token_vector[i];
00081     }
00082   } else {
00083     converted_parameter = parameterList;
00084   }
00085 
00086   return G4UIcommand::DoIt(converted_parameter);
00087 }

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

Definition at line 94 of file G4UIcmdWith3VectorAndUnit.cc.

00095 {
00096   G4double vx;
00097   G4double vy;
00098   G4double vz;
00099   char unts[30];
00100   std::istringstream is(paramString);
00101   is >> vx >> vy >> vz >> unts;
00102   return G4ThreeVector(vx,vy,vz);
00103 }

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

Definition at line 89 of file G4UIcmdWith3VectorAndUnit.cc.

References G4UIcommand::ConvertToDimensioned3Vector().

Referenced by G4ScoringMessenger::SetNewValue(), G4RTMessenger::SetNewValue(), G4ParticleGunMessenger::SetNewValue(), G4MatScanMessenger::SetNewValue(), G4HepRepMessenger::SetNewValue(), G4GeometryMessenger::SetNewValue(), and G4GeneralParticleSourceMessenger::SetNewValue().

00090 {
00091   return ConvertToDimensioned3Vector(paramString);
00092 }

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

Definition at line 105 of file G4UIcmdWith3VectorAndUnit.cc.

References G4UIcommand::ValueOf().

00106 {
00107   G4double vx;
00108   G4double vy;
00109   G4double vz;
00110   char unts[30];
00111   std::istringstream is(paramString);
00112   is >> vx >> vy >> vz >> unts;
00113   G4String unt = unts;
00114   return ValueOf(unt);
00115 }

void G4UIcmdWith3VectorAndUnit::SetDefaultUnit ( const char *  defUnit  ) 

Definition at line 182 of file G4UIcmdWith3VectorAndUnit.cc.

References G4UIcommand::CategoryOf(), G4UIcommand::GetParameter(), G4UIparameter::SetDefaultValue(), G4UIparameter::SetOmittable(), and SetUnitCategory().

Referenced by G4GeometryMessenger::G4GeometryMessenger(), G4MatScanMessenger::G4MatScanMessenger(), G4ParticleGunMessenger::G4ParticleGunMessenger(), G4ScoringMessenger::G4ScoringMessenger(), and G4GenericMessenger::Command::SetUnit().

00183 {
00184   G4UIparameter * untParam = GetParameter(3);
00185   untParam->SetOmittable(true);
00186   untParam->SetDefaultValue(defUnit);
00187   SetUnitCategory(CategoryOf(defUnit));
00188 }

void G4UIcmdWith3VectorAndUnit::SetDefaultValue ( G4ThreeVector  defVal  ) 

Definition at line 160 of file G4UIcmdWith3VectorAndUnit.cc.

References G4UIcommand::GetParameter(), and G4UIparameter::SetDefaultValue().

Referenced by G4MatScanMessenger::G4MatScanMessenger().

00161 {
00162   G4UIparameter * theParamX = GetParameter(0);
00163   theParamX->SetDefaultValue(vec.x());
00164   G4UIparameter * theParamY = GetParameter(1);
00165   theParamY->SetDefaultValue(vec.y());
00166   G4UIparameter * theParamZ = GetParameter(2);
00167   theParamZ->SetDefaultValue(vec.z());
00168 }

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

Definition at line 143 of file G4UIcmdWith3VectorAndUnit.cc.

References G4UIparameter::SetCurrentAsDefault(), G4UIparameter::SetOmittable(), and G4UIparameter::SetParameterName().

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

00145 {
00146   G4UIparameter * theParamX = GetParameter(0);
00147   theParamX->SetParameterName(theNameX);
00148   theParamX->SetOmittable(omittable);
00149   theParamX->SetCurrentAsDefault(currentAsDefault);
00150   G4UIparameter * theParamY = GetParameter(1);
00151   theParamY->SetParameterName(theNameY);
00152   theParamY->SetOmittable(omittable);
00153   theParamY->SetCurrentAsDefault(currentAsDefault);
00154   G4UIparameter * theParamZ = GetParameter(2);
00155   theParamZ->SetParameterName(theNameZ);
00156   theParamZ->SetOmittable(omittable);
00157   theParamZ->SetCurrentAsDefault(currentAsDefault);
00158 }

void G4UIcmdWith3VectorAndUnit::SetUnitCandidates ( const char *  candidateList  ) 

Definition at line 175 of file G4UIcmdWith3VectorAndUnit.cc.

References G4UIcommand::GetParameter(), and G4UIparameter::SetParameterCandidates().

Referenced by SetUnitCategory().

00176 {
00177   G4UIparameter * untParam = GetParameter(3);
00178   G4String canList = candidateList;
00179   untParam->SetParameterCandidates(canList);
00180 }

void G4UIcmdWith3VectorAndUnit::SetUnitCategory ( const char *  unitCategory  ) 

Definition at line 170 of file G4UIcmdWith3VectorAndUnit.cc.

References SetUnitCandidates(), and G4UIcommand::UnitsList().

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

00171 {
00172   SetUnitCandidates(UnitsList(unitCategory));
00173 }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:53:36 2013 for Geant4 by  doxygen 1.4.7