Import Geant4 0.1.0 source tree
This commit is contained in:
@@ -5,8 +5,8 @@
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4UIXaw.cc,v 2.4 1998/09/19 14:45:28 barrand Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
// $Id: G4UIXaw.cc,v 1.2 1999/04/13 01:26:27 yhajime Exp $
|
||||
// GEANT4 tag $Name: geant4-00-01 $
|
||||
//
|
||||
// G.Barrand
|
||||
|
||||
@@ -28,16 +28,18 @@
|
||||
#include "G4UIcommandStatus.hh"
|
||||
#include "G4Xt.hh"
|
||||
|
||||
|
||||
static void Callback (Widget,XtPointer,XtPointer);
|
||||
static G4bool ConvertStringToInt(const char*,int&);
|
||||
|
||||
static G4bool exitSession = true;
|
||||
static G4bool exitPause = true;
|
||||
static G4bool exitPause = true;
|
||||
static G4bool exitHelp = true;
|
||||
/***************************************************************************/
|
||||
G4UIXaw::G4UIXaw (
|
||||
int argc
|
||||
,char** argv
|
||||
)
|
||||
:fHelp(false)
|
||||
,fHelpChoice(0)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
@@ -111,16 +113,14 @@ void G4UIXaw::PauseSessionStart (
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(a_state=="G4_pause> ")
|
||||
{
|
||||
SecondaryLoop ("Pause, type continue to exit this state");
|
||||
}
|
||||
if(a_state=="G4_pause> ") {
|
||||
SecondaryLoop ("Pause, type continue to exit this state");
|
||||
}
|
||||
|
||||
if(a_state=="EndOfEvent")
|
||||
{
|
||||
// Picking with feed back in event data Done here !!!
|
||||
SecondaryLoop ("End of event, type continue to exit this state");
|
||||
}
|
||||
if(a_state=="EndOfEvent") {
|
||||
// Picking with feed back in event data Done here !!!
|
||||
SecondaryLoop ("End of event, type continue to exit this state");
|
||||
}
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4UIXaw::SecondaryLoop (
|
||||
@@ -140,169 +140,6 @@ void G4UIXaw::SecondaryLoop (
|
||||
Prompt ("session");
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4UIXaw::ApplyShellCommand (
|
||||
G4String a_string
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
if(UI==NULL) return;
|
||||
|
||||
G4String command = a_string.strip(G4String::leading);
|
||||
if( command(0) == '#' ) {
|
||||
|
||||
G4cout << command << endl;
|
||||
|
||||
} else if( command(0,2) == "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 );
|
||||
G4cout << "Not implemented." << endl;
|
||||
|
||||
} 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 G4UIXaw::ExecuteCommand (
|
||||
G4String aCommand
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
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 G4UIXaw::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 G4UIXaw::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 G4UIXaw::ListDirectory(
|
||||
G4String newCommand
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
G4String targetDir;
|
||||
if( newCommand.length() <= 3 ) {
|
||||
targetDir = "./";
|
||||
} 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();
|
||||
}
|
||||
}
|
||||
/***************************************************************************/
|
||||
Widget G4UIXaw::GetDialog (
|
||||
)
|
||||
/***************************************************************************/
|
||||
@@ -311,9 +148,40 @@ Widget G4UIXaw::GetDialog (
|
||||
return dialog;
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4bool G4UIXaw::GetHelpChoice(
|
||||
G4int& aInt
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
fHelp = true;
|
||||
//
|
||||
G4Xt* interactorManager = G4Xt::getInstance ();
|
||||
Prompt("Help");
|
||||
exitHelp = false;
|
||||
void* event;
|
||||
while((event = interactorManager->GetEvent())!=NULL) {
|
||||
interactorManager->DispatchEvent(event);
|
||||
if(exitHelp==true) break;
|
||||
}
|
||||
Prompt("session");
|
||||
//
|
||||
if(fHelp==false) return false;
|
||||
aInt = fHelpChoice;
|
||||
fHelp = false;
|
||||
return true;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4UIXaw::ExitHelp(
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
}
|
||||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
static void Callback (
|
||||
/***************************************************************************/
|
||||
void G4UIXaw::Callback (
|
||||
Widget a_widget
|
||||
,XtPointer a_tag
|
||||
,XtPointer a_data
|
||||
@@ -327,7 +195,12 @@ static void Callback (
|
||||
if(value==NULL) return;
|
||||
G4String command (value);
|
||||
|
||||
This->ApplyShellCommand (command);
|
||||
if(This->fHelp==true) {
|
||||
exitHelp = true;
|
||||
This->fHelp = ConvertStringToInt(command.data(),This->fHelpChoice);
|
||||
} else {
|
||||
This->ApplyShellCommand (command,exitSession,exitPause);
|
||||
}
|
||||
|
||||
Arg args[1];
|
||||
XtSetArg (args[0],XtNvalue,"");
|
||||
@@ -336,13 +209,21 @@ static void Callback (
|
||||
a_widget = NULL;
|
||||
a_data = NULL;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
G4bool ConvertStringToInt(
|
||||
const char* aString
|
||||
,int& aInt
|
||||
)
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
||||
{
|
||||
aInt = 0;
|
||||
if(aString==NULL) return false;
|
||||
char* s;
|
||||
long value = strtol(aString,&s,10);
|
||||
if(s==aString) return false;
|
||||
aInt = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user