Import Geant4 10.3.0 source tree
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
$Id: History 94366 2015-11-13 08:15:49Z gcosmo $
|
||||
$Id: History 99838 2016-10-07 10:06:37Z gcosmo $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
@@ -17,6 +17,19 @@ committal in the CVS repository !
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
|
||||
7 Oct, 2016 Laurent Garnier (intercoms-V10-02-05)
|
||||
- G4UIcommandTree : Set GetFirstMatchedString() public method
|
||||
|
||||
8 August, 2016 Makoto Asai (intercoms-V10-02-04)
|
||||
- G4UIcontrolMessenger : improve /control/getVal command.
|
||||
|
||||
5 August, 2016 Makoto Asai (intercoms-V10-02-01, -02 and -03)
|
||||
- G4UIcontrolMessenger : added new commands ifBatch,
|
||||
ifInteractive, doifBatch and doifInteractive.
|
||||
|
||||
25 July, 2016 Makoto Asai (intercoms-V10-02-00)
|
||||
- G4UIcontrolMessenger : added new commands strif and strdoif.
|
||||
|
||||
12 November, 2015 Laurent Garnier (intercoms-V10-01-03)
|
||||
- G4UImanager : Coverity fixes
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcommandTree.hh 77651 2013-11-27 08:47:55Z gcosmo $
|
||||
// $Id: G4UIcommandTree.hh 99838 2016-10-07 10:06:37Z gcosmo $
|
||||
//
|
||||
|
||||
#ifndef G4UIcommandTree_h
|
||||
@@ -56,7 +56,8 @@ class G4UIcommandTree
|
||||
G4UIcommand* FindPath(const char* commandPath) const;
|
||||
G4UIcommandTree* FindCommandTree(const char* commandPath);
|
||||
G4String CompleteCommandPath(const G4String& commandPath);
|
||||
// Complete most available caracters in common into command path in the command line
|
||||
G4String GetFirstMatchedString(const G4String&,const G4String&) const;
|
||||
// Complete most available caracters in common into command path in the command line
|
||||
// given
|
||||
|
||||
void List() const;
|
||||
@@ -67,7 +68,6 @@ class G4UIcommandTree
|
||||
private:
|
||||
G4String CreateFileName(const char* pName);
|
||||
G4String ModStr(const char* strS);
|
||||
G4String GetFirstMatchedString(const G4String&,const G4String&) const;
|
||||
|
||||
std::vector<G4UIcommand*> command;
|
||||
std::vector<G4UIcommandTree*> tree;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIcontrolMessenger.hh 80641 2014-05-05 15:10:28Z gcosmo $
|
||||
// $Id: G4UIcontrolMessenger.hh 98731 2016-08-09 10:49:49Z gcosmo $
|
||||
//
|
||||
|
||||
#ifndef G4UIcontrolMessenger_h
|
||||
@@ -67,6 +67,12 @@ class G4UIcommand;
|
||||
// /control/subtract
|
||||
// /control/multiply
|
||||
// /control/divide
|
||||
// /control/strif
|
||||
// /control/strdoif
|
||||
// /control/ifBatch
|
||||
// /control/ifInteractive
|
||||
// /control/doifBatch
|
||||
// /control/doifInteractive
|
||||
|
||||
class G4UIcontrolMessenger : public G4UImessenger
|
||||
{
|
||||
@@ -103,6 +109,12 @@ class G4UIcontrolMessenger : public G4UImessenger
|
||||
G4UIcommand * multiplyCommand;
|
||||
G4UIcommand * divideCommand;
|
||||
G4UIcommand * remainderCommand;
|
||||
G4UIcommand * strifCommand;
|
||||
G4UIcommand * strdoifCommand;
|
||||
G4UIcmdWithAString * ifBatchCommand;
|
||||
G4UIcmdWithAString * ifInteractiveCommand;
|
||||
G4UIcmdWithAString * doifBatchCommand;
|
||||
G4UIcmdWithAString * doifInteractiveCommand;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UIsession.hh 67965 2013-03-13 09:35:29Z gcosmo $
|
||||
// $Id: G4UIsession.hh 98731 2016-08-09 10:49:49Z gcosmo $
|
||||
//
|
||||
// $id$
|
||||
|
||||
@@ -46,6 +46,7 @@ class G4UIsession : public G4coutDestination
|
||||
|
||||
public:
|
||||
G4UIsession();
|
||||
G4UIsession(G4int iBatch);
|
||||
virtual ~G4UIsession();
|
||||
|
||||
virtual G4UIsession * SessionStart();
|
||||
@@ -60,6 +61,11 @@ class G4UIsession : public G4coutDestination
|
||||
virtual G4int ReceiveG4cerr(const G4String& cerrString);
|
||||
// These two methods will be invoked by G4strstreambuf.
|
||||
|
||||
protected:
|
||||
static G4int inSession;
|
||||
G4int ifBatch;
|
||||
public:
|
||||
static G4int InSession() { return inSession; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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&) {;}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user