Import Geant4 10.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-12-09 12:35:28 +01:00
parent 4ec577e5c4
commit a3452e42ac
3514 changed files with 210500 additions and 89628 deletions
+3 -2
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4UIbatch.cc 83401 2014-08-21 15:03:26Z gcosmo $
// $Id: G4UIbatch.cc 98731 2016-08-09 10:49:49Z gcosmo $
//
// ====================================================================
// G4UIbatch.cc
@@ -67,7 +67,8 @@ static void Tokenize(const G4String& str, std::vector<G4String>& tokens)
////////////////////////////////////////////////////////////////////
G4UIbatch::G4UIbatch(const char* fileName, G4UIsession* prevSession)
: previousSession(prevSession), isOpened(false)
: G4UIsession(1),
previousSession(prevSession), isOpened(false)
////////////////////////////////////////////////////////////////////
{
macroStream.open(fileName, std::ios::in);
+129 -5
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4UIcontrolMessenger.cc 80641 2014-05-05 15:10:28Z gcosmo $
// $Id: G4UIcontrolMessenger.cc 98731 2016-08-09 10:49:49Z gcosmo $
//
#include <stdlib.h>
@@ -38,6 +38,7 @@
#include "G4UIcmdWithoutParameter.hh"
#include "G4UIaliasList.hh"
#include "G4StateManager.hh"
#include "G4UIsession.hh"
#include "G4Tokenizer.hh"
#include "G4ios.hh"
@@ -141,11 +142,14 @@ G4UIcontrolMessenger::G4UIcontrolMessenger()
getValCmd = new G4UIcommand("/control/getVal",this);
getValCmd->SetGuidance("Get the current value of the UI command and define it as an alias.");
getValCmd->SetGuidance("Command is ignored if the UI command does not support GetCurrentValue().");
getValCmd->SetGuidance(" Syntax : <alias_name> <UI_command>");
getValCmd->SetGuidance(" Syntax : <alias_name> <UI_command> <iIdx>");
G4UIparameter* aliName = new G4UIparameter("alias_name",'s',false);
getValCmd->SetParameter(aliName);
G4UIparameter* comName = new G4UIparameter("UI_command",'s',false);
getValCmd->SetParameter(comName);
G4UIparameter* iIdxParam = new G4UIparameter("iIdx",'i',true);
iIdxParam->SetDefaultValue(0);
getValCmd->SetParameter(iIdxParam);
echoCmd = new G4UIcmdWithAString("/control/echo",this);
echoCmd->SetGuidance("Display the aliased value.");
@@ -182,12 +186,12 @@ G4UIcontrolMessenger::G4UIcontrolMessenger()
ifCommand->SetParameter(compParam);
G4UIparameter* rightParam = new G4UIparameter("right",'d',false);
ifCommand->SetParameter(rightParam);
G4UIparameter* macroFileParam = new G4UIparameter("aliasValue",'s',false);
G4UIparameter* macroFileParam = new G4UIparameter("macroFile",'s',false);
ifCommand->SetParameter(macroFileParam);
ifCommand->SetToBeBroadcasted(false);
doifCommand = new G4UIcommand("/control/doif",this);
doifCommand->SetGuidance("Execute a macro file if the expression is true.");
doifCommand->SetGuidance("Execute a UI command if the expression is true.");
doifCommand->SetGuidance(" Syntax : <double> <comp> <double> <UI_command>");
G4UIparameter* doleftParam = new G4UIparameter("left",'d',false);
doifCommand->SetParameter(doleftParam);
@@ -267,6 +271,54 @@ G4UIcontrolMessenger::G4UIcontrolMessenger()
remainderCommand->SetParameter(val5b);
remainderCommand->SetToBeBroadcasted(false);
strifCommand = new G4UIcommand("/control/strif",this);
strifCommand->SetGuidance("Execute a macro file if the expression is true.");
strifCommand->SetGuidance(" Syntax : <string> <comp> <string> <macro_file>");
G4UIparameter* strleftParam = new G4UIparameter("left",'s',false);
strifCommand->SetParameter(strleftParam);
G4UIparameter* strcompParam = new G4UIparameter("comp",'s',false);
strcompParam->SetParameterCandidates("== !=");
strifCommand->SetParameter(strcompParam);
G4UIparameter* strrightParam = new G4UIparameter("right",'s',false);
strifCommand->SetParameter(strrightParam);
G4UIparameter* strmacroFileParam = new G4UIparameter("macroFile",'s',false);
strifCommand->SetParameter(strmacroFileParam);
strifCommand->SetToBeBroadcasted(false);
strdoifCommand = new G4UIcommand("/control/strdoif",this);
strdoifCommand->SetGuidance("Execute a UI command if the expression is true.");
strdoifCommand->SetGuidance(" Syntax : <string> <comp> <string> <UI_command>");
G4UIparameter* strdoleftParam = new G4UIparameter("left",'s',false);
strdoifCommand->SetParameter(strdoleftParam);
G4UIparameter* strdocompParam = new G4UIparameter("comp",'s',false);
strdocompParam->SetParameterCandidates("== !=");
strdoifCommand->SetParameter(strdocompParam);
G4UIparameter* strdorightParam = new G4UIparameter("right",'s',false);
strdoifCommand->SetParameter(strdorightParam);
G4UIparameter* strdomacroFileParam = new G4UIparameter("UI_command",'s',false);
strdoifCommand->SetParameter(strdomacroFileParam);
strdoifCommand->SetToBeBroadcasted(false);
ifBatchCommand = new G4UIcmdWithAString("/control/ifBatch",this);
ifBatchCommand->SetGuidance("Execute a macro file if program is running in batch mode.");
ifBatchCommand->SetParameterName("macroFile",false);
ifBatchCommand->SetToBeBroadcasted(false);
ifInteractiveCommand = new G4UIcmdWithAString("/control/ifInteractive",this);
ifInteractiveCommand->SetGuidance("Execute a macro file if program is running in interactive mode.");
ifInteractiveCommand->SetParameterName("macroFile",false);
ifInteractiveCommand->SetToBeBroadcasted(false);
doifBatchCommand = new G4UIcmdWithAString("/control/doifBatch",this);
doifBatchCommand->SetGuidance("Execute a UI command if program is running in batch mode.");
doifBatchCommand->SetParameterName("UIcommand",false);
doifBatchCommand->SetToBeBroadcasted(false);
doifInteractiveCommand = new G4UIcmdWithAString("/control/doifInteractive",this);
doifInteractiveCommand->SetGuidance("Execute a UI command if program is running in interactive mode.");
doifInteractiveCommand->SetParameterName("UIcommand",false);
doifInteractiveCommand->SetToBeBroadcasted(false);
}
G4UIcontrolMessenger::~G4UIcontrolMessenger()
@@ -296,6 +348,12 @@ G4UIcontrolMessenger::~G4UIcontrolMessenger()
delete multiplyCommand;
delete divideCommand;
delete remainderCommand;
delete strifCommand;
delete strdoifCommand;
delete ifBatchCommand;
delete ifInteractiveCommand;
delete doifBatchCommand;
delete doifInteractiveCommand;
delete controlDirectory;
}
@@ -365,8 +423,17 @@ void G4UIcontrolMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
G4String curVal = UI->GetCurrentValues(com);
if(!(curVal.isNull()))
{
G4String theValue = curVal;
G4String iIdx = next();
if(!(iIdx.isNull()))
{
G4int idx = StoI(iIdx);
G4Tokenizer nextVal(curVal);
for(G4int i = 0;i<=idx;i++)
{ theValue = nextVal(); }
}
G4String st = "/control/alias ";
st += aliName + " " + curVal;
st += aliName + " " + theValue;
UI->ApplyCommand(st);
}
}
@@ -501,6 +568,63 @@ void G4UIcontrolMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
st += DtoS(l%r);
UI->ApplyCommand(st);
}
if(command==strifCommand)
{
G4Tokenizer next(newValue);
G4String l = next();
G4String comp = next();
G4String r = next();
G4String mac = next();
G4bool x = false;
if(comp=="==") { x = (l==r); }
else if(comp=="!=") { x = (l!=r); }
if(x) UI->ExecuteMacroFile(mac);
}
if(command==strdoifCommand)
{
G4Tokenizer next(newValue);
G4String l = next();
G4String comp = next();
G4String r = next();
G4String c1 = next();
G4String ca;
while(!((ca=next()).isNull()))
{
c1 += " ";
c1 += ca;
}
if(c1(0)=='"')
{
G4String strippedValue;
if(c1(c1.length()-1)=='"')
{ strippedValue = c1(1,c1.length()-2); }
else
{ strippedValue = c1(1,c1.length()-1); }
c1 = strippedValue;
}
G4bool x = false;
if(comp=="==") { x = (l==r); }
else if(comp=="!=") { x = (l!=r); }
if(x) UI->ApplyCommand(c1);
}
if(command==ifBatchCommand)
{
if(G4UIsession::InSession()==0) UI->ExecuteMacroFile(UI->FindMacroPath(newValue));
}
if(command==ifInteractiveCommand)
{
if(G4UIsession::InSession()>0) UI->ExecuteMacroFile(UI->FindMacroPath(newValue));
}
if(command==doifBatchCommand)
{
if(G4UIsession::InSession()==0) UI->ApplyCommand(newValue);
}
if(command==doifInteractiveCommand)
{
if(G4UIsession::InSession()>0) UI->ApplyCommand(newValue);
}
}
G4String G4UIcontrolMessenger::GetCurrentValue(G4UIcommand * command)
+12 -4
View File
@@ -24,18 +24,26 @@
// ********************************************************************
//
//
// $Id: G4UIsession.cc 67965 2013-03-13 09:35:29Z gcosmo $
// $Id: G4UIsession.cc 98731 2016-08-09 10:49:49Z gcosmo $
//
//
// ---------------------------------------------------------------------
#include "G4UIsession.hh"
G4UIsession::G4UIsession() {;}
G4int G4UIsession::inSession = 0;
G4UIsession::G4UIsession() : ifBatch(0)
{
inSession++;
}
G4UIsession::~G4UIsession() {;}
G4UIsession::G4UIsession(G4int iBatch) : ifBatch(iBatch)
{;}
G4UIsession * G4UIsession::SessionStart() { return NULL; }
G4UIsession::~G4UIsession()
{ if(!ifBatch) { inSession--; } }
G4UIsession * G4UIsession::SessionStart() { return nullptr; }
void G4UIsession::PauseSessionStart(const G4String&) {;}