Import Geant4 9.6.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 17:01:34 +02:00
parent b1eb5424d2
commit e2d2f9810a
10384 changed files with 698580 additions and 628834 deletions
@@ -73,6 +73,47 @@ G4InteractorMessenger::G4InteractorMessenger (
parameter->SetDefaultValue("");
addButton->SetParameter (parameter);
// /gui/addIcon :
addIcon = new G4UIcommand("/gui/addIcon",this);
addIcon->SetGuidance
("Add a non-checkable icon to the Icon toolbar.");
addIcon->SetGuidance
("If the Icon parameter is set to \"user_icon\", you should provide the icon file in xpm format, otherwise you have to choose one of the candidate icons");
addIcon->SetGuidance
("A command given without parameters will display a window that will allow one to choose the parameters (if needed) for this command.");
addIcon->SetGuidance
("E.g: /gui/addIcon \"Change background color\" user_icon /vis/viewer/set/background ../Images/background.xpm");
addIcon->SetGuidance
("Special cases for the Icon parameter:");
addIcon->SetGuidance
(" - open: Open an open-file-selector that can run the Command with File as argument.");
addIcon->SetGuidance
(" - save: Open a save-file-selector that can run the Command with File as argument.");
addIcon->SetGuidance
(" - move/rotate/pick/zoom_in/zoom_out: Theses icons are radio-button icons that can change cursor action.");
addIcon->SetGuidance
(" - wireframe/solid/hidden_line_removal/hidden_line_and_surface_removal: These icons are radio-button icons that can change drawing style.");
addIcon->SetGuidance
(" - perspective/ortho: These icons are radio-button icons that can change projection style.");
parameter = new G4UIparameter("Label",'s',false);
parameter->SetDefaultValue("");
addIcon->SetParameter (parameter);
parameter = new G4UIparameter("Icon",'s',false);
parameter->SetDefaultValue("");
parameter->SetParameterCandidates
("open save move rotate pick zoom_in zoom_out wireframe solid hidden_line_removal hidden_line_and_surface_removal perspective ortho user_icon");
addIcon->SetParameter (parameter);
parameter = new G4UIparameter("Command",'s',true);
parameter->SetDefaultValue("no_command");
addIcon->SetParameter (parameter);
parameter = new G4UIparameter("File",'s',true);
parameter->SetDefaultValue("no_file");
addIcon->SetParameter (parameter);
// /gui/system :
sys = new G4UIcommand("/gui/system",this);
sys->SetGuidance("Send a command to the system.");
@@ -85,6 +126,7 @@ G4InteractorMessenger::G4InteractorMessenger (
G4InteractorMessenger::~G4InteractorMessenger()
{
delete addButton;
delete addIcon;
delete addMenu;
delete interactorDirectory;
}
@@ -101,6 +143,8 @@ void G4InteractorMessenger::SetNewValue (
session->AddMenu((const char*)params[0],(const char*)params[1]);
} else if(command==addButton) {
session->AddButton((const char*)params[0],(const char*)params[1],(const char*)params[2]);
} else if(command==addIcon) {
session->AddIcon((const char*)params[0],(const char*)params[1],(const char*)params[2],(const char*)params[3]);
} else if(command==sys) {
system((const char*)params[0]);
}
+1 -2
View File
@@ -24,8 +24,7 @@
// ********************************************************************
//
//
// $Id: G4Qt.cc,v 1.17 2010-05-20 07:01:03 lgarnier Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
// $Id$
//
// L. Garnier
+137 -128
View File
@@ -24,8 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VBasicShell.cc,v 1.16 2010-06-08 04:39:22 kmura Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
// $Id$
//
#include "G4VBasicShell.hh"
@@ -42,22 +41,23 @@ G4VBasicShell::G4VBasicShell()
{
}
G4VBasicShell::~G4VBasicShell()
{;}
G4String G4VBasicShell::ModifyToFullPathCommand(const char* aCommandLine)
G4VBasicShell::~G4VBasicShell()
{
G4String rawCommandLine = (G4String)aCommandLine;
}
G4String G4VBasicShell::ModifyToFullPathCommand(const char* aCommandLine) const
{
G4String rawCommandLine = aCommandLine;
if(rawCommandLine.isNull()||rawCommandLine(0)=='\0') return rawCommandLine;
G4String commandLine = (G4String)rawCommandLine.strip(G4String::both);
G4String commandLine = rawCommandLine.strip(G4String::both);
G4String commandString;
G4String parameterString;
size_t i = commandLine.index(" ");
if( i != std::string::npos )
{
commandString = (G4String)commandLine(0,i);
commandString = commandLine(0,i);
parameterString = " ";
parameterString += (G4String)commandLine(i+1,commandLine.length()-(i+1));
parameterString += commandLine(i+1,commandLine.length()-(i+1));
}
else
{ commandString = commandLine; }
@@ -67,28 +67,28 @@ G4String G4VBasicShell::ModifyToFullPathCommand(const char* aCommandLine)
return fullPathCommandLine;
}
G4String G4VBasicShell::GetCurrentWorkingDirectory()
G4String G4VBasicShell::GetCurrentWorkingDirectory() const
{
return currentDirectory;
}
G4bool G4VBasicShell::ChangeDirectory(const char* newDir)
{
G4String aNewPrefix = (G4String)newDir;
G4String newPrefix = (G4String)aNewPrefix.strip(G4String::both);
G4String aNewPrefix = newDir;
G4String newPrefix = aNewPrefix.strip(G4String::both);
G4String newDirectory = ModifyPath( newPrefix );
if( newDirectory( newDirectory.length() - 1 ) != '/' )
{ newDirectory += "/"; }
if( FindDirectory( (const char*)newDirectory ) == NULL )
if( FindDirectory( newDirectory.c_str() ) == NULL )
{ return false; }
currentDirectory = newDirectory;
return true;
}
G4UIcommandTree* G4VBasicShell::FindDirectory(const char* dirName)
G4UIcommandTree* G4VBasicShell::FindDirectory(const char* dirName) const
{
G4String aDirName = (G4String)dirName;
G4String theDir = (G4String)aDirName.strip(G4String::both);
G4String aDirName = dirName;
G4String theDir = aDirName.strip(G4String::both);
G4String targetDir = ModifyPath( theDir );
if( targetDir( targetDir.length()-1 ) != '/' )
{ targetDir += "/"; }
@@ -99,22 +99,22 @@ G4UIcommandTree* G4VBasicShell::FindDirectory(const char* dirName)
while( idx < targetDir.length()-1 )
{
size_t i = targetDir.index("/",idx);
comTree = comTree->GetTree((G4String)targetDir(0,i+1));
if( comTree == NULL )
comTree = comTree->GetTree(targetDir.substr(0,i+1).c_str());
if( comTree == NULL )
{ return NULL; }
idx = i+1;
}
return comTree;
}
G4UIcommand* G4VBasicShell::FindCommand(const char* commandName)
G4UIcommand* G4VBasicShell::FindCommand(const char* commandName) const
{
G4String rawCommandLine = (G4String)commandName;
G4String commandLine = (G4String)rawCommandLine.strip(G4String::both);
G4String rawCommandLine = commandName;
G4String commandLine = rawCommandLine.strip(G4String::both);
G4String commandString;
size_t i = commandLine.index(" ");
if( i != std::string::npos )
{ commandString = (G4String)commandLine(0,i); }
{ commandString = commandLine(0,i); }
else
{ commandString = commandLine; }
@@ -122,42 +122,50 @@ G4UIcommand* G4VBasicShell::FindCommand(const char* commandName)
return G4UImanager::GetUIpointer()->GetTree()->FindPath(targetCom);
}
G4String G4VBasicShell::ModifyPath(G4String tempPath)
G4String G4VBasicShell::ModifyPath(const G4String& tempPath) const
{
G4String newPath = currentDirectory;
if( tempPath.length() == 0 ) return tempPath;
if( tempPath.length()>0 )
{
G4String newPath = "";
if( tempPath(0) == '/' ) // full path is given
{ newPath = tempPath; }
else if( tempPath(0) != '.' ) // add current prefix
{ newPath += tempPath; }
else if( tempPath(0,2) == "./" ) // add current prefix
{ newPath += (G4String)tempPath(2,tempPath.length()-2); }
else // swim up with ".."
{
while( 1 )
{
if( tempPath(0,2) == ".." )
{
if( newPath != "/" )
{
G4String tmpString = (G4String)newPath(0,newPath.length()-1);
newPath = (G4String)newPath(0,tmpString.last('/')+1);
}
if( tempPath == ".." || tempPath == "../" )
{ break; }
tempPath = (G4String)tempPath(3,tempPath.length()-3);
}
else
{
newPath += tempPath;
break;
}
}
// temporal full path
if( tempPath(0) == '/') newPath = tempPath;
else newPath = currentDirectory + tempPath;
// body of path...
while(1){
size_t idx = newPath.find("/./");
if( idx == G4String::npos) break;
newPath.erase(idx,2);
}
while(1) {
size_t idx = newPath.find("/../");
if( idx == G4String::npos) break;
if( idx == 0) {
newPath.erase(1,3);
continue;
}
size_t idx2 = newPath.find_last_of('/', idx-1);
if(idx2 != G4String::npos) newPath.erase(idx2, idx-idx2+3);
}
// end of path...
if(newPath(newPath.size()-3,3) == "/..") {
if( newPath.size() == 3) {
newPath = "/";
} else {
size_t idx = newPath.find_last_of('/', newPath.size()-4);
if(idx != G4String::npos) newPath.erase(idx+1);
}
}
if(newPath(newPath.size()-2,2) == "/.") newPath.erase(newPath.size()-1,1);
// truncate "/////" to "/"
while(1) {
size_t idx = newPath.find("//");
if( idx == G4String::npos) break;
newPath.erase(idx,1);
}
return newPath;
@@ -165,34 +173,32 @@ G4String G4VBasicShell::ModifyPath(G4String tempPath)
////////////////////////////////////////////
// Method used for command completion //////
////////////////////////////////////////////
G4String G4VBasicShell::Complete(G4String commandName)
G4String G4VBasicShell::Complete(const G4String& commandName)
{
G4String rawCommandLine = commandName;
G4String commandLine = rawCommandLine.strip(G4String::both);
size_t i = commandLine.index(" ");
if( i != std::string::npos ) return rawCommandLine; // Already entering parameters,
if( i != std::string::npos ) return rawCommandLine; // Already entering parameters,
// assume command path is correct.
G4String commandString = commandLine;
G4String commandString = commandLine;
G4String targetCom = ModifyPath(commandString);
G4UIcommandTree* tree = G4UImanager::GetUIpointer()->GetTree();
G4String value = FindMatchingPath(tree,targetCom);
if(value=="") return rawCommandLine;
return value;
}
G4String G4VBasicShell::FindMatchingPath(
G4UIcommandTree* aTree
,G4String aCommandPath
)
G4String G4VBasicShell::FindMatchingPath(G4UIcommandTree* aTree,
const G4String& aCommandPath)
{
return aTree->CompleteCommandPath(aCommandPath);
return aTree-> CompleteCommandPath(aCommandPath);
}
////////////////////////////////////////////
// Method involving an interactive G4cout //
////////////////////////////////////////////
/***************************************************************************/
void G4VBasicShell::ExecuteCommand (
G4String aCommand
)
void G4VBasicShell::ExecuteCommand(const G4String& aCommand)
/***************************************************************************/
// Should be put in G4VBasicShell.
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
@@ -218,10 +224,8 @@ void G4VBasicShell::ExecuteCommand (
}
}
/***************************************************************************/
void G4VBasicShell::ApplyShellCommand (
G4String a_string
,G4bool& exitSession
,G4bool& exitPause
void G4VBasicShell::ApplyShellCommand (const G4String& a_string,
G4bool& exitSession, G4bool& exitPause
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
@@ -229,37 +233,39 @@ void G4VBasicShell::ApplyShellCommand (
G4UImanager* UI = G4UImanager::GetUIpointer();
if(UI==NULL) return;
G4String command = a_string.strip(G4String::leading);
if( command(0) == '#' ) {
G4String command = a_string;
command.strip(G4String::leading);
G4cout << command << G4endl;
if( command(0) == '#' ) {
} else if( command == "ls" || (G4String)command(0,3) == "ls " ) {
G4cout << command << G4endl;
} else if( command == "ls" || command(0,3) == "ls " ) {
ListDirectory( command );
} else if( command == "pwd" ) {
} else if( command == "pwd" ) {
G4cout << "Current Working Directory : "
<< GetCurrentWorkingDirectory() << G4endl;
G4cout << "Current Working Directory : "
<< GetCurrentWorkingDirectory() << G4endl;
} else if( command == "cd" || (G4String)command(0,3) == "cd ") {
} else if( command == "cd" || command(0,3) == "cd ") {
ChangeDirectoryCommand ( command );
} else if( command == "help" || (G4String)command(0,5) == "help ") {
} else if( command == "help" || command(0,5) == "help ") {
TerminalHelp( command );
TerminalHelp( command );
} else if( command(0) == '?' ) {
} else if( command(0) == '?' ) {
ShowCurrent( command );
} else if( command == "hist" || command == "history") {
G4int nh = UI->GetNumberOfHistory();
for(G4int i=0;i<nh;i++) {
G4cout << i << ": " << UI->GetPreviousCommand(i) << G4endl;
for(G4int i=0;i<nh;i++) {
G4cout << i << ": " << UI->GetPreviousCommand(i) << G4endl;
}
} else if( command(0) == '!' ) {
@@ -270,15 +276,15 @@ void G4VBasicShell::ApplyShellCommand (
std::istringstream is(tt);
is >> vl;
G4int nh = UI->GetNumberOfHistory();
if(vl>=0 && vl<nh) {
G4String prev = UI->GetPreviousCommand(vl);
if(vl>=0 && vl<nh) {
G4String prev = UI->GetPreviousCommand(vl);
G4cout << prev << G4endl;
ExecuteCommand (ModifyToFullPathCommand(prev));
} else {
G4cerr << "history " << vl << " is not found." << G4endl;
} else {
G4cerr << "history " << vl << " is not found." << G4endl;
}
} else if( command == "exit" ) {
} else if( command == "exit" ) {
if( exitPause == false) { //In a secondary loop.
G4cout << "You are now processing RUN." << G4endl;
@@ -295,51 +301,54 @@ void G4VBasicShell::ApplyShellCommand (
} else {
ExecuteCommand (ModifyToFullPathCommand(a_string));
ExecuteCommand(ModifyToFullPathCommand(a_string));
}
}
void G4VBasicShell::ShowCurrent(G4String newCommand)
void G4VBasicShell::ShowCurrent(const G4String& newCommand) const
{
G4UImanager* UI = G4UImanager::GetUIpointer();
if(UI==NULL) return;
G4String comString = newCommand(1,newCommand.length()-1);
G4String comString = newCommand.substr(1,newCommand.length()-1);
G4String theCommand = ModifyToFullPathCommand(comString);
G4String curV = UI->GetCurrentValues(theCommand);
if( ! curV.isNull() ) {
G4cout << "Current value(s) of the parameter(s) : " << curV << G4endl;
if( ! curV.isNull() ) {
G4cout << "Current value(s) of the parameter(s) : " << curV << G4endl;
}
}
void G4VBasicShell::ChangeDirectoryCommand(G4String newCommand)
void G4VBasicShell::ChangeDirectoryCommand(const G4String& newCommand)
{
G4String prefix;
if( newCommand.length() <= 3 ) {
prefix = "/";
if( newCommand.length() <= 3 ) {
prefix = "/";
} else {
G4String aNewPrefix = newCommand(3,newCommand.length()-3);
G4String aNewPrefix = newCommand.substr(3, newCommand.length()-3);
prefix = aNewPrefix.strip(G4String::both);
}
if(!ChangeDirectory(prefix)) {
G4cout << "directory <" << prefix << "> not found." << G4endl;
if(!ChangeDirectory(prefix)) {
G4cout << "directory <" << prefix << "> not found." << G4endl;
}
}
void G4VBasicShell::ListDirectory(G4String newCommand)
void G4VBasicShell::ListDirectory(const G4String& newCommand) const
{
G4String targetDir;
if( newCommand.length() <= 3 ) {
if( newCommand.length() <= 3 ) {
targetDir = GetCurrentWorkingDirectory();
} else {
G4String newPrefix = newCommand(3,newCommand.length()-3);
G4String newPrefix = newCommand.substr(3, newCommand.length()-3);
targetDir = newPrefix.strip(G4String::both);
}
G4UIcommandTree* commandTree = FindDirectory( targetDir );
if( commandTree == NULL ) {
G4cout << "Directory <" << targetDir << "> is not found." << G4endl;
} else {
commandTree->ListCurrent();
if( commandTree == NULL ) {
G4cout << "Directory <" << targetDir << "> is not found." << G4endl;
} else {
commandTree->ListCurrent();
}
}
void G4VBasicShell::TerminalHelp(G4String newCommand)
void G4VBasicShell::TerminalHelp(const G4String& newCommand)
{
G4UImanager* UI = G4UImanager::GetUIpointer();
if(UI==NULL) return;
@@ -347,12 +356,12 @@ void G4VBasicShell::TerminalHelp(G4String newCommand)
size_t i = newCommand.index(" ");
if( i != std::string::npos )
{
G4String newValue = newCommand(i+1,newCommand.length()-(i+1));
G4String newValue = newCommand.substr(i+1, newCommand.length()-(i+1));
newValue.strip(G4String::both);
G4String targetCom = ModifyToFullPathCommand( newValue );
G4UIcommand* theCommand = treeTop->FindPath( targetCom );
if( theCommand != NULL )
{
G4String targetCom = ModifyToFullPathCommand(newValue);
G4UIcommand* theCommand = treeTop->FindPath(targetCom);
if( theCommand != NULL )
{
theCommand->List();
return;
}
@@ -371,7 +380,7 @@ void G4VBasicShell::TerminalHelp(G4String newCommand)
while( prefixIndex < prefix.length()-1 )
{
size_t ii = prefix.index("/",prefixIndex);
floor[iFloor+1] =
floor[iFloor+1] =
floor[iFloor]->GetTree(G4String(prefix(0,ii+1)));
prefixIndex = ii+1;
iFloor++;
@@ -381,31 +390,31 @@ void G4VBasicShell::TerminalHelp(G4String newCommand)
while(1){
//G4cout << G4endl << "Type the number ( 0:end, -n:n level back ) : "<<std::flush;
G4cout << G4endl << "Type the number ( 0:end, -n:n level back ) : "<<G4endl;
G4int i;
if(!GetHelpChoice(i)){
G4cout << G4endl << "Not a number, once more" << G4endl;
G4int j;
if(!GetHelpChoice(j)){
G4cout << G4endl << "Not a number, once more" << G4endl;
continue;
} else if( i < 0 ){
if( iFloor < (size_t)-i ) iFloor = 0;
else iFloor += i;
//iFloor += i;
} else if( j < 0 ){
if( iFloor < (size_t)-j ) iFloor = 0;
else iFloor += j;
//iFloor += j;
//if( iFloor < 0 ) iFloor = 0;
floor[iFloor]->ListCurrentWithNum();
floor[iFloor]->ListCurrentWithNum();
continue;
} else if(i == 0) {
} else if(j == 0) {
break;
} else if( i > 0 ) {
} else if( j > 0 ) {
G4int n_tree = floor[iFloor]->GetTreeEntry();
if( i > n_tree )
{
if( i <= n_tree + floor[iFloor]->GetCommandEntry() )
{
floor[iFloor]->GetCommand(i-n_tree)->List();
if( j > n_tree )
{
if( j <= n_tree + floor[iFloor]->GetCommandEntry() )
{
floor[iFloor]->GetCommand(j-n_tree)->List();
}
}
else
{
floor[iFloor+1] = floor[iFloor]->GetTree(i);
floor[iFloor+1] = floor[iFloor]->GetTree(j);
iFloor++;
floor[iFloor]->ListCurrentWithNum();
}
@@ -51,6 +51,11 @@ void G4VInteractiveSession::AddButton (const char*,const char*,const char*)
{
}
/***************************************************************************/
void G4VInteractiveSession::AddIcon (const char*,const char*,const char*,const char*)
{
}
/***************************************************************************/
void G4VInteractiveSession::AddInteractor (G4String a_name,
G4Interactor a_interactor)
@@ -24,8 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VInteractorManager.cc,v 1.13 2006-06-29 19:10:24 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
// $Id$
//
// G.Barrand
+1 -2
View File
@@ -24,8 +24,7 @@
// ********************************************************************
//
//
// $Id: G4Win32.cc,v 1.10 2008-11-14 16:21:42 lgarnier Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
// $Id$
//
// G.Barrand
+1 -2
View File
@@ -24,8 +24,7 @@
// ********************************************************************
//
//
// $Id: G4Xt.cc,v 1.11 2006-06-29 19:10:28 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
// $Id$
//
// G.Barrand