Import Geant4 6.2.0 source tree
This commit is contained in:
@@ -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