Import Geant4 0.1.0 source tree
This commit is contained in:
@@ -68,9 +68,9 @@ void G4InteractorMessenger::SetNewValue (
|
||||
G4String* params = new G4String [paramn];
|
||||
if(GetValues(newValue,paramn,params)==true) {
|
||||
if(command==addMenu) {
|
||||
session->AddMenu(params[0],params[1]);
|
||||
session->AddMenu((const char*)params[0],(const char*)params[1]);
|
||||
} else if(command==addButton) {
|
||||
session->AddButton(params[0],params[1],params[2]);
|
||||
session->AddButton((const char*)params[0],(const char*)params[1],(const char*)params[2]);
|
||||
}
|
||||
}
|
||||
delete [] params;
|
||||
@@ -84,17 +84,17 @@ G4bool GetValues (
|
||||
RWCTokenizer newValueToken( newValue );
|
||||
G4String aToken;
|
||||
for( int i=0; i<paramn;i++ ) {
|
||||
aToken = newValueToken();
|
||||
aToken = (G4String)newValueToken();
|
||||
if( aToken(0)=='"' ) {
|
||||
while( aToken(aToken.length()-1) != '"' ) {
|
||||
G4String additionalToken = newValueToken();
|
||||
G4String additionalToken = (G4String)newValueToken();
|
||||
if( additionalToken.isNull() ) {
|
||||
return false;
|
||||
}
|
||||
aToken += " ";
|
||||
aToken += additionalToken;
|
||||
}
|
||||
aToken = aToken.strip(G4String::both,'"');
|
||||
aToken = (G4String)aToken.strip(G4String::both,'"');
|
||||
}
|
||||
if( aToken.isNull() ) {
|
||||
return false;
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4VBasicShell.cc,v 2.2 1998/07/12 03:00:20 urbi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
// $Id: G4VBasicShell.cc,v 1.4 1999/05/19 17:40:56 stesting Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
//
|
||||
|
||||
#include "G4VBasicShell.hh"
|
||||
@@ -22,8 +22,8 @@
|
||||
#endif
|
||||
|
||||
G4VBasicShell::G4VBasicShell()
|
||||
:currentDirectory("/")
|
||||
{
|
||||
currentDirectory = "/";
|
||||
}
|
||||
|
||||
G4VBasicShell::~G4VBasicShell()
|
||||
@@ -31,17 +31,17 @@ G4VBasicShell::~G4VBasicShell()
|
||||
|
||||
G4String G4VBasicShell::ModifyToFullPathCommand(const char* aCommandLine)
|
||||
{
|
||||
G4String rawCommandLine = aCommandLine;
|
||||
G4String rawCommandLine = (G4String)aCommandLine;
|
||||
if(rawCommandLine.isNull()||rawCommandLine(0)=='\0') return rawCommandLine;
|
||||
G4String commandLine = rawCommandLine.strip(G4String::both);
|
||||
G4String commandLine = (G4String)rawCommandLine.strip(G4String::both);
|
||||
G4String commandString;
|
||||
G4String parameterString;
|
||||
int i = commandLine.index(" ");
|
||||
if( i != RW_NPOS )
|
||||
{
|
||||
commandString = commandLine(0,i);
|
||||
commandString = (G4String)commandLine(0,i);
|
||||
parameterString = " ";
|
||||
parameterString += commandLine(i+1,commandLine.length()-(i+1));
|
||||
parameterString += (G4String)commandLine(i+1,commandLine.length()-(i+1));
|
||||
}
|
||||
else
|
||||
{ commandString = commandLine; }
|
||||
@@ -58,12 +58,12 @@ G4String G4VBasicShell::GetCurrentWorkingDirectory()
|
||||
|
||||
G4bool G4VBasicShell::ChangeDirectory(const char* newDir)
|
||||
{
|
||||
G4String aNewPrefix = newDir;
|
||||
G4String newPrefix = aNewPrefix.strip(G4String::both);
|
||||
G4String aNewPrefix = (G4String)newDir;
|
||||
G4String newPrefix = (G4String)aNewPrefix.strip(G4String::both);
|
||||
G4String newDirectory = ModifyPath( newPrefix );
|
||||
if( newDirectory( newDirectory.length() - 1 ) != '/' )
|
||||
{ newDirectory += "/"; }
|
||||
if( FindDirectory( newDirectory ) == NULL )
|
||||
if( FindDirectory( (const char*)newDirectory ) == NULL )
|
||||
{ return false; }
|
||||
currentDirectory = newDirectory;
|
||||
return true;
|
||||
@@ -71,8 +71,8 @@ G4bool G4VBasicShell::ChangeDirectory(const char* newDir)
|
||||
|
||||
G4UIcommandTree* G4VBasicShell::FindDirectory(const char* dirName)
|
||||
{
|
||||
G4String aDirName = dirName;
|
||||
G4String theDir = aDirName.strip(G4String::both);
|
||||
G4String aDirName = (G4String)dirName;
|
||||
G4String theDir = (G4String)aDirName.strip(G4String::both);
|
||||
G4String targetDir = ModifyPath( theDir );
|
||||
if( targetDir( targetDir.length()-1 ) != '/' )
|
||||
{ targetDir += "/"; }
|
||||
@@ -83,7 +83,7 @@ G4UIcommandTree* G4VBasicShell::FindDirectory(const char* dirName)
|
||||
while( idx < targetDir.length()-1 )
|
||||
{
|
||||
int i = targetDir.index("/",idx);
|
||||
comTree = comTree->GetTree(targetDir(0,i+1));
|
||||
comTree = comTree->GetTree((G4String)targetDir(0,i+1));
|
||||
if( comTree == NULL )
|
||||
{ return NULL; }
|
||||
idx = i+1;
|
||||
@@ -93,12 +93,12 @@ G4UIcommandTree* G4VBasicShell::FindDirectory(const char* dirName)
|
||||
|
||||
G4UIcommand* G4VBasicShell::FindCommand(const char* commandName)
|
||||
{
|
||||
G4String rawCommandLine = commandName;
|
||||
G4String commandLine = rawCommandLine.strip(G4String::both);
|
||||
G4String rawCommandLine = (G4String)commandName;
|
||||
G4String commandLine = (G4String)rawCommandLine.strip(G4String::both);
|
||||
G4String commandString;
|
||||
int i = commandLine.index(" ");
|
||||
if( i != RW_NPOS )
|
||||
{ commandString = commandLine(0,i); }
|
||||
{ commandString = (G4String)commandLine(0,i); }
|
||||
else
|
||||
{ commandString = commandLine; }
|
||||
|
||||
@@ -109,12 +109,16 @@ G4UIcommand* G4VBasicShell::FindCommand(const char* commandName)
|
||||
G4String G4VBasicShell::ModifyPath(G4String tempPath)
|
||||
{
|
||||
G4String newPath = currentDirectory;
|
||||
|
||||
if( tempPath.length()>0 )
|
||||
{
|
||||
|
||||
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 += tempPath(2,tempPath.length()-2); }
|
||||
{ newPath += (G4String)tempPath(2,tempPath.length()-2); }
|
||||
else // swim up with ".."
|
||||
{
|
||||
while( 1 )
|
||||
@@ -123,12 +127,12 @@ G4String G4VBasicShell::ModifyPath(G4String tempPath)
|
||||
{
|
||||
if( newPath != "/" )
|
||||
{
|
||||
G4String tmpString = newPath(0,newPath.length()-1);
|
||||
newPath = newPath(0,tmpString.last('/')+1);
|
||||
G4String tmpString = (G4String)newPath(0,newPath.length()-1);
|
||||
newPath = (G4String)newPath(0,tmpString.last('/')+1);
|
||||
}
|
||||
if( tempPath == ".." || tempPath == "../" )
|
||||
{ break; }
|
||||
tempPath = tempPath(3,tempPath.length()-3);
|
||||
tempPath = (G4String)tempPath(3,tempPath.length()-3);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -137,7 +141,336 @@ G4String G4VBasicShell::ModifyPath(G4String tempPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return newPath;
|
||||
}
|
||||
////////////////////////////////////////////
|
||||
// Method used for command completion //////
|
||||
////////////////////////////////////////////
|
||||
G4String G4VBasicShell::Complete(G4String commandName)
|
||||
{
|
||||
G4String rawCommandLine = commandName;
|
||||
G4String commandLine = rawCommandLine.strip(G4String::both);
|
||||
int i = commandLine.index(" ");
|
||||
if( i != RW_NPOS ) return rawCommandLine; // Already entering parameters,
|
||||
// assume command path is correct.
|
||||
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
|
||||
)
|
||||
// From intercoms/src/G4UIcommandTree::FindPath.
|
||||
{
|
||||
G4String empty = "";
|
||||
if(aTree==NULL) return empty;
|
||||
G4String pathName = aTree->GetPathName();
|
||||
if( aCommandPath.index( pathName ) == RW_NPOS ) return empty;
|
||||
G4String remainingPath = aCommandPath;
|
||||
remainingPath.remove(0,pathName.length());
|
||||
int i = remainingPath.first('/');
|
||||
if( i == RW_NPOS ) {
|
||||
// Look for number of matching commands :
|
||||
RWTPtrOrderedVector<G4UIcommand> commands;
|
||||
int n_commandEntry = aTree->GetCommandEntry();
|
||||
for( int i_thCommand = 1; i_thCommand <= n_commandEntry; i_thCommand++ ) {
|
||||
G4UIcommand* cmd = aTree->GetCommand(i_thCommand);
|
||||
G4String ss = cmd->GetCommandName();
|
||||
ss.resize(remainingPath.length());
|
||||
if( remainingPath == ss ) commands.insert(cmd);
|
||||
}
|
||||
n_commandEntry = commands.entries();
|
||||
if(n_commandEntry==1) {
|
||||
return (pathName + commands[0]->GetCommandName());
|
||||
} else if (n_commandEntry>=2) {
|
||||
G4cout << "Matching commands :" << endl;
|
||||
for( int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ ) {
|
||||
G4UIcommand* cmd = commands[i_thCommand];
|
||||
G4cout << cmd->GetCommandName() << endl;
|
||||
}
|
||||
return empty;
|
||||
}
|
||||
// Look for sub tree :
|
||||
RWTPtrOrderedVector<G4UIcommandTree> trees;
|
||||
G4String nextPath = pathName;
|
||||
nextPath.append(remainingPath);
|
||||
int n_treeEntry = aTree->GetTreeEntry();
|
||||
for( int i_thTree = 1; i_thTree <= n_treeEntry; i_thTree++ ) {
|
||||
G4UIcommandTree* tree = aTree->GetTree(i_thTree);
|
||||
G4String ss = tree->GetPathName();
|
||||
ss.resize(nextPath.length());
|
||||
if( nextPath == ss ) trees.insert(tree);
|
||||
}
|
||||
n_treeEntry = trees.entries();
|
||||
if(n_treeEntry==1) {
|
||||
return trees[0]->GetPathName();
|
||||
} else if (n_treeEntry>=2) {
|
||||
G4cout << "Matching directories :" << endl;
|
||||
for( int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ ) {
|
||||
G4UIcommandTree* tree = trees[i_thTree];
|
||||
G4cout << tree->GetPathName() << endl;
|
||||
}
|
||||
return empty;
|
||||
} else {
|
||||
return empty; // No match.
|
||||
}
|
||||
} else {
|
||||
// Find path
|
||||
G4String nextPath = pathName;
|
||||
nextPath.append(remainingPath(0,i+1));
|
||||
int n_treeEntry = aTree->GetTreeEntry();
|
||||
for( int i_thTree = 1; i_thTree <= n_treeEntry; i_thTree++ ) {
|
||||
G4UIcommandTree* tree = aTree->GetTree(i_thTree);
|
||||
if( nextPath == tree->GetPathName() ) {
|
||||
return FindMatchingPath(tree,aCommandPath );
|
||||
}
|
||||
}
|
||||
}
|
||||
return empty;
|
||||
}
|
||||
////////////////////////////////////////////
|
||||
// Method involving an interactive G4cout //
|
||||
////////////////////////////////////////////
|
||||
/***************************************************************************/
|
||||
void G4VBasicShell::ExecuteCommand (
|
||||
G4String aCommand
|
||||
)
|
||||
/***************************************************************************/
|
||||
// Should be put in G4VBasicShell.
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(aCommand.length()<2) return;
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
if(UI==NULL) return;
|
||||
int commandStatus = UI->ApplyCommand(aCommand);
|
||||
switch(commandStatus) {
|
||||
case fCommandSucceeded:
|
||||
break;
|
||||
case fCommandNotFound:
|
||||
G4cerr << "command not found" << endl;
|
||||
break;
|
||||
case fIllegalApplicationState:
|
||||
G4cerr << "illegal application state -- command refused" << endl;
|
||||
break;
|
||||
case fParameterOutOfRange:
|
||||
case fParameterUnreadable:
|
||||
case fParameterOutOfCandidates:
|
||||
default:
|
||||
G4cerr << "command refused (" << commandStatus << ")" << endl;
|
||||
}
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4VBasicShell::ApplyShellCommand (
|
||||
G4String a_string
|
||||
,G4bool& exitSession
|
||||
,G4bool& exitPause
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
if(UI==NULL) return;
|
||||
|
||||
G4String command = a_string.strip(G4String::leading);
|
||||
if( command(0) == '#' ) {
|
||||
|
||||
G4cout << command << endl;
|
||||
|
||||
} else if( command == "ls" || command(0,3) == "ls " ) {
|
||||
|
||||
ListDirectory( command );
|
||||
|
||||
} else if( command == "pwd" ) {
|
||||
|
||||
G4cout << "Current Working Directory : "
|
||||
<< GetCurrentWorkingDirectory() << endl;
|
||||
|
||||
} else if( command(0,2) == "cd" ) {
|
||||
|
||||
ChangeDirectoryCommand ( command );
|
||||
|
||||
} else if( command(0,4) == "help" ) {
|
||||
|
||||
TerminalHelp( command );
|
||||
|
||||
} else if( command(0) == '?' ) {
|
||||
|
||||
ShowCurrent( command );
|
||||
|
||||
} else if( command(0,4) == "hist" ) {
|
||||
|
||||
G4int nh = UI->GetNumberOfHistory();
|
||||
for(int i=0;i<nh;i++) {
|
||||
G4cout << i << ": " << UI->GetPreviousCommand(i) << endl;
|
||||
}
|
||||
|
||||
} else if( command(0) == '!' ) {
|
||||
|
||||
G4String ss = command(1,command.length()-1);
|
||||
G4int vl;
|
||||
const char* tt = ss;
|
||||
istrstream is((char*)tt);
|
||||
is >> vl;
|
||||
G4int nh = UI->GetNumberOfHistory();
|
||||
if(vl>=0 && vl<nh) {
|
||||
G4String prev = UI->GetPreviousCommand(vl);
|
||||
G4cout << prev << endl;
|
||||
ExecuteCommand (ModifyToFullPathCommand(prev));
|
||||
} else {
|
||||
G4cerr << "history " << vl << " is not found." << endl;
|
||||
}
|
||||
|
||||
} else if( command(0,4) == "exit" ) {
|
||||
|
||||
if( exitPause == false) { //In a secondary loop.
|
||||
G4cout << "You are now processing RUN." << endl;
|
||||
G4cout << "Please abort it using \"/run/abort\" command first" << endl;
|
||||
G4cout << " and use \"continue\" command until the application" << endl;
|
||||
G4cout << " becomes to Idle." << endl;
|
||||
} else {
|
||||
exitSession = true;
|
||||
}
|
||||
|
||||
} else if( command(0,4) == "cont" ) {
|
||||
|
||||
exitPause = true;
|
||||
|
||||
} else {
|
||||
|
||||
ExecuteCommand (ModifyToFullPathCommand(a_string));
|
||||
|
||||
}
|
||||
}
|
||||
void G4VBasicShell::ShowCurrent(G4String newCommand)
|
||||
{
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
if(UI==NULL) return;
|
||||
G4String comString = newCommand(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 << endl;
|
||||
}
|
||||
}
|
||||
void G4VBasicShell::ChangeDirectoryCommand(G4String newCommand)
|
||||
{
|
||||
G4String prefix;
|
||||
if( newCommand.length() <= 3 ) {
|
||||
prefix = "/";
|
||||
} else {
|
||||
G4String aNewPrefix = newCommand(3,newCommand.length()-3);
|
||||
prefix = aNewPrefix.strip(G4String::both);
|
||||
}
|
||||
if(!ChangeDirectory(prefix)) {
|
||||
G4cout << "directory <" << prefix << "> not found." << endl;
|
||||
}
|
||||
}
|
||||
void G4VBasicShell::ListDirectory(G4String newCommand)
|
||||
{
|
||||
G4String targetDir;
|
||||
if( newCommand.length() <= 3 ) {
|
||||
targetDir = GetCurrentWorkingDirectory();
|
||||
} else {
|
||||
G4String newPrefix = newCommand(3,newCommand.length()-3);
|
||||
targetDir = newPrefix.strip(G4String::both);
|
||||
}
|
||||
G4UIcommandTree* commandTree = FindDirectory( targetDir );
|
||||
if( commandTree == NULL ) {
|
||||
G4cout << "Directory <" << targetDir << "> is not found." << endl;
|
||||
} else {
|
||||
commandTree->ListCurrent();
|
||||
}
|
||||
}
|
||||
void G4VBasicShell::TerminalHelp(G4String newCommand)
|
||||
{
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
if(UI==NULL) return;
|
||||
G4UIcommandTree * treeTop = UI->GetTree();
|
||||
int i = newCommand.index(" ");
|
||||
if( i != RW_NPOS )
|
||||
{
|
||||
G4String newValue = newCommand(i+1,newCommand.length()-(i+1));
|
||||
newValue.strip(G4String::both);
|
||||
G4String targetCom = ModifyToFullPathCommand( newValue );
|
||||
G4UIcommand* theCommand = treeTop->FindPath( targetCom );
|
||||
if( theCommand != NULL )
|
||||
{
|
||||
theCommand->List();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cout << "Command <" << newValue << " is not found." << endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
G4UIcommandTree * floor[10];
|
||||
floor[0] = treeTop;
|
||||
int iFloor = 0;
|
||||
int prefixIndex = 1;
|
||||
G4String prefix = GetCurrentWorkingDirectory();
|
||||
while( prefixIndex < prefix.length()-1 )
|
||||
{
|
||||
int ii = prefix.index("/",prefixIndex);
|
||||
floor[iFloor+1] =
|
||||
floor[iFloor]->GetTree(prefix(0,ii+1));
|
||||
prefixIndex = ii+1;
|
||||
iFloor++;
|
||||
}
|
||||
floor[iFloor]->ListCurrentWithNum();
|
||||
// 1998 Oct 2 non-number input
|
||||
while(1){
|
||||
//G4cout << endl << "Type the number ( 0:end, -n:n level back ) : "<<flush;
|
||||
G4cout << endl << "Type the number ( 0:end, -n:n level back ) : "<<endl;
|
||||
G4int i;
|
||||
if(!GetHelpChoice(i)){
|
||||
G4cout << endl << "Not a number, once more" << endl;
|
||||
continue;
|
||||
} else if( i < 0 ){
|
||||
iFloor += i;
|
||||
if( iFloor < 0 ) iFloor = 0;
|
||||
floor[iFloor]->ListCurrentWithNum();
|
||||
continue;
|
||||
} else if(i == 0) {
|
||||
break;
|
||||
} else if( i > 0 ) {
|
||||
int n_tree = floor[iFloor]->GetTreeEntry();
|
||||
if( i > n_tree )
|
||||
{
|
||||
if( i <= n_tree + floor[iFloor]->GetCommandEntry() )
|
||||
{
|
||||
floor[iFloor]->GetCommand(i-n_tree)->List();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
floor[iFloor+1] = floor[iFloor]->GetTree(i);
|
||||
iFloor++;
|
||||
floor[iFloor]->ListCurrentWithNum();
|
||||
}
|
||||
}
|
||||
}
|
||||
G4cout << "Exit from HELP." << endl << endl;
|
||||
//G4cout << endl;
|
||||
ExitHelp();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4VInteractorManager.cc,v 2.3 1998/08/07 12:39:53 barrand Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
// $Id: G4VInteractorManager.cc,v 1.5 1999/05/31 20:47:42 barrand Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
//
|
||||
// G.Barrand
|
||||
|
||||
@@ -24,14 +24,6 @@ G4VInteractorManager::G4VInteractorManager (
|
||||
:argc(0)
|
||||
,argv(NULL)
|
||||
,mainInteractor(NULL)
|
||||
,dispatchern(0)
|
||||
,dispatchers(NULL)
|
||||
,preActionn(0)
|
||||
,preActions(NULL)
|
||||
,postActionn(0)
|
||||
,postActions(NULL)
|
||||
,shelln(0)
|
||||
,shells(NULL)
|
||||
,secondaryLoopEnabled(TRUE)
|
||||
,alreadyInSecondaryLoop(FALSE)
|
||||
,exitSecondaryLoop(0)
|
||||
@@ -54,24 +46,15 @@ G4VInteractorManager::~G4VInteractorManager (
|
||||
}
|
||||
free (argv);
|
||||
}
|
||||
argv = NULL;
|
||||
argc = 0;
|
||||
if(dispatchers!=NULL) free(dispatchers);
|
||||
dispatchers = NULL;
|
||||
dispatchern = 0;
|
||||
if(preActions!=NULL) free(preActions);
|
||||
preActions = NULL;
|
||||
preActionn = 0;
|
||||
if(postActions!=NULL) free(postActions);
|
||||
postActions = NULL;
|
||||
postActionn = 0;
|
||||
if(shells!=NULL) free(shells);
|
||||
shells = NULL;
|
||||
shelln = 0;
|
||||
|
||||
secondaryLoopEnabled = TRUE;
|
||||
argv = NULL;
|
||||
argc = 0;
|
||||
dispatchers.clear();
|
||||
preActions.clear();
|
||||
postActions.clear();
|
||||
shells.clear();
|
||||
secondaryLoopEnabled = TRUE;
|
||||
alreadyInSecondaryLoop = FALSE;
|
||||
exitSecondaryLoop = 0;
|
||||
exitSecondaryLoop = 0;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4VInteractorManager::SetArguments (
|
||||
@@ -152,15 +135,8 @@ void G4VInteractorManager::AddDispatcher (
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(a_dispatcher==NULL) return;
|
||||
for(int count=0;count<dispatchern;count++) {
|
||||
if(dispatchers[count]==a_dispatcher) return; // Done.
|
||||
}
|
||||
if(dispatchern==0) dispatchers = (G4DispatchFunction*)malloc( sizeof(G4DispatchFunction));
|
||||
else dispatchers = (G4DispatchFunction*)realloc(dispatchers,
|
||||
(dispatchern+1) * sizeof(G4DispatchFunction));
|
||||
if(dispatchers==NULL) return;
|
||||
dispatchers[dispatchern] = a_dispatcher;
|
||||
dispatchern++;
|
||||
if(dispatchers.contains(a_dispatcher)==TRUE) return;
|
||||
dispatchers.insert(a_dispatcher);
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4VInteractorManager::RemoveDispatcher (
|
||||
@@ -169,12 +145,7 @@ void G4VInteractorManager::RemoveDispatcher (
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
for(int count=0;count<dispatchern;count++) {
|
||||
if(dispatchers[count]==a_dispatcher) {
|
||||
dispatchers[count] = NULL;
|
||||
return; // A dispatcher appears once in the List.
|
||||
}
|
||||
}
|
||||
dispatchers.removeAll(a_dispatcher);
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4VInteractorManager::DispatchEvent (
|
||||
@@ -183,12 +154,14 @@ void G4VInteractorManager::DispatchEvent (
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
int dispatchern = dispatchers.entries();
|
||||
G4DispatchFunction func;
|
||||
G4bool status;
|
||||
for(int count=0;count<dispatchern;count++) {
|
||||
if(
|
||||
(dispatchers[count]!=NULL) &&
|
||||
(dispatchers[count](a_event)==TRUE)
|
||||
)
|
||||
break;
|
||||
func = dispatchers[count];
|
||||
if(func!=NULL) {
|
||||
if(func(a_event)==true) return;
|
||||
}
|
||||
}
|
||||
}
|
||||
/***************************************************************************/
|
||||
@@ -199,17 +172,8 @@ void G4VInteractorManager::AddSecondaryLoopPreAction (
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(a_preAction==NULL) return;
|
||||
for(int count=0;count<preActionn;count++) {
|
||||
if(preActions[count]==a_preAction) return; // Done.
|
||||
}
|
||||
if(preActionn==0)
|
||||
preActions = (G4SecondaryLoopAction*)malloc( sizeof(G4SecondaryLoopAction));
|
||||
else
|
||||
preActions = (G4SecondaryLoopAction*)realloc(preActions,
|
||||
(preActionn+1) * sizeof(G4SecondaryLoopAction));
|
||||
if(preActions==NULL) return;
|
||||
preActions[preActionn] = a_preAction;
|
||||
preActionn++;
|
||||
if(preActions.contains(a_preAction)==TRUE) return;
|
||||
preActions.insert(a_preAction);
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4VInteractorManager::SecondaryLoopPreActions (
|
||||
@@ -217,6 +181,7 @@ void G4VInteractorManager::SecondaryLoopPreActions (
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
int preActionn = preActions.entries();
|
||||
for(int count=0;count<preActionn;count++) {
|
||||
if(preActions[count]!=NULL) preActions[count]();
|
||||
}
|
||||
@@ -229,17 +194,8 @@ void G4VInteractorManager::AddSecondaryLoopPostAction (
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(a_postAction==NULL) return;
|
||||
for(int count=0;count<postActionn;count++) {
|
||||
if(postActions[count]==a_postAction) return; // Done.
|
||||
}
|
||||
if(postActionn==0)
|
||||
postActions = (G4SecondaryLoopAction*)malloc( sizeof(G4SecondaryLoopAction));
|
||||
else
|
||||
postActions = (G4SecondaryLoopAction*)realloc(postActions,
|
||||
(postActionn+1) * sizeof(G4SecondaryLoopAction));
|
||||
if(postActions==NULL) return;
|
||||
postActions[postActionn] = a_postAction;
|
||||
postActionn++;
|
||||
if(postActions.contains(a_postAction)==TRUE) return;
|
||||
postActions.insert(a_postAction);
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4VInteractorManager::SecondaryLoopPostActions (
|
||||
@@ -247,6 +203,7 @@ void G4VInteractorManager::SecondaryLoopPostActions (
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
int postActionn = postActions.entries();
|
||||
for(int count=0;count<postActionn;count++) {
|
||||
if(postActions[count]!=NULL) postActions[count]();
|
||||
}
|
||||
@@ -262,10 +219,13 @@ void G4VInteractorManager::SecondaryLoop (
|
||||
if(secondaryLoopEnabled==FALSE) return;
|
||||
|
||||
if (alreadyInSecondaryLoop==FALSE) {
|
||||
G4cout << "------------------------------------------" << endl;
|
||||
G4cout << "You have entered a viewer secondary X event loop." << endl;
|
||||
G4cout << "Quit it with an 'Escape' viewer button" << endl;
|
||||
alreadyInSecondaryLoop = TRUE;
|
||||
exitSecondaryLoop = 0;
|
||||
SecondaryLoopPreActions ();
|
||||
// for(int count=0;count<shelln;count++) XWidgetUniconify(shells[count]);
|
||||
//for(int count=0;count<shelln;count++) XWidgetUniconify(shells[count]);
|
||||
void* event;
|
||||
while(1) {
|
||||
event = GetEvent();
|
||||
@@ -306,14 +266,8 @@ void G4VInteractorManager::AddShell (
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(a_shell==NULL) return;
|
||||
for(int count=0;count<shelln;count++) {
|
||||
if(shells[count]==a_shell) return; // Done.
|
||||
}
|
||||
if(shelln==0) shells = (G4Interactor*)malloc( sizeof(G4Interactor));
|
||||
else shells = (G4Interactor*)realloc(shells, (shelln+1) * sizeof(G4Interactor));
|
||||
if(shells==NULL) return;
|
||||
shells[shelln] = a_shell;
|
||||
shelln++;
|
||||
if(shells.contains(a_shell)==TRUE) return;
|
||||
shells.insert(a_shell);
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4VInteractorManager::RemoveShell (
|
||||
@@ -322,12 +276,7 @@ void G4VInteractorManager::RemoveShell (
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
for(int count=0;count<shelln;count++) {
|
||||
if(shells[count]==a_shell) {
|
||||
shells[count] = NULL;
|
||||
return; // A shell appears once in the List.
|
||||
}
|
||||
}
|
||||
shells.removeAll(a_shell);
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4VInteractorManager::SetParentInteractor (
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4Win32.cc,v 2.5 1998/09/19 14:45:38 barrand Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
// $Id: G4Win32.cc,v 1.4 1999/05/11 12:34:38 barrand Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
//
|
||||
// G.Barrand
|
||||
|
||||
@@ -39,8 +39,8 @@ G4Win32* G4Win32::getInstance (
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4Win32* G4Win32::getInstance (
|
||||
HANDLE a_hInstance
|
||||
,HANDLE a_hPrevInstance
|
||||
HINSTANCE a_hInstance
|
||||
,HINSTANCE a_hPrevInstance
|
||||
,LPSTR a_lpszCmdLine
|
||||
,int a_nCmdShow
|
||||
)
|
||||
@@ -57,8 +57,8 @@ G4Win32* G4Win32::getInstance (
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4Win32::G4Win32 (
|
||||
HANDLE a_hInstance
|
||||
,HANDLE a_hPrevInstance
|
||||
HINSTANCE a_hInstance
|
||||
,HINSTANCE a_hPrevInstance
|
||||
,LPSTR a_lpszCmdLine
|
||||
,int a_nCmdShow
|
||||
)
|
||||
@@ -85,7 +85,7 @@ G4Win32::G4Win32 (
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = LoadIcon (NULL,IDI_APPLICATION);
|
||||
wc.hCursor = LoadCursor(NULL,IDC_ARROW);
|
||||
wc.hbrBackground = GetStockObject(BLACK_BRUSH);
|
||||
wc.hbrBackground = GetStockBrush(BLACK_BRUSH);
|
||||
wc.lpszMenuName = className;
|
||||
wc.lpszClassName = className;
|
||||
::RegisterClass (&wc);
|
||||
@@ -103,8 +103,8 @@ G4Win32::G4Win32 (
|
||||
Win32Inited = TRUE;
|
||||
}
|
||||
|
||||
AddDispatcher ((G4DispatchFunction)G4Win32::dispatchWin32Event);
|
||||
SetMainInteractor (topWindow);
|
||||
AddDispatcher((G4DispatchFunction)G4Win32::dispatchWin32Event);
|
||||
SetMainInteractor(topWindow);
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4Win32::~G4Win32 (
|
||||
@@ -144,8 +144,8 @@ void G4Win32::FlushAndWaitExecution (
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4Win32::getWinMainArguments (
|
||||
HANDLE* a_hInstance
|
||||
,HANDLE* a_hPrevInstance
|
||||
HINSTANCE* a_hInstance
|
||||
,HINSTANCE* a_hPrevInstance
|
||||
,LPSTR* a_lpszCmdLine
|
||||
,int* a_nCmdShow
|
||||
)
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4Xt.cc,v 2.5 1998/08/25 12:23:53 barrand Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
// $Id: G4Xt.cc,v 1.2 1999/04/13 01:26:33 yhajime Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
//
|
||||
// G.Barrand
|
||||
|
||||
|
||||
Reference in New Issue
Block a user