Import Geant4 6.2.0 source tree
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# $Id: GNUmakefile,v 1.1 1999/01/07 16:09:20 gunter Exp $
|
||||
# $Id: GNUmakefile,v 1.2 2004/06/01 15:36:48 gcosmo Exp $
|
||||
# -------------------------------------------------------------
|
||||
# GNUmakefile for intercoms library. Gabriele Cosmo, 11/11/96.
|
||||
# -------------------------------------------------------------
|
||||
@@ -9,6 +9,8 @@ ifndef G4INSTALL
|
||||
G4INSTALL = ../..
|
||||
endif
|
||||
|
||||
GLOBLIBS = libG4global.lib
|
||||
|
||||
include $(G4INSTALL)/config/architecture.gmk
|
||||
|
||||
CPPFLAGS += -I$(G4BASE)/global/management/include \
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$Id: History,v 1.54 2003/06/07 16:41:03 gcosmo Exp $
|
||||
$Id: History,v 1.57 2004/06/07 13:28:55 gcosmo Exp $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
@@ -17,6 +17,18 @@ committal in the CVS repository !
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
|
||||
Jun 7, 2004, G.Cosmo (intercoms-V06-01-02)
|
||||
- GNUmakefile: added definition of GLOBLIBS for DLLs support on Windows.
|
||||
|
||||
May 16, 2004, M.Asai (intercoms-V06-01-01)
|
||||
- Introducing utility methods ConvertToStringWithBestUnit() and
|
||||
ConvertToStringWithDefaultUnit() for command classes taking a unit parameter.
|
||||
|
||||
May 16, 2004, M.Asai (intercoms-V06-01-00)
|
||||
- Introducing static methods in G4UIcommand class for conversion between
|
||||
a string and a value. Some implementation of derived classes are modified
|
||||
accordingly.
|
||||
|
||||
Jun 07, 2003, G.Cosmo (intercoms-V05-01-02)
|
||||
- G4UItokenNum.hh: corrected implementation of operator=().
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcmdWith3Vector.hh,v 1.5 2002/04/26 22:03:35 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-05-02-patch-01 $
|
||||
// $Id: G4UIcmdWith3Vector.hh,v 1.6 2004/05/16 18:42:29 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-06-02 $
|
||||
//
|
||||
//
|
||||
|
||||
@@ -44,13 +44,9 @@ class G4UIcmdWith3Vector : public G4UIcommand
|
||||
(const char * theCommandPath,G4UImessenger * theMessenger);
|
||||
// Constructor. The command string with full path directory
|
||||
// and the pointer to the messenger must be given.
|
||||
G4ThreeVector GetNew3VectorValue(const char* paramString);
|
||||
static G4ThreeVector GetNew3VectorValue(const char* paramString);
|
||||
// Convert string which represents three double values to
|
||||
// G4ThreeVector.
|
||||
G4String ConvertToString(G4ThreeVector vec);
|
||||
// Convert G4ThreeVector to a string which represents three
|
||||
// double values. This method must be used by the messenger
|
||||
// for its GetCurrentValues() method.
|
||||
void SetParameterName(const char * theNameX,const char * theNameY,
|
||||
const char * theNameZ,G4bool omittable,G4bool currentAsDefault=false);
|
||||
// Set the parameter names for three parameters. Names are used by
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcmdWith3VectorAndUnit.hh,v 1.5 2002/04/26 22:03:35 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-05-02-patch-01 $
|
||||
// $Id: G4UIcmdWith3VectorAndUnit.hh,v 1.7 2004/05/16 20:42:37 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-06-02 $
|
||||
//
|
||||
//
|
||||
|
||||
@@ -44,21 +44,24 @@ class G4UIcmdWith3VectorAndUnit : public G4UIcommand
|
||||
(const char * theCommandPath,G4UImessenger * theMessenger);
|
||||
// Constructor. The command string with full path directory
|
||||
// and the pointer to the messenger must be given.
|
||||
G4ThreeVector GetNew3VectorValue(const char* paramString);
|
||||
static G4ThreeVector GetNew3VectorValue(const char* paramString);
|
||||
// Convert string which represents three double values and a unit to
|
||||
// G4ThreeVector. Values are converted to the Geant4 internal unit.
|
||||
G4ThreeVector GetNew3VectorRawValue(const char* paramString);
|
||||
static G4ThreeVector GetNew3VectorRawValue(const char* paramString);
|
||||
// Convert string which represents three double values and a unit to
|
||||
// G4ThreeVector. Values are NOT converted to the Geant4 internal unit
|
||||
// but just as the given string.
|
||||
G4double GetNewUnitValue(const char* paramString);
|
||||
static G4double GetNewUnitValue(const char* paramString);
|
||||
// Convert the unit string to the value of the unit. "paramString"
|
||||
// must contain three double values AND a unit string.
|
||||
G4String ConvertToString(G4ThreeVector vec,const char * unitName);
|
||||
// Convert G4ThreeVector and the unit to a string which represents three
|
||||
// double values and the unit. This method must be used by the messenger
|
||||
// for its GetCurrentValues() method. Values of the three vector will be
|
||||
// devided by the value of the unit.
|
||||
G4String ConvertToStringWithBestUnit(G4ThreeVector vec);
|
||||
// Convert a 3 vector value to a string of digits and unit. Best unit is
|
||||
// chosen from the unit category of default unit (in case SetDefaultUnit()
|
||||
// is defined) or category defined by SetUnitCategory().
|
||||
G4String ConvertToStringWithDefaultUnit(G4ThreeVector vec);
|
||||
// Convert a 3 vector value to a string of digits and unit. Best unit is
|
||||
// chosen from the category defined by SetUnitCategory() in case default
|
||||
// unit is not defined.
|
||||
void SetParameterName(const char * theNameX,const char * theNameY,
|
||||
const char * theNameZ,G4bool omittable,G4bool currentAsDefault=false);
|
||||
// Set the parameter names for three parameters. Names are used by
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcmdWithABool.hh,v 1.5 2002/04/26 22:03:35 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-05-02-patch-01 $
|
||||
// $Id: G4UIcmdWithABool.hh,v 1.6 2004/05/16 18:42:30 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-06-02 $
|
||||
//
|
||||
//
|
||||
|
||||
@@ -47,11 +47,8 @@ class G4UIcmdWithABool : public G4UIcommand
|
||||
(const char * theCommandPath,G4UImessenger * theMessenger);
|
||||
// Constructor. The command string with full path directory
|
||||
// and the pointer to the messenger must be given.
|
||||
G4bool GetNewBoolValue(const char* paramString);
|
||||
static G4bool GetNewBoolValue(const char* paramString);
|
||||
// Convert string which represents a boolean value to G4bool.
|
||||
G4String ConvertToString(G4bool intValue);
|
||||
// Convert a boolean value to a string. This method must be used by
|
||||
// the messenger for its GetCurrentValues() method.
|
||||
void SetParameterName(const char * theName,G4bool omittable,
|
||||
G4bool currentAsDefault=false);
|
||||
// Set the parameter name for a boolean parameter.
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcmdWithADouble.hh,v 1.5 2002/04/26 22:03:35 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-05-02-patch-01 $
|
||||
// $Id: G4UIcmdWithADouble.hh,v 1.6 2004/05/16 18:42:30 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-06-02 $
|
||||
//
|
||||
//
|
||||
|
||||
@@ -43,11 +43,8 @@ class G4UIcmdWithADouble : public G4UIcommand
|
||||
(const char * theCommandPath,G4UImessenger * theMessenger);
|
||||
// Constructor. The command string with full path directory
|
||||
// and the pointer to the messenger must be given.
|
||||
G4double GetNewDoubleValue(const char* paramString);
|
||||
static G4double GetNewDoubleValue(const char* paramString);
|
||||
// Convert string which represents a double value to a double.
|
||||
G4String ConvertToString(G4double dblValue);
|
||||
// Convert a double value to a string. This method must be used by
|
||||
// the messenger for its GetCurrentValues() method.
|
||||
void SetParameterName(const char * theName,G4bool omittable,
|
||||
G4bool currentAsDefault=false);
|
||||
// Set the parameter name. The name is used by the range checking.
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcmdWithADoubleAndUnit.hh,v 1.5 2002/04/26 22:03:35 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-05-02-patch-01 $
|
||||
// $Id: G4UIcmdWithADoubleAndUnit.hh,v 1.7 2004/05/16 20:42:37 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-06-02 $
|
||||
//
|
||||
//
|
||||
|
||||
@@ -43,21 +43,24 @@ class G4UIcmdWithADoubleAndUnit : public G4UIcommand
|
||||
(const char * theCommandPath,G4UImessenger * theMessenger);
|
||||
// Constructor. The command string with full path directory
|
||||
// and the pointer to the messenger must be given.
|
||||
G4double GetNewDoubleValue(const char* paramString);
|
||||
static G4double GetNewDoubleValue(const char* paramString);
|
||||
// Convert string which represents a double value and a unit to
|
||||
// double. Value is converted to the Geant4 internal unit.
|
||||
G4double GetNewDoubleRawValue(const char* paramString);
|
||||
static G4double GetNewDoubleRawValue(const char* paramString);
|
||||
// Convert string which represents a double value and a unit to
|
||||
// double. Value is NOT converted to the Geant4 internal unit
|
||||
// but just as the given string.
|
||||
G4double GetNewUnitValue(const char* paramString);
|
||||
static G4double GetNewUnitValue(const char* paramString);
|
||||
// Convert the unit string to the value of the unit. "paramString"
|
||||
// must contain a double value AND a unit string.
|
||||
G4String ConvertToString(G4double dblValue,const char * unitName);
|
||||
// Convert a double value and the unit to a string which represents a
|
||||
// double value and the unit. This method must be used by the messenger
|
||||
// for its GetCurrentValues() method. Value of the double will be
|
||||
// devided by the value of the unit.
|
||||
G4String ConvertToStringWithBestUnit(G4double val);
|
||||
// Convert a double value to a string of digits and unit. Best unit is
|
||||
// chosen from the unit category of default unit (in case SetDefaultUnit()
|
||||
// is defined) or category defined by SetUnitCategory().
|
||||
G4String ConvertToStringWithDefaultUnit(G4double val);
|
||||
// Convert a double value to a string of digits and unit. Best unit is
|
||||
// chosen from the category defined by SetUnitCategory() in case default
|
||||
// unit is not defined.
|
||||
void SetParameterName(const char * theName,G4bool omittable,
|
||||
G4bool currentAsDefault=false);
|
||||
// Set the parameter name for double parameterxs. Name is used by
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcmdWithAnInteger.hh,v 1.5 2002/04/26 22:03:35 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-05-02-patch-01 $
|
||||
// $Id: G4UIcmdWithAnInteger.hh,v 1.6 2004/05/16 18:42:30 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-06-02 $
|
||||
//
|
||||
//
|
||||
|
||||
@@ -43,11 +43,8 @@ class G4UIcmdWithAnInteger : public G4UIcommand
|
||||
(const char * theCommandPath,G4UImessenger * theMessenger);
|
||||
// Constructor. The command string with full path directory
|
||||
// and the pointer to the messenger must be given.
|
||||
G4int GetNewIntValue(const char* paramString);
|
||||
static G4int GetNewIntValue(const char* paramString);
|
||||
// Convert string which represents an integer to an integer.
|
||||
G4String ConvertToString(G4int intValue);
|
||||
// Convert an integer value to a string. This method must be used by
|
||||
// the messenger for its GetCurrentValues() method.
|
||||
void SetParameterName(const char * theName,G4bool omittable,
|
||||
G4bool currentAsDefault=false);
|
||||
// Set the parameter name. The name is used by the range checking.
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcommand.hh,v 1.13 2003/06/16 16:55:32 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-05-02-patch-01 $
|
||||
// $Id: G4UIcommand.hh,v 1.14 2004/05/16 18:42:30 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-06-02 $
|
||||
//
|
||||
//
|
||||
|
||||
@@ -35,6 +35,7 @@ class G4UImessenger;
|
||||
#include "G4ApplicationState.hh"
|
||||
#include <vector>
|
||||
#include "G4UItokenNum.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
|
||||
// class description:
|
||||
//
|
||||
@@ -78,10 +79,30 @@ class G4UIcommand
|
||||
G4bool IsAvailable();
|
||||
virtual void List();
|
||||
|
||||
public:
|
||||
public: // with description
|
||||
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 methods for conversion from value(s) to a string. These methods are to be
|
||||
// used by GetCurrentValues() methods of concrete messengers.
|
||||
|
||||
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 methods for conversion from a string to a value of the returning type.
|
||||
// These methods are to be used directly by SetNewValues() methods of concrete
|
||||
// messengers, or GetNewXXXValue() of classes derived from this G4UIcommand class.
|
||||
|
||||
static G4double ValueOf(const char* unitName);
|
||||
static G4String CategoryOf(const char* unitName);
|
||||
static G4String UnitsList(const char* unitCategory);
|
||||
// Static methods for unit and its category.
|
||||
|
||||
private:
|
||||
void G4UIcommandCommonConstructorCode (const char * theCommandPath);
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcmdWith3Vector.cc,v 1.5 2003/06/16 16:55:36 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-05-02-patch-01 $
|
||||
// $Id: G4UIcmdWith3Vector.cc,v 1.6 2004/05/16 18:42:30 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-06-02 $
|
||||
//
|
||||
//
|
||||
|
||||
@@ -43,21 +43,7 @@ G4UIcmdWith3Vector::G4UIcmdWith3Vector
|
||||
|
||||
G4ThreeVector G4UIcmdWith3Vector::GetNew3VectorValue(const char* paramString)
|
||||
{
|
||||
G4double vx;
|
||||
G4double vy;
|
||||
G4double vz;
|
||||
std::istrstream is((char*)paramString);
|
||||
is >> vx >> vy >> vz;
|
||||
return G4ThreeVector(vx,vy,vz);
|
||||
}
|
||||
|
||||
G4String G4UIcmdWith3Vector::ConvertToString(G4ThreeVector vec)
|
||||
{
|
||||
char st[100];
|
||||
std::ostrstream os(st,100);
|
||||
os << vec.x() << " " << vec.y() << " " << vec.z() << '\0';
|
||||
G4String vl = st;
|
||||
return vl;
|
||||
return ConvertTo3Vector(paramString);
|
||||
}
|
||||
|
||||
void G4UIcmdWith3Vector::SetParameterName
|
||||
|
||||
@@ -21,12 +21,14 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcmdWith3VectorAndUnit.cc,v 1.5 2003/06/16 16:55:37 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-05-02-patch-01 $
|
||||
// $Id: G4UIcmdWith3VectorAndUnit.cc,v 1.7 2004/05/16 20:42:37 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-06-02 $
|
||||
//
|
||||
//
|
||||
|
||||
#include "G4UIcmdWith3VectorAndUnit.hh"
|
||||
#include "G4Tokenizer.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include <strstream>
|
||||
|
||||
G4UIcmdWith3VectorAndUnit::G4UIcmdWith3VectorAndUnit
|
||||
@@ -46,15 +48,7 @@ G4UIcmdWith3VectorAndUnit::G4UIcmdWith3VectorAndUnit
|
||||
|
||||
G4ThreeVector G4UIcmdWith3VectorAndUnit::GetNew3VectorValue(const char* paramString)
|
||||
{
|
||||
G4double vx;
|
||||
G4double vy;
|
||||
G4double vz;
|
||||
char unts[30];
|
||||
std::istrstream is((char*)paramString);
|
||||
is >> vx >> vy >> vz >> unts;
|
||||
G4String unt = unts;
|
||||
G4double uv = ValueOf(unt);
|
||||
return G4ThreeVector(vx*uv,vy*uv,vz*uv);
|
||||
return ConvertToDimensioned3Vector(paramString);
|
||||
}
|
||||
|
||||
G4ThreeVector G4UIcmdWith3VectorAndUnit::GetNew3VectorRawValue(const char* paramString)
|
||||
@@ -80,18 +74,29 @@ G4double G4UIcmdWith3VectorAndUnit::GetNewUnitValue(const char* paramString)
|
||||
return ValueOf(unt);
|
||||
}
|
||||
|
||||
G4String G4UIcmdWith3VectorAndUnit::ConvertToString
|
||||
(G4ThreeVector vec,const char * unitName)
|
||||
G4String G4UIcmdWith3VectorAndUnit::ConvertToStringWithBestUnit(G4ThreeVector vec)
|
||||
{
|
||||
G4String unt = unitName;
|
||||
G4double uv = ValueOf(unitName);
|
||||
|
||||
char st[100];
|
||||
std::ostrstream os(st,100);
|
||||
os << vec.x()/uv << " " << vec.y()/uv << " " << vec.z()/uv
|
||||
<< " " << unitName << '\0';
|
||||
G4String vl = st;
|
||||
return vl;
|
||||
G4UIparameter* unitParam = GetParameter(3);
|
||||
G4String canList = unitParam->GetParameterCandidates();
|
||||
G4Tokenizer candidateTokenizer(canList);
|
||||
G4String aToken = candidateTokenizer();
|
||||
char strg[120];
|
||||
std::ostrstream os(strg,120);
|
||||
os << G4BestUnit(vec,CategoryOf(aToken)) << '\0';
|
||||
|
||||
G4String st = strg;
|
||||
return st;
|
||||
}
|
||||
|
||||
G4String G4UIcmdWith3VectorAndUnit::ConvertToStringWithDefaultUnit(G4ThreeVector vec)
|
||||
{
|
||||
G4UIparameter* unitParam = GetParameter(3);
|
||||
G4String st;
|
||||
if(unitParam->IsOmittable())
|
||||
{ st = ConvertToString(vec,unitParam->GetDefaultValue()); }
|
||||
else
|
||||
{ st = ConvertToStringWithBestUnit(vec); }
|
||||
return st;
|
||||
}
|
||||
|
||||
void G4UIcmdWith3VectorAndUnit::SetParameterName
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcmdWithABool.cc,v 1.5 2003/06/16 16:55:38 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-05-02-patch-01 $
|
||||
// $Id: G4UIcmdWithABool.cc,v 1.6 2004/05/16 18:42:30 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-06-02 $
|
||||
//
|
||||
//
|
||||
|
||||
@@ -39,19 +39,7 @@ G4UIcmdWithABool::G4UIcmdWithABool
|
||||
|
||||
G4bool G4UIcmdWithABool::GetNewBoolValue(const char* paramString)
|
||||
{
|
||||
G4String v = paramString;
|
||||
v.toUpper();
|
||||
G4bool vl = false;
|
||||
if( v=="Y" || v=="YES" || v=="1" || v=="T" || v=="TRUE" )
|
||||
{ vl = true; }
|
||||
return vl;
|
||||
}
|
||||
|
||||
G4String G4UIcmdWithABool::ConvertToString(G4bool blValue)
|
||||
{
|
||||
G4String vl = "0";
|
||||
if(blValue) vl = "1";
|
||||
return vl;
|
||||
return ConvertToBool(paramString);
|
||||
}
|
||||
|
||||
void G4UIcmdWithABool::SetParameterName
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcmdWithADouble.cc,v 1.5 2003/06/16 16:55:39 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-05-02-patch-01 $
|
||||
// $Id: G4UIcmdWithADouble.cc,v 1.6 2004/05/16 18:42:30 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-06-02 $
|
||||
//
|
||||
//
|
||||
|
||||
@@ -39,19 +39,7 @@ G4UIcmdWithADouble::G4UIcmdWithADouble
|
||||
|
||||
G4double G4UIcmdWithADouble::GetNewDoubleValue(const char* paramString)
|
||||
{
|
||||
G4double vl;
|
||||
std::istrstream is((char*)paramString);
|
||||
is >> vl;
|
||||
return vl;
|
||||
}
|
||||
|
||||
G4String G4UIcmdWithADouble::ConvertToString(G4double dblValue)
|
||||
{
|
||||
char st[20];
|
||||
std::ostrstream os(st,20);
|
||||
os << dblValue << '\0';
|
||||
G4String vl = st;
|
||||
return vl;
|
||||
return ConvertToDouble(paramString);
|
||||
}
|
||||
|
||||
void G4UIcmdWithADouble::SetParameterName
|
||||
|
||||
@@ -21,12 +21,14 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcmdWithADoubleAndUnit.cc,v 1.5 2003/06/16 16:55:40 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-05-02-patch-01 $
|
||||
// $Id: G4UIcmdWithADoubleAndUnit.cc,v 1.7 2004/05/16 20:42:37 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-06-02 $
|
||||
//
|
||||
//
|
||||
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
#include "G4Tokenizer.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include <strstream>
|
||||
|
||||
G4UIcmdWithADoubleAndUnit::G4UIcmdWithADoubleAndUnit
|
||||
@@ -42,14 +44,7 @@ G4UIcmdWithADoubleAndUnit::G4UIcmdWithADoubleAndUnit
|
||||
|
||||
G4double G4UIcmdWithADoubleAndUnit::GetNewDoubleValue(const char* paramString)
|
||||
{
|
||||
G4double vl;
|
||||
char unts[30];
|
||||
|
||||
std::istrstream is((char*)paramString);
|
||||
is >> vl >> unts;
|
||||
G4String unt = unts;
|
||||
|
||||
return (vl*ValueOf(unt));
|
||||
return ConvertToDimensionedDouble(paramString);
|
||||
}
|
||||
|
||||
G4double G4UIcmdWithADoubleAndUnit::GetNewDoubleRawValue(const char* paramString)
|
||||
@@ -75,17 +70,29 @@ G4double G4UIcmdWithADoubleAndUnit::GetNewUnitValue(const char* paramString)
|
||||
return ValueOf(unt);
|
||||
}
|
||||
|
||||
G4String G4UIcmdWithADoubleAndUnit::ConvertToString
|
||||
(G4double dblValue,const char * unitName)
|
||||
G4String G4UIcmdWithADoubleAndUnit::ConvertToStringWithBestUnit(G4double val)
|
||||
{
|
||||
G4String unt = unitName;
|
||||
G4double uv = ValueOf(unitName);
|
||||
|
||||
char st[50];
|
||||
std::ostrstream os(st,50);
|
||||
os << dblValue/uv << " " << unitName << '\0';
|
||||
G4String vl = st;
|
||||
return vl;
|
||||
G4UIparameter* unitParam = GetParameter(1);
|
||||
G4String canList = unitParam->GetParameterCandidates();
|
||||
G4Tokenizer candidateTokenizer(canList);
|
||||
G4String aToken = candidateTokenizer();
|
||||
char strg[60];
|
||||
std::ostrstream os(strg,60);
|
||||
os << G4BestUnit(val,CategoryOf(aToken)) << '\0';
|
||||
|
||||
G4String st = strg;
|
||||
return st;
|
||||
}
|
||||
|
||||
G4String G4UIcmdWithADoubleAndUnit::ConvertToStringWithDefaultUnit(G4double val)
|
||||
{
|
||||
G4UIparameter* unitParam = GetParameter(1);
|
||||
G4String st;
|
||||
if(unitParam->IsOmittable())
|
||||
{ st = ConvertToString(val,unitParam->GetDefaultValue()); }
|
||||
else
|
||||
{ st = ConvertToStringWithBestUnit(val); }
|
||||
return st;
|
||||
}
|
||||
|
||||
void G4UIcmdWithADoubleAndUnit::SetParameterName
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcmdWithAnInteger.cc,v 1.5 2003/06/16 16:55:42 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-05-02-patch-01 $
|
||||
// $Id: G4UIcmdWithAnInteger.cc,v 1.6 2004/05/16 18:42:30 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-06-02 $
|
||||
//
|
||||
//
|
||||
|
||||
@@ -39,19 +39,7 @@ G4UIcmdWithAnInteger::G4UIcmdWithAnInteger
|
||||
|
||||
G4int G4UIcmdWithAnInteger::GetNewIntValue(const char* paramString)
|
||||
{
|
||||
G4int vl;
|
||||
std::istrstream is((char*)paramString);
|
||||
is >> vl;
|
||||
return vl;
|
||||
}
|
||||
|
||||
G4String G4UIcmdWithAnInteger::ConvertToString(G4int intValue)
|
||||
{
|
||||
char st[20];
|
||||
std::ostrstream os(st,20);
|
||||
os << intValue << '\0';
|
||||
G4String vl = st;
|
||||
return vl;
|
||||
return ConvertToInt(paramString);
|
||||
}
|
||||
|
||||
void G4UIcmdWithAnInteger::SetParameterName
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcommand.cc,v 1.22 2003/06/16 16:55:43 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-05-02-patch-01 $
|
||||
// $Id: G4UIcommand.cc,v 1.23 2004/05/16 18:42:30 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-06-02 $
|
||||
//
|
||||
//
|
||||
|
||||
@@ -342,6 +342,127 @@ void G4UIcommand::List()
|
||||
G4cout << G4endl;
|
||||
}
|
||||
|
||||
G4String G4UIcommand::ConvertToString(G4bool boolVal)
|
||||
{
|
||||
G4String vl = "0";
|
||||
if(boolVal) vl = "1";
|
||||
return vl;
|
||||
}
|
||||
|
||||
G4String G4UIcommand::ConvertToString(G4int intValue)
|
||||
{
|
||||
char st[20];
|
||||
std::ostrstream os(st,20);
|
||||
os << intValue << '\0';
|
||||
G4String vl = st;
|
||||
return vl;
|
||||
}
|
||||
|
||||
G4String G4UIcommand::ConvertToString(G4double doubleValue)
|
||||
{
|
||||
char st[40];
|
||||
std::ostrstream os(st,40);
|
||||
os << doubleValue << '\0';
|
||||
G4String vl = st;
|
||||
return vl;
|
||||
}
|
||||
|
||||
G4String G4UIcommand::ConvertToString(G4double doubleValue,const char* unitName)
|
||||
{
|
||||
G4String unt = unitName;
|
||||
G4double uv = ValueOf(unitName);
|
||||
|
||||
char st[60];
|
||||
std::ostrstream os(st,60);
|
||||
os << doubleValue/uv << " " << unitName << '\0';
|
||||
G4String vl = st;
|
||||
return vl;
|
||||
}
|
||||
|
||||
G4String G4UIcommand::ConvertToString(G4ThreeVector vec)
|
||||
{
|
||||
char st[100];
|
||||
std::ostrstream os(st,100);
|
||||
os << vec.x() << " " << vec.y() << " " << vec.z() << '\0';
|
||||
G4String vl = st;
|
||||
return vl;
|
||||
}
|
||||
|
||||
G4String G4UIcommand::ConvertToString(G4ThreeVector vec,const char* unitName)
|
||||
{
|
||||
G4String unt = unitName;
|
||||
G4double uv = ValueOf(unitName);
|
||||
|
||||
char st[120];
|
||||
std::ostrstream os(st,120);
|
||||
os << vec.x()/uv << " " << vec.y()/uv << " " << vec.z()/uv
|
||||
<< " " << unitName << '\0';
|
||||
G4String vl = st;
|
||||
return vl;
|
||||
}
|
||||
|
||||
G4bool G4UIcommand::ConvertToBool(const char* st)
|
||||
{
|
||||
G4String v = st;
|
||||
v.toUpper();
|
||||
G4bool vl = false;
|
||||
if( v=="Y" || v=="YES" || v=="1" || v=="T" || v=="TRUE" )
|
||||
{ vl = true; }
|
||||
return vl;
|
||||
}
|
||||
|
||||
G4int G4UIcommand::ConvertToInt(const char* st)
|
||||
{
|
||||
G4int vl;
|
||||
std::istrstream is((char*)st);
|
||||
is >> vl;
|
||||
return vl;
|
||||
}
|
||||
|
||||
G4double G4UIcommand::ConvertToDouble(const char* st)
|
||||
{
|
||||
G4double vl;
|
||||
std::istrstream is((char*)st);
|
||||
is >> vl;
|
||||
return vl;
|
||||
}
|
||||
|
||||
G4double G4UIcommand::ConvertToDimensionedDouble(const char* st)
|
||||
{
|
||||
G4double vl;
|
||||
char unts[30];
|
||||
|
||||
std::istrstream is((char*)st);
|
||||
is >> vl >> unts;
|
||||
G4String unt = unts;
|
||||
|
||||
return (vl*ValueOf(unt));
|
||||
}
|
||||
|
||||
G4ThreeVector G4UIcommand::ConvertTo3Vector(const char* st)
|
||||
{
|
||||
G4double vx;
|
||||
G4double vy;
|
||||
G4double vz;
|
||||
std::istrstream is((char*)st);
|
||||
is >> vx >> vy >> vz;
|
||||
return G4ThreeVector(vx,vy,vz);
|
||||
}
|
||||
|
||||
G4ThreeVector G4UIcommand::ConvertToDimensioned3Vector(const char* st)
|
||||
{
|
||||
G4double vx;
|
||||
G4double vy;
|
||||
G4double vz;
|
||||
char unts[30];
|
||||
std::istrstream is((char*)st);
|
||||
is >> vx >> vy >> vz >> unts;
|
||||
G4String unt = unts;
|
||||
G4double uv = ValueOf(unt);
|
||||
return G4ThreeVector(vx*uv,vy*uv,vz*uv);
|
||||
}
|
||||
|
||||
|
||||
// ----- the following is used by CheckNewValue() ------------
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user