Import Geant4 4.0.0 source tree
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIaliasList.cc,v 1.4 2001/10/16 08:14:32 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-00 $
|
||||
//
|
||||
|
||||
#include "G4UIaliasList.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
G4UIaliasList::G4UIaliasList()
|
||||
{ }
|
||||
|
||||
G4UIaliasList::~G4UIaliasList()
|
||||
{
|
||||
G4int i;
|
||||
G4int n_treeEntry = alias.size();
|
||||
for( i=0; i < n_treeEntry; i++ )
|
||||
{ delete alias[i];
|
||||
delete value[i]; }
|
||||
}
|
||||
|
||||
G4int G4UIaliasList::operator==(const G4UIaliasList &right) const
|
||||
{
|
||||
return ( this == &right );
|
||||
}
|
||||
|
||||
G4int G4UIaliasList::operator!=(const G4UIaliasList &right) const
|
||||
{
|
||||
return ( this != &right );
|
||||
}
|
||||
|
||||
void G4UIaliasList::AddNewAlias(G4String aliasName, G4String aliasValue)
|
||||
{
|
||||
if(FindAlias(aliasName))
|
||||
{
|
||||
G4cerr << "Alias <" << aliasName << "> already exist. Command ignored."
|
||||
<< G4endl;
|
||||
return;
|
||||
}
|
||||
G4String* newAlias = new G4String(aliasName);
|
||||
alias.push_back(newAlias);
|
||||
G4String* newValue = new G4String(aliasValue);
|
||||
value.push_back(newValue);
|
||||
}
|
||||
|
||||
void G4UIaliasList::RemoveAlias(G4String aliasName)
|
||||
{
|
||||
G4int i = FindAliasID(aliasName);
|
||||
if(i<0)
|
||||
{
|
||||
G4cerr << "Alias <" << aliasName << "> does not exist. Command ignored."
|
||||
<< G4endl;
|
||||
return;
|
||||
}
|
||||
alias.erase(alias.begin()+i);
|
||||
value.erase(value.begin()+i);
|
||||
}
|
||||
|
||||
void G4UIaliasList::ChangeAlias(G4String aliasName, G4String aliasValue)
|
||||
{
|
||||
G4int i = FindAliasID(aliasName);
|
||||
if(i<0)
|
||||
{
|
||||
AddNewAlias(aliasName,aliasValue);
|
||||
return;
|
||||
}
|
||||
*(value[i]) = aliasValue;
|
||||
}
|
||||
|
||||
G4String* G4UIaliasList::FindAlias(G4String aliasName)
|
||||
{
|
||||
G4int i = FindAliasID(aliasName);
|
||||
if(i<0)
|
||||
{ return 0; }
|
||||
return value[i];
|
||||
}
|
||||
|
||||
G4int G4UIaliasList::FindAliasID(G4String aliasName)
|
||||
{
|
||||
G4int i_entry = alias.size();
|
||||
for(G4int i=0;i<i_entry;i++)
|
||||
{ if(*(alias[i])==aliasName) return i; }
|
||||
return -1;
|
||||
}
|
||||
|
||||
void G4UIaliasList::List()
|
||||
{
|
||||
G4int i_entry = alias.size();
|
||||
for(G4int i1=0;i1<i_entry-1;i1++)
|
||||
for(G4int i2=i1+1;i2<i_entry;i2++)
|
||||
{
|
||||
if(*(alias[i1])>*(alias[i2]))
|
||||
{
|
||||
G4String* tmp = alias[i1];
|
||||
alias[i1] = alias[i2];
|
||||
alias[i2] = tmp;
|
||||
tmp = value[i1];
|
||||
value[i1] = value[i2];
|
||||
value[i2] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
for(G4int i=0;i<i_entry;i++)
|
||||
{ G4cout << " " << *(alias[i]) << " : " << *(value[i]) << G4endl; }
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIbatch.cc,v 1.3.2.1 2001/06/28 19:10:17 gunter Exp $
|
||||
// GEANT4 tag $Name: $
|
||||
// $Id: G4UIbatch.cc,v 1.9 2001/10/16 08:14:32 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-00 $
|
||||
//
|
||||
|
||||
#include "G4UIbatch.hh"
|
||||
@@ -55,7 +55,7 @@ G4UIsession * G4UIbatch::SessionStart()
|
||||
if(!openFailed)
|
||||
{
|
||||
char commandLine[256];
|
||||
int lineLength = 255;
|
||||
G4int lineLength = 255;
|
||||
|
||||
while(1)
|
||||
{
|
||||
@@ -67,10 +67,39 @@ G4UIsession * G4UIbatch::SessionStart()
|
||||
}
|
||||
if( macroFile.eof() ) break;
|
||||
commandLine[lineLength] = '\0';
|
||||
if( commandLine[0] != '#' )
|
||||
{ UImanager->ApplyCommand(commandLine); }
|
||||
G4String commandString = commandLine;
|
||||
G4String nC= commandString.strip(G4String::both);
|
||||
if( commandLine[0] == '#')
|
||||
{ if(G4UImanager::GetUIpointer()->GetVerboseLevel()==2)
|
||||
{ G4cout << commandLine << G4endl; }
|
||||
}
|
||||
else if( nC.length() == 0 )
|
||||
{ continue; }
|
||||
else if(nC == "exit")
|
||||
{ break; }
|
||||
else
|
||||
{ G4cout << commandLine << G4endl; }
|
||||
{
|
||||
G4int rc = UImanager->ApplyCommand(commandLine);
|
||||
if(rc)
|
||||
{
|
||||
switch(rc)
|
||||
{
|
||||
case fCommandNotFound:
|
||||
G4cerr << "***** COMMAND NOT FOUND <"
|
||||
<< commandLine << "> *****" << G4endl;
|
||||
break;
|
||||
case fIllegalApplicationState:
|
||||
G4cerr << "***** Illegal application state <"
|
||||
<< commandLine << "> *****" << G4endl;
|
||||
break;
|
||||
default:
|
||||
G4int pn = rc%100;
|
||||
G4cerr << "***** Illegal parameter (" << pn << ") <"
|
||||
<< commandLine << "> *****" << G4endl;
|
||||
}
|
||||
G4cerr << "***** Command ignored *****" << G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return previousSession;
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcmdWith3Vector.cc,v 1.2.4.1 2001/06/28 19:10:17 gunter Exp $
|
||||
// GEANT4 tag $Name: $
|
||||
// $Id: G4UIcmdWith3Vector.cc,v 1.3 2001/07/11 10:01:16 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-04-00 $
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcmdWith3VectorAndUnit.cc,v 1.2.4.1 2001/06/28 19:10:17 gunter Exp $
|
||||
// GEANT4 tag $Name: $
|
||||
// $Id: G4UIcmdWith3VectorAndUnit.cc,v 1.3 2001/07/11 10:01:16 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-04-00 $
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcmdWithABool.cc,v 1.2.4.1 2001/06/28 19:10:17 gunter Exp $
|
||||
// GEANT4 tag $Name: $
|
||||
// $Id: G4UIcmdWithABool.cc,v 1.3 2001/07/11 10:01:16 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-04-00 $
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcmdWithADouble.cc,v 1.2.4.1 2001/06/28 19:10:17 gunter Exp $
|
||||
// GEANT4 tag $Name: $
|
||||
// $Id: G4UIcmdWithADouble.cc,v 1.3 2001/07/11 10:01:16 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-04-00 $
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcmdWithADoubleAndUnit.cc,v 1.2.4.1 2001/06/28 19:10:17 gunter Exp $
|
||||
// GEANT4 tag $Name: $
|
||||
// $Id: G4UIcmdWithADoubleAndUnit.cc,v 1.3 2001/07/11 10:01:16 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-04-00 $
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcmdWithAString.cc,v 1.2.4.1 2001/06/28 19:10:17 gunter Exp $
|
||||
// GEANT4 tag $Name: $
|
||||
// $Id: G4UIcmdWithAString.cc,v 1.3 2001/07/11 10:01:16 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-04-00 $
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcmdWithAnInteger.cc,v 1.2.4.1 2001/06/28 19:10:18 gunter Exp $
|
||||
// GEANT4 tag $Name: $
|
||||
// $Id: G4UIcmdWithAnInteger.cc,v 1.3 2001/07/11 10:01:16 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-04-00 $
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcmdWithoutParameter.cc,v 1.2.4.1 2001/06/28 19:10:18 gunter Exp $
|
||||
// GEANT4 tag $Name: $
|
||||
// $Id: G4UIcmdWithoutParameter.cc,v 1.3 2001/07/11 10:01:16 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-04-00 $
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcommand.cc,v 1.8.2.1 2001/06/28 19:10:18 gunter Exp $
|
||||
// GEANT4 tag $Name: $
|
||||
// $Id: G4UIcommand.cc,v 1.18 2001/10/23 07:51:36 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-00 $
|
||||
//
|
||||
//
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include "G4UIcommandStatus.hh"
|
||||
#include "G4StateManager.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "g4rw/ctoken.h"
|
||||
#include "G4Tokenizer.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
G4UIcommand::G4UIcommand():paramERR(0) { }
|
||||
@@ -60,6 +60,7 @@ G4UIcommand::G4UIcommand(const char * theCommandPath,
|
||||
availabelStateList.push_back(Idle);
|
||||
availabelStateList.push_back(GeomClosed);
|
||||
availabelStateList.push_back(EventProc);
|
||||
availabelStateList.push_back(Abort);
|
||||
}
|
||||
|
||||
void G4UIcommand::G4UIcommandCommonConstructorCode
|
||||
@@ -67,7 +68,7 @@ void G4UIcommand::G4UIcommandCommonConstructorCode
|
||||
{
|
||||
commandPath = theCommandPath;
|
||||
commandName = theCommandPath;
|
||||
int commandNameIndex = commandName.last('/');
|
||||
G4int commandNameIndex = commandName.last('/');
|
||||
commandName.remove(0,commandNameIndex+1);
|
||||
|
||||
G4UImanager::GetUIpointer()->AddNewCommand(this);
|
||||
@@ -78,18 +79,18 @@ G4UIcommand::~G4UIcommand()
|
||||
G4UImanager* fUImanager = G4UImanager::GetUIpointer();
|
||||
if(fUImanager) fUImanager->RemoveCommand(this);
|
||||
|
||||
int n_parameterEntry = parameter.size();
|
||||
for( int i_thParameter=0; i_thParameter < n_parameterEntry; i_thParameter++ )
|
||||
G4int n_parameterEntry = parameter.size();
|
||||
for( G4int i_thParameter=0; i_thParameter < n_parameterEntry; i_thParameter++ )
|
||||
{ delete parameter[i_thParameter]; }
|
||||
parameter.clear();
|
||||
}
|
||||
|
||||
int G4UIcommand::operator==(const G4UIcommand &right) const
|
||||
G4int G4UIcommand::operator==(const G4UIcommand &right) const
|
||||
{
|
||||
return ( commandPath == right.GetCommandPath() );
|
||||
}
|
||||
|
||||
int G4UIcommand::operator!=(const G4UIcommand &right) const
|
||||
G4int G4UIcommand::operator!=(const G4UIcommand &right) const
|
||||
{
|
||||
return ( commandPath != right.GetCommandPath() );
|
||||
}
|
||||
@@ -97,13 +98,13 @@ int G4UIcommand::operator!=(const G4UIcommand &right) const
|
||||
G4int G4UIcommand::DoIt(G4String parameterList)
|
||||
{
|
||||
G4String correctParameters;
|
||||
int n_parameterEntry = parameter.size();
|
||||
G4int n_parameterEntry = parameter.size();
|
||||
if( n_parameterEntry != 0 )
|
||||
{
|
||||
G4String aToken;
|
||||
G4String correctToken;
|
||||
G4Tokenizer parameterToken( parameterList );
|
||||
for( int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ )
|
||||
for( G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ )
|
||||
{
|
||||
if(i_thParameter > 0)
|
||||
{
|
||||
@@ -112,7 +113,8 @@ G4int G4UIcommand::DoIt(G4String parameterList)
|
||||
aToken = parameterToken();
|
||||
if( aToken.length()>0 && aToken(0)=='"' )
|
||||
{
|
||||
while( aToken(aToken.length()-1) != '"' )
|
||||
while( aToken(aToken.length()-1) != '"'
|
||||
|| ( aToken.length()==1 && aToken(0)=='"' ))
|
||||
{
|
||||
G4String additionalToken = parameterToken();
|
||||
if( additionalToken.isNull() )
|
||||
@@ -120,24 +122,58 @@ G4int G4UIcommand::DoIt(G4String parameterList)
|
||||
aToken += " ";
|
||||
aToken += additionalToken;
|
||||
}
|
||||
// aToken.strip(G4String::both,'"');
|
||||
}
|
||||
else if(i_thParameter==n_parameterEntry-1 && parameter[i_thParameter]->GetParameterType()=='s')
|
||||
{
|
||||
G4String anotherToken;
|
||||
while(!((anotherToken=parameterToken()).isNull()))
|
||||
{
|
||||
G4int idxs = anotherToken.index("#");
|
||||
if(idxs==G4int(G4std::string::npos))
|
||||
{
|
||||
aToken += " ";
|
||||
aToken += anotherToken;
|
||||
}
|
||||
else if(idxs>0)
|
||||
{
|
||||
aToken += " ";
|
||||
aToken += anotherToken(0,idxs);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{ break; }
|
||||
}
|
||||
}
|
||||
|
||||
if( aToken.isNull() || aToken == "!" )
|
||||
{
|
||||
if(parameter[i_thParameter]->IsOmittable())
|
||||
{
|
||||
if(parameter[i_thParameter]->GetCurrentAsDefault())
|
||||
{
|
||||
G4Tokenizer cvt(messenger->GetCurrentValue(this));
|
||||
G4Tokenizer cvSt(messenger->GetCurrentValue(this));
|
||||
G4String parVal;
|
||||
for(int ii=0;ii<i_thParameter;ii++)
|
||||
{ parVal = cvt(); }
|
||||
G4String aCVToken = cvt();
|
||||
for(G4int ii=0;ii<i_thParameter;ii++)
|
||||
{
|
||||
parVal = cvSt();
|
||||
if (parVal(0)=='"')
|
||||
{
|
||||
while( parVal(parVal.length()-1) != '"' )
|
||||
{
|
||||
G4String additionalToken = cvSt();
|
||||
if( additionalToken.isNull() )
|
||||
{ return fParameterUnreadable+i_thParameter; }
|
||||
parVal += " ";
|
||||
parVal += additionalToken;
|
||||
}
|
||||
}
|
||||
}
|
||||
G4String aCVToken = cvSt();
|
||||
if (aCVToken(0)=='"')
|
||||
{
|
||||
while( aCVToken(aCVToken.length()-1) != '"' )
|
||||
{
|
||||
G4String additionalToken = cvt();
|
||||
G4String additionalToken = cvSt();
|
||||
if( additionalToken.isNull() )
|
||||
{ return fParameterUnreadable+i_thParameter; }
|
||||
aCVToken += " ";
|
||||
@@ -155,7 +191,7 @@ G4int G4UIcommand::DoIt(G4String parameterList)
|
||||
}
|
||||
else
|
||||
{
|
||||
int stat = parameter[i_thParameter]->CheckNewValue( aToken );
|
||||
G4int stat = parameter[i_thParameter]->CheckNewValue( aToken );
|
||||
if(stat) return stat+i_thParameter;
|
||||
correctParameters.append(aToken);
|
||||
}
|
||||
@@ -230,8 +266,8 @@ G4bool G4UIcommand::IsAvailable()
|
||||
G4ApplicationState currentState
|
||||
= G4StateManager::GetStateManager()->GetCurrentState();
|
||||
|
||||
int nState = availabelStateList.size();
|
||||
for(int i=0;i<nState;i++)
|
||||
G4int nState = availabelStateList.size();
|
||||
for(G4int i=0;i<nState;i++)
|
||||
{
|
||||
if(availabelStateList[i]==currentState)
|
||||
{
|
||||
@@ -270,12 +306,12 @@ G4String G4UIcommand::UnitsList(G4String unitCategory)
|
||||
G4UnitsContainer& UCnt = UTbl[i]->GetUnitsList();
|
||||
retStr = UCnt[0]->GetSymbol();
|
||||
G4int je = UCnt.size();
|
||||
for(int j=1;j<je;j++)
|
||||
for(G4int j=1;j<je;j++)
|
||||
{
|
||||
retStr += " ";
|
||||
retStr += UCnt[j]->GetSymbol();
|
||||
}
|
||||
for(int k=0;k<je;k++)
|
||||
for(G4int k=0;k<je;k++)
|
||||
{
|
||||
retStr += " ";
|
||||
retStr += UCnt[k]->GetName();
|
||||
@@ -290,15 +326,15 @@ void G4UIcommand::List()
|
||||
if(commandPath(commandPath.length()-1)!='/')
|
||||
{ G4cout << "Command " << commandPath << G4endl; }
|
||||
G4cout << "Guidance :" << G4endl;
|
||||
int n_guidanceEntry = commandGuidance.size();
|
||||
for( int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ )
|
||||
G4int n_guidanceEntry = commandGuidance.size();
|
||||
for( G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ )
|
||||
{ G4cout << commandGuidance[i_thGuidance] << G4endl; }
|
||||
if( ! rangeString.isNull() )
|
||||
{ G4cout << " Range of parameters : " << rangeString << G4endl; }
|
||||
int n_parameterEntry = parameter.size();
|
||||
G4int n_parameterEntry = parameter.size();
|
||||
if( n_parameterEntry > 0 )
|
||||
{
|
||||
for( int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ )
|
||||
for( G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ )
|
||||
{ parameter[i_thParameter]->List(); }
|
||||
}
|
||||
G4cout << G4endl;
|
||||
@@ -313,7 +349,7 @@ void G4UIcommand::List()
|
||||
//#include "checkNewValue_debug.icc"
|
||||
//#define DEBUG 1
|
||||
|
||||
int G4UIcommand::
|
||||
G4int G4UIcommand::
|
||||
CheckNewValue(G4String newValue)
|
||||
{
|
||||
yystype result;
|
||||
@@ -325,7 +361,7 @@ CheckNewValue(G4String newValue)
|
||||
|
||||
// ------------------ type check routines -------------------
|
||||
|
||||
int G4UIcommand::
|
||||
G4int G4UIcommand::
|
||||
TypeCheck(G4String newValues)
|
||||
{
|
||||
G4String aNewValue;
|
||||
@@ -367,14 +403,14 @@ TypeCheck(G4String newValues)
|
||||
}
|
||||
|
||||
|
||||
int G4UIcommand::
|
||||
G4int G4UIcommand::
|
||||
IsInt(const char* buf, short maxDigits)
|
||||
{
|
||||
const char* p= buf;
|
||||
int length=0;
|
||||
G4int length=0;
|
||||
if( *p == '+' || *p == '-') { ++p; }
|
||||
if( isdigit( (int)(*p) )) {
|
||||
while( isdigit( (int)(*p) )) { ++p; ++length; }
|
||||
if( isdigit( (G4int)(*p) )) {
|
||||
while( isdigit( (G4int)(*p) )) { ++p; ++length; }
|
||||
if( *p == '\0' ) {
|
||||
if( length > maxDigits) {
|
||||
G4cerr <<"digit length exceeds"<<G4endl;
|
||||
@@ -391,23 +427,23 @@ IsInt(const char* buf, short maxDigits)
|
||||
}
|
||||
|
||||
|
||||
int G4UIcommand::
|
||||
G4int G4UIcommand::
|
||||
ExpectExponent(const char* str) // used only by IsDouble()
|
||||
{
|
||||
int maxExplength;
|
||||
G4int maxExplength;
|
||||
if( IsInt( str, maxExplength=7 )) return 1;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
|
||||
int G4UIcommand::
|
||||
G4int G4UIcommand::
|
||||
IsDouble(const char* buf)
|
||||
{
|
||||
const char* p= buf;
|
||||
switch( *p) {
|
||||
case '+': case '-': ++p;
|
||||
if( isdigit(*p) ) {
|
||||
while( isdigit( (int)(*p) )) { ++p; }
|
||||
while( isdigit( (G4int)(*p) )) { ++p; }
|
||||
switch ( *p ) {
|
||||
case '\0': return 1;
|
||||
// break;
|
||||
@@ -418,7 +454,7 @@ IsDouble(const char* buf)
|
||||
if( *p == '\0' ) return 1;
|
||||
if( *p == 'e' || *p =='E' ) return ExpectExponent(++p );
|
||||
if( isdigit(*p) ) {
|
||||
while( isdigit( (int)(*p) )) { ++p; }
|
||||
while( isdigit( (G4int)(*p) )) { ++p; }
|
||||
if( *p == '\0' ) return 1;
|
||||
if( *p == 'e' || *p =='E') return ExpectExponent(++p);
|
||||
} else return 0; break;
|
||||
@@ -427,7 +463,7 @@ IsDouble(const char* buf)
|
||||
}
|
||||
if( *p == '.' ) { ++p;
|
||||
if( isdigit(*p) ) {
|
||||
while( isdigit( (int)(*p) )) { ++p; }
|
||||
while( isdigit( (G4int)(*p) )) { ++p; }
|
||||
if( *p == '\0' ) return 1;
|
||||
if( *p == 'e' || *p =='E') return ExpectExponent(++p);
|
||||
}
|
||||
@@ -435,20 +471,20 @@ IsDouble(const char* buf)
|
||||
break;
|
||||
case '.': ++p;
|
||||
if( isdigit(*p) ) {
|
||||
while( isdigit( (int)(*p) )) { ++p; }
|
||||
while( isdigit( (G4int)(*p) )) { ++p; }
|
||||
if( *p == '\0' ) return 1;
|
||||
if( *p == 'e' || *p =='E' ) return ExpectExponent(++p);
|
||||
} break;
|
||||
default: // digit is expected
|
||||
if( isdigit(*p) ) {
|
||||
while( isdigit( (int)(*p) )) { ++p; }
|
||||
while( isdigit( (G4int)(*p) )) { ++p; }
|
||||
if( *p == '\0' ) return 1;
|
||||
if( *p == 'e' || *p =='E') return ExpectExponent(++p);
|
||||
if( *p == '.' ) { ++p;
|
||||
if( *p == '\0' ) return 1;
|
||||
if( *p == 'e' || *p =='E') return ExpectExponent(++p);
|
||||
if( isdigit(*p) ) {
|
||||
while( isdigit( (int)(*p) )) { ++p; }
|
||||
while( isdigit( (G4int)(*p) )) { ++p; }
|
||||
if( *p == '\0' ) return 1;
|
||||
if( *p == 'e' || *p =='E') return ExpectExponent(++p);
|
||||
}
|
||||
@@ -460,7 +496,7 @@ IsDouble(const char* buf)
|
||||
|
||||
|
||||
// ------------------ range Check routines -------------------
|
||||
int G4UIcommand::
|
||||
G4int G4UIcommand::
|
||||
RangeCheck(G4String newValue) {
|
||||
yystype result;
|
||||
char type;
|
||||
@@ -578,7 +614,7 @@ yystype G4UIcommand::
|
||||
EqualityExpression(void)
|
||||
{
|
||||
yystype arg1, arg2;
|
||||
int operat;
|
||||
G4int operat;
|
||||
yystype result;
|
||||
#ifdef DEBUG
|
||||
G4cerr << " EqualityExpression()" <<G4endl;
|
||||
@@ -609,7 +645,7 @@ yystype G4UIcommand::
|
||||
RelationalExpression(void)
|
||||
{
|
||||
yystype arg1, arg2;
|
||||
int operat;
|
||||
G4int operat;
|
||||
yystype result;
|
||||
#ifdef DEBUG
|
||||
G4cerr << " RelationalExpression()" <<G4endl;
|
||||
@@ -732,8 +768,8 @@ PrimaryExpression(void)
|
||||
|
||||
//---------------- semantic routines ---------------------------------
|
||||
|
||||
int G4UIcommand::
|
||||
Eval2(yystype arg1, int op, yystype arg2)
|
||||
G4int G4UIcommand::
|
||||
Eval2(yystype arg1, G4int op, yystype arg2)
|
||||
{
|
||||
char newValtype;
|
||||
if( (arg1.type != IDENTIFIER) && (arg2.type != IDENTIFIER)) {
|
||||
@@ -790,10 +826,10 @@ Eval2(yystype arg1, int op, yystype arg2)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int G4UIcommand::
|
||||
CompareInt(int arg1, int op, int arg2)
|
||||
G4int G4UIcommand::
|
||||
CompareInt(G4int arg1, G4int op, G4int arg2)
|
||||
{
|
||||
int result=-1;
|
||||
G4int result=-1;
|
||||
G4String opr;
|
||||
switch (op) {
|
||||
case GT: result = ( arg1 > arg2); opr= ">" ; break;
|
||||
@@ -815,10 +851,10 @@ CompareInt(int arg1, int op, int arg2)
|
||||
return result;
|
||||
}
|
||||
|
||||
int G4UIcommand::
|
||||
CompareDouble(double arg1, int op, double arg2)
|
||||
G4int G4UIcommand::
|
||||
CompareDouble(G4double arg1, G4int op, G4double arg2)
|
||||
{
|
||||
int result=-1;
|
||||
G4int result=-1;
|
||||
G4String opr;
|
||||
switch (op) {
|
||||
case GT: result = ( arg1 > arg2); opr= ">"; break;
|
||||
@@ -877,7 +913,7 @@ IsParameter(G4String nam)
|
||||
tokenNum G4UIcommand::
|
||||
Yylex() // reads input and returns token number, KR486
|
||||
{ // (returns EOF)
|
||||
int c;
|
||||
G4int c;
|
||||
G4String buf;
|
||||
|
||||
while(( c= G4UIpGetc())==' '|| c=='\t' || c== '\n' )
|
||||
@@ -932,10 +968,10 @@ Yylex() // reads input and returns token number, KR486
|
||||
}
|
||||
|
||||
|
||||
int G4UIcommand::
|
||||
Follow(int expect, int ifyes, int ifno)
|
||||
G4int G4UIcommand::
|
||||
Follow(G4int expect, G4int ifyes, G4int ifno)
|
||||
{
|
||||
int c = G4UIpGetc();
|
||||
G4int c = G4UIpGetc();
|
||||
if ( c== expect)
|
||||
return ifyes;
|
||||
G4UIpUngetc(c);
|
||||
@@ -943,16 +979,16 @@ Follow(int expect, int ifyes, int ifno)
|
||||
}
|
||||
|
||||
//------------------ low level routines -----------------------------
|
||||
int G4UIcommand::
|
||||
G4int G4UIcommand::
|
||||
G4UIpGetc() { // emulation of getc()
|
||||
int length = rangeString.length();
|
||||
G4int length = rangeString.length();
|
||||
if( bp < length)
|
||||
return rangeString(bp++);
|
||||
else
|
||||
return EOF;
|
||||
}
|
||||
int G4UIcommand::
|
||||
G4UIpUngetc(int c) { // emulation of ungetc()
|
||||
G4int G4UIcommand::
|
||||
G4UIpUngetc(G4int c) { // emulation of ungetc()
|
||||
if (c<0) return -1;
|
||||
if (bp >0 && c == rangeString(bp-1)) {
|
||||
--bp;
|
||||
|
||||
@@ -21,11 +21,13 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcommandTree.cc,v 1.6.2.1 2001/06/28 19:10:18 gunter Exp $
|
||||
// GEANT4 tag $Name: $
|
||||
// $Id: G4UIcommandTree.cc,v 1.10 2001/10/16 08:14:32 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-00 $
|
||||
//
|
||||
|
||||
#include "G4UIcommandTree.hh"
|
||||
#include "G4StateManager.hh"
|
||||
#include "g4std/fstream"
|
||||
#include "G4ios.hh"
|
||||
|
||||
G4UIcommandTree::G4UIcommandTree()
|
||||
@@ -46,18 +48,18 @@ G4UIcommandTree::G4UIcommandTree(const char * thePathName)
|
||||
|
||||
G4UIcommandTree::~G4UIcommandTree()
|
||||
{
|
||||
int i;
|
||||
int n_treeEntry = tree.size();
|
||||
G4int i;
|
||||
G4int n_treeEntry = tree.size();
|
||||
for( i=0; i < n_treeEntry; i++ )
|
||||
{ delete tree[i]; }
|
||||
}
|
||||
|
||||
int G4UIcommandTree::operator==(const G4UIcommandTree &right) const
|
||||
G4int G4UIcommandTree::operator==(const G4UIcommandTree &right) const
|
||||
{
|
||||
return ( pathName == right.GetPathName() );
|
||||
}
|
||||
|
||||
int G4UIcommandTree::operator!=(const G4UIcommandTree &right) const
|
||||
G4int G4UIcommandTree::operator!=(const G4UIcommandTree &right) const
|
||||
{
|
||||
return ( pathName != right.GetPathName() );
|
||||
}
|
||||
@@ -72,12 +74,12 @@ void G4UIcommandTree::AddNewCommand(G4UIcommand *newCommand)
|
||||
guidance = newCommand;
|
||||
return;
|
||||
}
|
||||
int i = remainingPath.first('/');
|
||||
if( i == int(G4std::string::npos) )
|
||||
G4int i = remainingPath.first('/');
|
||||
if( i == G4int(G4std::string::npos) )
|
||||
{
|
||||
// Find command
|
||||
int n_commandEntry = command.size();
|
||||
for( int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ )
|
||||
G4int n_commandEntry = command.size();
|
||||
for( G4int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ )
|
||||
{
|
||||
if( remainingPath == command[i_thCommand]->GetCommandName() )
|
||||
{ return; }
|
||||
@@ -90,8 +92,8 @@ void G4UIcommandTree::AddNewCommand(G4UIcommand *newCommand)
|
||||
// Find path
|
||||
G4String nextPath = pathName;
|
||||
nextPath.append(remainingPath(0,i+1));
|
||||
int n_treeEntry = tree.size();
|
||||
for( int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ )
|
||||
G4int n_treeEntry = tree.size();
|
||||
for( G4int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ )
|
||||
{
|
||||
if( nextPath == tree[i_thTree]->GetPathName() )
|
||||
{
|
||||
@@ -117,12 +119,12 @@ void G4UIcommandTree::RemoveCommand(G4UIcommand *aCommand)
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = remainingPath.first('/');
|
||||
if( i == int(G4std::string::npos) )
|
||||
G4int i = remainingPath.first('/');
|
||||
if( i == G4int(G4std::string::npos) )
|
||||
{
|
||||
// Find command
|
||||
int n_commandEntry = command.size();
|
||||
for( int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ )
|
||||
G4int n_commandEntry = command.size();
|
||||
for( G4int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ )
|
||||
{
|
||||
if( remainingPath == command[i_thCommand]->GetCommandName() )
|
||||
{
|
||||
@@ -136,13 +138,13 @@ void G4UIcommandTree::RemoveCommand(G4UIcommand *aCommand)
|
||||
// Find path
|
||||
G4String nextPath = pathName;
|
||||
nextPath.append(remainingPath(0,i+1));
|
||||
int n_treeEntry = tree.size();
|
||||
for( int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ )
|
||||
G4int n_treeEntry = tree.size();
|
||||
for( G4int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ )
|
||||
{
|
||||
if( nextPath == tree[i_thTree]->GetPathName() )
|
||||
{
|
||||
tree[i_thTree]->RemoveCommand( aCommand );
|
||||
int n_commandRemain = tree[i_thTree]->GetCommandEntry();
|
||||
G4int n_commandRemain = tree[i_thTree]->GetCommandEntry();
|
||||
if(n_commandRemain==0)
|
||||
{
|
||||
G4UIcommandTree * emptyTree = tree[i_thTree];
|
||||
@@ -162,12 +164,12 @@ G4UIcommand * G4UIcommandTree::FindPath(G4String commandPath)
|
||||
{ return NULL; }
|
||||
G4String remainingPath = commandPath;
|
||||
remainingPath.remove(0,pathName.length());
|
||||
int i = remainingPath.first('/');
|
||||
if( i == int(G4std::string::npos) )
|
||||
G4int i = remainingPath.first('/');
|
||||
if( i == G4int(G4std::string::npos) )
|
||||
{
|
||||
// Find command
|
||||
int n_commandEntry = command.size();
|
||||
for( int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ )
|
||||
G4int n_commandEntry = command.size();
|
||||
for( G4int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ )
|
||||
{
|
||||
if( remainingPath == command[i_thCommand]->GetCommandName() )
|
||||
{ return command[i_thCommand]; }
|
||||
@@ -178,8 +180,8 @@ G4UIcommand * G4UIcommandTree::FindPath(G4String commandPath)
|
||||
// Find path
|
||||
G4String nextPath = pathName;
|
||||
nextPath.append(remainingPath(0,i+1));
|
||||
int n_treeEntry = tree.size();
|
||||
for( int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ )
|
||||
G4int n_treeEntry = tree.size();
|
||||
for( G4int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ )
|
||||
{
|
||||
if( nextPath == tree[i_thTree]->GetPathName() )
|
||||
{ return tree[i_thTree]->FindPath( commandPath ); }
|
||||
@@ -193,15 +195,15 @@ void G4UIcommandTree::ListCurrent()
|
||||
G4cout << "Command directory path : " << pathName << G4endl;
|
||||
if( guidance != NULL ) guidance->List();
|
||||
G4cout << " Sub-directories : " << G4endl;
|
||||
int n_treeEntry = tree.size();
|
||||
for( int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ )
|
||||
G4int n_treeEntry = tree.size();
|
||||
for( G4int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ )
|
||||
{
|
||||
G4cout << " " << tree[i_thTree]->GetPathName()
|
||||
<< " " << tree[i_thTree]->GetTitle() << G4endl;
|
||||
}
|
||||
G4cout << " Commands : " << G4endl;
|
||||
int n_commandEntry = command.size();
|
||||
for( int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ )
|
||||
G4int n_commandEntry = command.size();
|
||||
for( G4int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ )
|
||||
{
|
||||
G4cout << " " << command[i_thCommand]->GetCommandName()
|
||||
<< " * " << command[i_thCommand]->GetTitle() << G4endl;
|
||||
@@ -212,18 +214,18 @@ void G4UIcommandTree::ListCurrentWithNum()
|
||||
{
|
||||
G4cout << "Command directory path : " << pathName << G4endl;
|
||||
if( guidance != NULL ) guidance->List();
|
||||
int i = 0;
|
||||
G4int i = 0;
|
||||
G4cout << " Sub-directories : " << G4endl;
|
||||
int n_treeEntry = tree.size();
|
||||
for( int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ )
|
||||
G4int n_treeEntry = tree.size();
|
||||
for( G4int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ )
|
||||
{
|
||||
i++;
|
||||
G4cout << " " << i << ") " << tree[i_thTree]->GetPathName()
|
||||
<< " " << tree[i_thTree]->GetTitle() << G4endl;
|
||||
}
|
||||
G4cout << " Commands : " << G4endl;
|
||||
int n_commandEntry = command.size();
|
||||
for( int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ )
|
||||
G4int n_commandEntry = command.size();
|
||||
for( G4int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ )
|
||||
{
|
||||
i++;
|
||||
G4cout << " " << i << ") " << command[i_thCommand]->GetCommandName()
|
||||
@@ -234,16 +236,130 @@ void G4UIcommandTree::ListCurrentWithNum()
|
||||
void G4UIcommandTree::List()
|
||||
{
|
||||
ListCurrent();
|
||||
int n_commandEntry = command.size();
|
||||
for( int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ )
|
||||
G4int n_commandEntry = command.size();
|
||||
for( G4int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ )
|
||||
{
|
||||
command[i_thCommand]->List();
|
||||
}
|
||||
int n_treeEntry = tree.size();
|
||||
for( int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ )
|
||||
G4int n_treeEntry = tree.size();
|
||||
for( G4int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ )
|
||||
{
|
||||
tree[i_thTree]->List();
|
||||
}
|
||||
}
|
||||
|
||||
G4String G4UIcommandTree::CreateFileName(G4String pName)
|
||||
{
|
||||
G4String fn = pName;
|
||||
G4int idxs;
|
||||
while((idxs=fn.index("/"))!=G4int(G4std::string::npos))
|
||||
{ fn(idxs) = '_'; }
|
||||
fn += ".html";
|
||||
return fn;
|
||||
}
|
||||
|
||||
G4String G4UIcommandTree::ModStr(G4String str)
|
||||
{
|
||||
G4String sx;
|
||||
for(G4int i=0;i<G4int(str.length());i++)
|
||||
{
|
||||
char c = str(i);
|
||||
switch(c)
|
||||
{
|
||||
case '<':
|
||||
sx += "<"; break;
|
||||
case '>':
|
||||
sx += ">"; break;
|
||||
case '&':
|
||||
sx += "&"; break;
|
||||
default:
|
||||
sx += c;
|
||||
}
|
||||
}
|
||||
return sx;
|
||||
}
|
||||
|
||||
void G4UIcommandTree::CreateHTML()
|
||||
{
|
||||
G4String ofileName = CreateFileName(pathName);
|
||||
G4std::ofstream oF(ofileName, G4std::ios::out);
|
||||
|
||||
oF << "<html><head><title>Commands in " << ModStr(pathName) << "</title></head>" << G4endl;
|
||||
oF << "<body bgcolor=\"#ffffff\"><h2>" << ModStr(pathName) << "</h2><p>" << G4endl;
|
||||
|
||||
if( guidance != NULL )
|
||||
{
|
||||
for(G4int i=0;i<guidance->GetGuidanceEntries();i++)
|
||||
{ oF << ModStr(guidance->GetGuidanceLine(i)) << "<br>" << G4endl; }
|
||||
}
|
||||
|
||||
oF << "<p><hr><p>" << G4endl;
|
||||
|
||||
oF << "<h2>Sub-directories : </h2><dl>" << G4endl;
|
||||
for( G4int i_thTree = 0; i_thTree < G4int(tree.size()); i_thTree++ )
|
||||
{
|
||||
oF << "<p><br><p><dt><a href=\"" << CreateFileName(tree[i_thTree]->GetPathName())
|
||||
<< "\">" << ModStr(tree[i_thTree]->GetPathName()) << "</a>" << G4endl;
|
||||
oF << "<p><dd>" << ModStr(tree[i_thTree]->GetTitle()) << G4endl;
|
||||
tree[i_thTree]->CreateHTML();
|
||||
}
|
||||
|
||||
oF << "</dl><p><hr><p>" << G4endl;
|
||||
|
||||
oF << "<h2>Commands : </h2><dl>" << G4endl;
|
||||
for( G4int i_thCommand = 0; i_thCommand < G4int(command.size()); i_thCommand++ )
|
||||
{
|
||||
G4UIcommand* cmd = command[i_thCommand];
|
||||
oF << "<p><br><p><dt><b>" << ModStr(cmd->GetCommandName());
|
||||
if(cmd->GetParameterEntries()>0)
|
||||
{
|
||||
for(G4int i_thParam=0;i_thParam<cmd->GetParameterEntries();i_thParam++)
|
||||
{ oF << " [<i>" << ModStr(cmd->GetParameter(i_thParam)->GetParameterName()) << "</i>]"; }
|
||||
}
|
||||
oF << "</b>" << G4endl;
|
||||
oF << "<p><dd>" << G4endl;
|
||||
for(G4int i=0;i<cmd->GetGuidanceEntries();i++)
|
||||
{ oF << ModStr(cmd->GetGuidanceLine(i)) << "<br>" << G4endl; }
|
||||
if(!(cmd->GetRange()).isNull())
|
||||
{ oF << "<p><dd>Range : " << ModStr(cmd->GetRange()) << G4endl; }
|
||||
G4std::vector<G4ApplicationState>* availabelStateList = cmd->GetStateList();
|
||||
if(availabelStateList->size()==6)
|
||||
{ oF << "<p><dd>Available at all Geant4 states." << G4endl; }
|
||||
else
|
||||
{
|
||||
oF << "<p><dd>Available Geant4 state(s) : ";
|
||||
for(G4int ias=0;ias<G4int(availabelStateList->size());ias++)
|
||||
{ oF << G4StateManager::GetStateManager()->GetStateString((*availabelStateList)[ias]) << " " << G4endl; }
|
||||
}
|
||||
if(cmd->GetParameterEntries()>0)
|
||||
{
|
||||
oF << "<p><dd>Parameters<table border=1>" << G4endl;
|
||||
for(G4int i_thParam=0;i_thParam<cmd->GetParameterEntries();i_thParam++)
|
||||
{
|
||||
G4UIparameter* prm = cmd->GetParameter(i_thParam);
|
||||
oF << "<tr><td>" << ModStr(prm->GetParameterName()) << G4endl;
|
||||
oF << "<td>type " << prm->GetParameterType() << G4endl;
|
||||
oF << "<td>";
|
||||
if(prm->IsOmittable())
|
||||
{
|
||||
oF << "Omittable : ";
|
||||
if(prm->GetCurrentAsDefault())
|
||||
{ oF << "current value is used as the default value." << G4endl; }
|
||||
else
|
||||
{ oF << "default value = " << prm->GetDefaultValue() << G4endl; }
|
||||
}
|
||||
oF << "<td>";
|
||||
if(!(prm->GetParameterRange()).isNull())
|
||||
{ oF << "Parameter range : " << ModStr(prm->GetParameterRange()) << G4endl; }
|
||||
else if(!(prm->GetParameterCandidates()).isNull())
|
||||
{ oF << "Parameter candidates : " << ModStr(prm->GetParameterCandidates()) << G4endl; }
|
||||
}
|
||||
oF << "</table>" << G4endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
oF << "</dl></body></html>" << G4endl;
|
||||
oF.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,16 +21,21 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcontrolMessenger.cc,v 1.2.4.1 2001/06/28 19:10:18 gunter Exp $
|
||||
// GEANT4 tag $Name: $
|
||||
// $Id: G4UIcontrolMessenger.cc,v 1.8 2001/10/11 01:38:00 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-04-00 $
|
||||
//
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "G4UIcontrolMessenger.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4UIparameter.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4UIcmdWithAnInteger.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
#include "G4UIaliasList.hh"
|
||||
#include "G4StateManager.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
G4UIcontrolMessenger::G4UIcontrolMessenger()
|
||||
@@ -41,7 +46,44 @@ G4UIcontrolMessenger::G4UIcontrolMessenger()
|
||||
ExecuteCommand = new G4UIcmdWithAString("/control/execute",this);
|
||||
ExecuteCommand->SetGuidance("Execute a macro file.");
|
||||
ExecuteCommand->SetParameterName("fileName",false);
|
||||
|
||||
loopCommand = new G4UIcommand("/control/loop",this);
|
||||
loopCommand->SetGuidance("Execute a macro file more than once.");
|
||||
loopCommand->SetGuidance("Loop counter can be used as an aliased variable.");
|
||||
G4UIparameter* param1 = new G4UIparameter("macroFile",'s',false);
|
||||
loopCommand->SetParameter(param1);
|
||||
G4UIparameter* param2 = new G4UIparameter("counterName",'s',false);
|
||||
loopCommand->SetParameter(param2);
|
||||
G4UIparameter* param3 = new G4UIparameter("initialValue",'d',false);
|
||||
loopCommand->SetParameter(param3);
|
||||
G4UIparameter* param4 = new G4UIparameter("finalValue",'d',false);
|
||||
loopCommand->SetParameter(param4);
|
||||
G4UIparameter* param5 = new G4UIparameter("stepSize",'d',true);
|
||||
param5->SetDefaultValue(1.0);
|
||||
loopCommand->SetParameter(param5);
|
||||
|
||||
foreachCommand = new G4UIcommand("/control/foreach",this);
|
||||
foreachCommand->SetGuidance("Execute a macro file more than once.");
|
||||
foreachCommand->SetGuidance("Loop counter can be used as an aliased variable.");
|
||||
foreachCommand->SetGuidance("Values must be separated by a space.");
|
||||
G4UIparameter* param6 = new G4UIparameter("macroFile",'s',false);
|
||||
foreachCommand->SetParameter(param6);
|
||||
G4UIparameter* param7 = new G4UIparameter("counterName",'s',false);
|
||||
foreachCommand->SetParameter(param7);
|
||||
G4UIparameter* param8 = new G4UIparameter("valueList",'s',false);
|
||||
foreachCommand->SetParameter(param8);
|
||||
|
||||
suppressAbortionCommand = new G4UIcmdWithAnInteger("/control/suppressAbortion",this);
|
||||
suppressAbortionCommand->SetGuidance("Suppress the program abortion caused by G4Exception.");
|
||||
suppressAbortionCommand->SetGuidance("Suppression level = 0 : no suppression");
|
||||
suppressAbortionCommand->SetGuidance(" = 1 : suppress during EventProc state");
|
||||
suppressAbortionCommand->SetGuidance(" = 2 : full suppression, i.e. no abortion by G4Exception");
|
||||
suppressAbortionCommand->SetGuidance("When abortion is suppressed, you will get error messages issued by G4Exception,");
|
||||
suppressAbortionCommand->SetGuidance("and there is NO guarantee for the correct result after the G4Exception error message.");
|
||||
suppressAbortionCommand->SetParameterName("level",true);
|
||||
suppressAbortionCommand->SetRange("level >= 0 && level <= 2");
|
||||
suppressAbortionCommand->SetDefaultValue(0);
|
||||
|
||||
verboseCommand = new G4UIcmdWithAnInteger("/control/verbose",this);
|
||||
verboseCommand->SetGuidance("Applied command will also be shown on screen.");
|
||||
verboseCommand->SetGuidance("This command is useful with MACRO file.");
|
||||
@@ -62,21 +104,57 @@ G4UIcontrolMessenger::G4UIcontrolMessenger()
|
||||
= new G4UIcmdWithoutParameter("/control/stopSavingHistory",this);
|
||||
stopStoreHistoryCommand->SetGuidance("Stop saving history file.");
|
||||
|
||||
aliasCommand = new G4UIcommand("/control/alias",this);
|
||||
aliasCommand->SetGuidance("Set an alias.");
|
||||
aliasCommand->SetGuidance("String can be aliased by this command.");
|
||||
aliasCommand->SetGuidance("The string may contain one or more spaces,");
|
||||
aliasCommand->SetGuidance("the string must be enclosed by double quotes (\").");
|
||||
aliasCommand->SetGuidance("To use an alias, enclose the alias name with");
|
||||
aliasCommand->SetGuidance("parenthis \"{\" and \"}\".");
|
||||
G4UIparameter* aliasNameParam = new G4UIparameter("aliasName",'s',false);
|
||||
aliasCommand->SetParameter(aliasNameParam);
|
||||
G4UIparameter* aliasValueParam = new G4UIparameter("aliasValue",'s',false);
|
||||
aliasCommand->SetParameter(aliasValueParam);
|
||||
|
||||
unaliasCommand = new G4UIcmdWithAString("/control/unalias",this);
|
||||
unaliasCommand->SetGuidance("Remove an alias.");
|
||||
unaliasCommand->SetParameterName("aliasName",false);
|
||||
|
||||
listAliasCommand = new G4UIcmdWithoutParameter("/control/listAlias",this);
|
||||
listAliasCommand->SetGuidance("List aliases.");
|
||||
|
||||
shellCommand = new G4UIcmdWithAString("/control/shell",this);
|
||||
shellCommand->SetGuidance("Execute a (Unix) SHELL command.");
|
||||
|
||||
ManualCommand = new G4UIcmdWithAString("/control/manual",this);
|
||||
ManualCommand->SetGuidance("Display all of sub-directories and commands.");
|
||||
ManualCommand->SetGuidance("Directory path should be given by FULL-PATH.");
|
||||
ManualCommand->SetParameterName("dirPath",true);
|
||||
ManualCommand->SetDefaultValue("/");
|
||||
|
||||
HTMLCommand = new G4UIcmdWithAString("/control/createHTML",this);
|
||||
HTMLCommand->SetGuidance("Generate HTML files for all of sub-directories and commands.");
|
||||
HTMLCommand->SetGuidance("Directory path should be given by FULL-PATH.");
|
||||
HTMLCommand->SetParameterName("dirPath",true);
|
||||
HTMLCommand->SetDefaultValue("/");
|
||||
|
||||
}
|
||||
|
||||
G4UIcontrolMessenger::~G4UIcontrolMessenger()
|
||||
{
|
||||
delete ExecuteCommand;
|
||||
delete suppressAbortionCommand;
|
||||
delete verboseCommand;
|
||||
delete historyCommand;
|
||||
delete stopStoreHistoryCommand;
|
||||
delete ManualCommand;
|
||||
|
||||
delete aliasCommand;
|
||||
delete unaliasCommand;
|
||||
delete listAliasCommand;
|
||||
delete shellCommand;
|
||||
delete loopCommand;
|
||||
delete foreachCommand;
|
||||
delete HTMLCommand;
|
||||
delete controlDirectory;
|
||||
}
|
||||
|
||||
@@ -88,6 +166,10 @@ void G4UIcontrolMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
|
||||
{
|
||||
UI->ExecuteMacroFile(newValue);
|
||||
}
|
||||
if(command==suppressAbortionCommand)
|
||||
{
|
||||
G4StateManager::GetStateManager()->SetSuppressAbortion(suppressAbortionCommand->GetNewIntValue(newValue));
|
||||
}
|
||||
if(command==verboseCommand)
|
||||
{
|
||||
UI->SetVerboseLevel(verboseCommand->GetNewIntValue(newValue));
|
||||
@@ -104,6 +186,35 @@ void G4UIcontrolMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
|
||||
{
|
||||
UI->ListCommands(newValue);
|
||||
}
|
||||
if(command==aliasCommand)
|
||||
{
|
||||
UI->SetAlias(newValue);
|
||||
}
|
||||
if(command==unaliasCommand)
|
||||
{
|
||||
UI->RemoveAlias(newValue);
|
||||
}
|
||||
if(command==listAliasCommand)
|
||||
{
|
||||
UI->ListAlias();
|
||||
}
|
||||
if(command==shellCommand)
|
||||
{
|
||||
system(newValue);
|
||||
}
|
||||
if(command==loopCommand)
|
||||
{
|
||||
UI->LoopS(newValue);
|
||||
}
|
||||
if(command==foreachCommand)
|
||||
{
|
||||
UI->ForeachS(newValue);
|
||||
}
|
||||
if(command==HTMLCommand)
|
||||
{
|
||||
UI->CreateHTML(newValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
G4String G4UIcontrolMessenger::GetCurrentValue(G4UIcommand * command)
|
||||
@@ -115,6 +226,10 @@ G4String G4UIcontrolMessenger::GetCurrentValue(G4UIcommand * command)
|
||||
{
|
||||
currentValue = verboseCommand->ConvertToString(UI->GetVerboseLevel());
|
||||
}
|
||||
if(command==suppressAbortionCommand)
|
||||
{
|
||||
currentValue = suppressAbortionCommand->ConvertToString(G4StateManager::GetStateManager()->GetSuppressAbortion());
|
||||
}
|
||||
|
||||
return currentValue;
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIdirectory.cc,v 1.2.4.1 2001/06/28 19:10:18 gunter Exp $
|
||||
// GEANT4 tag $Name: $
|
||||
// $Id: G4UIdirectory.cc,v 1.3 2001/07/11 10:01:16 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-04-00 $
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
@@ -21,14 +21,13 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UImanager.cc,v 1.8.2.1 2001/06/28 19:10:18 gunter Exp $
|
||||
// GEANT4 tag $Name: $
|
||||
// $Id: G4UImanager.cc,v 1.20 2001/11/24 18:37:11 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-04-00 $
|
||||
//
|
||||
//
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4UIcommandStatus.hh"
|
||||
#include "G4UIcommandTree.hh"
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4UIsession.hh"
|
||||
@@ -38,9 +37,12 @@
|
||||
#include "G4ios.hh"
|
||||
#include "G4strstreambuf.hh"
|
||||
#include "G4StateManager.hh"
|
||||
#include "G4UIaliasList.hh"
|
||||
#include "G4Tokenizer.hh"
|
||||
|
||||
#include "g4std/strstream"
|
||||
|
||||
|
||||
G4UImanager * G4UImanager::fUImanager = 0;
|
||||
G4bool G4UImanager::fUImanagerHasBeenKilled = false;
|
||||
|
||||
@@ -62,6 +64,7 @@ G4UImanager::G4UImanager()
|
||||
{
|
||||
savedCommand = 0;
|
||||
treeTop = new G4UIcommandTree("/");
|
||||
aliasList = new G4UIaliasList;
|
||||
G4String nullString;
|
||||
savedParameters = nullString;
|
||||
verboseLevel = 0;
|
||||
@@ -86,6 +89,7 @@ G4UImanager::~G4UImanager()
|
||||
delete UImessenger;
|
||||
delete UnitsMessenger;
|
||||
delete treeTop;
|
||||
delete aliasList;
|
||||
fUImanagerHasBeenKilled = true;
|
||||
fUImanager = NULL;
|
||||
}
|
||||
@@ -93,9 +97,9 @@ G4UImanager::~G4UImanager()
|
||||
G4UImanager::G4UImanager(const G4UImanager &right) { }
|
||||
const G4UImanager & G4UImanager::operator=(const G4UImanager &right)
|
||||
{ return right; }
|
||||
int G4UImanager::operator==(const G4UImanager &right) const
|
||||
G4int G4UImanager::operator==(const G4UImanager &right) const
|
||||
{ return false; }
|
||||
int G4UImanager::operator!=(const G4UImanager &right) const
|
||||
G4int G4UImanager::operator!=(const G4UImanager &right) const
|
||||
{ return true; }
|
||||
|
||||
G4String G4UImanager::GetCurrentValues(const char * aCommand)
|
||||
@@ -111,7 +115,7 @@ G4String G4UImanager::GetCurrentValues(const char * aCommand)
|
||||
}
|
||||
|
||||
G4String G4UImanager::GetCurrentStringValue(const char * aCommand,
|
||||
int parameterNumber, G4bool reGet)
|
||||
G4int parameterNumber, G4bool reGet)
|
||||
{
|
||||
if(reGet || savedCommand == NULL)
|
||||
{
|
||||
@@ -119,7 +123,7 @@ int parameterNumber, G4bool reGet)
|
||||
}
|
||||
G4Tokenizer savedToken( savedParameters );
|
||||
G4String token;
|
||||
for(int i_thParameter=0;i_thParameter<parameterNumber;i_thParameter++)
|
||||
for(G4int i_thParameter=0;i_thParameter<parameterNumber;i_thParameter++)
|
||||
{
|
||||
token = savedToken();
|
||||
if( token.isNull() ) return G4String();
|
||||
@@ -139,7 +143,7 @@ const char * aParameterName, G4bool reGet)
|
||||
{
|
||||
G4String parameterValues = GetCurrentValues( aCommand );
|
||||
}
|
||||
for(int i=0;i<savedCommand->GetParameterEntries();i++)
|
||||
for(G4int i=0;i<savedCommand->GetParameterEntries();i++)
|
||||
{
|
||||
if( aParameterName ==
|
||||
savedCommand->GetParameter(i)->GetParameterName() )
|
||||
@@ -161,7 +165,7 @@ const char * aParameterName, G4bool reGet)
|
||||
}
|
||||
|
||||
G4int G4UImanager::GetCurrentIntValue(const char * aCommand,
|
||||
int parameterNumber, G4bool reGet)
|
||||
G4int parameterNumber, G4bool reGet)
|
||||
{
|
||||
G4String targetParameter =
|
||||
GetCurrentStringValue( aCommand, parameterNumber, reGet );
|
||||
@@ -185,7 +189,7 @@ const char * aParameterName, G4bool reGet)
|
||||
}
|
||||
|
||||
G4double G4UImanager::GetCurrentDoubleValue(const char * aCommand,
|
||||
int parameterNumber, G4bool reGet)
|
||||
G4int parameterNumber, G4bool reGet)
|
||||
{
|
||||
G4String targetParameter =
|
||||
GetCurrentStringValue( aCommand, parameterNumber, reGet );
|
||||
@@ -206,6 +210,12 @@ void G4UImanager::RemoveCommand(G4UIcommand * aCommand)
|
||||
treeTop->RemoveCommand( aCommand );
|
||||
}
|
||||
|
||||
void G4UImanager::ExecuteMacroFile(const char * fileName)
|
||||
{
|
||||
G4String fn = fileName;
|
||||
ExecuteMacroFile(fn);
|
||||
}
|
||||
|
||||
void G4UImanager::ExecuteMacroFile(G4String fileName)
|
||||
{
|
||||
G4UIsession* batchSession = new G4UIbatch(fileName,session);
|
||||
@@ -215,20 +225,148 @@ void G4UImanager::ExecuteMacroFile(G4String fileName)
|
||||
session = previousSession;
|
||||
}
|
||||
|
||||
int G4UImanager::ApplyCommand(const char * aCommand)
|
||||
void G4UImanager::LoopS(G4String valueList)
|
||||
{
|
||||
G4Tokenizer parameterToken( valueList );
|
||||
G4String mf = parameterToken();
|
||||
G4String vn = parameterToken();
|
||||
G4String c1 = parameterToken();
|
||||
c1 += " ";
|
||||
c1 += parameterToken();
|
||||
c1 += " ";
|
||||
c1 += parameterToken();
|
||||
const char* t1 = c1;
|
||||
G4std::istrstream is((char*)t1);
|
||||
G4double d1;
|
||||
G4double d2;
|
||||
G4double d3;
|
||||
is >> d1 >> d2 >> d3;
|
||||
Loop(mf,vn,d1,d2,d3);
|
||||
}
|
||||
|
||||
void G4UImanager::Loop(const char * macroFile,const char * variableName,
|
||||
G4double initialValue,G4double finalValue,G4double stepSize)
|
||||
{
|
||||
G4String mf = macroFile;
|
||||
G4String vn = variableName;
|
||||
Loop(mf,vn,initialValue,finalValue,stepSize);
|
||||
}
|
||||
|
||||
void G4UImanager::Loop(G4String macroFile,G4String variableName,
|
||||
G4double initialValue,G4double finalValue,G4double stepSize)
|
||||
{
|
||||
G4String cd;
|
||||
for(G4double d=initialValue;d<=finalValue;d+=stepSize)
|
||||
{
|
||||
char st[20];
|
||||
G4std::ostrstream os(st,20);
|
||||
os << d << '\0';
|
||||
cd += st;
|
||||
cd += " ";
|
||||
}
|
||||
Foreach(macroFile,variableName,cd);
|
||||
}
|
||||
|
||||
void G4UImanager::ForeachS(G4String valueList)
|
||||
{
|
||||
G4Tokenizer parameterToken( valueList );
|
||||
G4String mf = parameterToken();
|
||||
G4String vn = parameterToken();
|
||||
G4String c1 = parameterToken();
|
||||
G4String ca;
|
||||
while(!((ca=parameterToken()).isNull()))
|
||||
{
|
||||
c1 += " ";
|
||||
c1 += ca;
|
||||
}
|
||||
Foreach(mf,vn,c1);
|
||||
}
|
||||
|
||||
void G4UImanager::Foreach(const char * macroFile,const char * variableName,
|
||||
const char * candidates)
|
||||
{
|
||||
G4String mf = macroFile;
|
||||
G4String vn = variableName;
|
||||
G4String cd = candidates;
|
||||
Foreach(mf,vn,cd);
|
||||
}
|
||||
|
||||
void G4UImanager::Foreach(G4String macroFile,G4String variableName,G4String candidates)
|
||||
{
|
||||
G4Tokenizer parameterToken( candidates );
|
||||
G4String cd;
|
||||
while(!((cd=parameterToken()).isNull()))
|
||||
{
|
||||
SetAlias(variableName+" "+cd);
|
||||
ExecuteMacroFile(macroFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
G4int G4UImanager::ApplyCommand(const char * aCommand)
|
||||
{
|
||||
G4String theCommand = aCommand;
|
||||
return ApplyCommand(theCommand);
|
||||
}
|
||||
|
||||
int G4UImanager::ApplyCommand(G4String aCommand)
|
||||
G4String G4UImanager::SolveAlias(G4String aCmd)
|
||||
{
|
||||
if(verboseLevel) G4cout << aCommand << G4endl;
|
||||
G4String aCommand = aCmd;
|
||||
G4int ia = aCommand.index("{");
|
||||
G4int iz = aCommand.index("#");
|
||||
while((ia != G4int(G4std::string::npos))&&((iz==G4int(G4std::string::npos))||(ia<iz)))
|
||||
{
|
||||
G4int ibx = -1;
|
||||
while(ibx<0)
|
||||
{
|
||||
G4int ib = aCommand.index("}");
|
||||
if( ib == G4int(G4std::string::npos) )
|
||||
{
|
||||
G4cerr << aCommand << G4endl;
|
||||
for(G4int iz=0;iz<ia;iz++) G4cerr << " ";
|
||||
G4cerr << "^" << G4endl;
|
||||
G4cerr << "Unmatched alias parenthis -- command ignored" << G4endl;
|
||||
return fAliasNotFound;
|
||||
}
|
||||
G4String ps = aCommand(ia+1,aCommand.length()-(ia+1));
|
||||
G4int ic = ps.index("{");
|
||||
G4int id = ps.index("}");
|
||||
if(ic!=G4int(G4std::string::npos) && ic < id)
|
||||
{ ia+=ic+1; }
|
||||
else
|
||||
{ ibx = ib; }
|
||||
}
|
||||
//--- Here ia represents the position of innermost "{"
|
||||
//--- and ibx represents corresponding "}"
|
||||
G4String subs;
|
||||
if(ia>0) subs = aCommand(0,ia);
|
||||
G4String alis = aCommand(ia+1,ibx-ia-1);
|
||||
G4String rems = aCommand(ibx+1,aCommand.length()-ibx);
|
||||
// G4cout << "<" << subs << "> <" << alis << "> <" << rems << ">" << G4endl;
|
||||
G4String* alVal = aliasList->FindAlias(alis);
|
||||
if(!alVal)
|
||||
{
|
||||
G4cerr << "Alias <" << alis << "> not found -- command ignored" << G4endl;
|
||||
G4String nullStr;
|
||||
return nullStr;
|
||||
}
|
||||
aCommand = subs+(*alVal)+rems;
|
||||
ia = aCommand.index("{");
|
||||
}
|
||||
return aCommand;
|
||||
}
|
||||
|
||||
G4int G4UImanager::ApplyCommand(G4String aCommand)
|
||||
{
|
||||
G4String aCmd = SolveAlias(aCommand);
|
||||
if(aCmd.isNull()) return fAliasNotFound;
|
||||
aCommand = aCmd;
|
||||
if(verboseLevel) G4cout << aCommand << G4endl;
|
||||
G4String commandString;
|
||||
G4String commandParameter;
|
||||
int i = aCommand.index(" ");
|
||||
if( i != int(G4std::string::npos) )
|
||||
|
||||
G4int i = aCommand.index(" ");
|
||||
if( i != G4int(G4std::string::npos) )
|
||||
{
|
||||
commandString = aCommand(0,i);
|
||||
commandParameter = aCommand(i+1,aCommand.length()-(i+1));
|
||||
@@ -238,12 +376,32 @@ int G4UImanager::ApplyCommand(G4String aCommand)
|
||||
commandString = aCommand;
|
||||
}
|
||||
|
||||
// remove doubled slash
|
||||
G4int len = commandString.length();
|
||||
G4int ll = 0;
|
||||
G4String a1;
|
||||
G4String a2;
|
||||
while(ll<len-1)
|
||||
{
|
||||
if(commandString(ll,2)=="//")
|
||||
{
|
||||
if(ll==0)
|
||||
{ commandString.remove(ll,1); }
|
||||
else
|
||||
{
|
||||
a1 = commandString(0,ll);
|
||||
a2 = commandString(ll+1,len-ll-1);
|
||||
commandString = a1+a2;
|
||||
}
|
||||
len--;
|
||||
}
|
||||
else
|
||||
{ ll++; }
|
||||
}
|
||||
|
||||
G4UIcommand * targetCommand = treeTop->FindPath( commandString );
|
||||
if( targetCommand == NULL )
|
||||
{
|
||||
// G4cout << commandString << " NOT FOUND." << G4endl;
|
||||
return fCommandNotFound;
|
||||
}
|
||||
{ return fCommandNotFound; }
|
||||
|
||||
if(!(targetCommand->IsAvailable()))
|
||||
{ return fIllegalApplicationState; }
|
||||
@@ -297,10 +455,10 @@ G4UIcommandTree* G4UImanager::FindDirectory(const char* dirName)
|
||||
G4UIcommandTree* comTree = treeTop;
|
||||
if( targetDir == "/" )
|
||||
{ return comTree; }
|
||||
int idx = 1;
|
||||
while( idx < int(targetDir.length())-1 )
|
||||
G4int idx = 1;
|
||||
while( idx < G4int(targetDir.length())-1 )
|
||||
{
|
||||
int i = targetDir.index("/",idx);
|
||||
G4int i = targetDir.index("/",idx);
|
||||
comTree = comTree->GetTree(targetDir(0,i+1));
|
||||
if( comTree == NULL )
|
||||
{ return NULL; }
|
||||
@@ -351,10 +509,59 @@ void G4UImanager::Interact(G4String pC)
|
||||
|
||||
|
||||
|
||||
void G4UImanager::SetCoutDestination(G4UIsession *const value)
|
||||
void G4UImanager::SetCoutDestination(G4UIsession *const value)
|
||||
{
|
||||
G4coutbuf.SetDestination(value);
|
||||
G4cerrbuf.SetDestination(value);
|
||||
}
|
||||
|
||||
void G4UImanager::SetAlias(const char * aliasLine)
|
||||
{
|
||||
G4String aL = aliasLine;
|
||||
SetAlias(aL);
|
||||
}
|
||||
|
||||
void G4UImanager::SetAlias(G4String aliasLine)
|
||||
{
|
||||
G4int i = aliasLine.index(" ");
|
||||
G4String aliasName = aliasLine(0,i);
|
||||
G4String aliasValue = aliasLine(i+1,aliasLine.length()-(i+1));
|
||||
if(aliasValue(0)=='"')
|
||||
{
|
||||
G4String strippedValue;
|
||||
if(aliasValue(aliasValue.length()-1)=='"')
|
||||
{ strippedValue = aliasValue(1,aliasValue.length()-2); }
|
||||
else
|
||||
{ strippedValue = aliasValue(1,aliasValue.length()-1); }
|
||||
aliasValue = strippedValue;
|
||||
}
|
||||
|
||||
aliasList->ChangeAlias(aliasName,aliasValue);
|
||||
}
|
||||
|
||||
void G4UImanager::RemoveAlias(const char * aliasName)
|
||||
{
|
||||
G4String aL = aliasName;
|
||||
RemoveAlias(aL);
|
||||
}
|
||||
|
||||
void G4UImanager::RemoveAlias(G4String aliasName)
|
||||
{
|
||||
G4String targetAlias = aliasName.strip(G4String::both);
|
||||
aliasList->RemoveAlias(targetAlias);
|
||||
}
|
||||
|
||||
void G4UImanager::ListAlias()
|
||||
{
|
||||
aliasList->List();
|
||||
}
|
||||
|
||||
void G4UImanager::CreateHTML(const char* dir)
|
||||
{
|
||||
G4UIcommandTree* tr = FindDirectory(dir);
|
||||
if(tr!=0)
|
||||
{ tr->CreateHTML(); }
|
||||
else
|
||||
{ G4cerr << "Directory <" << dir << "> is not found." << G4endl; }
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UImessenger.cc,v 1.2.4.1 2001/06/28 19:10:18 gunter Exp $
|
||||
// GEANT4 tag $Name: $
|
||||
// $Id: G4UImessenger.cc,v 1.3 2001/07/11 10:01:16 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-04-00 $
|
||||
//
|
||||
|
||||
#include "G4UImessenger.hh"
|
||||
|
||||
@@ -21,14 +21,14 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIparameter.cc,v 1.5.2.1 2001/06/28 19:10:18 gunter Exp $
|
||||
// GEANT4 tag $Name: $
|
||||
// $Id: G4UIparameter.cc,v 1.10 2001/10/23 07:51:37 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-00 $
|
||||
//
|
||||
|
||||
#include "G4UIparameter.hh"
|
||||
#include "G4UIcommandStatus.hh"
|
||||
|
||||
#include "g4rw/ctoken.h"
|
||||
#include "G4Tokenizer.hh"
|
||||
|
||||
#include "G4ios.hh"
|
||||
G4UIparameter::G4UIparameter():paramERR(0)
|
||||
@@ -76,12 +76,12 @@ G4UIparameter::G4UIparameter(const char * theName, char theType, G4bool theOmitt
|
||||
G4UIparameter::~G4UIparameter()
|
||||
{ }
|
||||
|
||||
int G4UIparameter::operator==(const G4UIparameter &right) const
|
||||
G4int G4UIparameter::operator==(const G4UIparameter &right) const
|
||||
{
|
||||
return ( this == &right );
|
||||
}
|
||||
|
||||
int G4UIparameter::operator!=(const G4UIparameter &right) const
|
||||
G4int G4UIparameter::operator!=(const G4UIparameter &right) const
|
||||
{
|
||||
return ( this != &right );
|
||||
}
|
||||
@@ -130,7 +130,7 @@ void G4UIparameter::SetDefaultValue(G4double theDefaultValue)
|
||||
//#include "checkNewValue_debug.icc"
|
||||
//#define DEBUG 1
|
||||
|
||||
int G4UIparameter::
|
||||
G4int G4UIparameter::
|
||||
CheckNewValue( G4String newValue ) {
|
||||
if( TypeCheck(newValue) == 0) return fParameterUnreadable;
|
||||
if( ! parameterRange.isNull() )
|
||||
@@ -140,11 +140,11 @@ CheckNewValue( G4String newValue ) {
|
||||
return 0; // succeeded
|
||||
}
|
||||
|
||||
int G4UIparameter::
|
||||
G4int G4UIparameter::
|
||||
CandidateCheck(G4String newValue) {
|
||||
G4Tokenizer candidateTokenizer(parameterCandidate);
|
||||
G4String aToken;
|
||||
int iToken = 0;
|
||||
G4int iToken = 0;
|
||||
while( ! (aToken=candidateTokenizer()).isNull() )
|
||||
{
|
||||
iToken++;
|
||||
@@ -154,7 +154,7 @@ CandidateCheck(G4String newValue) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int G4UIparameter::
|
||||
G4int G4UIparameter::
|
||||
RangeCheck(G4String newValue) {
|
||||
yystype result;
|
||||
bp = 0; // reset buffer pointer for G4UIpGetc()
|
||||
@@ -180,7 +180,7 @@ RangeCheck(G4String newValue) {
|
||||
}
|
||||
|
||||
|
||||
int G4UIparameter::
|
||||
G4int G4UIparameter::
|
||||
TypeCheck(G4String newValue)
|
||||
{
|
||||
char type = toupper( parameterType );
|
||||
@@ -216,14 +216,14 @@ TypeCheck(G4String newValue)
|
||||
}
|
||||
|
||||
|
||||
int G4UIparameter::
|
||||
G4int G4UIparameter::
|
||||
IsInt(const char* buf, short maxDigits) // do not allow any G4std::ws
|
||||
{
|
||||
const char* p= buf;
|
||||
int length=0;
|
||||
G4int length=0;
|
||||
if( *p == '+' || *p == '-') { ++p; }
|
||||
if( isdigit( (int)(*p) )) {
|
||||
while( isdigit( (int)(*p) )) { ++p; ++length; }
|
||||
if( isdigit( (G4int)(*p) )) {
|
||||
while( isdigit( (G4int)(*p) )) { ++p; ++length; }
|
||||
if( *p == '\0' ) {
|
||||
if( length > maxDigits) {
|
||||
G4cerr <<"digit length exceeds"<<G4endl;
|
||||
@@ -240,22 +240,22 @@ IsInt(const char* buf, short maxDigits) // do not allow any G4std::ws
|
||||
}
|
||||
|
||||
|
||||
int G4UIparameter::
|
||||
G4int G4UIparameter::
|
||||
ExpectExponent(const char* str) // used only by IsDouble()
|
||||
{
|
||||
int maxExplength;
|
||||
G4int maxExplength;
|
||||
if( IsInt( str, maxExplength=7 )) return 1;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
int G4UIparameter::
|
||||
G4int G4UIparameter::
|
||||
IsDouble(const char* buf) // see state diagram for this spec.
|
||||
{
|
||||
const char* p= buf;
|
||||
switch( *p) {
|
||||
case '+': case '-': ++p;
|
||||
if( isdigit(*p) ) {
|
||||
while( isdigit( (int)(*p) )) { ++p; }
|
||||
while( isdigit( (G4int)(*p) )) { ++p; }
|
||||
switch ( *p ) {
|
||||
case '\0': return 1; //break;
|
||||
case 'E': case 'e':
|
||||
@@ -264,7 +264,7 @@ IsDouble(const char* buf) // see state diagram for this spec.
|
||||
if( *p == '\0' ) return 1;
|
||||
if( *p == 'e' || *p =='E' ) return ExpectExponent(++p );
|
||||
if( isdigit(*p) ) {
|
||||
while( isdigit( (int)(*p) )) { ++p; }
|
||||
while( isdigit( (G4int)(*p) )) { ++p; }
|
||||
if( *p == '\0' ) return 1;
|
||||
if( *p == 'e' || *p =='E') return ExpectExponent(++p);
|
||||
} else return 0; break;
|
||||
@@ -273,7 +273,7 @@ IsDouble(const char* buf) // see state diagram for this spec.
|
||||
}
|
||||
if( *p == '.' ) { ++p;
|
||||
if( isdigit(*p) ) {
|
||||
while( isdigit( (int)(*p) )) { ++p; }
|
||||
while( isdigit( (G4int)(*p) )) { ++p; }
|
||||
if( *p == '\0' ) return 1;
|
||||
if( *p == 'e' || *p =='E') return ExpectExponent(++p);
|
||||
}
|
||||
@@ -281,20 +281,20 @@ IsDouble(const char* buf) // see state diagram for this spec.
|
||||
break;
|
||||
case '.': ++p;
|
||||
if( isdigit(*p) ) {
|
||||
while( isdigit( (int)(*p) )) { ++p; }
|
||||
while( isdigit( (G4int)(*p) )) { ++p; }
|
||||
if( *p == '\0' ) return 1;
|
||||
if( *p == 'e' || *p =='E' ) return ExpectExponent(++p);
|
||||
} break;
|
||||
default: // digit is expected
|
||||
if( isdigit(*p) ) {
|
||||
while( isdigit( (int)(*p) )) { ++p; }
|
||||
while( isdigit( (G4int)(*p) )) { ++p; }
|
||||
if( *p == '\0' ) return 1;
|
||||
if( *p == 'e' || *p =='E') return ExpectExponent(++p);
|
||||
if( *p == '.' ) { ++p;
|
||||
if( *p == '\0' ) return 1;
|
||||
if( *p == 'e' || *p =='E') return ExpectExponent(++p);
|
||||
if( isdigit(*p) ) {
|
||||
while( isdigit( (int)(*p) )) { ++p; }
|
||||
while( isdigit( (G4int)(*p) )) { ++p; }
|
||||
if( *p == '\0' ) return 1;
|
||||
if( *p == 'e' || *p =='E') return ExpectExponent(++p);
|
||||
}
|
||||
@@ -393,7 +393,7 @@ yystype G4UIparameter::
|
||||
EqualityExpression(void)
|
||||
{
|
||||
yystype arg1, arg2;
|
||||
int operat;
|
||||
G4int operat;
|
||||
yystype result;
|
||||
#ifdef DEBUG
|
||||
G4cerr << " EqualityExpression()" <<G4endl;
|
||||
@@ -424,7 +424,7 @@ yystype G4UIparameter::
|
||||
RelationalExpression(void)
|
||||
{
|
||||
yystype arg1, arg2;
|
||||
int operat;
|
||||
G4int operat;
|
||||
yystype result;
|
||||
#ifdef DEBUG
|
||||
G4cerr << " RelationalExpression()" <<G4endl;
|
||||
@@ -547,13 +547,13 @@ PrimaryExpression(void)
|
||||
|
||||
//---------------- semantic routines ---------------------------------
|
||||
|
||||
int G4UIparameter::
|
||||
Eval2(yystype arg1, int op, yystype arg2)
|
||||
G4int G4UIparameter::
|
||||
Eval2(yystype arg1, G4int op, yystype arg2)
|
||||
{
|
||||
if( (arg1.type != IDENTIFIER) && (arg2.type != IDENTIFIER)) {
|
||||
G4cerr << parameterName
|
||||
<< ": meaningless comparison "
|
||||
<< int(arg1.type) << " " << int(arg2.type) << G4endl;
|
||||
<< G4int(arg1.type) << " " << G4int(arg2.type) << G4endl;
|
||||
paramERR = 1;
|
||||
}
|
||||
char type = toupper( parameterType );
|
||||
@@ -603,10 +603,10 @@ Eval2(yystype arg1, int op, yystype arg2)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int G4UIparameter::
|
||||
CompareInt(int arg1, int op, int arg2)
|
||||
G4int G4UIparameter::
|
||||
CompareInt(G4int arg1, G4int op, G4int arg2)
|
||||
{
|
||||
int result=-1;
|
||||
G4int result=-1;
|
||||
G4String opr;
|
||||
switch (op) {
|
||||
case GT: result = ( arg1 > arg2); opr= ">" ; break;
|
||||
@@ -628,10 +628,10 @@ CompareInt(int arg1, int op, int arg2)
|
||||
return result;
|
||||
}
|
||||
|
||||
int G4UIparameter::
|
||||
CompareDouble(double arg1, int op, double arg2)
|
||||
G4int G4UIparameter::
|
||||
CompareDouble(G4double arg1, G4int op, G4double arg2)
|
||||
{
|
||||
int result=-1;
|
||||
G4int result=-1;
|
||||
G4String opr;
|
||||
switch (op) {
|
||||
case GT: result = ( arg1 > arg2); opr= ">"; break;
|
||||
@@ -658,7 +658,7 @@ CompareDouble(double arg1, int op, double arg2)
|
||||
tokenNum G4UIparameter::
|
||||
Yylex() // reads input and returns token number KR486
|
||||
{ // (returns EOF)
|
||||
int c;
|
||||
G4int c;
|
||||
G4String buf;
|
||||
|
||||
while(( c= G4UIpGetc())==' '|| c=='\t' || c== '\n' )
|
||||
@@ -713,10 +713,10 @@ Yylex() // reads input and returns token number KR486
|
||||
}
|
||||
|
||||
|
||||
int G4UIparameter::
|
||||
Follow(int expect, int ifyes, int ifno)
|
||||
G4int G4UIparameter::
|
||||
Follow(G4int expect, G4int ifyes, G4int ifno)
|
||||
{
|
||||
int c = G4UIpGetc();
|
||||
G4int c = G4UIpGetc();
|
||||
if ( c== expect)
|
||||
return ifyes;
|
||||
G4UIpUngetc(c);
|
||||
@@ -724,16 +724,16 @@ Follow(int expect, int ifyes, int ifno)
|
||||
}
|
||||
|
||||
//------------------ low level routines -----------------------------
|
||||
int G4UIparameter::
|
||||
G4int G4UIparameter::
|
||||
G4UIpGetc() { // emulation of getc()
|
||||
int length = parameterRange.length();
|
||||
G4int length = parameterRange.length();
|
||||
if( bp < length)
|
||||
return parameterRange(bp++);
|
||||
else
|
||||
return EOF;
|
||||
}
|
||||
int G4UIparameter::
|
||||
G4UIpUngetc(int c) { // emulation of ungetc()
|
||||
G4int G4UIparameter::
|
||||
G4UIpUngetc(G4int c) { // emulation of ungetc()
|
||||
if (c<0) return -1;
|
||||
if (bp >0 && c == parameterRange(bp-1)) {
|
||||
--bp;
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIsession.cc,v 1.3.4.1 2001/06/28 19:10:18 gunter Exp $
|
||||
// GEANT4 tag $Name: $
|
||||
// $Id: G4UIsession.cc,v 1.4 2001/07/11 10:01:17 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-04-00 $
|
||||
//
|
||||
//
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UnitsMessenger.cc,v 1.2.4.1 2001/06/28 19:10:18 gunter Exp $
|
||||
// GEANT4 tag $Name: $
|
||||
// $Id: G4UnitsMessenger.cc,v 1.3 2001/07/11 10:01:17 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-04-00 $
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4VGlobalFastSimulationManager.cc,v 1.2.4.1 2001/06/28 19:10:19 gunter Exp $
|
||||
// GEANT4 tag $Name: $
|
||||
// $Id: G4VGlobalFastSimulationManager.cc,v 1.3 2001/07/11 10:01:17 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-04-00 $
|
||||
//
|
||||
//
|
||||
// Abstract interface for GEANT4 Global Fast Simulation Manager.
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4VVisManager.cc,v 1.3.4.1 2001/06/28 19:10:19 gunter Exp $
|
||||
// GEANT4 tag $Name: $
|
||||
// $Id: G4VVisManager.cc,v 1.4 2001/07/11 10:01:17 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-04-00 $
|
||||
//
|
||||
//
|
||||
// Abstract interface for GEANT4 Visualization Manager.
|
||||
|
||||
Reference in New Issue
Block a user