Import Geant4 0.0.0 source tree
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
# $Id: GNUmakefile,v 2.2 1998/07/07 16:57:13 allison Exp $
|
||||
# -------------------------------------------------------------
|
||||
# GNUmakefile for interfaces/GAG library. John Allison, 6/7/98.
|
||||
|
||||
name := G4UIGAG
|
||||
|
||||
ifndef G4INSTALL
|
||||
G4INSTALL = ../../..
|
||||
endif
|
||||
|
||||
include $(G4INSTALL)/config/architecture.gmk
|
||||
include $(G4INSTALL)/config/G4UI_BUILD.gmk
|
||||
include $(G4INSTALL)/config/interactivity.gmk
|
||||
|
||||
G4TMPDIR = $(G4TMP)/$(G4SYSTEM)/$(name)
|
||||
|
||||
CPPFLAGS += -I$(G4BASE)/global/management/include
|
||||
CPPFLAGS += -I$(G4BASE)/interfaces/common/include
|
||||
CPPFLAGS += -I$(G4BASE)/intercoms/include
|
||||
|
||||
include $(G4INSTALL)/config/common.gmk
|
||||
@@ -0,0 +1,94 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4UIGAG.hh,v 2.3 1998/10/13 05:48:33 masayasu Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
// G4UIGAG.hh
|
||||
// GAG(Geant4 adaptive GUI) interface class
|
||||
// 18.Feb.98 Y.Nagamatu and T.Kodama created G4UIGAG from G4UIterminal
|
||||
|
||||
// If you want to use GAG (Tcl and JAVA version),
|
||||
// read a document file README_Momo.html.
|
||||
|
||||
#ifndef G4UIGAG_h
|
||||
#define G4UIGAG_h 1
|
||||
|
||||
#include "G4UIsession.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include <fstream.h>
|
||||
|
||||
enum UImode { terminal_mode , java_mode, tcl_mode };
|
||||
enum ChangeOfTree { notChanged=0, added, deleted, addedAndDeleted };
|
||||
|
||||
class G4UIGAG : public G4UIsession
|
||||
{
|
||||
public:
|
||||
G4UIGAG();
|
||||
~G4UIGAG();
|
||||
|
||||
G4UIsession * SessionStart();
|
||||
void PauseSessionStart(G4String);
|
||||
void Prompt(G4String);
|
||||
G4String GetCommand();
|
||||
G4int ReceiveG4cout(G4String);
|
||||
G4int ReceiveG4cerr(G4String);
|
||||
void SessionTerminate();
|
||||
|
||||
private:
|
||||
G4String prefix;
|
||||
G4UImanager * UI;
|
||||
G4String promptCharacter;
|
||||
G4bool iExit;
|
||||
G4bool iCont;
|
||||
UImode uiMode;
|
||||
|
||||
private:
|
||||
G4String JVersion;
|
||||
G4String TVersion;
|
||||
void ExecuteCommand(G4String);
|
||||
void ChangeDirectory(G4String);
|
||||
void ListDirectory(G4String);
|
||||
void TerminalHelp(G4String);
|
||||
G4String ModifyPrefix(G4String);
|
||||
G4UIcommandTree * FindDirPath(G4String);
|
||||
void ShowCurrent(G4String);
|
||||
G4String GetFullPath(G4String);
|
||||
|
||||
void SendCommandProperties(G4UIcommandTree *);
|
||||
void SendParameterProperties(G4UIcommandTree *);
|
||||
void SendAParamProperty(G4UIcommand *);
|
||||
void SendATclParamProperty(G4UIcommand *);
|
||||
void CodeGenJavaTree(G4UIcommandTree *,int recursiveLevel);
|
||||
void CodeGenJavaParams(G4UIcommandTree *,int recursiveLevel);
|
||||
void CodeGenTclTree(G4UIcommandTree *, int recursiveLevel);
|
||||
void CodeGenTclParams(G4UIcommandTree *, int recursiveLevel);
|
||||
void SendDisableList(G4UIcommandTree *, int recursiveLevel);
|
||||
|
||||
void NotifyStateChange(void);
|
||||
void NotifyCommandUpdate(void);
|
||||
void NotifyParameterUpdate(G4UIcommand *);
|
||||
|
||||
int CommandUpdated(void);
|
||||
void UpdateState(void);
|
||||
void UpdateParamVal(void); // if param is updated,
|
||||
// call NotifyParameterUpdate()
|
||||
|
||||
// --- the following are used by Notify*Update() and *Updated()
|
||||
void GetNewTreeStructure( G4UIcommandTree*,int recursiveLevel);
|
||||
void GetNewTreeValues( G4UIcommandTree*,int recursiveLevel);
|
||||
|
||||
RWTValOrderedVector<G4String> previousTreeCommands;
|
||||
RWTValOrderedVector<G4String> newTreeCommands;
|
||||
RWTValOrderedVector<G4String> previousTreeParams;
|
||||
RWTValOrderedVector<G4String> newTreeParams;
|
||||
RWTValOrderedVector<G4UIcommand*> previousTreePCP;
|
||||
RWTValOrderedVector<G4UIcommand*> newTreePCP;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,946 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4UIGAG.cc,v 2.9 1998/12/09 08:00:23 yhajime Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
// G4UIGAG.cc
|
||||
// 18.Feb.98 M.Nagamatu and T.Kodama created G4UIGAG from G4UIterminal
|
||||
|
||||
#include "G4UIGAG.hh"
|
||||
#include "G4StateManager.hh"
|
||||
#include "G4UIcommandTree.hh"
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4UIcommandStatus.hh"
|
||||
#ifdef WIN32
|
||||
# include <Strstrea.h>
|
||||
#else
|
||||
# include <strstream.h>
|
||||
#endif
|
||||
|
||||
#ifdef GNU_GCC
|
||||
template class RWTValVector<G4UIcommand *>;
|
||||
template class RWTValVector<RWCString>;
|
||||
#endif
|
||||
|
||||
G4UIGAG::G4UIGAG(): TVersion("T1.0a"), JVersion("J1.0a")
|
||||
{
|
||||
//G4cout << "G4UIGAG: Apr15,98." << endl;
|
||||
prefix = "/";
|
||||
UI = G4UImanager::GetUIpointer();
|
||||
UI->SetSession(this);
|
||||
UI->SetCoutDestination(this);
|
||||
G4StateManager * statM = G4StateManager::GetStateManager();
|
||||
promptCharacter = statM->GetStateString(statM->GetCurrentState());
|
||||
uiMode = terminal_mode; // GAG
|
||||
iExit = false;
|
||||
iCont = false;
|
||||
// -- Initialize Notify routines begin
|
||||
G4UIcommandTree * tree = UI->GetTree();
|
||||
GetNewTreeStructure(tree,0);
|
||||
GetNewTreeValues(tree,0);
|
||||
previousTreeCommands = newTreeCommands;
|
||||
previousTreeParams = newTreeParams;
|
||||
previousTreePCP = newTreePCP;
|
||||
// -- end
|
||||
}
|
||||
|
||||
G4UIGAG::~G4UIGAG()
|
||||
{
|
||||
if( G4UImanager::GetUIpointer() != 0)
|
||||
{
|
||||
UI->SetSession(NULL);
|
||||
UI->SetCoutDestination(NULL);
|
||||
// G4cout << "GAG session deleted" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
G4UIsession * G4UIGAG::SessionStart()
|
||||
{
|
||||
iExit = true;
|
||||
G4StateManager * statM = G4StateManager::GetStateManager();
|
||||
promptCharacter = statM->GetStateString(statM->GetCurrentState());
|
||||
G4String newCommand = GetCommand();
|
||||
while( iExit )
|
||||
{
|
||||
ExecuteCommand(newCommand);
|
||||
promptCharacter = statM->GetStateString(statM->GetCurrentState());
|
||||
newCommand = GetCommand();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void G4UIGAG::PauseSessionStart(G4String msg)
|
||||
{
|
||||
promptCharacter = msg;
|
||||
G4cout << "@@PROMPT \"" << promptCharacter << "\"" << endl;
|
||||
iCont = true;
|
||||
G4String newCommand = GetCommand();
|
||||
while( iCont )
|
||||
{
|
||||
ExecuteCommand(newCommand);
|
||||
newCommand = GetCommand();
|
||||
}
|
||||
}
|
||||
|
||||
void G4UIGAG::ExecuteCommand(G4String aCommand)
|
||||
{
|
||||
G4UIcommandTree * tree = UI->GetTree();
|
||||
if(aCommand.length()<2) return;
|
||||
int commandStatus = UI->ApplyCommand(aCommand);
|
||||
UpdateState();
|
||||
if ( uiMode == terminal_mode){
|
||||
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;
|
||||
}
|
||||
}else{
|
||||
switch(commandStatus) {
|
||||
case fCommandSucceeded:
|
||||
{
|
||||
GetNewTreeStructure(tree,0);
|
||||
GetNewTreeValues(tree,0);
|
||||
if (CommandUpdated()) {
|
||||
NotifyCommandUpdate();
|
||||
} else {
|
||||
UpdateParamVal(); // if param is updated, call notifyPara...
|
||||
}
|
||||
previousTreeCommands = newTreeCommands;
|
||||
previousTreeParams = newTreeParams;
|
||||
previousTreePCP = newTreePCP;
|
||||
}
|
||||
break;
|
||||
case fCommandNotFound:
|
||||
G4cout << "@@ErrResult \"command not found.\"" << endl;
|
||||
break;
|
||||
case fIllegalApplicationState:
|
||||
G4cout << "@@ErrResult \"Illegal application state -- command refused\"" << endl;
|
||||
break;
|
||||
case fParameterOutOfRange:
|
||||
G4cout << "@@ErrResult \"Parameter Out of Range.\"" << endl;
|
||||
break;
|
||||
case fParameterUnreadable:
|
||||
G4cout << "@@ErrResult \"Parameter Unreadable.\"" << endl;
|
||||
break;
|
||||
case fParameterOutOfCandidates:
|
||||
G4cout << "@@ErrResult \"Parameter Out of Candidates.\"" << endl;
|
||||
break;
|
||||
default:
|
||||
G4cout << "@@ErrResult \"command refused (" << commandStatus << ")\"" << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
G4int G4UIGAG::ReceiveG4cout(G4String coutString)
|
||||
{
|
||||
cout << coutString << flush;
|
||||
return 0;
|
||||
}
|
||||
|
||||
G4int G4UIGAG::ReceiveG4cerr(G4String cerrString)
|
||||
{
|
||||
cerr << cerrString << flush;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void G4UIGAG::Prompt(G4String aPrompt)
|
||||
{
|
||||
promptCharacter = aPrompt;
|
||||
}
|
||||
|
||||
G4String G4UIGAG::GetCommand()
|
||||
{
|
||||
G4String newCommand;
|
||||
G4String nullString;
|
||||
while( 1 )
|
||||
{
|
||||
G4UIcommandTree* tree = UI->GetTree();
|
||||
if ( uiMode != terminal_mode ){
|
||||
G4cout << "@@PROMPT \"" << promptCharacter << "\"" << endl;
|
||||
}
|
||||
if ( uiMode != java_mode ){
|
||||
G4cout << promptCharacter << "> " << flush;
|
||||
}else{
|
||||
G4cout << "@@Ready" << endl;
|
||||
}
|
||||
newCommand.readLine( cin );
|
||||
if (!cin.good()) { cin.clear(); newCommand = nullString; iExit=false;break;}
|
||||
while( newCommand(newCommand.length()-1) == '_' )
|
||||
{
|
||||
G4String newLine;
|
||||
newCommand.remove(newCommand.length()-1);
|
||||
newLine.readLine( cin );
|
||||
if (!cin.good()) { cin.clear(); newCommand = nullString; iExit=false;break;}
|
||||
newCommand.append(newLine);
|
||||
}
|
||||
|
||||
G4String nC = newCommand.strip(G4String::leading);
|
||||
// -------------------- nC.toUpper();
|
||||
if( nC == "@@GAGmodeJAVA" ) {
|
||||
uiMode = java_mode;
|
||||
G4cout << endl << "@@Version " << JVersion << endl;
|
||||
SendCommandProperties(tree);
|
||||
NotifyStateChange();
|
||||
}
|
||||
else if( nC == "@@GAGmodeTcl" ) {
|
||||
uiMode = tcl_mode;
|
||||
G4cout << endl << "@@Version " << TVersion << endl;
|
||||
SendCommandProperties(tree);
|
||||
NotifyStateChange();
|
||||
}
|
||||
else if( nC(0) == '#' )
|
||||
{ G4cout << nC << endl; }
|
||||
|
||||
else if( nC == "ls" || nC(0,3) == "ls " )
|
||||
{ ListDirectory( nC ); }
|
||||
else if( nC == "pwd" )
|
||||
{ G4cout << "Current Working Directory : " << prefix << endl; }
|
||||
else if( nC(0,2) == "cd" || nC(0,3) == "cd " )
|
||||
{ ChangeDirectory( nC ); }
|
||||
else if( nC == "help" || nC(0,5) == "help ")
|
||||
{ TerminalHelp( nC ); }
|
||||
else if( nC(0) == '?' )
|
||||
{ ShowCurrent( nC ); }
|
||||
else if( nC(0,4) == "hist" || nC == "history")
|
||||
{
|
||||
G4int nh = UI->GetNumberOfHistory();
|
||||
for(int i=0;i<nh;i++)
|
||||
{ G4cout << i << ": " << UI->GetPreviousCommand(i) << endl; }
|
||||
}
|
||||
else if( nC(0) == '!' )
|
||||
{
|
||||
G4String ss = nC(1,nC.length()-1);
|
||||
G4int vl;
|
||||
const char* tt = ss;
|
||||
istrstream is((char*)tt);
|
||||
is >> vl;
|
||||
G4int nh = UI->GetNumberOfHistory();
|
||||
if(vl>=0 && vl<nh)
|
||||
{
|
||||
newCommand = UI->GetPreviousCommand(vl);
|
||||
G4cout << newCommand << endl;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{ G4cerr << "history " << vl << " is not found." << endl; }
|
||||
}
|
||||
else if( nC(0,4) == "exit" )
|
||||
{
|
||||
if( iCont )
|
||||
{
|
||||
if ( uiMode == terminal_mode){
|
||||
G4cerr << "You are now processing RUN." << endl;
|
||||
G4cerr << "Please abrot it using \"/run/abort\" command first" << endl;
|
||||
G4cerr << " and use \"continue\" command until the application" << endl;
|
||||
G4cerr << " becomes to Idle." << endl;
|
||||
}else{
|
||||
G4cout << "@@ErrResult \"You are now processing RUN.\"" << endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
iExit = false;
|
||||
newCommand = nullString;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if( nC == "cont" || nC == "continue" )
|
||||
{
|
||||
iCont = false;
|
||||
newCommand = nullString;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{ break; }
|
||||
}
|
||||
return GetFullPath(newCommand);
|
||||
}
|
||||
|
||||
G4String G4UIGAG::GetFullPath( G4String aNewCommand )
|
||||
{
|
||||
G4String newCommand = aNewCommand.strip(G4String::both);
|
||||
G4String tmpString;
|
||||
if( newCommand(0) == '/' )
|
||||
{ tmpString = newCommand; }
|
||||
else if( newCommand(0,3) == "../" )
|
||||
{
|
||||
G4String tmpPrefix = prefix;
|
||||
G4int i_direc = 0;
|
||||
while( i_direc < newCommand.length() )
|
||||
{
|
||||
if( newCommand(i_direc,3) == "../" )
|
||||
{
|
||||
i_direc += 3;
|
||||
prefix = ModifyPrefix( G4String("../") );
|
||||
}
|
||||
else
|
||||
{ break; }
|
||||
}
|
||||
tmpString = prefix;
|
||||
tmpString.append( newCommand( i_direc, newCommand.length()-i_direc ) );
|
||||
prefix = tmpPrefix;
|
||||
}
|
||||
else
|
||||
{
|
||||
tmpString = prefix;
|
||||
tmpString.append( newCommand );
|
||||
}
|
||||
return tmpString;
|
||||
}
|
||||
|
||||
void G4UIGAG::SessionTerminate()
|
||||
{
|
||||
G4cout << "***** Terminal session end *****" << endl;
|
||||
}
|
||||
|
||||
void G4UIGAG::ShowCurrent( G4String newCommand )
|
||||
{
|
||||
G4String theCommand = GetFullPath(newCommand(1,newCommand.length()-1));
|
||||
G4String curV = UI->GetCurrentValues(theCommand);
|
||||
if( ! (curV.isNull()||curV(0)=='\0' ) ) {
|
||||
if (uiMode == terminal_mode){
|
||||
G4cout << "Current value(s) of the parameter(s) : " << curV << endl;
|
||||
}else{
|
||||
G4cout << "@@CurrentValue " << curV << endl;
|
||||
}
|
||||
} else if (uiMode == terminal_mode){
|
||||
G4cout << "Current value is not available." << endl;
|
||||
} else {
|
||||
G4cout << "@@ErrResult \"Current value is not available.\"" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void G4UIGAG::ChangeDirectory( G4String newCommand )
|
||||
{
|
||||
G4String savedPrefix = prefix;
|
||||
if( newCommand.length() <= 3 )
|
||||
{ prefix = "/"; }
|
||||
else
|
||||
{
|
||||
G4String aNewPrefix = newCommand(3,newCommand.length()-3);
|
||||
G4String newPrefix = aNewPrefix.strip(G4String::both);
|
||||
if( newPrefix(0) == '/' )
|
||||
{ prefix = newPrefix; }
|
||||
else if( newPrefix(0) != '.' )
|
||||
{
|
||||
prefix += newPrefix;
|
||||
}
|
||||
else
|
||||
{ prefix = ModifyPrefix( newPrefix ); }
|
||||
}
|
||||
if( prefix( prefix.length() - 1 ) != '/' )
|
||||
{ prefix += "/"; }
|
||||
if( FindDirPath( prefix ) == NULL )
|
||||
{
|
||||
G4cout << "Directory <" << prefix << "> is not found." << endl;
|
||||
prefix = savedPrefix;
|
||||
}
|
||||
}
|
||||
|
||||
void G4UIGAG::ListDirectory( G4String newCommand )
|
||||
{
|
||||
G4String targetDir('\0');
|
||||
if( newCommand.length() <= 3 )
|
||||
{ targetDir = prefix; }
|
||||
else
|
||||
{
|
||||
G4String newPrefix = newCommand(3,newCommand.length()-3);
|
||||
newPrefix.strip(G4String::both);
|
||||
if( newPrefix(0) == '/' )
|
||||
{ targetDir = newPrefix; }
|
||||
else if( newPrefix(0) != '.' )
|
||||
{
|
||||
targetDir = prefix;
|
||||
targetDir += newPrefix;
|
||||
}
|
||||
else
|
||||
{ targetDir = ModifyPrefix( newPrefix ); }
|
||||
}
|
||||
if( targetDir( targetDir.length() - 1 ) != '/' )
|
||||
{ targetDir += "/"; }
|
||||
G4UIcommandTree * commandTree = FindDirPath( targetDir );
|
||||
if( commandTree == NULL )
|
||||
{ G4cout << "Directory <" << targetDir << "> is not found." << endl; }
|
||||
else
|
||||
{ commandTree->ListCurrent(); }
|
||||
}
|
||||
|
||||
void G4UIGAG::TerminalHelp(G4String newCommand)
|
||||
{
|
||||
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);
|
||||
if( newValue(0) != '/' )
|
||||
{ newValue.prepend( prefix ); }
|
||||
G4UIcommand * theCommand = treeTop->FindPath( newValue );
|
||||
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;
|
||||
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;
|
||||
cin >> i;
|
||||
if(!cin.good()){
|
||||
cin.clear();
|
||||
cin.ignore(30,'\n');
|
||||
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();
|
||||
//iFloor++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
floor[iFloor+1] = floor[iFloor]->GetTree(i);
|
||||
iFloor++;
|
||||
floor[iFloor]->ListCurrentWithNum();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
G4cout << "Exit from HELP." << endl << endl;
|
||||
G4cout << endl;
|
||||
// cin.flush();
|
||||
char temp[100];
|
||||
cin.getline( temp, 100 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
G4String G4UIGAG::ModifyPrefix(G4String newCommand)
|
||||
{
|
||||
G4String newPrefix = prefix;
|
||||
while( 1 )
|
||||
{
|
||||
if( newCommand(0,2) == ".." )
|
||||
{
|
||||
if( newPrefix != "/" )
|
||||
{
|
||||
G4String tmpString = newPrefix(0,newPrefix.length()-1);
|
||||
newPrefix = newPrefix(0,tmpString.last('/')+1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newPrefix += newCommand;
|
||||
break;
|
||||
}
|
||||
if( newCommand == ".." || newCommand == "../" )
|
||||
{ break; }
|
||||
newCommand = newCommand(3,newCommand.length()-3);
|
||||
}
|
||||
return newPrefix;
|
||||
}
|
||||
|
||||
G4UIcommandTree * G4UIGAG::FindDirPath(G4String newCommand)
|
||||
{
|
||||
G4UIcommandTree * comTree = UI->GetTree();
|
||||
int idx = 1;
|
||||
while( idx < newCommand.length()-1 )
|
||||
{
|
||||
int i = newCommand.index("/",idx);
|
||||
comTree = comTree->GetTree(newCommand(0,i+1));
|
||||
if( comTree == NULL )
|
||||
{ return NULL; }
|
||||
idx = i+1;
|
||||
}
|
||||
return comTree;
|
||||
}
|
||||
|
||||
// ----- for JAVA GAG (by T.Kodama)
|
||||
|
||||
void G4UIGAG::SendCommandProperties(G4UIcommandTree * tree)
|
||||
{
|
||||
if( tree == NULL ) {
|
||||
G4cerr << "GetTree() returnes null." << endl;
|
||||
return;
|
||||
}
|
||||
if (uiMode == java_mode){
|
||||
G4cout << "@@JTreeBegin" << endl;
|
||||
CodeGenJavaTree(tree, 0);
|
||||
G4cout << "@@JTreeEnd" << endl;
|
||||
CodeGenJavaParams(tree, 0);
|
||||
}else{
|
||||
G4cout << endl << "@@maketree_start" << endl;
|
||||
CodeGenTclTree(tree,0);
|
||||
G4cout << "@@maketree_end" << endl;
|
||||
CodeGenTclParams(tree, 0);
|
||||
}
|
||||
}
|
||||
void G4UIGAG::SendParameterProperties(G4UIcommandTree * tree)
|
||||
{
|
||||
if( tree == NULL ) {
|
||||
G4cerr << "GetTree() returnes null." << endl;
|
||||
return;
|
||||
}
|
||||
if (uiMode == java_mode){
|
||||
CodeGenJavaParams(tree, 0);
|
||||
}else{
|
||||
CodeGenTclParams(tree, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void G4UIGAG::CodeGenJavaTree(G4UIcommandTree * tree, int level)
|
||||
{
|
||||
int treeEntry, commandEntry;
|
||||
treeEntry = tree->GetTreeEntry();
|
||||
commandEntry = tree->GetCommandEntry();
|
||||
|
||||
if(level!=0) {
|
||||
for(int i=0; i<commandEntry; i++){
|
||||
G4cout << tree->GetCommand(i+1)->GetCommandPath() << endl;
|
||||
}
|
||||
}
|
||||
if(treeEntry == 0) return; //end recursion
|
||||
|
||||
for(int j=0; j<treeEntry; j++){
|
||||
CodeGenJavaTree(tree->GetTree(j+1), level+1);
|
||||
}
|
||||
}
|
||||
|
||||
void G4UIGAG::CodeGenJavaParams(G4UIcommandTree * tree, int level) //recursive
|
||||
{
|
||||
int treeEntry, commandEntry, i;
|
||||
G4UIcommand * Comp;
|
||||
G4UIcommandTree * treeLink;
|
||||
|
||||
treeEntry = tree->GetTreeEntry();
|
||||
commandEntry = tree->GetCommandEntry();
|
||||
|
||||
for(i=0; i<commandEntry; i++) {
|
||||
SendAParamProperty(tree->GetCommand(i+1));
|
||||
}
|
||||
if( treeEntry == 0 ) return; // end recursion
|
||||
|
||||
for(i=0; i< treeEntry; i++) {
|
||||
treeLink = tree->GetTree(i+1);
|
||||
G4cout << "@@JDirGuideBegin" << endl;
|
||||
G4cout << treeLink->GetPathName() << endl << treeLink->GetTitle() << endl;
|
||||
G4cout << "@@JDirGuideEnd" << endl;
|
||||
CodeGenJavaParams(treeLink, level+1);
|
||||
}
|
||||
}
|
||||
|
||||
void G4UIGAG::SendAParamProperty(G4UIcommand * Comp)
|
||||
{
|
||||
int guidanceEntry, parameterEntry;
|
||||
G4String title, title2;
|
||||
G4UIparameter * prp;
|
||||
char c[2];
|
||||
guidanceEntry = Comp->GetGuidanceEntries();
|
||||
parameterEntry = Comp->GetParameterEntries();
|
||||
G4cout << "@@JParamBegin" << endl;
|
||||
G4cout << Comp->GetCommandPath() << endl;
|
||||
G4cout << guidanceEntry << endl;
|
||||
for (int j=0; j<guidanceEntry; j++){
|
||||
title = Comp->GetGuidanceLine(j);
|
||||
title2 = "";
|
||||
if (title != ""){
|
||||
for(int i=0; i< title.length(); i++){
|
||||
c[0]=title(i);
|
||||
c[1]= '\0';
|
||||
if ( c[0] == '\n' || c[0] == '\r') {
|
||||
c[0]= ' ';
|
||||
}
|
||||
title2.append(c);
|
||||
}
|
||||
}
|
||||
G4cout << title2 << endl;
|
||||
}
|
||||
G4cout << Comp->GetRange() << endl;
|
||||
G4cout << parameterEntry << endl;
|
||||
for( int par=0; par<parameterEntry; par++) {
|
||||
prp = (G4UIparameter *)Comp->GetParameter(par);
|
||||
G4cout << prp->GetParameterName() << endl;
|
||||
G4cout << prp->GetParameterGuidance() << endl;
|
||||
G4cout << prp->GetParameterType() << endl;
|
||||
G4cout << prp->IsOmittable() << endl;
|
||||
G4cout << prp->GetDefaultValue() << endl;
|
||||
G4cout << prp->GetParameterRange() << endl;
|
||||
G4cout << prp->GetParameterCandidates() << endl;
|
||||
}
|
||||
G4cout << "@@JParamEnd" << endl;
|
||||
}
|
||||
|
||||
void G4UIGAG::SendDisableList(G4UIcommandTree * tree, int level)
|
||||
{
|
||||
int treeEntry, commandEntry;
|
||||
G4UIcommand * Comp;
|
||||
treeEntry = tree->GetTreeEntry();
|
||||
commandEntry = tree->GetCommandEntry();
|
||||
|
||||
for(int com=0; com<commandEntry; com++) {
|
||||
Comp = tree->GetCommand(com+1);
|
||||
if( Comp->IsAvailable()==false ) {
|
||||
G4cout << Comp->GetCommandPath()<<endl;
|
||||
}
|
||||
}
|
||||
if( treeEntry == 0 ) return; // end recursion
|
||||
|
||||
for( int i=0; i<treeEntry; i++) {
|
||||
SendDisableList(tree->GetTree(i+1), level+1);
|
||||
// be sure the function name is the same
|
||||
}
|
||||
}
|
||||
|
||||
// ----- for Tcl GAG
|
||||
|
||||
void G4UIGAG::CodeGenTclTree(G4UIcommandTree * tree, int level)
|
||||
{
|
||||
int i, j;
|
||||
int treeEntry, commandEntry, guidanceEntry;
|
||||
treeEntry = tree->GetTreeEntry();
|
||||
commandEntry = tree->GetCommandEntry();
|
||||
G4String commandPath, pathName, title1, title2;
|
||||
G4UIcommandTree * t;
|
||||
G4UIcommand * Comp;
|
||||
|
||||
for(int com=0; com<commandEntry; com++){
|
||||
Comp = tree->GetCommand(com+1);
|
||||
commandPath = Comp->GetCommandPath();
|
||||
G4cout << commandPath << " @@command" << endl;
|
||||
guidanceEntry = Comp->GetGuidanceEntries();
|
||||
if (guidanceEntry == 0){
|
||||
title2 = "...Title not available...";
|
||||
} else {
|
||||
title2 = "";
|
||||
j = 0;
|
||||
while(1){
|
||||
title1 = Comp->GetGuidanceLine(j);
|
||||
for(i=0; i< title1.length(); i++){
|
||||
char c[2];
|
||||
c[0]=title1(i);
|
||||
c[1]= '\0';
|
||||
if( c[0] == '\"') {
|
||||
title2.append("\\\""); // a Backslash and a double quote
|
||||
} else if ( c[0] == '\n' || c[0] == '\r') {
|
||||
title2.append("\\n");
|
||||
} else title2.append(c);
|
||||
}
|
||||
j++;
|
||||
if (j >= guidanceEntry) break;
|
||||
title2.append("\\n");
|
||||
}
|
||||
}
|
||||
G4cout << commandPath << " @@title \""<< title2 <<"\""<< endl;
|
||||
}
|
||||
|
||||
if(treeEntry == 0) return; //end recursion
|
||||
|
||||
for(i=0; i< treeEntry; i++){
|
||||
t = tree->GetTree(i+1);
|
||||
pathName = t->GetPathName();
|
||||
title1 = t->GetTitle();
|
||||
title2 = "";
|
||||
for(int i=0; i<title1.length(); i++){
|
||||
char c[2];
|
||||
c[0]=title1(i);
|
||||
c[1]= '\0';
|
||||
if( c[0] == '\"')
|
||||
title2.append("\\\""); // a Backslash and a double quote
|
||||
else title2.append(c);
|
||||
}
|
||||
if(level==0) G4cout << pathName<< endl;
|
||||
else G4cout << pathName<< " @@cascade"<<endl;
|
||||
G4cout << pathName << " @@title \"" << title1 << "\""<<endl;
|
||||
CodeGenTclTree(t, level+1);
|
||||
}
|
||||
}
|
||||
|
||||
void G4UIGAG::CodeGenTclParams( G4UIcommandTree * tree, int level) // recursive
|
||||
{
|
||||
int treeEntry, commandEntry;
|
||||
G4UIcommand * Comp;
|
||||
treeEntry = tree->GetTreeEntry();
|
||||
commandEntry = tree->GetCommandEntry();
|
||||
|
||||
for(int com=0; com<commandEntry; com++) {
|
||||
Comp = tree->GetCommand(com+1);
|
||||
SendATclParamProperty(Comp);
|
||||
}
|
||||
if( treeEntry == 0 ) return; // end recursion
|
||||
|
||||
for( int i=0; i<treeEntry; i++) {
|
||||
CodeGenTclParams(tree->GetTree(i+1), level+1);
|
||||
// be sure the function name is the same
|
||||
}
|
||||
}
|
||||
|
||||
void G4UIGAG::SendATclParamProperty(G4UIcommand * Comp)
|
||||
{
|
||||
G4UIparameter * prp;
|
||||
int parameterEntry = Comp->GetParameterEntries();
|
||||
G4String commandPath = Comp->GetCommandPath();
|
||||
G4String commandRange = Comp->GetRange();
|
||||
G4cout << "@@parameter_start" << endl;
|
||||
G4cout << commandPath << " @@param " << parameterEntry << endl;
|
||||
G4cout << "@@command_range \"" << commandRange << "\"" << endl;
|
||||
for( int par=0; par<parameterEntry; par++) {
|
||||
prp = (G4UIparameter *)Comp->GetParameter(par);
|
||||
G4cout << "{" ;
|
||||
G4cout << "@@param_name : \"" << prp->GetParameterName() <<"\""<<endl;
|
||||
G4String guide1,guide2;
|
||||
guide1 = prp->GetParameterGuidance();
|
||||
guide2 = "";
|
||||
for(int i=0; i<guide1.length(); i++){
|
||||
char c[2];
|
||||
c[0]=guide1(i);
|
||||
c[1]= '\0';
|
||||
if( c[0] == '\"')
|
||||
guide2.append("\\\""); // a Backslash and a double quote
|
||||
else guide2.append(c);
|
||||
}
|
||||
G4cout << " @@param_guide : \"" << guide2 << "\""<<endl;
|
||||
G4cout << " @@param_type : \"" << prp->GetParameterType()<<"\""<<endl;
|
||||
G4cout << " @@param_omit : \"" << prp->IsOmittable()<<"\""<<endl;
|
||||
G4cout << " @@param_default : \""<< prp->GetDefaultValue()<<"\""<<endl;
|
||||
G4cout << " @@param_range : \""<< prp->GetParameterRange()<<"\""<<endl;
|
||||
G4cout << " @@param_candidate : \"" << prp->GetParameterCandidates()<< "\""<<endl;
|
||||
G4cout << "}" << endl;
|
||||
}
|
||||
G4cout << "@@parameter_end" << endl;
|
||||
}
|
||||
|
||||
void G4UIGAG::NotifyStateChange(void)
|
||||
{
|
||||
G4String stateString;
|
||||
G4StateManager * statM = G4StateManager::GetStateManager();
|
||||
G4UIcommandTree * tree = UI->GetTree();
|
||||
stateString = statM->GetStateString(statM->GetCurrentState());
|
||||
if ( uiMode != terminal_mode ){
|
||||
G4cout << "@@State \"" << stateString << "\"" << endl;
|
||||
G4cout << "@@DisableListBegin"<<endl;
|
||||
SendDisableList(tree, 0);
|
||||
G4cout << "@@DisableListEnd" <<endl;
|
||||
}
|
||||
}
|
||||
|
||||
void G4UIGAG::NotifyCommandUpdate(void)
|
||||
{
|
||||
G4UIcommandTree * tree = UI->GetTree();
|
||||
SendCommandProperties(tree);
|
||||
}
|
||||
|
||||
void G4UIGAG::NotifyParameterUpdate(G4UIcommand* com)
|
||||
{
|
||||
if (uiMode == java_mode)
|
||||
SendAParamProperty(com);
|
||||
else
|
||||
SendATclParamProperty(com);
|
||||
}
|
||||
|
||||
//####### update check routines ####################################
|
||||
void G4UIGAG::UpdateState(void)
|
||||
{
|
||||
static G4ApplicationState previousState= PreInit;
|
||||
G4ApplicationState newState;
|
||||
G4StateManager *statM = G4StateManager::GetStateManager();
|
||||
newState = statM->GetCurrentState();
|
||||
if( newState != previousState )
|
||||
{
|
||||
NotifyStateChange();
|
||||
previousState = newState;
|
||||
}
|
||||
}
|
||||
|
||||
int G4UIGAG::CommandUpdated(void)
|
||||
{
|
||||
int added=0, deleted=0;
|
||||
int pEntry= previousTreeCommands.entries();
|
||||
int nEntry= newTreeCommands.entries();
|
||||
int i,j;
|
||||
for( i=0; i<pEntry; i++) { // check deleted command(s)
|
||||
for( j=0; j<nEntry; j++) {
|
||||
if( previousTreeCommands(i) == newTreeCommands(j)) break;
|
||||
}
|
||||
if( j==nEntry ) {
|
||||
deleted = 1;
|
||||
//G4cout <<"deleted: "<< previousTreeCommands(i) << endl;
|
||||
}
|
||||
}
|
||||
for( i=0; i<nEntry; i++) { // check added command(s)
|
||||
for( j=0; j<pEntry; j++) {
|
||||
if( newTreeCommands(i) == previousTreeCommands(j)) break;
|
||||
}
|
||||
if( j==pEntry ) {
|
||||
added = 1;
|
||||
// G4cout <<"added: "<< newTreeCommands(i) << endl;
|
||||
}
|
||||
}
|
||||
if( added && deleted==0 ) {G4cout<<"c added"<<endl;return added;}
|
||||
if( added==0 && deleted ) {G4cout<<"c deleted"<<endl;return deleted;}
|
||||
if( added && deleted ) {G4cout<<"c add/deleted"<<endl;return addedAndDeleted;}
|
||||
return notChanged;
|
||||
}
|
||||
|
||||
void G4UIGAG::GetNewTreeStructure(G4UIcommandTree * tree, int level)
|
||||
{
|
||||
G4String commandPath;
|
||||
G4String title;
|
||||
G4String pathName; //tree name
|
||||
G4UIcommandTree * t;
|
||||
int treeEntry = tree->GetTreeEntry();
|
||||
int commandEntry = tree->GetCommandEntry();
|
||||
|
||||
if( level==0 ) { newTreeCommands.clear();}
|
||||
for(int com=0; com<commandEntry; com++){
|
||||
commandPath = tree->GetCommand(com+1)->GetCommandPath();
|
||||
title = tree->GetCommand(com+1)->GetTitle();
|
||||
newTreeCommands.insert( commandPath + " " + title );
|
||||
}
|
||||
|
||||
if(treeEntry == 0) return; //end recursion
|
||||
|
||||
for(int i=0; i< treeEntry; i++){
|
||||
t = tree->GetTree(i+1);
|
||||
pathName = t->GetPathName();
|
||||
title = t->GetTitle();
|
||||
newTreeCommands.insert( pathName + " " + title );
|
||||
GetNewTreeStructure(t, level+1);
|
||||
}
|
||||
}
|
||||
|
||||
void G4UIGAG::UpdateParamVal(void)
|
||||
{
|
||||
// call NotifyParameterUpdate() if the value of each
|
||||
// command/parameter is updated.
|
||||
// assuming the command structure is not changed.
|
||||
int pEntry= previousTreeParams.entries();
|
||||
int nEntry= newTreeParams.entries();
|
||||
int i;
|
||||
G4UIcommand* Comp;
|
||||
if (pEntry != nEntry) return;
|
||||
for( i=0; i<nEntry; i++) {
|
||||
if( previousTreeParams(i) != newTreeParams(i)){
|
||||
Comp = newTreePCP(i);
|
||||
G4cout << Comp->GetCommandPath()
|
||||
<< " command is updated." <<endl;
|
||||
NotifyParameterUpdate(Comp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//void G4UIGAG::paramUpdate(void)
|
||||
//{
|
||||
// int added=0, deleted=0;
|
||||
// int pEntry= previousTreeParams.entries();
|
||||
// int nEntry= newTreeParams.entries();
|
||||
// int i,j;
|
||||
//
|
||||
// if (pEntry != nEntry) return NULL;
|
||||
// for( i=0; i<pEntry; i++) { // check deleted param(s)
|
||||
// for( j=0; j<nEntry; j++) {
|
||||
// if( previousTreeParams(i) == newTreeParams(j)) break;
|
||||
// }
|
||||
// if( j==nEntry ) {
|
||||
// deleted = 1;
|
||||
// //G4cout <<"para deleted: "<< previousTreeParams(i) << endl;
|
||||
// }
|
||||
// }
|
||||
// for( i=0; i<nEntry; i++) { // check added param(s)
|
||||
// for( j=0; j<pEntry; j++) {
|
||||
// if( newTreeParams(i) == previousTreeParams(j)) break;
|
||||
// }
|
||||
// if( j==pEntry ) {
|
||||
// added = 1;
|
||||
// //G4cout <<"para added: "<< newTreeParams(i) << endl;
|
||||
// }
|
||||
// }
|
||||
// if( added && deleted==0 ) {G4cout<<"p added"<<endl;return added;}
|
||||
// if( added==0 && deleted ) {G4cout<<"p deleted"<<endl;return deleted;}
|
||||
// if( added && deleted ) {G4cout<<"p add/deleted"<<endl; return addedAndDeleted;}
|
||||
// return notChanged;
|
||||
//}
|
||||
|
||||
void G4UIGAG::GetNewTreeValues( G4UIcommandTree * tree, int level) // recursive
|
||||
{
|
||||
G4String commandPath;
|
||||
G4String pathName; //tree name
|
||||
G4UIcommandTree * t;
|
||||
int parameterEntry;
|
||||
int treeEntry = tree->GetTreeEntry();
|
||||
int commandEntry = tree->GetCommandEntry();
|
||||
G4UIcommand * Comp;
|
||||
G4UIparameter * prp;
|
||||
G4String param, str(" ");
|
||||
|
||||
if( level==0 ) { newTreeParams.clear(); }
|
||||
for(int com=0; com<commandEntry; com++) {
|
||||
Comp = tree->GetCommand(com+1);
|
||||
commandPath = Comp->GetCommandPath();
|
||||
parameterEntry = Comp->GetParameterEntries();
|
||||
param = commandPath +" ";
|
||||
for( int par=0; par< parameterEntry; par++) {
|
||||
prp = (G4UIparameter *)Comp->GetParameter(par);
|
||||
param += prp->GetParameterName() +" ";
|
||||
str(0) = prp->GetParameterType();
|
||||
param += str + " ";
|
||||
param += prp->GetDefaultValue() +" ";
|
||||
param += prp->GetParameterRange() +" ";
|
||||
param += prp->GetParameterCandidates();
|
||||
}
|
||||
newTreeParams.insert( param + "\n");
|
||||
newTreePCP.insert( Comp );
|
||||
}
|
||||
if( treeEntry == 0 ) return; // end recursion
|
||||
for( int i=0; i< treeEntry; i++) {
|
||||
t = tree->GetTree(i+1);
|
||||
GetNewTreeValues(t, level+1);
|
||||
}
|
||||
}
|
||||
//######################################################
|
||||
@@ -0,0 +1,57 @@
|
||||
# $Id: GNUmakefile,v 2.5 1998/07/08 11:29:45 allison Exp $
|
||||
# -----------------------------------------------------------------------
|
||||
# GNUmakefile for interfaces. John Allison, 5/7/98.
|
||||
# -----------------------------------------------------------------------
|
||||
|
||||
MAKEFLAGS= --no-print-directory
|
||||
|
||||
name := G4interfaces
|
||||
|
||||
ifndef G4INSTALL
|
||||
G4INSTALL = ../..
|
||||
endif
|
||||
|
||||
include $(G4INSTALL)/config/architecture.gmk
|
||||
include $(G4INSTALL)/config/G4UI_BUILD.gmk
|
||||
include $(G4INSTALL)/config/interactivity.gmk
|
||||
|
||||
G4LIBDIR := $(G4LIB)/$(G4SYSTEM)
|
||||
G4TMPDIR := $(G4TMP)/$(G4SYSTEM)/$(name)
|
||||
ifndef G4UI_BUILD
|
||||
G4UI_BUILD := yes
|
||||
endif
|
||||
ifndef G4UI_BUILD_BASIC_SESSION
|
||||
G4UI_BUILD_BASIC_SESSION := yes
|
||||
endif
|
||||
|
||||
########################### interfaces/common #######################
|
||||
|
||||
ifdef G4UI_BUILD
|
||||
SUBDIRS := common
|
||||
SUBLIBS := G4UIcommon
|
||||
endif
|
||||
|
||||
########################### interfaces/basic #######################
|
||||
|
||||
ifdef G4UI_BUILD_BASIC_SESSION
|
||||
SUBDIRS += basic
|
||||
SUBLIBS += G4UIbasic
|
||||
endif
|
||||
|
||||
########################### interfaces/GAG #######################
|
||||
|
||||
ifdef G4UI_BUILD_GAG_SESSION
|
||||
SUBDIRS += GAG
|
||||
SUBLIBS += G4UIGAG
|
||||
endif
|
||||
|
||||
########################### interfaces/OPACS #######################
|
||||
|
||||
ifdef G4UI_BUILD_WO_SESSION
|
||||
SUBDIRS += OPACS
|
||||
SUBLIBS += G4UIOPACS
|
||||
endif
|
||||
|
||||
########################### interfaces/XVT - not currently implemented #####
|
||||
|
||||
include $(G4INSTALL)/config/globlib.gmk
|
||||
@@ -0,0 +1,140 @@
|
||||
$Id: History,v 2.20 1998/12/09 08:06:43 yhajime Exp $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
|
||||
=========================================================
|
||||
|
||||
Category History file
|
||||
---------------------
|
||||
This file should be used by G4 developers and category coordinators
|
||||
to briefly summarize all major modifications introduced in the code
|
||||
and keep track of all category-tags.
|
||||
It DOES NOT substitute the CVS log-message one should put at every
|
||||
committal in the CVS repository !
|
||||
|
||||
----------------------------------------------------------
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
interfaces-00-03-07 9th December 1998 Hajime Yoshida/Masayasu Nagamatu
|
||||
- minor improvements in Help of G4UIterminal.cc
|
||||
- G4UIGAG's Help in terminal mode is now equivalent to G4UIterminal.cc
|
||||
|
||||
interfaces-00-03-06 27th November 1998 Hajime Yoshida/Masayasu Nagamatu
|
||||
- added 'if' protection to the destructor of G4UIterminal/G4UIGAG.
|
||||
|
||||
interfaces-00-03-05 12th November 1998 Masayasu Nagamatu
|
||||
-test/G4cout_test01/ added an example for redirectiong stream using G4cout
|
||||
|
||||
interfaces-00-03-04 13th October 1998 Masayasu Nagamatu
|
||||
- G4cout - changes to G4UIterminal.cc, G4UIGAG.hh, G4UIGAG.cc.
|
||||
|
||||
07 Ocotober 1998 Guy Barrand:
|
||||
- G4UIXm.cc, G4UIWin32.cc : cout, cerr control.
|
||||
|
||||
interfaces-00-03-03 7th October Hajime Yoshida
|
||||
- Bug fix to prevent "help" crashing in some circumstances.
|
||||
|
||||
interfaces-00-03-02 14th Sep. Hajime Yoshida
|
||||
- fix to G4UIGAG (not bugs but correction of minor
|
||||
ydifferences with G4UIterminal)
|
||||
|
||||
interfaces-00-03-01 12th Sep. Hajime Yoshida and Masayasu Nagamatu
|
||||
- CTRL-D doesn't invoke infinite loop.
|
||||
- CRTL-D now means
|
||||
- EOF in the redirected cin
|
||||
- End of Session, just as "exit" command of GEANT4
|
||||
- Affected files are basic/src/G4UIterminal.cc
|
||||
GAG/src/G4UIGAG.cc
|
||||
|
||||
interfaces-00-02-01 9th August John Allison
|
||||
- Tagged Guy's changes.
|
||||
|
||||
7th August Guy Barrand.
|
||||
- common, OPACS : new interactor parenting logic.
|
||||
|
||||
interfaces-00-01-04 8th July 1998 John Allison
|
||||
- Emptied xvt_standalone_test; files moved to environments/XVT.
|
||||
|
||||
interfaces-00-01-03 7th July 1998 John Allison
|
||||
- Emptied standalone_test; files moved to environments/Momo or no
|
||||
longer needed.
|
||||
|
||||
7th July 1998 Guy Barrand
|
||||
- Added include $(G4INSTALL)/config/interactivity.gmk to GNUmakefiles.
|
||||
|
||||
interfaces-00-01-02 7th July 1998 John Allison
|
||||
- Forced revision 2.1 on files in newly committed directories.
|
||||
|
||||
interfaces-00-01-01 6th July 1998 John Allison
|
||||
- Big restructuring. Moved files from include/ and src/ to:
|
||||
common/, basic/, GAG/, OPACS/, XVT/.
|
||||
Created G4UI_BUILD.gmk and G4UI_USE.gmk in config/.
|
||||
Changed the GNUmakefiles accordingly.
|
||||
|
||||
interfaces-00-07-01 2nd July 1998 Gabriele Cosmo
|
||||
- Updates to G4UIWo and G4VInteractorManager by G.Barrand.
|
||||
|
||||
interfaces-00-06-05 26th June 1998 Gabriele Cosmo
|
||||
- Updated GNUmakefiles to new electromagnetics structure.
|
||||
|
||||
interfaces-00-06-04a 22nd June 1998 John Allison
|
||||
- Removed ./standalone_test/run/example34/GNUmakefile.G4VIS_USE and
|
||||
./standalone_test/run/example35/GNUmakefile.G4VIS_USE
|
||||
|
||||
interfaces-00-06-04 22nd June 1998 John Allison
|
||||
- Added #ifdef GNU_GCC for template instantiation in src/G4UIGAG.cc.
|
||||
- Changed GNUmakefiles for G4VIS_USE.gmk.
|
||||
|
||||
May 6, 98 M.Asai
|
||||
- Introducing a new abstract base class G4VBasicShell.
|
||||
- G4UIterminal has been modified according to use G4VBasicShell.
|
||||
|
||||
22th April 1998 Hajime Yoshida / Masayasu Nagamatsu (interfaces-00-05-03)
|
||||
- the following three directories are tagged.
|
||||
interfaces/standalone_test/Momo/java/GGE
|
||||
interfaces/standalone_test/Momo/java/RMI
|
||||
interfaces/standalone_test/run/example35
|
||||
|
||||
20th April 1998 Hajime Yoshida / Masayasu Nagamatsu (interfaces-00-05-02)
|
||||
- update for Momo and G4UIGAG, including many improvement and bug fixes.
|
||||
see the interfaces/standalone_test/README_Momo.html for datails.
|
||||
- example35 is added; new example program to show the capability of GUI(GAG).
|
||||
|
||||
15th April 1998 : Guy Barrand
|
||||
- From discussion with John and Simone G4VToolkit
|
||||
has been renamed to G4VInteractorManager.
|
||||
|
||||
4th April 1998 Nagamatu Masayasu (interfaces-00-05-01)
|
||||
- correspond to the modification by G.Barrand
|
||||
G4UI_BUILD_xxx_DRIVER -> G4UI_BUILD_xxx_SESSION
|
||||
Modifications for Win32/NT.
|
||||
|
||||
April 2, 98 G.Barrand
|
||||
- G4UI_BUILD_xxx_DRIVER -> G4UI_BUILD_xxx_SESSION
|
||||
- Modifications for Win32/NT.
|
||||
|
||||
26th March 1998 John Allison
|
||||
- Changed G4VisManager to MyVisManager in example34.cc and xvt.benchmark.cc
|
||||
for vis-00-05-01 and later.
|
||||
|
||||
6th March 1998 Hajime Yoshida / Nagamatu Masayasu (interfaces-00-04-01)
|
||||
- First tag with modeling under visualization
|
||||
- small bug fix for Momo
|
||||
|
||||
29th January 1998 Masayasu Nagamatu / Hajime Yoshida (interfaces-00-03-01)
|
||||
- Update of Momo(GAG/GGE), standalone_test/ directory.
|
||||
|
||||
27th January 1998 John Allison
|
||||
- Simplfied use of G4VIS flags in test GNUmakefiles.
|
||||
- New way of instantiating G4VisManager in test main() programs.
|
||||
|
||||
December 19, 97 G. Cosmo - (alpha03)
|
||||
|
||||
- Created.
|
||||
|
||||
Januray 19 , 98 G. Barrand
|
||||
|
||||
- Update G4UIXaw, G4UIXm to take into account
|
||||
pauseStartSession method.
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
# $Id: GNUmakefile,v 2.2 1998/07/07 16:57:17 allison Exp $
|
||||
# -------------------------------------------------------------
|
||||
# GNUmakefile for interfaces/OPACS library. John Allison, 6/7/98.
|
||||
|
||||
name := G4UIOPACS
|
||||
|
||||
ifndef G4INSTALL
|
||||
G4INSTALL = ../../..
|
||||
endif
|
||||
|
||||
include $(G4INSTALL)/config/architecture.gmk
|
||||
include $(G4INSTALL)/config/G4UI_BUILD.gmk
|
||||
include $(G4INSTALL)/config/interactivity.gmk
|
||||
|
||||
G4TMPDIR = $(G4TMP)/$(G4SYSTEM)/$(name)
|
||||
|
||||
CPPFLAGS += -I$(G4BASE)/global/management/include
|
||||
CPPFLAGS += -I$(G4BASE)/interfaces/common/include
|
||||
CPPFLAGS += -I$(G4BASE)/intercoms/include
|
||||
|
||||
include $(G4INSTALL)/config/common.gmk
|
||||
@@ -0,0 +1,38 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4UIWo.hh,v 2.3 1998/10/23 14:42:27 barrand Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
#ifndef G4UIWo_h
|
||||
#define G4UIWo_h
|
||||
|
||||
#if defined(G4UI_BUILD_WO_SESSION) || defined(G4UI_USE_WO)
|
||||
|
||||
#include "G4UIsession.hh"
|
||||
|
||||
class G4WoMessenger;
|
||||
|
||||
class G4UIWo : public G4UIsession {
|
||||
public:
|
||||
G4UIWo(int,char**);
|
||||
~G4UIWo();
|
||||
G4UIsession* SessionStart();
|
||||
void Prompt(G4String);
|
||||
void SessionTerminate();
|
||||
void PauseSessionStart(G4String);
|
||||
G4int ReceiveG4cout(G4String);
|
||||
G4int ReceiveG4cerr(G4String);
|
||||
private:
|
||||
void SecondaryLoop(G4String);
|
||||
G4WoMessenger* woMessenger;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4WoMessenger.hh,v 2.3 1998/07/12 03:42:49 urbi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
#ifndef G4WoMessenger_h
|
||||
#define G4WoMessenger_h 1
|
||||
|
||||
#ifdef G4UI_BUILD_WO_SESSION
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4UImessenger.hh"
|
||||
|
||||
class G4UIdirectory;
|
||||
class G4UIcmdWithoutParameter;
|
||||
class G4UIcmdWithAString;
|
||||
|
||||
#include <OShell.h>
|
||||
|
||||
class G4WoMessenger: public G4UImessenger
|
||||
{
|
||||
public:
|
||||
G4WoMessenger(OShell);
|
||||
~G4WoMessenger();
|
||||
public:
|
||||
void SetNewValue (G4UIcommand * command,G4String newValues);
|
||||
G4String GetCurrentValue(G4UIcommand * command);
|
||||
private:
|
||||
OShell shell;
|
||||
private: //commands
|
||||
G4UIdirectory* WoDirectory;
|
||||
G4UIcmdWithoutParameter* sendExitCmd;
|
||||
G4UIcmdWithAString* oshCmd;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4oCommon.hh,v 2.2 1998/07/12 02:59:59 urbi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
/*
|
||||
Included by G4o.h.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*G4*/
|
||||
#include <G4UImanager.hh>
|
||||
|
||||
/*Co*/
|
||||
#include <CMemory.h>
|
||||
#include <CPrinter.h>
|
||||
#include <CText.h>
|
||||
#include <CFile.h>
|
||||
#include <OType.h>
|
||||
#include <OShell.h>
|
||||
#include <OProcess.h>
|
||||
|
||||
|
||||
static void SetTypes ();
|
||||
static void ExecuteScript (char*);
|
||||
static int Execute_G4 (int,char**,OProcess);
|
||||
static int DoMethod (OIdentifier,char*,void*,int,char**,void*,int*);
|
||||
static G4UIcommand* GetCommandIdentifier (char*);
|
||||
static void GetCommands (G4UIcommandTree*,int*,char***);
|
||||
static int ProduceODB (G4UIcommand*,char*);
|
||||
|
||||
@@ -0,0 +1,463 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4oCommon.icc,v 2.2 1998/07/12 03:00:00 urbi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
/*
|
||||
Included by G4o.cc.
|
||||
*/
|
||||
|
||||
/***************************************************************************/
|
||||
void SetTypes (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
OType otype;
|
||||
/*.........................................................................*/
|
||||
if(OTypeGetIdentifier("G4")!=NULL) return; /*Done*/
|
||||
|
||||
otype = OTypeCreate ("G4");
|
||||
OTypeSetDoMethodFunction (otype,DoMethod);
|
||||
OTypeAddNewClassMethodProperty (otype,"getCommandGuidance" ,OPropertyString,NULL);
|
||||
OTypeAddNewClassMethodProperty (otype,"askListOfCommands" ,OPropertyString,NULL);
|
||||
OTypeAddNewClassMethodProperty (otype,"createCommandPanel" ,OPropertyVoid,NULL);
|
||||
|
||||
}
|
||||
/***************************************************************************/
|
||||
int Execute_G4 (
|
||||
int a_argn
|
||||
,char** a_args
|
||||
,OProcess a_process
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*
|
||||
osh> G4 <string:command> <string:param 1> ...
|
||||
*/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
int count;
|
||||
char* string = NULL;
|
||||
/*.........................................................................*/
|
||||
if(a_argn<=1)
|
||||
{
|
||||
CWarnF ("At least one argument expected in:\n%s\n",OProcessGetCommand(a_process));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
for(count=1;count<a_argn;count++)
|
||||
{
|
||||
CStringConcatenate (&string,a_args[count]);
|
||||
CStringConcatenate (&string," ");
|
||||
}
|
||||
ExecuteScript (string);
|
||||
CStringDelete (string);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void ExecuteScript (
|
||||
char* a_string
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
G4UImanager* UI;
|
||||
int linen = 0;
|
||||
char** lines = NULL;
|
||||
/*.........................................................................*/
|
||||
UI = G4UImanager::GetUIpointer();
|
||||
if(UI==NULL) return;
|
||||
lines = CTextCreateFromString (a_string,&linen);
|
||||
if( (linen!=0) && (lines!=NULL) )
|
||||
{
|
||||
int count;
|
||||
for(count=0;count<linen;count++)
|
||||
{
|
||||
CStringTrim(lines[count]);
|
||||
if( (lines[count]==NULL) || (lines[count][0]=='\0') || (lines[count][0]=='#') ) continue;
|
||||
UI->ApplyCommand(lines[count]);
|
||||
}
|
||||
}
|
||||
CTextDelete (linen,lines);
|
||||
}
|
||||
/***************************************************************************/
|
||||
int DoMethod (
|
||||
OIdentifier This
|
||||
,char* a_name
|
||||
,void* a_user
|
||||
,int a_argn
|
||||
,char** a_args
|
||||
,void* a_addr
|
||||
,int* a_number
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
/*.........................................................................*/
|
||||
if(a_number!=NULL) *a_number = 0;
|
||||
if(a_name==NULL) return 0;
|
||||
|
||||
if(This==NULL)
|
||||
{
|
||||
if(strcmp(a_name,"getCommandGuidance")==0)
|
||||
{
|
||||
G4UIcommand* command;
|
||||
char* string = NULL;
|
||||
int count,linen,paramn;
|
||||
if(a_argn!=1)
|
||||
{
|
||||
CWarnF ("One arguments expected for %s property.\n",a_name);
|
||||
return 0;
|
||||
}
|
||||
command = GetCommandIdentifier(a_args[0]);
|
||||
if(command==NULL)
|
||||
{
|
||||
CWarnF ("Unknown G4 command :\n%s\n",a_args[0]);
|
||||
return 0;
|
||||
}
|
||||
linen = command->GetGuidanceEntries();
|
||||
for(count=0;count<linen;count++)
|
||||
{
|
||||
CStringConcatenate (&string,(char*)command->GetGuidanceLine(count).data());
|
||||
CStringConcatenate (&string,"\n");
|
||||
}
|
||||
paramn = command->GetParameterEntries();
|
||||
for(count=0;count<paramn;count++)
|
||||
{
|
||||
char* info;
|
||||
char* line;
|
||||
G4UIparameter* parameter = (G4UIparameter*)command->GetParameter(count);
|
||||
|
||||
info = (char*)parameter->GetParameterName().data();
|
||||
line = CStringCreateF(12+strlen(info)+1,"Parameter : %s\n",info);
|
||||
CStringConcatenate (&string,line);
|
||||
CStringDelete (line);
|
||||
|
||||
if( ! parameter->GetParameterGuidance().isNull() )
|
||||
{
|
||||
CStringConcatenate (&string,(char*)parameter->GetParameterGuidance().data());
|
||||
CStringConcatenate (&string,"\n");
|
||||
}
|
||||
|
||||
line = CStringCreateF(19+1+1," Parameter type : %c\n",parameter->GetParameterType());
|
||||
CStringConcatenate (&string,line);
|
||||
CStringDelete (line);
|
||||
|
||||
if(parameter->IsOmittable()==True)
|
||||
line = CStringDuplicate(" Omittable : true\n");
|
||||
else
|
||||
line = CStringDuplicate(" Omittable : false\n");
|
||||
CStringConcatenate (&string,line);
|
||||
CStringDelete (line);
|
||||
|
||||
if( ! parameter->GetDefaultValue().isNull() )
|
||||
{
|
||||
info = (char*)parameter->GetDefaultValue().data();
|
||||
line = CStringCreateF(19+strlen(info)+1," Default value : %s\n",info);
|
||||
CStringConcatenate (&string,line);
|
||||
CStringDelete (line);
|
||||
}
|
||||
|
||||
if( ! parameter->GetParameterRange().isNull() )
|
||||
{
|
||||
info = (char*)parameter->GetParameterRange().data();
|
||||
line = CStringCreateF(19+strlen(info)+1," Parameter range : %s\n",info);
|
||||
CStringConcatenate (&string,line);
|
||||
CStringDelete (line);
|
||||
}
|
||||
}
|
||||
*((char**)a_addr) = string;
|
||||
return FREE_BLOCK;
|
||||
}
|
||||
else if(strcmp(a_name,"askListOfCommands")==0)
|
||||
{
|
||||
G4UIcommandTree* treeTop;
|
||||
char* string = NULL;
|
||||
G4UImanager* UI;
|
||||
int linen = 0;
|
||||
char** lines = NULL;
|
||||
UI = G4UImanager::GetUIpointer();
|
||||
if(UI==NULL) return 0;
|
||||
treeTop = UI->GetTree();
|
||||
if(treeTop==NULL) return 0;
|
||||
if(a_argn==1) treeTop = treeTop->GetTree(a_args[0]);
|
||||
GetCommands (treeTop,&linen,&lines);
|
||||
string = CTextConvertToString (linen,lines,"\n");
|
||||
CTextDelete (linen,lines);
|
||||
*((char**)a_addr) = string;
|
||||
return FREE_BLOCK;
|
||||
}
|
||||
else if(strcmp(a_name,"createCommandPanel")==0)
|
||||
{
|
||||
if(a_argn!=2)
|
||||
{
|
||||
CWarnF ("Two arguments expected for %s property.\n",a_name);
|
||||
return 0;
|
||||
}
|
||||
return ProduceODB(GetCommandIdentifier(a_args[0]),a_args[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
CInfoF ("G4_DoMethod: %s is not a class routine property.\n",a_name);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
CInfoF ("G4_DoMethod: %s is not a routine property.\n",a_name);
|
||||
|
||||
a_user = NULL;
|
||||
a_argn = 0;
|
||||
a_args = NULL;
|
||||
a_addr = NULL;
|
||||
return 0;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void GetCommands (
|
||||
G4UIcommandTree* a_tree
|
||||
,int* a_linen
|
||||
,char*** a_lines
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
/*.........................................................................*/
|
||||
if(a_tree==NULL) return;
|
||||
|
||||
int n_commandEntry = a_tree->GetCommandEntry();
|
||||
for( int i_thCommand = 1; i_thCommand <= n_commandEntry; i_thCommand++ )
|
||||
{
|
||||
G4UIcommand* command = a_tree->GetCommand(i_thCommand);
|
||||
CTextAddLine (a_linen,a_lines,(char*)command->GetCommandPath().data());
|
||||
}
|
||||
|
||||
int n_treeEntry = a_tree->GetTreeEntry();
|
||||
for( int i_thTree = 1; i_thTree <= n_treeEntry; i_thTree++ )
|
||||
{
|
||||
GetCommands (a_tree->GetTree(i_thTree),a_linen,a_lines);
|
||||
}
|
||||
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4UIcommand* GetCommandIdentifier (
|
||||
char* a_name
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
G4UImanager* UI;
|
||||
G4UIcommandTree* treeTop;
|
||||
/*.........................................................................*/
|
||||
if(a_name==NULL) return NULL;
|
||||
UI = G4UImanager::GetUIpointer();
|
||||
if(UI==NULL) return NULL;
|
||||
treeTop = UI->GetTree();
|
||||
if(treeTop==NULL) return NULL;
|
||||
return treeTop->FindPath(a_name);
|
||||
}
|
||||
/***************************************************************************/
|
||||
int ProduceODB (
|
||||
G4UIcommand* a_command
|
||||
,char* a_name
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
FILE* file;
|
||||
int paramn,parami;
|
||||
char* top = NULL;
|
||||
/*.........................................................................*/
|
||||
if(a_command==NULL) return 0;
|
||||
|
||||
paramn = a_command->GetParameterEntries();
|
||||
|
||||
file = CFileOpenForWriting (a_name);
|
||||
if(file==NULL) return 0;
|
||||
|
||||
fprintf (file,"\
|
||||
!----------------------------\n\
|
||||
begin OInterface\n\
|
||||
prefix = G4Params_\n\
|
||||
end\n\
|
||||
!----------------------------\n\
|
||||
begin OWidget\n\
|
||||
name = G4Params_palette\n\
|
||||
type = XmFormDialog\n\
|
||||
children = G4Params_command\
|
||||
");
|
||||
for(parami=0;parami<paramn;parami++)
|
||||
{
|
||||
fprintf (file," G4Params_label_%d G4Params_text_%d",parami,parami);
|
||||
}
|
||||
fprintf (file," G4Params_ok G4Params_apply G4Params_cancel\n\
|
||||
autoUnmanage = False\n\
|
||||
dialogTitle = G4 parameters\n\
|
||||
end\n\
|
||||
!----------------------------\n\
|
||||
begin OWidget\n\
|
||||
name = G4Params_command\n\
|
||||
type = XmPushButton\n\
|
||||
labelString = %s\n\
|
||||
background = black\n\
|
||||
foreground = white\n\
|
||||
leftAttachment = attach_form\n\
|
||||
rightAttachment = attach_form\n\
|
||||
topAttachment = attach_form\n\
|
||||
activateCallback = osh>\\\n\
|
||||
command=`getWidgetResource G4Params_command labelString`\\\n\
|
||||
echo `do G4 getCommandGuidance $command`\n\
|
||||
end\n\
|
||||
",a_command->GetCommandPath().data());
|
||||
|
||||
for(parami=0;parami<paramn;parami++)
|
||||
{
|
||||
G4UIparameter* parameter = (G4UIparameter*)a_command->GetParameter(parami);
|
||||
fprintf (file,"\
|
||||
!----------------------------\n\
|
||||
begin OWidget\n\
|
||||
name = G4Params_label_%d\n\
|
||||
type = XmLabel\n\
|
||||
labelString = %s\n\
|
||||
createCallback = osh> setWidgetResource `thisWidget` height `getWidgetResource G4Params_text_%d height`\n\
|
||||
leftAttachment = attach_form\n\
|
||||
",parami,parameter->GetParameterName().data(),parami);
|
||||
if(parami==0)
|
||||
{
|
||||
fprintf (file,"\
|
||||
topAttachment = attach_widget\n\
|
||||
topWidget = G4Params_command\n\
|
||||
");
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (file,"\
|
||||
topAttachment = attach_widget\n\
|
||||
topWidget = G4Params_text_%d\n\
|
||||
",parami-1);
|
||||
}
|
||||
fprintf (file,"\
|
||||
end\n\
|
||||
!----------------------------\n\
|
||||
begin OWidget\n\
|
||||
name = G4Params_text_%d\n\
|
||||
type = XmText\n\
|
||||
leftAttachment = attach_widget\n\
|
||||
leftWidget = G4Params_label_%d\n\
|
||||
rightAttachment = attach_form\n\
|
||||
",parami,parami);
|
||||
if(parami==0)
|
||||
{
|
||||
fprintf (file,"\
|
||||
topAttachment = attach_widget\n\
|
||||
topWidget = G4Params_command\n\
|
||||
");
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (file,"\
|
||||
topAttachment = attach_widget\n\
|
||||
topWidget = G4Params_text_%d\n\
|
||||
",parami-1);
|
||||
}
|
||||
|
||||
if( ! parameter->GetDefaultValue().isNull() )
|
||||
{
|
||||
fprintf (file,"\
|
||||
value = %s\n\
|
||||
",parameter->GetDefaultValue().data());
|
||||
}
|
||||
|
||||
fprintf (file,"\
|
||||
end\n\
|
||||
");
|
||||
|
||||
}
|
||||
|
||||
if(paramn>=1)
|
||||
{
|
||||
top = CStringCreateF(14+32,"G4Params_text_%d",paramn-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
top = CStringDuplicate("G4Params_command");
|
||||
}
|
||||
|
||||
fprintf (file,"\
|
||||
!----------------------------\n\
|
||||
begin OWidget\n\
|
||||
name = G4Params_ok\n\
|
||||
type = XmPushButton\n\
|
||||
labelString = Ok\n\
|
||||
activateCallback = osh>\\\n\
|
||||
command=`getWidgetResource G4Params_command labelString`\\\n\
|
||||
");
|
||||
for(parami=0;parami<paramn;parami++)
|
||||
{
|
||||
fprintf (file,"\
|
||||
param_%d=`getWidgetResource G4Params_text_%d value`\\\n\
|
||||
",parami,parami);
|
||||
}
|
||||
fprintf (file,"\
|
||||
G4 $command");
|
||||
for(parami=0;parami<paramn;parami++)
|
||||
{
|
||||
fprintf (file," $param_%d",parami);
|
||||
}
|
||||
fprintf (file,"\\\n\
|
||||
unmanageWidget `thisWidgetParent`\n\
|
||||
bottomAttachment = attach_form\n\
|
||||
leftAttachment = attach_form\n\
|
||||
topAttachment = attach_widget\n\
|
||||
topWidget = %s\n\
|
||||
end\n\
|
||||
!----------------------------\n\
|
||||
begin OWidget\n\
|
||||
name = G4Params_apply\n\
|
||||
type = XmPushButton\n\
|
||||
labelString = Apply\n\
|
||||
activateCallback = osh>\\\n\
|
||||
command=`getWidgetResource G4Params_command labelString`\\\n\
|
||||
",top);
|
||||
for(parami=0;parami<paramn;parami++)
|
||||
{
|
||||
fprintf (file,"\
|
||||
param_%d=`getWidgetResource G4Params_text_%d value`\\\n\
|
||||
",parami,parami);
|
||||
}
|
||||
fprintf (file,"\
|
||||
G4 $command");
|
||||
for(parami=0;parami<paramn;parami++)
|
||||
{
|
||||
fprintf (file," $param_%d",parami);
|
||||
}
|
||||
fprintf (file,"\n\
|
||||
bottomAttachment = attach_form\n\
|
||||
leftAttachment = attach_widget\n\
|
||||
leftWidget = G4Params_ok\n\
|
||||
topAttachment = attach_widget\n\
|
||||
topWidget = %s\n\
|
||||
end\n\
|
||||
!----------------------------\n\
|
||||
begin OWidget\n\
|
||||
name = G4Params_cancel\n\
|
||||
type = XmPushButton\n\
|
||||
labelString = Cancel\n\
|
||||
activateCallback = osh> unmanageWidget `thisWidgetParent`\n\
|
||||
bottomAttachment = attach_form\n\
|
||||
leftAttachment = attach_widget\n\
|
||||
leftWidget = G4Params_apply\n\
|
||||
rightAttachment = attach_form\n\
|
||||
topAttachment = attach_widget\n\
|
||||
topWidget = %s\n\
|
||||
end\n\
|
||||
",top,top);
|
||||
|
||||
CStringDelete (top);
|
||||
|
||||
fclose(file);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -0,0 +1,361 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4UIWo.cc,v 2.5 1998/10/23 14:42:29 barrand Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//G4UIWo.cc -- copied from G4UIterminal.cc
|
||||
|
||||
//#define DEBUG
|
||||
|
||||
#ifdef G4UI_BUILD_WO_SESSION
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef HAS_XM
|
||||
#include <Xm/MainW.h> //For G4OIX
|
||||
#include <Xm/Label.h>
|
||||
#endif
|
||||
#ifdef HAS_XAW
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <Xaw/Label.h>
|
||||
#endif
|
||||
|
||||
// Below are the "wanted" packages header files.
|
||||
// begin Want_h
|
||||
#include <WoWo.h>
|
||||
#include <WoXtw.h>
|
||||
#include <WoXm.h>
|
||||
#include <WoXaw.h>
|
||||
#include <WoXo.h>
|
||||
//end Want_h
|
||||
|
||||
/*Co*/
|
||||
#include <CPrinter.h>
|
||||
#include <CString.h>
|
||||
#include <CFile.h>
|
||||
#include <CText.h>
|
||||
#include <OShell.h>
|
||||
/*Xx*/
|
||||
#include <XWidget.h>
|
||||
/*Xo*/
|
||||
#include <XoCamera.h>
|
||||
/*Wo*/
|
||||
#include <OEvent.h>
|
||||
#include <OWidget.h>
|
||||
#include <OInterface.h>
|
||||
/*G4*/
|
||||
#include "G4UIWo.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4UIcommandTree.hh"
|
||||
#include "G4WoMessenger.hh"
|
||||
#include "G4StateManager.hh"
|
||||
#include "G4Xt.hh"
|
||||
#include "G4oCommon.hh"
|
||||
|
||||
static Widget CreateG4View (String,Widget,String,ArgList,Cardinal);
|
||||
static Widget CreateG4XoView (Widget,String,ArgList,Cardinal);
|
||||
static Widget CreateG4OIXView (Widget,String,ArgList,Cardinal);
|
||||
|
||||
static int Inited = 0;
|
||||
/***************************************************************************/
|
||||
G4UIWo::G4UIWo (
|
||||
int argc
|
||||
,char** argv
|
||||
)
|
||||
:woMessenger(NULL)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
if(UI!=NULL) UI->SetSession(this);
|
||||
|
||||
if(Inited==1) return; // Below code must be executed once.
|
||||
|
||||
// Below are the "wanted" packages include c files.
|
||||
// begin Want_c
|
||||
#include <WoWo.ic>
|
||||
#include <WoXtw.ic>
|
||||
#include <WoXm.ic>
|
||||
#include <WoXaw.ic>
|
||||
#include <WoXo.ic>
|
||||
// end Want_c
|
||||
|
||||
//Declare G4 interpreter to Wo.
|
||||
OInterpreterCreate ("G4",ExecuteScript,NULL,NULL,NULL);
|
||||
OShellAddNewCommand (WoGetShellInterpreter(),"G4/G4",Execute_G4);
|
||||
SetTypes ();
|
||||
|
||||
//Declare osh to G4.
|
||||
woMessenger = new G4WoMessenger (WoGetShellInterpreter());
|
||||
|
||||
//Declare G4/vis~/views to Wo.
|
||||
#ifdef HAS_XO
|
||||
OClassDeclareCompoundWidget ("G4/G4XoView" ,CreateG4XoView ,xoCameraWidgetClass);
|
||||
#endif
|
||||
#ifdef HAS_XM
|
||||
OClassDeclareCompoundWidget ("G4/G4OIXView",CreateG4OIXView,xmMainWindowWidgetClass);
|
||||
OClassDeclareWidgetClass ("G4/ThumbWheel" ,NULL);
|
||||
OClassDeclareWidgetClass ("G4/SoGLwMDrawingArea",NULL);
|
||||
OClassDeclareWidgetClass ("G4/XoSoArea" ,NULL);
|
||||
#endif
|
||||
|
||||
G4Xt* interactorManager = G4Xt::getInstance (argc,argv,"Wo");
|
||||
Widget top = (Widget)interactorManager->GetMainInteractor();
|
||||
XtAppContext context = XtWidgetToApplicationContext(top);
|
||||
|
||||
WoSetXt (context,top);
|
||||
interactorManager->AddDispatcher ((G4DispatchFunction)WoDispatchEvent);
|
||||
|
||||
// Load file in SessionStart.
|
||||
// At this moment the G4VisManager is expected to be created.
|
||||
// It is needed if an odb file is expected to create some upper G4View.
|
||||
WoSetInterfaceFile ("nil");
|
||||
WoStartup (argc,argv);
|
||||
|
||||
if(UI!=NULL) UI->SetCoutDestination(this);
|
||||
|
||||
Inited = 1;
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4UIWo::~G4UIWo (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
if(UI!=NULL) {
|
||||
UI->SetSession(NULL);
|
||||
UI->SetCoutDestination(NULL);
|
||||
}
|
||||
if(woMessenger!=NULL) delete woMessenger;
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4UIsession* G4UIWo::SessionStart (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
static int Done = 0;
|
||||
G4Xt* interactorManager = G4Xt::getInstance ();
|
||||
if(Done==0) { //Load odb file.
|
||||
char* fileName = NULL;
|
||||
if(getenv("WOENVIRONMENT")!=NULL) {
|
||||
fileName = CStringDuplicate (getenv("WOENVIRONMENT"));
|
||||
} else {
|
||||
char** argv;
|
||||
int argc;
|
||||
argv = interactorManager->GetArguments (&argc);
|
||||
if(argc>=1) {
|
||||
char* aname = CFileGetName (argv[0]);
|
||||
fileName = CStringCreateF (strlen(aname)+4,"%s.odb",aname);
|
||||
CStringDelete (aname);
|
||||
}
|
||||
}
|
||||
WoSetInterfaceFile (fileName);
|
||||
OInterfaceLoadFile (fileName,NULL);
|
||||
OInterfaceSetExtentNotModified ();
|
||||
if(OWidgetHasMappedShell()==0) XWidgetMap (OWidgetGetFirstShell());
|
||||
CStringDelete (fileName);
|
||||
Done = 1;
|
||||
}
|
||||
int value;
|
||||
// Prompt ("session");
|
||||
interactorManager->DisableSecondaryLoop ();
|
||||
void* event;
|
||||
while((event = interactorManager->GetEvent())!=NULL) {
|
||||
if(OEventIsExit((XEvent*)event,&value)==1)
|
||||
{
|
||||
WoDispatchEvent (event);
|
||||
break;
|
||||
}
|
||||
interactorManager->DispatchEvent(event);
|
||||
}
|
||||
interactorManager->EnableSecondaryLoop ();
|
||||
return this;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4UIWo::Prompt (
|
||||
G4String aPrompt
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
CWarnF("%s\n",aPrompt.data());
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4UIWo::SessionTerminate (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4UIWo::PauseSessionStart (
|
||||
G4String a_state
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
#ifdef DEBUG
|
||||
G4cout << "debug : G4UIWo::PauseSessionStart : begin : " << a_state << endl;
|
||||
#endif
|
||||
|
||||
if(a_state=="G4_pause> ")
|
||||
{
|
||||
SecondaryLoop ("G4Pause.osh");
|
||||
}
|
||||
|
||||
if(a_state=="BeginOfRun")
|
||||
{
|
||||
WoExecuteShellFileInSameContext ("G4RunBegin.osh");
|
||||
}
|
||||
else if(a_state=="EndOfRun")
|
||||
{
|
||||
WoExecuteShellFileInSameContext ("G4RunEnd.osh");
|
||||
}
|
||||
else if(a_state=="BeginOfEvent")
|
||||
{
|
||||
WoExecuteShellFileInSameContext ("G4EventBegin.osh");
|
||||
}
|
||||
else if(a_state=="EndOfEvent")
|
||||
{
|
||||
// Picking with feed back in event data Done here !!!
|
||||
SecondaryLoop ("G4EventEnd.osh");
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
G4cout << "debug : G4UIWo::PauseSessionStart : end." << endl;
|
||||
#endif
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4UIWo::SecondaryLoop (
|
||||
G4String a_file
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
G4Xt* interactorManager = G4Xt::getInstance ();
|
||||
int value;
|
||||
// Prompt (a_prompt);
|
||||
WoExecuteShellFileInSameContext ((char*)a_file.data());
|
||||
void* event;
|
||||
while((event = interactorManager->GetEvent())!=NULL) {
|
||||
if(OEventIsExit((XEvent*)event,&value)==1) {
|
||||
WoDispatchEvent (event);
|
||||
break;
|
||||
}
|
||||
interactorManager->DispatchEvent(event);
|
||||
}
|
||||
// Prompt ("session");
|
||||
WoExecuteShellFileInSameContext ((char*)"G4Session.osh");
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4int G4UIWo::ReceiveG4cout (
|
||||
G4String a_string
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
CWarnF ("%s",a_string.data());
|
||||
return 0;
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4int G4UIWo::ReceiveG4cerr (
|
||||
G4String a_string
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
CWarnF ("%s",a_string.data());
|
||||
return 0;
|
||||
}
|
||||
/***************************************************************************/
|
||||
Widget CreateG4XoView (
|
||||
Widget a_parent
|
||||
,String a_name
|
||||
,ArgList a_list
|
||||
,Cardinal a_number
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
/*.........................................................................*/
|
||||
return CreateG4View("Xo",a_parent,a_name,a_list,a_number);
|
||||
}
|
||||
/***************************************************************************/
|
||||
Widget CreateG4OIXView (
|
||||
Widget a_parent
|
||||
,String a_name
|
||||
,ArgList a_list
|
||||
,Cardinal a_number
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
/*.........................................................................*/
|
||||
return CreateG4View("OIX",a_parent,a_name,a_list,a_number);
|
||||
}
|
||||
/***************************************************************************/
|
||||
Widget CreateG4View (
|
||||
String a_gs
|
||||
,Widget a_parent
|
||||
,String a_name
|
||||
,ArgList /*a_list*/
|
||||
,Cardinal /*a_number*/
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
Widget widget = NULL;
|
||||
/*.........................................................................*/
|
||||
if(a_gs==NULL) return NULL;
|
||||
if(a_parent==NULL) return NULL;
|
||||
if(a_name==NULL) return NULL;
|
||||
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
if(UI!=NULL) {
|
||||
|
||||
G4Xt* interactorManager = G4Xt::getInstance ();
|
||||
|
||||
interactorManager->SetParentInteractor (a_parent);
|
||||
interactorManager->SetCreationString (a_name);
|
||||
// Give name ???
|
||||
char* command;
|
||||
command = CStringCreateF(37+strlen(a_gs),
|
||||
"/vis~/create_view/new_graphics_system %s",
|
||||
a_gs);
|
||||
UI->ApplyCommand (command);
|
||||
CStringDelete (command);
|
||||
widget = (Widget)interactorManager->GetCreatedInteractor ();
|
||||
if(widget==a_parent) {
|
||||
widget = NULL; //No viewer created !
|
||||
}
|
||||
interactorManager->SetParentInteractor (NULL);
|
||||
interactorManager->SetCreatedInteractor (NULL);
|
||||
interactorManager->SetCreationString (NULL);
|
||||
|
||||
}
|
||||
|
||||
if(widget==NULL) {
|
||||
Arg args[1];
|
||||
CWarnF ("G4UIWo::CreateG4View : can't create a %s view.\n Create a label instead.\n",a_gs);
|
||||
#ifdef HAS_XM
|
||||
widget = XmCreateLabel (a_parent,a_name,args,0);
|
||||
XtManageChild (widget);
|
||||
#endif
|
||||
#ifdef HAS_XAW
|
||||
widget = XtCreateManagedWidget (a_name,labelWidgetClass,a_parent,args,0);
|
||||
#endif
|
||||
}
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
#include "G4oCommon.icc"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,59 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4WoMessenger.cc,v 2.3 1998/07/12 03:42:52 urbi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
#ifdef G4UI_BUILD_WO_SESSION
|
||||
|
||||
#include "G4WoMessenger.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
|
||||
#include <Wo.h>
|
||||
|
||||
G4WoMessenger::G4WoMessenger(OShell a_shell)
|
||||
:shell(NULL)
|
||||
,WoDirectory(NULL)
|
||||
,sendExitCmd(NULL)
|
||||
,oshCmd(NULL)
|
||||
{
|
||||
shell = a_shell;
|
||||
|
||||
WoDirectory = new G4UIdirectory("/Wo/");
|
||||
WoDirectory->SetGuidance ("Wo control commands.");
|
||||
|
||||
sendExitCmd = new G4UIcmdWithoutParameter("/Wo/sendExit",this);
|
||||
sendExitCmd->SetGuidance ("Exit Wo event event loop..");
|
||||
|
||||
oshCmd = new G4UIcmdWithAString("/Wo/osh",this);
|
||||
oshCmd->SetGuidance ("osh interpreter.");
|
||||
oshCmd->SetParameterName("Command",true);
|
||||
oshCmd->SetDefaultValue ("");
|
||||
}
|
||||
G4WoMessenger::~G4WoMessenger() {
|
||||
if(oshCmd!=NULL) delete oshCmd;
|
||||
if(sendExitCmd!=NULL) delete sendExitCmd;
|
||||
if(WoDirectory!=NULL) delete WoDirectory;
|
||||
}
|
||||
|
||||
void G4WoMessenger::SetNewValue(G4UIcommand * command,G4String newValues)
|
||||
{
|
||||
if(command==oshCmd) {
|
||||
OShellExecute (shell,(char*)newValues.data());
|
||||
} else if(command==sendExitCmd) {
|
||||
WoSendExit ();
|
||||
}
|
||||
}
|
||||
G4String G4WoMessenger::GetCurrentValue(G4UIcommand * command)
|
||||
{
|
||||
G4String cv;
|
||||
return cv;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,21 @@
|
||||
# $Id: GNUmakefile,v 2.2 1998/07/07 16:57:20 allison Exp $
|
||||
# -------------------------------------------------------------
|
||||
# GNUmakefile for interfaces/XVT library. John Allison, 6/7/98.
|
||||
|
||||
name := G4UIXVT
|
||||
|
||||
ifndef G4INSTALL
|
||||
G4INSTALL = ../../..
|
||||
endif
|
||||
|
||||
include $(G4INSTALL)/config/architecture.gmk
|
||||
include $(G4INSTALL)/config/G4UI_BUILD.gmk
|
||||
include $(G4INSTALL)/config/interactivity.gmk
|
||||
|
||||
G4TMPDIR = $(G4TMP)/$(G4SYSTEM)/$(name)
|
||||
|
||||
CPPFLAGS += -I$(G4BASE)/global/management/include
|
||||
CPPFLAGS += -I$(G4BASE)/interfaces/common/include
|
||||
CPPFLAGS += -I$(G4BASE)/intercoms/include
|
||||
|
||||
include $(G4INSTALL)/config/common.gmk
|
||||
@@ -0,0 +1,220 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4UIxvt.hh,v 2.2 1998/07/12 03:00:04 urbi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// XVT driver class header //
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~ //
|
||||
// Written by: Simon Prior //
|
||||
// Date: 22/04/97 //
|
||||
// //
|
||||
// Updated for state machine: 12/08/97 //
|
||||
// //
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
#ifndef G4UIxvt_h
|
||||
#define G4UIxvt_h
|
||||
|
||||
#if defined(G4UI_BUILD_XVT_SESSION) || defined(G4UI_USE_XVT)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// define the named pipe names //
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define XvtToGeant "XvtToGeant.tmp"
|
||||
#define GeantToXvt "GeantToXvt.tmp"
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// mode for opening a named pipe //
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define FILE_MODE (0664 | S_IFIFO)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// If compiling using AFS different libraries required //
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef _AIX
|
||||
#include <sys/mode.h> // mkfifo utils
|
||||
#endif
|
||||
|
||||
#include <unistd.h> // POSIX standards for stdin, out, err.
|
||||
//#include <values.h>
|
||||
#include <sys/stat.h> // mkfifo utils for HP
|
||||
#include <fcntl.h> // Open, Close, Unlink etc
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdio.h> // sscanf, sprinf
|
||||
|
||||
#ifndef FIONREAD
|
||||
#include <sys/filio.h> // FIONREAD defines
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Geant4 specific includes //
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "G4UIsession.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4UIcommandTree.hh"
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// State machine Geant4 includes //
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "G4VStateDependent.hh"
|
||||
#include <fstream.h>
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// New data structures, one to hold the parameter information of a //
|
||||
// command and one to hold information on the command itself. //
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct G4parameterData
|
||||
{
|
||||
G4String name;
|
||||
G4String guidance;
|
||||
G4String defaultValue;
|
||||
G4String range;
|
||||
G4String candidate;
|
||||
char type;
|
||||
G4String omittable;
|
||||
} G4parameterData;
|
||||
|
||||
typedef struct G4commandData
|
||||
{
|
||||
int flag;
|
||||
G4String name;
|
||||
G4String guidance;
|
||||
int numOfParameters;
|
||||
G4parameterData parameters[10];
|
||||
|
||||
// G4String bitmapName;
|
||||
|
||||
int commandNumber;
|
||||
} G4commandData;
|
||||
|
||||
|
||||
class G4UIxvt : public G4UIsession//, public G4VStateDependent
|
||||
{
|
||||
public:
|
||||
G4UIxvt();
|
||||
~G4UIxvt();
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Inherited virtual functions //
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
// void SessionStart(void);
|
||||
G4UIsession* SessionStart(void);
|
||||
G4String GetCommand(void);
|
||||
void SessionTerminate(void);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// New state machine methods //
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
G4bool Notify(G4ApplicationState requestedState);
|
||||
|
||||
inline void set_breakPointAt(int id,G4bool flg)
|
||||
{
|
||||
brktbl[id] = flg;
|
||||
noBreakFlag = !(brktbl[0]||brktbl[1]||brktbl[2]||brktbl[3]);
|
||||
};
|
||||
|
||||
void set_verbose(void);
|
||||
|
||||
private:
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Terminal and interface data members (might be taken out as //
|
||||
// they are not needed for the XVT GUI) //
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
G4UImanager * UI;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// New state machine data members //
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
G4bool iExit;
|
||||
G4bool iCont;
|
||||
G4bool brktbl[4];
|
||||
G4bool noBreakFlag;
|
||||
G4bool verboseFlag;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// New state machine methods //
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
void additionalSession(void);
|
||||
G4bool breakRequested(G4ApplicationState,G4ApplicationState);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// IPC Data Members //
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
int fd_XvtToGeant, fd_GeantToXvt;
|
||||
char textDump[100];
|
||||
int number;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// IPC methods //
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
void openConnections(void);
|
||||
int checkXvtToGeantPipe(void);
|
||||
G4String readXvtToGeant(void);
|
||||
void writeGeantToXvt(const G4String& theString);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Terminal and TCL methods updated for use with XVT //
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
void codeGen(G4UIcommandTree *,int recursive_level);
|
||||
void listCurrentDirectory(void);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Command handling data members //
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
G4commandData commandArray[200];
|
||||
int currentPosition, lastPosition;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Command handling methods //
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
void fillArrayEntries(G4UIcommandTree * tree, int level);
|
||||
void sendArrayEntriesToXvt(void);
|
||||
void briefListCommands(void);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Debugging methods //
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void listCommandArray(void);
|
||||
void errorHandler(const G4String& theError);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,41 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4UIxvtMessenger.hh,v 2.3 1998/07/12 03:42:55 urbi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// The original code (written by Makoto Asai) has been adapted for use //
|
||||
// with the XVT Geant GUI //
|
||||
// //
|
||||
// By: Simon Prior 11/08/97 //
|
||||
// //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef G4UIxvtMessenger_h
|
||||
#define G4UIxvtMessenger_h 1
|
||||
|
||||
#if defined(G4UI_BUILD_XVT_SESSION) || defined(G4UI_USE_XVT)
|
||||
|
||||
#include "G4UImessenger.hh"
|
||||
#include "G4UImanager.hh"
|
||||
|
||||
class G4UIxvt;
|
||||
|
||||
class G4UIxvtMessenger : public G4UImessenger
|
||||
{
|
||||
public:
|
||||
G4UIxvtMessenger(G4UIxvt*);
|
||||
void SetNewValue(G4UIcommand * command,G4String newValue);
|
||||
private:
|
||||
G4UIxvt* xvtptr;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,803 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4UIxvt.cc,v 2.3 1998/07/13 17:13:24 urbi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
#ifdef G4UI_BUILD_XVT_SESSION
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// XVT driver class implementation
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Written by: Simon Prior
|
||||
// Date: 23/04/97
|
||||
//
|
||||
// Updated for state machine: 12/08/97
|
||||
//
|
||||
// The update consisted of adding the new state methods and I also deleted
|
||||
// a lot of old redundant code (like ChangeDirectory etc which aren't
|
||||
// needed with the XVT GUI).
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
#include "G4UIxvt.hh"
|
||||
#include "G4StateManager.hh"
|
||||
#include "G4UIxvtMessenger.hh"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// G4UIxvt - Consructor
|
||||
//
|
||||
// Initalise the class variables.
|
||||
//
|
||||
// Note: number is the number of bytes transfered with each read or write.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
G4UIxvt::G4UIxvt()
|
||||
{
|
||||
UI = G4UImanager::GetUIpointer();
|
||||
|
||||
iExit = false;
|
||||
iCont = false;
|
||||
|
||||
for(int i=0;i<4;i++)
|
||||
{
|
||||
brktbl[i] = false;
|
||||
}
|
||||
|
||||
noBreakFlag = true;
|
||||
verboseFlag = true;
|
||||
new G4UIxvtMessenger(this);
|
||||
|
||||
number = 100;
|
||||
currentPosition = 0;
|
||||
lastPosition = 100;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ~G4UIxvt - Destructor
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
G4UIxvt::~G4UIxvt()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Notify
|
||||
//
|
||||
// Notifies the user of the state changes of the system.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//G4bool G4UIxvt::Notify(G4ApplicationState requestedState)
|
||||
//{
|
||||
// G4StateManager * statM = G4StateManager::GetStateManager();
|
||||
// G4ApplicationState previousState = statM->GetPreviousState();
|
||||
//
|
||||
// if(verboseFlag)
|
||||
// {
|
||||
// writeGeantToXvt("========== STATE CHANGE ===========");
|
||||
// writeGeantToXvt("FROM: " + statM->GetStateString(previousState));
|
||||
// writeGeantToXvt(" TO: " + statM->GetStateString(requestedState));
|
||||
// writeGeantToXvt("===================================");
|
||||
// }
|
||||
//
|
||||
// if(requestedState==Pause || breakRequested(previousState,requestedState))
|
||||
// {
|
||||
// additionalSession();
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
//}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// breakRequested
|
||||
//
|
||||
// Notifies and puts breaks in the Geant4 run.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
G4bool G4UIxvt::breakRequested(G4ApplicationState previousState,
|
||||
G4ApplicationState requestedState)
|
||||
{
|
||||
if(noBreakFlag) return false;
|
||||
|
||||
G4bool ans = false;
|
||||
|
||||
if(previousState==Idle && requestedState==GeomClosed && brktbl[0])
|
||||
{
|
||||
writeGeantToXvt("====== BREAKPOINT NOTIFICATION ======");
|
||||
writeGeantToXvt("BreakPoint at: BEGIN OF RUN");
|
||||
writeGeantToXvt("Enter 'continue' command to proceed");
|
||||
writeGeantToXvt("=====================================");
|
||||
|
||||
ans = true;
|
||||
}
|
||||
|
||||
if(previousState==GeomClosed && requestedState==EventProc && brktbl[1])
|
||||
{
|
||||
writeGeantToXvt("====== BREAKPOINT NOTIFICATION ======");
|
||||
writeGeantToXvt("BreakPoint at: BEGIN OF EVENT");
|
||||
writeGeantToXvt("Enter 'continue' command to proceed");
|
||||
writeGeantToXvt("=====================================");
|
||||
|
||||
ans = true;
|
||||
}
|
||||
|
||||
if(previousState==EventProc && requestedState==GeomClosed && brktbl[2])
|
||||
{
|
||||
writeGeantToXvt("====== BREAKPOINT NOTIFICATION ======");
|
||||
writeGeantToXvt("BreakPoint at: END OF EVENT");
|
||||
writeGeantToXvt("Enter 'continue' command to proceed");
|
||||
writeGeantToXvt("=====================================");
|
||||
|
||||
ans = true;
|
||||
}
|
||||
|
||||
if(previousState==GeomClosed && requestedState==Idle && brktbl[3])
|
||||
{
|
||||
writeGeantToXvt("====== BREAKPOINT NOTIFICATION ======");
|
||||
writeGeantToXvt("BreakPoint at: END OF RUN");
|
||||
writeGeantToXvt("Enter 'continue' command to proceed");
|
||||
writeGeantToXvt("=====================================");
|
||||
|
||||
ans = true;
|
||||
}
|
||||
|
||||
return ans;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// set_verbose
|
||||
//
|
||||
// Toggles the Verbose state of the GUI concerning the state machine.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void G4UIxvt::set_verbose(void)
|
||||
{
|
||||
verboseFlag = !verboseFlag;
|
||||
|
||||
if (verboseFlag)
|
||||
{
|
||||
writeGeantToXvt("Verbose mode switched ON");
|
||||
}
|
||||
else
|
||||
{
|
||||
writeGeantToXvt("Verbose mode switched OFF");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SessionStart
|
||||
//
|
||||
// Informs user of Geant Kernel starting and does a 'brief' command listing.
|
||||
// Update: 12/08/97 - now used as main control of Geant (get command is
|
||||
// currently called from here NOT from the UIManager.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//void G4UIxvt::SessionStart(void)
|
||||
G4UIsession* G4UIxvt::SessionStart(void)
|
||||
{
|
||||
openConnections();
|
||||
writeGeantToXvt("Connection to Geant open...\0");
|
||||
|
||||
G4UImanager * UI = G4UImanager::GetUIpointer();
|
||||
G4UIcommandTree * comTree = UI->GetTree();
|
||||
|
||||
fillArrayEntries(comTree, 0);
|
||||
|
||||
G4cout << " --------- List of Array Entries ---------- " << endl;
|
||||
|
||||
listCommandArray();
|
||||
briefListCommands();
|
||||
|
||||
// --- Enter main program control --- //
|
||||
|
||||
iExit = true;
|
||||
|
||||
while( iExit )
|
||||
{
|
||||
G4String newCommand = GetCommand();
|
||||
if(newCommand.length()>1) UI->ApplyCommand(newCommand);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// additionalSession
|
||||
//
|
||||
//
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void G4UIxvt::additionalSession(void)
|
||||
{
|
||||
writeGeantToXvt("=== Entering Addtional Session ===");
|
||||
iCont = true;
|
||||
while( iCont )
|
||||
{
|
||||
G4String newCommand = GetCommand();
|
||||
if(newCommand.length()>1) UI->ApplyCommand(newCommand);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SessionTerminate
|
||||
//
|
||||
// Informs user that Geant has terminated.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void G4UIxvt::SessionTerminate(void)
|
||||
{
|
||||
writeGeantToXvt("XVT <-> Geant4 terminating...");
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// openConnections
|
||||
//
|
||||
// This method opens the IPC connection.
|
||||
//
|
||||
// Open the named pipes in the current directory using the
|
||||
// appropriate permissions.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void G4UIxvt::openConnections(void)
|
||||
{
|
||||
int o_flags;
|
||||
|
||||
o_flags = O_WRONLY | O_NONBLOCK;
|
||||
|
||||
if((fd_GeantToXvt = open(GeantToXvt, o_flags)) == -1)
|
||||
{
|
||||
errorHandler("GeantToXvt pipe opening");
|
||||
}
|
||||
|
||||
o_flags = O_RDONLY | O_NONBLOCK;
|
||||
|
||||
if((fd_XvtToGeant = open(XvtToGeant, o_flags)) == -1)
|
||||
{
|
||||
errorHandler("XvtToGeant pipe opening");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// checkXvtToGeantPipe
|
||||
//
|
||||
// This method checks to see if the XvtToGeant pipe contains anything.
|
||||
// Thus meaning it will be readable without blocking.
|
||||
//
|
||||
// Returns 0 if nothing present, 1 otherwise.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
int G4UIxvt::checkXvtToGeantPipe(void)
|
||||
{
|
||||
int nbytes;
|
||||
ioctl(fd_XvtToGeant, FIONREAD, &nbytes);
|
||||
|
||||
if (nbytes > 0)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// readXvtToGeant
|
||||
//
|
||||
// This method grabs the data in the XvtToGeant named pipe, and
|
||||
// returns it to the caller.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
G4String G4UIxvt::readXvtToGeant(void)
|
||||
{
|
||||
int bytes_read = read(fd_XvtToGeant, textDump, number);
|
||||
textDump[bytes_read] = '\0';
|
||||
G4String newString = textDump;
|
||||
return newString;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// writeGeantToXvt
|
||||
//
|
||||
// This method writes the passed string to the GeantToXvt named pipe.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void G4UIxvt::writeGeantToXvt(const G4String& theString)
|
||||
{
|
||||
int write_check = write(fd_GeantToXvt, theString, number);
|
||||
|
||||
if(write_check == -1)
|
||||
G4cout << "ERROR WITH WRITE!!" << endl;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// errorHandler
|
||||
//
|
||||
// A general purpose error handler. It can be called by any method. A string
|
||||
// is passed so that this method simply prints a message via G4cout that explains
|
||||
// what the error is.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void G4UIxvt::errorHandler(const G4String& theError)
|
||||
{
|
||||
G4cout << "Error with " << theError << endl;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// GetCommand
|
||||
//
|
||||
// This method is called by SessionStart to get a command from the user.
|
||||
//
|
||||
// It enters a loop to repeatedly check the Geant end of the named pipe.
|
||||
// When something is present in the pipe (sent by XVT GUI) it then grabs it
|
||||
// and returns the string to the caller.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
G4String G4UIxvt::GetCommand()
|
||||
{
|
||||
G4String newCommand('\0');
|
||||
G4UImanager * UI = G4UImanager::GetUIpointer();
|
||||
while( 1 )
|
||||
{
|
||||
int Done = 0;
|
||||
|
||||
while (!Done)
|
||||
{
|
||||
if (checkXvtToGeantPipe())
|
||||
{
|
||||
newCommand = readXvtToGeant();
|
||||
Done = 1;
|
||||
}
|
||||
else
|
||||
; // Pipe is empty so loop again
|
||||
}
|
||||
|
||||
G4String nC = newCommand;
|
||||
|
||||
if(nC == "getCommands")
|
||||
{
|
||||
sendArrayEntriesToXvt();
|
||||
}
|
||||
else if( nC == "/control/exit" )
|
||||
{
|
||||
if( iCont )
|
||||
{
|
||||
writeGeantToXvt("You are now processing RUN.");
|
||||
writeGeantToXvt("Please abort it using \"/run/abort\" command first");
|
||||
writeGeantToXvt("and use \"continue\" command until the application");
|
||||
writeGeantToXvt("becomes Idle.");
|
||||
}
|
||||
else
|
||||
{
|
||||
iExit = false;
|
||||
newCommand = "/";
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if( nC(0,4) == "cont" )
|
||||
{
|
||||
iCont = false;
|
||||
newCommand = "/";
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( newCommand(0) != '/' )
|
||||
G4cerr << "IT GOT THERE!!!!" << endl;
|
||||
// If you ever see the error message in the output something has gone
|
||||
// wrong.
|
||||
|
||||
return newCommand;
|
||||
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// codeGen
|
||||
//
|
||||
// Traverses the command tree and retrieves the directories and
|
||||
// subdirectories of available commands.
|
||||
//
|
||||
// This does a 'brief' listing, i.e. does not List the guidance or
|
||||
// parameters.
|
||||
//
|
||||
// I have updated this method from the TCL implementation for XVT.
|
||||
// The differences are that G4cout is not used and some string concatenation
|
||||
// is Done differently (i.e. not with G4cout).
|
||||
//
|
||||
// This is still however not really needed and might be deleted.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void G4UIxvt::codeGen(G4UIcommandTree * tree, int level)
|
||||
{
|
||||
int treeEntry;
|
||||
int commandEntry;
|
||||
treeEntry = tree->GetTreeEntry();
|
||||
commandEntry = tree->GetCommandEntry();
|
||||
G4String commandPath;
|
||||
G4String pathName; //tree name
|
||||
G4UIcommandTree * t;
|
||||
|
||||
// --- this loop lists the current directory and its commands --- //
|
||||
|
||||
for(int com=0; com<commandEntry; com++)
|
||||
{
|
||||
commandPath = tree->GetCommand(com+1)->GetCommandPath();
|
||||
if(level==0)
|
||||
{
|
||||
// This is not normally executed
|
||||
writeGeantToXvt(commandPath); // Unsure as to what this does
|
||||
}
|
||||
else
|
||||
{
|
||||
writeGeantToXvt(commandPath + " command"); // this gives the commands
|
||||
}
|
||||
}
|
||||
|
||||
if(treeEntry == 0)
|
||||
return; //end recursion
|
||||
|
||||
for(int i=0; i< treeEntry; i++)
|
||||
{
|
||||
t = tree->GetTree(i+1);
|
||||
pathName = t->GetPathName();
|
||||
if(level == 0)
|
||||
{
|
||||
writeGeantToXvt(pathName); // This is the directory name
|
||||
}
|
||||
else
|
||||
{
|
||||
writeGeantToXvt(pathName + " cascade"); // This is the sub dirs
|
||||
}
|
||||
|
||||
codeGen(t, level+1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// briefListCommands
|
||||
//
|
||||
// This method uses codeGen to traverse the tree and List the commands
|
||||
// and directories - it does a brief listing, i.e. no parameters or guidance
|
||||
// accompanying the text.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void G4UIxvt::briefListCommands(void)
|
||||
{
|
||||
writeGeantToXvt("--- Brief List of available commands ---");
|
||||
G4UIcommandTree * comTree = UI->GetTree();
|
||||
codeGen(comTree, 0);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ListCurrentDirectory
|
||||
//
|
||||
// This is the XVT specific implementation of the 'List Current' method
|
||||
// from the G4UICommandTree class.
|
||||
//
|
||||
// It is almost the same only instead of any couts all the data is written
|
||||
// to the named pipe for XVT to process.
|
||||
//
|
||||
// Although this is entirely XVT specific it may be deleted because it is
|
||||
// not really needed. (most directory navigation methods that were so
|
||||
// important in the terminal session aren't needed in this XVT GUI
|
||||
// implementation.)
|
||||
//
|
||||
// I have left it here in case similar code is needed in the future - this
|
||||
// demonstrates how to access the command tree etc.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void G4UIxvt::listCurrentDirectory(void)
|
||||
{
|
||||
G4UIcommandTree * comTree = UI->GetTree();
|
||||
G4String path = comTree->GetPathName();
|
||||
|
||||
writeGeantToXvt("Command Directory Path: " + path);
|
||||
|
||||
// --- Guidance code --- //
|
||||
|
||||
G4UIcommand * tempGuidance = (G4UIcommand *)comTree->GetGuidance();
|
||||
|
||||
if (tempGuidance != NULL)
|
||||
{
|
||||
writeGeantToXvt("Command: " + tempGuidance->GetCommandPath());
|
||||
writeGeantToXvt("Guidance: ");
|
||||
|
||||
int n_guidanceEntry = tempGuidance->GetGuidanceEntries();
|
||||
|
||||
for (int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ )
|
||||
{
|
||||
writeGeantToXvt(tempGuidance->GetGuidanceLine(i_thGuidance));
|
||||
}
|
||||
|
||||
int n_parameterEntry = tempGuidance->GetParameterEntries();
|
||||
|
||||
if(n_parameterEntry > 0)
|
||||
{
|
||||
for( int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ )
|
||||
{
|
||||
G4UIparameter * tempParameter = (G4UIparameter *)tempGuidance->GetParameter(i_thParameter);
|
||||
|
||||
writeGeantToXvt("Parameter: " + tempParameter->GetParameterName());
|
||||
writeGeantToXvt(tempParameter->GetParameterGuidance());
|
||||
writeGeantToXvt("Parameter type: " + tempParameter->GetParameterType());
|
||||
|
||||
// --- remember to fix the below bug --- //
|
||||
|
||||
// writeGeantToXvt("Omittable: " + tempParameter->IsOmittable());
|
||||
|
||||
writeGeantToXvt("Default Value: " + tempParameter->GetDefaultValue());
|
||||
writeGeantToXvt("Parameter Range: " + tempParameter->GetParameterRange());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- End of Guidance code --- //
|
||||
|
||||
writeGeantToXvt("Sub Directories: ");
|
||||
|
||||
int n_treeEntry = comTree->GetTreeEntry();
|
||||
|
||||
for( int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ )
|
||||
{
|
||||
G4UIcommandTree * tempTree = comTree->GetTree(i_thTree + 1);
|
||||
writeGeantToXvt(tempTree->GetPathName() + tempTree->GetTitle());
|
||||
}
|
||||
|
||||
writeGeantToXvt("Commands : ");
|
||||
|
||||
int n_commandEntry = comTree->GetCommandEntry();
|
||||
|
||||
for( int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ )
|
||||
{
|
||||
G4UIcommand * tempCommand = comTree->GetCommand(i_thCommand + 1);
|
||||
writeGeantToXvt(tempCommand->GetCommandName() + tempCommand->GetTitle());
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Methods for handling the command information //
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// sendArrayEntriesToXvt
|
||||
//
|
||||
// This goes through the commandArray when called and sends all the command
|
||||
// information down the named pipe to XVT.
|
||||
//
|
||||
// It must first send the control command 'comTree' to alert XVT of the
|
||||
// following commands - XVT can then take action to fill its own 'commandArray'
|
||||
// with the ensuing strings passed to it.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void G4UIxvt::sendArrayEntriesToXvt(void)
|
||||
{
|
||||
writeGeantToXvt("comTree");
|
||||
|
||||
char theInt[5];
|
||||
sprintf(theInt, "%d", currentPosition);
|
||||
|
||||
writeGeantToXvt(theInt);
|
||||
|
||||
// --- Output all the Data from the array to the named pipe --- //
|
||||
|
||||
for (int i = 0; i < currentPosition; i++)
|
||||
{
|
||||
// --- Send flag to XVT --- //
|
||||
sprintf(theInt, "%d",commandArray[i].flag);
|
||||
writeGeantToXvt(theInt);
|
||||
|
||||
// --- Send name and guidance --- //
|
||||
writeGeantToXvt(commandArray[i].name);
|
||||
writeGeantToXvt(commandArray[i].guidance);
|
||||
|
||||
// --- Send number of parameters --- //
|
||||
sprintf(theInt, "%d", commandArray[i].numOfParameters);
|
||||
writeGeantToXvt(theInt);
|
||||
|
||||
// --- if there are parameters send them next --- //
|
||||
if (commandArray[i].numOfParameters > 0)
|
||||
{
|
||||
for(int x = 0; x < commandArray[i].numOfParameters; x++)
|
||||
{
|
||||
writeGeantToXvt(commandArray[i].parameters[x].name);
|
||||
writeGeantToXvt(commandArray[i].parameters[x].guidance);
|
||||
writeGeantToXvt(commandArray[i].parameters[x].defaultValue);
|
||||
writeGeantToXvt(commandArray[i].parameters[x].range);
|
||||
writeGeantToXvt(commandArray[i].parameters[x].candidate);
|
||||
writeGeantToXvt(commandArray[i].parameters[x].type);
|
||||
writeGeantToXvt(commandArray[i].parameters[x].omittable);
|
||||
}
|
||||
}
|
||||
|
||||
// --- Send number --- //
|
||||
sprintf(theInt, "%d", commandArray[i].commandNumber);
|
||||
writeGeantToXvt(theInt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// fillArrayEntries
|
||||
//
|
||||
// This traverses the command tree and fills in the command structures in
|
||||
// the class variable 'commandArray'.
|
||||
//
|
||||
// Note: for flag value:
|
||||
//
|
||||
// 0 = Directory
|
||||
// 1 = command
|
||||
// 2 = subdirectory
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void G4UIxvt::fillArrayEntries(G4UIcommandTree * tree, int level)
|
||||
{
|
||||
int treeEntry;
|
||||
int commandEntry;
|
||||
|
||||
treeEntry = tree->GetTreeEntry();
|
||||
commandEntry = tree->GetCommandEntry();
|
||||
|
||||
G4String commandPath;
|
||||
G4String pathName; //tree name
|
||||
G4UIcommandTree * t;
|
||||
|
||||
// New variables
|
||||
G4UIcommand * tempCommand;
|
||||
G4UIparameter * tempParameter;
|
||||
|
||||
// --- this loop lists the current directory and its commands --- //
|
||||
|
||||
for(int com=0; com<commandEntry; com++)
|
||||
{
|
||||
tempCommand = (G4UIcommand *)tree->GetCommand(com+1);
|
||||
|
||||
commandPath = tree->GetCommand(com+1)->GetCommandPath();
|
||||
if(level==0)
|
||||
{
|
||||
// --- This code shouldn't ever get executed --- //
|
||||
G4cout << "Printing command Path" << commandPath << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
commandArray[currentPosition].flag = 1;
|
||||
commandArray[currentPosition].name = commandPath;
|
||||
commandArray[currentPosition].guidance = tempCommand->GetTitle();
|
||||
commandArray[currentPosition].numOfParameters = tempCommand->GetParameterEntries();
|
||||
|
||||
int numParam = tempCommand->GetParameterEntries();
|
||||
|
||||
if(numParam != 0)
|
||||
{
|
||||
for(int x = 0; x < numParam; x++)
|
||||
{
|
||||
tempParameter = (G4UIparameter*)tempCommand->GetParameter(x);
|
||||
|
||||
commandArray[currentPosition].parameters[x].name = tempParameter->GetParameterName();
|
||||
commandArray[currentPosition].parameters[x].guidance = tempParameter->GetParameterGuidance();
|
||||
commandArray[currentPosition].parameters[x].defaultValue = tempParameter->GetDefaultValue();
|
||||
commandArray[currentPosition].parameters[x].range = tempParameter->GetParameterRange();
|
||||
commandArray[currentPosition].parameters[x].candidate = tempParameter->GetParameterCandidate();
|
||||
commandArray[currentPosition].parameters[x].type = tempParameter->GetParameterType();
|
||||
// commandArray[currentPosition].parameters[x].omittable = tempParameter->IsOmittable();
|
||||
}
|
||||
}
|
||||
|
||||
commandArray[currentPosition].commandNumber = currentPosition;
|
||||
|
||||
currentPosition = currentPosition + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if(treeEntry == 0)
|
||||
return; //end recursion
|
||||
|
||||
G4UIcommand * treeGuidance;
|
||||
|
||||
for(int i=0; i< treeEntry; i++)
|
||||
{
|
||||
t = tree->GetTree(i+1);
|
||||
pathName = t->GetPathName();
|
||||
|
||||
treeGuidance = (G4UIcommand *)t->GetGuidance();
|
||||
|
||||
if(level == 0)
|
||||
{
|
||||
commandArray[currentPosition].flag = 0;
|
||||
commandArray[currentPosition].name = pathName;
|
||||
commandArray[currentPosition].guidance = treeGuidance->GetTitle();
|
||||
commandArray[currentPosition].numOfParameters = 0;
|
||||
commandArray[currentPosition].commandNumber = currentPosition;
|
||||
|
||||
currentPosition = currentPosition + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
commandArray[currentPosition].flag = 2;
|
||||
commandArray[currentPosition].name = pathName;
|
||||
commandArray[currentPosition].guidance = treeGuidance->GetTitle();
|
||||
commandArray[currentPosition].numOfParameters = 0;
|
||||
commandArray[currentPosition].commandNumber = currentPosition;
|
||||
|
||||
currentPosition = currentPosition + 1;
|
||||
}
|
||||
|
||||
fillArrayEntries(t, level+1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// A debugging routine //
|
||||
// //
|
||||
// This method is purely used for debugging purposes - will be deleted //
|
||||
// from the final code (when we are sure it is bug free) //
|
||||
// //
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void G4UIxvt::listCommandArray(void)
|
||||
{
|
||||
for(int i = 0; i < currentPosition; i++)
|
||||
{
|
||||
G4cout << "CommandArray, Entry-> " << i << endl
|
||||
<< "Flag-> " << commandArray[i].flag << endl
|
||||
<< "Name-> " << commandArray[i].name << endl
|
||||
<< "Guidance-> " << commandArray[i].guidance << endl
|
||||
<< "Number of Parameters-> " << commandArray[i].numOfParameters << endl;
|
||||
|
||||
int numParam = commandArray[i].numOfParameters;
|
||||
|
||||
if (numParam != 0)
|
||||
{
|
||||
for(int x = 0; x < numParam; x++)
|
||||
{
|
||||
G4cout << "Parameters for this command: " << endl << endl
|
||||
<< "Parameter Name-> " << commandArray[i].parameters[x].name << endl
|
||||
<< "Parameter Guidance-> " << commandArray[i].parameters[x].guidance << endl
|
||||
<< "Parameter Default Value-> " << commandArray[i].parameters[x].defaultValue << endl
|
||||
<< "Parameter Range-> " << commandArray[i].parameters[x].range << endl
|
||||
<< "Parameter Candidate-> " << commandArray[i].parameters[x].candidate << endl
|
||||
<< "Parameter Type-> " << commandArray[i].parameters[x].type << endl
|
||||
<< "Parameter Omittable-> " << commandArray[i].parameters[x].omittable << endl
|
||||
<< endl << endl;
|
||||
}
|
||||
}
|
||||
|
||||
G4cout << "Number-> " << commandArray[i].commandNumber << endl << endl;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,78 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4UIxvtMessenger.cc,v 2.4 1998/07/13 17:13:26 urbi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
#ifdef G4UI_BUILD_XVT_SESSION
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// The original code (written by Makoto Asai) has been adapted for use //
|
||||
// with the XVT Geant GUI //
|
||||
// //
|
||||
// By: Simon Prior 11/08/97 //
|
||||
// //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#include "G4UIxvtMessenger.hh"
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4UIparameter.hh"
|
||||
#include "G4UIxvt.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
|
||||
G4UIxvtMessenger::G4UIxvtMessenger(G4UIxvt* tempxvt)
|
||||
:xvtptr(tempxvt)
|
||||
{
|
||||
G4UIcommand * command;
|
||||
G4UIparameter * param;
|
||||
|
||||
command = new G4UIcommand("/control/setBreakAt",this);
|
||||
command->SetGuidance("Set a break point at the begining or end of");
|
||||
command->SetGuidance("each run or event.");
|
||||
command->SetGuidance(" Available points :");
|
||||
command->SetGuidance(" beginOfRun, endOfRun, beginOfEvent, EndOfEvent");
|
||||
param = new G4UIparameter("point",'c',false);
|
||||
command->SetParameter(param);
|
||||
AddUIcommand( command );
|
||||
|
||||
command = new G4UIcommand("/control/removeBreakPoint",this);
|
||||
command->SetGuidance("Reset all of assigned break.");
|
||||
AddUIcommand( command );
|
||||
|
||||
command = new G4UIcommand("/control/noticeState",this);
|
||||
command->SetGuidance("Toggle Verbose flag of G4UIxvt for state change.");
|
||||
command->SetGuidance("If it is on, all state change will be displayed.");
|
||||
AddUIcommand( command );
|
||||
}
|
||||
|
||||
void G4UIxvtMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
|
||||
{
|
||||
if(command->GetCommandName()=="setBreakAt")
|
||||
{
|
||||
int id = -1;
|
||||
if(newValue=="beginOfRun") id=0;
|
||||
if(newValue=="beginOfEvent") id=1;
|
||||
if(newValue=="EndOfEvent") id=2;
|
||||
if(newValue=="endOfRun") id=3;
|
||||
if(id<0)
|
||||
{ G4cout << "Unknown break point <" << newValue << "> ignored." << endl; }
|
||||
else
|
||||
{ xvtptr->set_breakPointAt(id,true); }
|
||||
}
|
||||
if(command->GetCommandName()=="removeBreakPoint")
|
||||
{
|
||||
for(int i=0;i<4;i++)
|
||||
{ xvtptr->set_breakPointAt(i,false); }
|
||||
}
|
||||
if(command->GetCommandName()=="noticeState")
|
||||
{
|
||||
xvtptr->set_verbose();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,21 @@
|
||||
# $Id: GNUmakefile,v 2.2 1998/07/07 16:57:27 allison Exp $
|
||||
# -------------------------------------------------------------
|
||||
# GNUmakefile for interfaces/basic library. John Allison, 6/7/98.
|
||||
|
||||
name := G4UIbasic
|
||||
|
||||
ifndef G4INSTALL
|
||||
G4INSTALL = ../../..
|
||||
endif
|
||||
|
||||
include $(G4INSTALL)/config/architecture.gmk
|
||||
include $(G4INSTALL)/config/G4UI_BUILD.gmk
|
||||
include $(G4INSTALL)/config/interactivity.gmk
|
||||
|
||||
G4TMPDIR = $(G4TMP)/$(G4SYSTEM)/$(name)
|
||||
|
||||
CPPFLAGS += -I$(G4BASE)/global/management/include
|
||||
CPPFLAGS += -I$(G4BASE)/interfaces/common/include
|
||||
CPPFLAGS += -I$(G4BASE)/intercoms/include
|
||||
|
||||
include $(G4INSTALL)/config/common.gmk
|
||||
@@ -0,0 +1,61 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4UIWin32.hh,v 2.5 1998/10/23 14:39:02 barrand Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
#ifndef G4UIWin32_h
|
||||
#define G4UIWin32_h
|
||||
|
||||
#if defined(G4UI_BUILD_WIN32_SESSION) || defined(G4UI_USE_WIN32)
|
||||
|
||||
#include <rw/tvhdict.h>
|
||||
|
||||
#include "G4VBasicShell.hh"
|
||||
#include "G4VInteractiveSession.hh"
|
||||
|
||||
#include "G4Win32.hh"
|
||||
|
||||
class G4VInteractorManager;
|
||||
|
||||
class G4UIWin32 : public G4VBasicShell, public G4VInteractiveSession {
|
||||
public:
|
||||
G4UIWin32 (HINSTANCE,HINSTANCE,LPSTR,int);
|
||||
~G4UIWin32 ();
|
||||
|
||||
G4UIsession* SessionStart ();
|
||||
void Prompt (G4String);
|
||||
void SessionTerminate ();
|
||||
void PauseSessionStart (G4String);
|
||||
G4int ReceiveG4cout(G4String);
|
||||
G4int ReceiveG4cerr(G4String);
|
||||
void ApplyShellCommand (G4String);
|
||||
void AddMenu (const char*,const char*);
|
||||
void AddButton (const char*,const char*,const char*);
|
||||
G4String GetCommand (int);
|
||||
void TextAppendString(char*);
|
||||
private:
|
||||
void SecondaryLoop (G4String);
|
||||
void ExecuteCommand (G4String);
|
||||
void ShowCurrent (G4String);
|
||||
void ChangeDirectoryCommand (G4String);
|
||||
void ListDirectory (G4String);
|
||||
G4VInteractorManager* interactorManager;
|
||||
HWND mainWindow;
|
||||
HWND textWindow,editWindow;
|
||||
HMENU menuBar,defaultMenu;
|
||||
RWTValHashDictionary<int,G4String> commands;
|
||||
void* textBuffer;
|
||||
int textRows,textCols;
|
||||
static LRESULT CALLBACK MainWindowProc(HWND,UINT,WPARAM,LPARAM);
|
||||
static LRESULT CALLBACK TextWindowProc(HWND,UINT,WPARAM,LPARAM);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4UIXaw.hh,v 2.3 1998/09/19 14:45:24 barrand Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
#ifndef G4UIXaw_h
|
||||
#define G4UIXaw_h
|
||||
|
||||
#if defined(G4UI_BUILD_XAW_SESSION) || defined(G4UI_USE_XAW)
|
||||
|
||||
#include <X11/Intrinsic.h>
|
||||
|
||||
#include "G4VBasicShell.hh"
|
||||
|
||||
class G4UIsession;
|
||||
class G4UImanager;
|
||||
|
||||
class G4UIXaw : public G4VBasicShell
|
||||
{
|
||||
public:
|
||||
G4UIXaw(int,char**);
|
||||
~G4UIXaw();
|
||||
|
||||
G4UIsession* SessionStart ();
|
||||
void Prompt (G4String);
|
||||
void SessionTerminate ();
|
||||
void PauseSessionStart (G4String);
|
||||
void ApplyShellCommand (G4String);
|
||||
Widget GetDialog ();
|
||||
private:
|
||||
void SecondaryLoop (G4String);
|
||||
void ExecuteCommand (G4String);
|
||||
void ShowCurrent (G4String);
|
||||
void ChangeDirectoryCommand (G4String);
|
||||
void ListDirectory (G4String);
|
||||
private:
|
||||
Widget shell,dialog;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4UIXm.hh,v 2.5 1998/10/23 14:39:04 barrand Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
#ifndef G4UIXm_h
|
||||
#define G4UIXm_h
|
||||
|
||||
#if defined(G4UI_BUILD_XM_SESSION) || defined(G4UI_USE_XM)
|
||||
|
||||
#include <rw/tvhdict.h>
|
||||
|
||||
#include <X11/Intrinsic.h>
|
||||
|
||||
#include "G4VBasicShell.hh"
|
||||
#include "G4VInteractiveSession.hh"
|
||||
|
||||
class G4UIsession;
|
||||
|
||||
class G4UIXm : public G4VBasicShell, public G4VInteractiveSession {
|
||||
public:
|
||||
G4UIXm(int,char**);
|
||||
~G4UIXm();
|
||||
|
||||
G4UIsession* SessionStart();
|
||||
void Prompt(G4String);
|
||||
void SessionTerminate();
|
||||
void PauseSessionStart(G4String);
|
||||
G4int ReceiveG4cout(G4String);
|
||||
G4int ReceiveG4cerr(G4String);
|
||||
void ApplyShellCommand(G4String);
|
||||
void AddMenu(const char*,const char*);
|
||||
void AddButton(const char*,const char*,const char*);
|
||||
G4String GetCommand(Widget);
|
||||
private:
|
||||
void SecondaryLoop(G4String);
|
||||
void ExecuteCommand(G4String);
|
||||
void ShowCurrent(G4String);
|
||||
void ChangeDirectoryCommand(G4String);
|
||||
void ListDirectory(G4String);
|
||||
private:
|
||||
Widget shell,command,menuBar,text;
|
||||
RWTValHashDictionary<Widget,G4String> commands;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4UIterminal.hh,v 2.2 1998/07/12 03:00:10 urbi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
|
||||
#ifndef G4UIterminal_h
|
||||
#define G4UIterminal_h 1
|
||||
|
||||
#include "G4VBasicShell.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include <fstream.h>
|
||||
|
||||
class G4UIterminal : public G4VBasicShell
|
||||
{
|
||||
public:
|
||||
G4UIterminal();
|
||||
~G4UIterminal();
|
||||
|
||||
G4UIsession * SessionStart();
|
||||
void PauseSessionStart(G4String);
|
||||
G4int ReceiveG4cout(G4String coutString);
|
||||
G4int ReceiveG4cerr(G4String cerrString);
|
||||
|
||||
private:
|
||||
G4UImanager * UI;
|
||||
G4String promptCharacter;
|
||||
G4bool iExit;
|
||||
G4bool iCont;
|
||||
|
||||
private:
|
||||
void ExecuteCommand(G4String);
|
||||
G4String GetCommand();
|
||||
void ChangeDirectoryCommand(G4String);
|
||||
void ListDirectory(G4String);
|
||||
void TerminalHelp(G4String);
|
||||
void ShowCurrent(G4String);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,723 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4UIWin32.cc,v 2.6 1998/10/23 14:39:11 barrand Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
// G.Barrand
|
||||
|
||||
//#define DEBUG
|
||||
|
||||
#ifdef G4UI_BUILD_WIN32_SESSION
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <wingdi.h>
|
||||
|
||||
#include <Strstrea.h>
|
||||
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4StateManager.hh"
|
||||
#include "G4UIcommandTree.hh"
|
||||
#include "G4UIcommandStatus.hh"
|
||||
#include "G4Win32.hh"
|
||||
|
||||
#include "G4UIWin32.hh"
|
||||
|
||||
#define TEXT_MAX_LINES 300
|
||||
|
||||
class TextBuffer {
|
||||
public:
|
||||
TextBuffer():linei(0),linen(TEXT_MAX_LINES),endOfPage(0),heightOfPage(12) {
|
||||
lines = new G4String[linen];
|
||||
}
|
||||
~TextBuffer() {
|
||||
delete [] lines;
|
||||
}
|
||||
int GetNumberOfLines () {
|
||||
return linei;
|
||||
}
|
||||
void SetHeightOfPage (int a_height) {
|
||||
heightOfPage = a_height;
|
||||
}
|
||||
void SetEndOfPage (int a_value) {
|
||||
if( (a_value<0) || (a_value>=linei)) {
|
||||
endOfPage = linei-1;
|
||||
} else {
|
||||
endOfPage = a_value;
|
||||
}
|
||||
}
|
||||
int GetEndOfPage () {
|
||||
return endOfPage;
|
||||
}
|
||||
void IncrementEndOfPage () {
|
||||
endOfPage++;
|
||||
if(endOfPage>=linei) endOfPage = linei-1;
|
||||
}
|
||||
void DecrementEndOfPage () {
|
||||
endOfPage--;
|
||||
if(endOfPage<0) endOfPage = 0;
|
||||
}
|
||||
void JumpDownEndOfPage () {
|
||||
endOfPage += heightOfPage;
|
||||
if(endOfPage>=linei) endOfPage = linei-1;
|
||||
}
|
||||
void JumpUpEndOfPage () {
|
||||
endOfPage -= heightOfPage;
|
||||
if(endOfPage<0) endOfPage = 0;
|
||||
}
|
||||
G4bool AppendString (char* a_string) {
|
||||
G4bool value = false;
|
||||
if( (a_string==NULL) || (a_string[0]=='\0') ) return value;
|
||||
int length = strlen(a_string);
|
||||
if(a_string[length-1]=='\n') {
|
||||
lines[linei] += a_string;
|
||||
lines[linei] = lines[linei].strip(G4String::trailing,'\n');
|
||||
linei++;
|
||||
value = true;
|
||||
} else {
|
||||
lines[linei] += a_string;
|
||||
}
|
||||
if(linei>=linen) {
|
||||
for(int count=0;count<linen;count++) {
|
||||
lines[count] = "";
|
||||
}
|
||||
linei = 0;
|
||||
}
|
||||
if(value==true) endOfPage = linei-1;
|
||||
return value;
|
||||
}
|
||||
void Draw (HDC a_hdc,RECT* a_rect) {
|
||||
TEXTMETRIC tm;
|
||||
GetTextMetrics (a_hdc,&tm);
|
||||
short charWidth = tm.tmAveCharWidth;
|
||||
short charHeight = tm.tmHeight + tm.tmExternalLeading;
|
||||
for(int row=0;row<heightOfPage;row++) {
|
||||
int rowi = endOfPage - row;
|
||||
short y = a_rect->bottom - charHeight * (row + 1);
|
||||
if((rowi>=0)&&(rowi<linei)) {
|
||||
const char* string = lines[rowi].data();
|
||||
if(string!=NULL) {
|
||||
TextOut (a_hdc,0,y,(char*)string,strlen((char*)string));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private:
|
||||
G4String* lines;
|
||||
int linen;
|
||||
int linei;
|
||||
int endOfPage,heightOfPage;
|
||||
};
|
||||
|
||||
static char mainClassName[] = "G4UIWin32";
|
||||
static char textClassName[] = "G4UIWin32/Text";
|
||||
static G4bool exitSession = true;
|
||||
static G4bool exitPause = true;
|
||||
static G4UIsession* tmpSession = NULL;
|
||||
|
||||
static FARPROC oldEditWindowProc;
|
||||
static LRESULT CALLBACK EditWindowProc(HWND,UINT,WPARAM,LPARAM);
|
||||
|
||||
static int actionIdentifier = 0;
|
||||
|
||||
static unsigned CommandsHashFun(const int& identifier) {
|
||||
return (unsigned)identifier;
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4UIWin32::G4UIWin32 (
|
||||
HANDLE a_hInstance
|
||||
,HANDLE a_hPrevInstance
|
||||
,LPSTR a_lpszCmdLine
|
||||
,int a_nCmdShow
|
||||
)
|
||||
:mainWindow(NULL)
|
||||
,textWindow(NULL)
|
||||
,editWindow(NULL)
|
||||
,menuBar(NULL)
|
||||
,commands(CommandsHashFun)
|
||||
,textBuffer(NULL)
|
||||
,textCols(80)
|
||||
,textRows(12)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
if(UI!=NULL) UI->SetSession(this);
|
||||
|
||||
interactorManager = G4Win32::getInstance (a_hInstance,a_hPrevInstance,
|
||||
a_lpszCmdLine,a_nCmdShow);
|
||||
static G4bool Done = FALSE;
|
||||
if(Done==FALSE) {
|
||||
if(a_hPrevInstance==NULL) {
|
||||
WNDCLASS wc;
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.lpfnWndProc = (WNDPROC)G4UIWin32::MainWindowProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = a_hInstance;
|
||||
wc.hIcon = LoadIcon(NULL,IDI_APPLICATION);
|
||||
wc.hCursor = LoadCursor(NULL,IDC_ARROW);
|
||||
wc.hbrBackground = GetStockObject(BLACK_BRUSH);
|
||||
wc.lpszMenuName = mainClassName;
|
||||
wc.lpszClassName = mainClassName;
|
||||
::RegisterClass (&wc);
|
||||
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.lpfnWndProc = (WNDPROC)G4UIWin32::TextWindowProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = a_hInstance;
|
||||
wc.hIcon = LoadIcon(NULL,IDI_APPLICATION);
|
||||
wc.hCursor = LoadCursor(NULL,IDC_ARROW);
|
||||
wc.hbrBackground = GetStockObject(WHITE_BRUSH);
|
||||
wc.lpszMenuName = textClassName;
|
||||
wc.lpszClassName = textClassName;
|
||||
::RegisterClass (&wc);
|
||||
}
|
||||
Done = TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
*/
|
||||
menuBar = CreateMenu();
|
||||
defaultMenu = CreatePopupMenu();
|
||||
AppendMenu(menuBar,MF_POPUP,(UINT)defaultMenu,"Geant4");
|
||||
|
||||
textBuffer = new TextBuffer();
|
||||
|
||||
tmpSession = this;
|
||||
mainWindow = ::CreateWindow(mainClassName,mainClassName,
|
||||
WS_OVERLAPPEDWINDOW,
|
||||
CW_USEDEFAULT,CW_USEDEFAULT,
|
||||
0,0,
|
||||
NULL,menuBar,a_hInstance,NULL);
|
||||
tmpSession = NULL;
|
||||
::SetWindowLong(mainWindow,GWL_USERDATA,LONG(this));
|
||||
|
||||
::SetForegroundWindow(mainWindow);
|
||||
::ShowWindow(mainWindow,SW_SHOWDEFAULT);
|
||||
::UpdateWindow(mainWindow);
|
||||
|
||||
if(UI!=NULL) UI->SetCoutDestination(this);
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4UIWin32::~G4UIWin32 (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
if(UI!=NULL) {
|
||||
UI->SetSession(NULL);
|
||||
UI->SetCoutDestination(NULL);
|
||||
}
|
||||
delete textBuffer;
|
||||
::DestroyWindow(mainWindow);
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4UIsession* G4UIWin32::SessionStart (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(interactorManager==NULL) return this;
|
||||
Prompt ("session");
|
||||
exitSession = false;
|
||||
interactorManager->DisableSecondaryLoop ();
|
||||
void* event;
|
||||
while((event = interactorManager->GetEvent())!=NULL) {
|
||||
interactorManager->DispatchEvent(event);
|
||||
if(exitSession==true) break;
|
||||
}
|
||||
interactorManager->EnableSecondaryLoop ();
|
||||
return this;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4UIWin32::Prompt (
|
||||
G4String a_prompt
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4UIWin32::SessionTerminate (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4UIWin32::PauseSessionStart (
|
||||
G4String a_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");
|
||||
}
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4UIWin32::SecondaryLoop (
|
||||
G4String a_prompt
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(interactorManager==NULL) return;
|
||||
Prompt (a_prompt);
|
||||
exitPause = false;
|
||||
void* event;
|
||||
while((event = interactorManager->GetEvent())!=NULL) {
|
||||
interactorManager->DispatchEvent(event);
|
||||
if(exitPause==true) break;
|
||||
}
|
||||
Prompt ("session");
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4UIWin32::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 == "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 );
|
||||
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 G4UIWin32::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;
|
||||
}
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4int G4UIWin32::ReceiveG4cout (
|
||||
G4String a_string
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
TextAppendString((char*)a_string.data());
|
||||
return 0;
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4int G4UIWin32::ReceiveG4cerr (
|
||||
G4String a_string
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
TextAppendString((char*)a_string.data());
|
||||
return 0;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4UIWin32::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 G4UIWin32::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 G4UIWin32::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();
|
||||
}
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4UIWin32::AddMenu (
|
||||
const char* a_name
|
||||
,const char* a_label
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(a_name==NULL) return;
|
||||
if(defaultMenu!=NULL) {
|
||||
DeleteMenu (menuBar,0,MF_BYPOSITION);
|
||||
defaultMenu = NULL;
|
||||
}
|
||||
HMENU hMenu = CreatePopupMenu();
|
||||
AppendMenu(menuBar,MF_POPUP,(UINT)hMenu,a_label);
|
||||
AddInteractor(a_name,(G4Interactor)hMenu);
|
||||
DrawMenuBar(mainWindow);
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4UIWin32::AddButton (
|
||||
const char* a_menu
|
||||
,const char* a_label
|
||||
,const char* a_command
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(a_menu==NULL) return;
|
||||
if(a_label==NULL) return;
|
||||
if(a_command==NULL) return;
|
||||
HMENU hMenu = (HMENU)GetInteractor(a_menu);
|
||||
actionIdentifier++;
|
||||
commands[actionIdentifier] = a_command;
|
||||
AppendMenu (hMenu,MF_STRING,actionIdentifier,a_label);
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4String G4UIWin32::GetCommand (
|
||||
int a_id
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
return commands[a_id];
|
||||
}
|
||||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
LRESULT CALLBACK G4UIWin32::MainWindowProc (
|
||||
HWND a_window
|
||||
,UINT a_message
|
||||
,WPARAM a_wParam
|
||||
,LPARAM a_lParam
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
static short charWidth,charHeight;
|
||||
|
||||
switch (a_message) {
|
||||
case WM_CREATE:{
|
||||
HDC hdc;
|
||||
TEXTMETRIC tm;
|
||||
RECT rect;
|
||||
GetWindowRect (a_window,&rect);
|
||||
|
||||
hdc = GetDC (a_window);
|
||||
GetTextMetrics (hdc,&tm);
|
||||
charWidth = tm.tmAveCharWidth;
|
||||
charHeight = tm.tmHeight + tm.tmExternalLeading;
|
||||
ReleaseDC (a_window,hdc);
|
||||
|
||||
G4UIWin32* This = (G4UIWin32*)tmpSession;
|
||||
|
||||
This->textWindow = CreateWindow (textClassName,NULL,
|
||||
WS_CHILD | WS_VISIBLE | WS_VSCROLL,
|
||||
0,0,
|
||||
This->textCols * charWidth,
|
||||
This->textRows * charHeight,
|
||||
a_window,NULL,
|
||||
GetWindowInstance(a_window),
|
||||
NULL);
|
||||
::SetWindowLong (This->textWindow,GWL_USERDATA,LONG(This));
|
||||
|
||||
This->editWindow = CreateWindow ("edit",NULL,
|
||||
WS_CHILD | WS_VISIBLE | WS_BORDER,
|
||||
0,This->textRows * charHeight,
|
||||
This->textCols * charWidth,charHeight,
|
||||
a_window,(HMENU)1,
|
||||
GetWindowInstance(a_window),
|
||||
NULL);
|
||||
oldEditWindowProc = (FARPROC)GetWindowLong(This->editWindow,GWL_WNDPROC);
|
||||
SetWindowLong (This->editWindow,GWL_WNDPROC,(LONG)EditWindowProc);
|
||||
|
||||
MoveWindow (a_window,
|
||||
rect.left,rect.top,
|
||||
2 * GetSystemMetrics(SM_CXFRAME) +
|
||||
This->textCols * charWidth,
|
||||
GetSystemMetrics(SM_CYCAPTION) +
|
||||
2 * GetSystemMetrics(SM_CYFRAME) +
|
||||
This->textRows * charHeight + charHeight,
|
||||
TRUE);
|
||||
|
||||
}return 0;
|
||||
case WM_SIZE:{
|
||||
G4UIWin32* This = (G4UIWin32*)::GetWindowLong(a_window,GWL_USERDATA);
|
||||
if(This!=NULL) {
|
||||
// Client size :
|
||||
int width = LOWORD(a_lParam);
|
||||
int height = HIWORD(a_lParam);
|
||||
int editHeight = /*2 * GetSystemMetrics(SM_CYBORDER) + */ charHeight;
|
||||
MoveWindow (This->textWindow,
|
||||
0,0,
|
||||
width,height - editHeight,
|
||||
FALSE);
|
||||
MoveWindow (This->editWindow,
|
||||
0,height - editHeight,
|
||||
width,charHeight,
|
||||
FALSE);
|
||||
((TextBuffer*)This->textBuffer)->SetHeightOfPage(height/charHeight);
|
||||
}
|
||||
}return 0;
|
||||
case WM_SETFOCUS:{
|
||||
G4UIWin32* This = (G4UIWin32*)::GetWindowLong(a_window,GWL_USERDATA);
|
||||
SetFocus (This->editWindow);
|
||||
}return 0;
|
||||
case WM_COMMAND:{
|
||||
G4UIWin32* This = (G4UIWin32*)::GetWindowLong(a_window,GWL_USERDATA);
|
||||
if(This!=NULL) {
|
||||
G4String command = This->GetCommand(a_wParam);
|
||||
This->ApplyShellCommand (command);
|
||||
}
|
||||
}return 0;
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
}
|
||||
return (DefWindowProc(a_window,a_message,a_wParam,a_lParam));
|
||||
}
|
||||
/***************************************************************************/
|
||||
LRESULT CALLBACK G4UIWin32::TextWindowProc (
|
||||
HWND a_window
|
||||
,UINT a_message
|
||||
,WPARAM a_wParam
|
||||
,LPARAM a_lParam
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
switch (a_message) {
|
||||
case WM_PAINT:{
|
||||
G4UIWin32* This = (G4UIWin32*)::GetWindowLong(a_window,GWL_USERDATA);
|
||||
if(This!=NULL) {
|
||||
TextBuffer* textBuffer = (TextBuffer*)This->textBuffer;
|
||||
RECT rect;
|
||||
GetClientRect (a_window,&rect);
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc = BeginPaint(a_window,&ps);
|
||||
textBuffer->Draw(hdc,&rect);
|
||||
EndPaint(a_window,&ps);
|
||||
}
|
||||
}return 0;
|
||||
case WM_VSCROLL:{
|
||||
G4UIWin32* This = (G4UIWin32*)::GetWindowLong(a_window,GWL_USERDATA);
|
||||
if(This!=NULL) {
|
||||
TextBuffer* textBuffer = (TextBuffer*)This->textBuffer;
|
||||
int what = LOWORD(a_wParam);
|
||||
switch(what) {
|
||||
case SB_LINEUP:
|
||||
textBuffer->DecrementEndOfPage();
|
||||
break;
|
||||
case SB_LINEDOWN:
|
||||
textBuffer->IncrementEndOfPage();
|
||||
break;
|
||||
case SB_PAGEUP:
|
||||
textBuffer->JumpUpEndOfPage();
|
||||
break;
|
||||
case SB_PAGEDOWN:
|
||||
textBuffer->JumpDownEndOfPage();
|
||||
break;
|
||||
case SB_THUMBPOSITION:
|
||||
case SB_THUMBTRACK:
|
||||
textBuffer->SetEndOfPage(HIWORD(a_wParam));
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
int eop = textBuffer->GetEndOfPage();
|
||||
SetScrollPos(a_window,SB_VERT,eop,TRUE);
|
||||
InvalidateRect(a_window,NULL,TRUE);
|
||||
}}return 0;
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
}
|
||||
return (DefWindowProc(a_window,a_message,a_wParam,a_lParam));
|
||||
}
|
||||
/***************************************************************************/
|
||||
LRESULT CALLBACK EditWindowProc (
|
||||
HWND a_window
|
||||
,UINT a_message
|
||||
,WPARAM a_wParam
|
||||
,LPARAM a_lParam
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
switch (a_message) {
|
||||
case WM_KEYDOWN:
|
||||
switch(a_wParam){
|
||||
case VK_RETURN:{
|
||||
G4UIWin32* This = (G4UIWin32*)::GetWindowLong(
|
||||
GetParent(a_window),GWL_USERDATA);
|
||||
char buffer[128];
|
||||
GetWindowText (a_window,buffer,128);
|
||||
G4String command (buffer);
|
||||
SetWindowText (a_window,"");
|
||||
This->ApplyShellCommand (command);
|
||||
}break;
|
||||
}
|
||||
}
|
||||
return CallWindowProc(oldEditWindowProc,
|
||||
a_window,a_message,
|
||||
a_wParam,a_lParam);
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4UIWin32::TextAppendString (
|
||||
char* a_string
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if( (a_string==NULL) || (a_string[0]=='\0') ) return;
|
||||
if(textWindow==NULL) return;
|
||||
if(((TextBuffer*)textBuffer)->AppendString(a_string)==true) {
|
||||
// The appending triggers and end of line, and then updates window :
|
||||
RECT rect;
|
||||
GetClientRect(textWindow,&rect);
|
||||
InvalidateRect(textWindow,NULL,TRUE); //To erase background.
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc = GetDC(textWindow);
|
||||
((TextBuffer*)textBuffer)->Draw(hdc,&rect);
|
||||
ReleaseDC (textWindow,hdc);
|
||||
int linen = ((TextBuffer*)textBuffer)->GetNumberOfLines();
|
||||
SetScrollRange(textWindow,SB_VERT,0,linen-1,TRUE);
|
||||
SetScrollPos(textWindow,SB_VERT,linen-1,TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,348 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// 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 $
|
||||
//
|
||||
// G.Barrand
|
||||
|
||||
//#define DEBUG
|
||||
|
||||
#ifdef G4UI_BUILD_XAW_SESSION
|
||||
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <X11/StringDefs.h>
|
||||
#include <X11/Shell.h>
|
||||
|
||||
#include <Xaw/Dialog.h>
|
||||
#include <Xaw/Command.h>
|
||||
|
||||
#include "G4UIXaw.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4StateManager.hh"
|
||||
#include "G4UIcommandTree.hh"
|
||||
#include "G4UIcommandStatus.hh"
|
||||
#include "G4Xt.hh"
|
||||
|
||||
|
||||
static void Callback (Widget,XtPointer,XtPointer);
|
||||
|
||||
static G4bool exitSession = true;
|
||||
static G4bool exitPause = true;
|
||||
/***************************************************************************/
|
||||
G4UIXaw::G4UIXaw (
|
||||
int argc
|
||||
,char** argv
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
if(UI!=NULL) UI->SetSession(this);
|
||||
|
||||
G4Xt* interactorManager = G4Xt::getInstance (argc,argv,"Xaw");
|
||||
Widget top = (Widget)interactorManager->GetMainInteractor();
|
||||
|
||||
shell = XtAppCreateShell ("G4UIXaw","G4UIXaw",topLevelShellWidgetClass,XtDisplay(top),NULL,0);
|
||||
|
||||
Arg args[2];
|
||||
XtSetArg (args[0],XtNlabel,"G4 command");
|
||||
XtSetArg (args[1],XtNvalue,""); // Needed to have a text Area.
|
||||
dialog = XtCreateManagedWidget ("dialog",dialogWidgetClass,shell,args,2);
|
||||
|
||||
XawDialogAddButton (dialog,"Ok",Callback,(XtPointer)this);
|
||||
|
||||
XtRealizeWidget (shell);
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4UIXaw::~G4UIXaw (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
XtDestroyWidget (shell);
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
if(UI!=NULL) UI->SetSession(NULL);
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4UIsession* G4UIXaw::SessionStart (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
G4Xt* interactorManager = G4Xt::getInstance ();
|
||||
Prompt ("session");
|
||||
exitSession = false;
|
||||
interactorManager->DisableSecondaryLoop ();
|
||||
void* event;
|
||||
while((event = interactorManager->GetEvent())!=NULL) {
|
||||
interactorManager->DispatchEvent(event);
|
||||
if(exitSession==true) break;
|
||||
}
|
||||
interactorManager->EnableSecondaryLoop ();
|
||||
return this;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4UIXaw::Prompt (
|
||||
G4String aPrompt
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
Arg args[1];
|
||||
XtSetArg (args[0],XtNlabel,aPrompt.data());
|
||||
XtSetValues (dialog,args,1);
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4UIXaw::SessionTerminate (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4UIXaw::PauseSessionStart (
|
||||
G4String a_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");
|
||||
}
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4UIXaw::SecondaryLoop (
|
||||
G4String a_prompt
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
G4Xt* interactorManager = G4Xt::getInstance ();
|
||||
Prompt (a_prompt);
|
||||
exitPause = false;
|
||||
void* event;
|
||||
while((event = interactorManager->GetEvent())!=NULL) {
|
||||
interactorManager->DispatchEvent(event);
|
||||
if(exitPause==true) break;
|
||||
}
|
||||
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 (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
return dialog;
|
||||
}
|
||||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
static void Callback (
|
||||
Widget a_widget
|
||||
,XtPointer a_tag
|
||||
,XtPointer a_data
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
G4UIXaw* This = (G4UIXaw*)a_tag;
|
||||
Widget dialog = This->GetDialog();
|
||||
char* value = XawDialogGetValueString(dialog);
|
||||
if(value==NULL) return;
|
||||
G4String command (value);
|
||||
|
||||
This->ApplyShellCommand (command);
|
||||
|
||||
Arg args[1];
|
||||
XtSetArg (args[0],XtNvalue,"");
|
||||
XtSetValues (dialog,args,1);
|
||||
|
||||
a_widget = NULL;
|
||||
a_data = NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,550 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4UIXm.cc,v 2.7 1998/10/23 14:39:13 barrand Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
// G.Barrand
|
||||
|
||||
//#define DEBUG
|
||||
|
||||
#ifdef G4UI_BUILD_XM_SESSION
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Strstrea.h>
|
||||
#else
|
||||
#include <strstream.h>
|
||||
#endif
|
||||
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <X11/Shell.h>
|
||||
|
||||
#include <Xm/Xm.h>
|
||||
#include <Xm/Command.h>
|
||||
#include <Xm/RowColumn.h>
|
||||
#include <Xm/Form.h>
|
||||
#include <Xm/PushB.h>
|
||||
#include <Xm/CascadeB.h>
|
||||
#include <Xm/Text.h>
|
||||
|
||||
#include "G4UIXm.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4StateManager.hh"
|
||||
#include "G4UIcommandTree.hh"
|
||||
#include "G4UIcommandStatus.hh"
|
||||
|
||||
#include "G4Xt.hh"
|
||||
|
||||
static void XmTextAppendString (Widget,char*);
|
||||
|
||||
static void commandCallback (Widget,XtPointer,XtPointer);
|
||||
static void buttonCallback (Widget,XtPointer,XtPointer);
|
||||
static void clearButtonCallback (Widget,XtPointer,XtPointer);
|
||||
static char* XmConvertCompoundStringToString (XmString,int);
|
||||
|
||||
static G4bool exitSession = true;
|
||||
static G4bool exitPause = true;
|
||||
static unsigned CommandsHashFun (const Widget& interactor) {
|
||||
// Is it correct to return a pointer ?
|
||||
return (unsigned)(unsigned long)interactor;
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4UIXm::G4UIXm (
|
||||
int argc
|
||||
,char** argv
|
||||
)
|
||||
:shell(NULL)
|
||||
,command(NULL)
|
||||
,menuBar(NULL)
|
||||
,text(NULL)
|
||||
,commands(CommandsHashFun)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
if(UI!=NULL) UI->SetSession(this);
|
||||
|
||||
G4Xt* interactorManager = G4Xt::getInstance (argc,argv,"Xm");
|
||||
|
||||
Widget top = (Widget)interactorManager->GetMainInteractor();
|
||||
|
||||
shell = XtAppCreateShell ("G4UIXm","G4UIXm",
|
||||
topLevelShellWidgetClass,XtDisplay(top),
|
||||
NULL,0);
|
||||
Widget form = XmCreateForm (shell,"form",NULL,0);
|
||||
XtManageChild (form);
|
||||
|
||||
Arg args[9];
|
||||
XtSetArg(args[0],XmNtopAttachment ,XmATTACH_FORM);
|
||||
XtSetArg(args[1],XmNleftAttachment ,XmATTACH_FORM);
|
||||
XtSetArg(args[2],XmNrightAttachment ,XmATTACH_FORM);
|
||||
menuBar = XmCreateMenuBar (form,"menuBar",args,3);
|
||||
|
||||
XtSetArg(args[0],XmNtopAttachment ,XmATTACH_NONE);
|
||||
XtSetArg(args[1],XmNleftAttachment ,XmATTACH_FORM);
|
||||
XtSetArg(args[2],XmNrightAttachment ,XmATTACH_FORM);
|
||||
XtSetArg(args[3],XmNbottomAttachment,XmATTACH_FORM);
|
||||
command = XmCreateCommand (form,"command",args,4);
|
||||
XtManageChild (command);
|
||||
|
||||
XtSetArg(args[0],XmNtopAttachment ,XmATTACH_NONE);
|
||||
XtSetArg(args[1],XmNleftAttachment ,XmATTACH_FORM);
|
||||
XtSetArg(args[2],XmNrightAttachment ,XmATTACH_FORM);
|
||||
XtSetArg(args[3],XmNbottomAttachment,XmATTACH_WIDGET);
|
||||
XtSetArg(args[4],XmNbottomWidget ,command);
|
||||
XmString cps = XmStringLtoRCreate("Clear",XmSTRING_DEFAULT_CHARSET);
|
||||
XtSetArg (args[5],XmNlabelString,cps);
|
||||
Widget clearButton = XmCreatePushButton(form,"clearButton",args,6);
|
||||
XmStringFree (cps);
|
||||
XtManageChild (clearButton);
|
||||
|
||||
XtSetArg(args[0],XmNtopAttachment ,XmATTACH_WIDGET);
|
||||
XtSetArg(args[1],XmNtopWidget ,menuBar);
|
||||
XtSetArg(args[2],XmNleftAttachment ,XmATTACH_FORM);
|
||||
XtSetArg(args[3],XmNrightAttachment ,XmATTACH_FORM);
|
||||
XtSetArg(args[4],XmNbottomAttachment,XmATTACH_WIDGET);
|
||||
XtSetArg(args[5],XmNbottomWidget ,clearButton);
|
||||
XtSetArg(args[6],XmNeditMode ,XmMULTI_LINE_EDIT);
|
||||
XtSetArg(args[7],XmNrows ,12);
|
||||
XtSetArg(args[8],XmNcolumns ,80);
|
||||
text = XmCreateScrolledText (form,"text",args,9);
|
||||
XtManageChild (text);
|
||||
|
||||
XtAddCallback(clearButton,XmNactivateCallback,
|
||||
clearButtonCallback,(XtPointer)text);
|
||||
XtAddCallback(command,XmNcommandEnteredCallback,
|
||||
commandCallback,(XtPointer)this);
|
||||
|
||||
XtRealizeWidget(shell);
|
||||
XtMapWidget(shell);
|
||||
|
||||
if(UI!=NULL) UI->SetCoutDestination(this);
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4UIXm::~G4UIXm(
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
if(UI!=NULL) {
|
||||
UI->SetSession(NULL);
|
||||
UI->SetCoutDestination(NULL);
|
||||
}
|
||||
XtDestroyWidget(shell);
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4UIsession* G4UIXm::SessionStart (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
G4Xt* interactorManager = G4Xt::getInstance ();
|
||||
Prompt("session");
|
||||
exitSession = false;
|
||||
interactorManager->DisableSecondaryLoop ();
|
||||
void* event;
|
||||
while((event = interactorManager->GetEvent())!=NULL) {
|
||||
interactorManager->DispatchEvent(event);
|
||||
if(exitSession==true) break;
|
||||
}
|
||||
interactorManager->EnableSecondaryLoop ();
|
||||
return this;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4UIXm::Prompt (
|
||||
G4String aPrompt
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
Arg args[1];
|
||||
char* str = (char*)XtNewString(aPrompt.data());
|
||||
XmString cps = XmStringLtoRCreate(str,XmSTRING_DEFAULT_CHARSET);
|
||||
XtFree(str);
|
||||
XtSetArg(args[0],XmNpromptString,cps);
|
||||
XtSetValues(command,args,1);
|
||||
XmStringFree(cps);
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4UIXm::SessionTerminate (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4UIXm::PauseSessionStart (
|
||||
G4String a_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");
|
||||
}
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4UIXm::SecondaryLoop (
|
||||
G4String a_prompt
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
G4Xt* interactorManager = G4Xt::getInstance ();
|
||||
Prompt(a_prompt);
|
||||
exitPause = false;
|
||||
void* event;
|
||||
while((event = interactorManager->GetEvent())!=NULL) {
|
||||
interactorManager->DispatchEvent(event);
|
||||
if(exitPause==true) break;
|
||||
}
|
||||
Prompt("session");
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4UIXm::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 == "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 );
|
||||
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 G4UIXm::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;
|
||||
}
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4int G4UIXm::ReceiveG4cout (
|
||||
G4String a_string
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
XmTextAppendString(text,(char*)a_string.data());
|
||||
return 0;
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4int G4UIXm::ReceiveG4cerr (
|
||||
G4String a_string
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
XmTextAppendString(text,(char*)a_string.data());
|
||||
return 0;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4UIXm::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 G4UIXm::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 G4UIXm::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();
|
||||
}
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4UIXm::AddMenu (
|
||||
const char* a_name
|
||||
,const char* a_label
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(menuBar==NULL) return;
|
||||
if(a_name==NULL) return;
|
||||
if(a_label==NULL) return;
|
||||
XtManageChild (menuBar);
|
||||
// Pulldown menu :
|
||||
Widget widget;
|
||||
widget = XmCreatePulldownMenu (menuBar,(char*)a_name,NULL,0);
|
||||
AddInteractor (a_name,(G4Interactor)widget);
|
||||
// Cascade button :
|
||||
Arg args[2];
|
||||
XmString cps = XmStringLtoRCreate((char*)a_label,XmSTRING_DEFAULT_CHARSET);
|
||||
XtSetArg (args[0],XmNlabelString,cps);
|
||||
XtSetArg (args[1],XmNsubMenuId,widget);
|
||||
widget = XmCreateCascadeButton (menuBar,(char*)a_name,args,2);
|
||||
XmStringFree (cps);
|
||||
XtManageChild (widget);
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4UIXm::AddButton (
|
||||
const char* a_menu
|
||||
,const char* a_label
|
||||
,const char* a_command
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(a_menu==NULL) return;
|
||||
if(a_label==NULL) return;
|
||||
if(a_command==NULL) return;
|
||||
Widget parent = (Widget)GetInteractor(a_menu);
|
||||
if(parent==NULL) return;
|
||||
Widget widget = XmCreatePushButton(parent,(char*)a_label,NULL,0);
|
||||
XtManageChild (widget);
|
||||
XtAddCallback (widget,XmNactivateCallback,buttonCallback,(XtPointer)this);
|
||||
commands[widget] = a_command;
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4String G4UIXm::GetCommand (
|
||||
Widget a_widget
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
return commands[a_widget];
|
||||
}
|
||||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
void commandCallback (
|
||||
Widget a_widget
|
||||
,XtPointer a_tag
|
||||
,XtPointer a_data
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
G4UIXm* This = (G4UIXm*)a_tag;
|
||||
|
||||
XmString cps = ((XmCommandCallbackStruct*)a_data)->value;
|
||||
char* ss = XmConvertCompoundStringToString(cps,0);
|
||||
G4String command (ss);
|
||||
XtFree (ss);
|
||||
|
||||
This->ApplyShellCommand (command);
|
||||
|
||||
a_widget = NULL;
|
||||
a_tag = NULL;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void clearButtonCallback (
|
||||
Widget a_widget
|
||||
,XtPointer a_tag
|
||||
,XtPointer
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
XmTextSetString((Widget)a_tag,"");
|
||||
}
|
||||
/***************************************************************************/
|
||||
void buttonCallback (
|
||||
Widget a_widget
|
||||
,XtPointer a_tag
|
||||
,XtPointer
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
G4UIXm* This = (G4UIXm*)a_tag;
|
||||
G4String ss = This->GetCommand (a_widget);
|
||||
//printf ("debug : execute:\n%s\n",ss.data());
|
||||
This->ApplyShellCommand (ss);
|
||||
}
|
||||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
char* XmConvertCompoundStringToString (
|
||||
XmString a_cps
|
||||
,int a_number
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(a_cps==NULL) return NULL;
|
||||
char* ss = NULL;
|
||||
XmStringContext context;
|
||||
XmStringInitContext(&context,a_cps);
|
||||
int icount = 0;
|
||||
Boolean Done = False;
|
||||
while(Done==False) {
|
||||
char* text = NULL;
|
||||
XmStringCharSet charset = NULL;
|
||||
XmStringDirection direct;
|
||||
Boolean sep;
|
||||
if(XmStringGetNextSegment(context,&text,&charset,&direct,&sep)==True) {
|
||||
XtFree(charset);
|
||||
if(sep==True) Done = True;
|
||||
if(icount==a_number) {
|
||||
ss = text;
|
||||
break;
|
||||
}
|
||||
icount++;
|
||||
XtFree(text);
|
||||
}
|
||||
else
|
||||
Done = True;
|
||||
}
|
||||
XmStringFreeContext(context);
|
||||
return ss;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void XmTextAppendString (
|
||||
Widget This
|
||||
,char* a_string
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(This==NULL) return;
|
||||
if(!XtIsSubclass(This,xmTextWidgetClass)) return;
|
||||
if(a_string==NULL) return;
|
||||
XmTextPosition lastpos = XmTextGetLastPosition(This);
|
||||
XmTextReplace(This,lastpos,lastpos,a_string);
|
||||
XmTextSetInsertionPosition(This,XmTextGetLastPosition(This));
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,316 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4UIterminal.cc,v 2.9 1998/12/09 07:55:43 yhajime Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
|
||||
#include "G4UIterminal.hh"
|
||||
#include "G4StateManager.hh"
|
||||
#include "G4UIcommandTree.hh"
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4UIcommandStatus.hh"
|
||||
#include "G4ios.hh"
|
||||
#ifdef WIN32
|
||||
# include <Strstrea.h>
|
||||
#else
|
||||
# include <strstream.h>
|
||||
#endif
|
||||
|
||||
G4UIterminal::G4UIterminal()
|
||||
{
|
||||
UI = G4UImanager::GetUIpointer();
|
||||
UI->SetSession(this);
|
||||
UI->SetCoutDestination(this);
|
||||
G4StateManager * statM = G4StateManager::GetStateManager();
|
||||
promptCharacter = statM->GetStateString(statM->GetCurrentState())
|
||||
+ G4String("> ");
|
||||
iExit = false;
|
||||
iCont = false;
|
||||
}
|
||||
|
||||
G4UIterminal::~G4UIterminal()
|
||||
{
|
||||
if( G4UImanager::GetUIpointer() != 0)
|
||||
{
|
||||
UI->SetSession(NULL);
|
||||
UI->SetCoutDestination(NULL);
|
||||
// G4cout << "Terminal session deleted" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
G4UIsession * G4UIterminal::SessionStart()
|
||||
{
|
||||
iExit = true;
|
||||
G4StateManager * statM = G4StateManager::GetStateManager();
|
||||
promptCharacter = statM->GetStateString(statM->GetCurrentState())
|
||||
+ G4String("> ");
|
||||
G4String newCommand = GetCommand();
|
||||
while( iExit )
|
||||
{
|
||||
ExecuteCommand(newCommand);
|
||||
promptCharacter = statM->GetStateString(statM->GetCurrentState())
|
||||
+ G4String("> ");
|
||||
newCommand = GetCommand();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void G4UIterminal::PauseSessionStart(G4String msg)
|
||||
{
|
||||
promptCharacter = msg;
|
||||
iCont = true;
|
||||
G4String newCommand = GetCommand();
|
||||
while( iCont )
|
||||
{
|
||||
ExecuteCommand(newCommand);
|
||||
newCommand = GetCommand();
|
||||
}
|
||||
}
|
||||
|
||||
G4int G4UIterminal::ReceiveG4cout(G4String coutString)
|
||||
{
|
||||
cout << coutString << flush;
|
||||
return 0;
|
||||
}
|
||||
|
||||
G4int G4UIterminal::ReceiveG4cerr(G4String cerrString)
|
||||
{
|
||||
cerr << cerrString << flush;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void G4UIterminal::ExecuteCommand(G4String aCommand)
|
||||
{
|
||||
if(aCommand.length()<2) return;
|
||||
int commandStatus = UI->ApplyCommand(aCommand);
|
||||
switch(commandStatus)
|
||||
{
|
||||
case fCommandSucceeded:
|
||||
break;
|
||||
case fCommandNotFound:
|
||||
G4cerr << "command <" << aCommand << "> not found" << endl;
|
||||
if ( aCommand.index("@@") != RW_NPOS) {
|
||||
G4cout << "@@G4UIterminal" << endl;
|
||||
}
|
||||
break;
|
||||
case fIllegalApplicationState:
|
||||
G4cerr << "illegal application state -- command refused" << endl;
|
||||
break;
|
||||
case fParameterOutOfRange:
|
||||
case fParameterUnreadable:
|
||||
case fParameterOutOfCandidates:
|
||||
default:
|
||||
G4cerr << "command refused (" << commandStatus << ")" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
G4String G4UIterminal::GetCommand()
|
||||
{
|
||||
G4String newCommand;
|
||||
G4String nullString;
|
||||
while( 1 )
|
||||
{
|
||||
G4cout << promptCharacter;
|
||||
G4cout.flush();
|
||||
newCommand.readLine( cin );
|
||||
if (!cin.good()) { cin.clear(); newCommand = nullString; iExit=false; break; }
|
||||
while( newCommand(newCommand.length()-1) == '_' )
|
||||
{
|
||||
G4String newLine;
|
||||
newCommand.remove(newCommand.length()-1);
|
||||
newLine.readLine( cin );
|
||||
if (!cin.good()) { cin.clear(); newCommand = nullString; iExit=false; break; }
|
||||
newCommand.append(newLine);
|
||||
}
|
||||
|
||||
G4String nC = newCommand.strip(G4String::leading);
|
||||
// -------------------- nC.toUpper();
|
||||
if( nC(0) == '#' )
|
||||
{ G4cout << nC << endl; }
|
||||
else if( nC == "ls" || nC(0,3) == "ls " )
|
||||
{ ListDirectory( nC ); }
|
||||
else if( nC == "pwd" )
|
||||
{
|
||||
G4cout << "Current Working Directory : "
|
||||
<< GetCurrentWorkingDirectory() << endl;
|
||||
}
|
||||
else if( nC == "cd" || nC(0,3) == "cd " )
|
||||
{ ChangeDirectoryCommand( nC ); }
|
||||
else if( nC == "help" || nC(0,5) == "help " )
|
||||
{ TerminalHelp( nC ); }
|
||||
else if( nC(0) == '?' )
|
||||
{ ShowCurrent( nC ); }
|
||||
else if( nC == "hist" || nC == "history" )
|
||||
{
|
||||
G4int nh = UI->GetNumberOfHistory();
|
||||
for(int i=0;i<nh;i++)
|
||||
{ G4cout << i << ": " << UI->GetPreviousCommand(i) << endl; }
|
||||
}
|
||||
else if( nC(0) == '!' )
|
||||
{
|
||||
G4String ss = nC(1,nC.length()-1);
|
||||
G4int vl;
|
||||
const char* tt = ss;
|
||||
istrstream is((char*)tt);
|
||||
is >> vl;
|
||||
G4int nh = UI->GetNumberOfHistory();
|
||||
if(vl>=0 && vl<nh)
|
||||
{
|
||||
newCommand = UI->GetPreviousCommand(vl);
|
||||
G4cout << newCommand << endl;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{ G4cerr << "history " << vl << " is not found." << endl; }
|
||||
}
|
||||
else if( nC == "exit" )
|
||||
{
|
||||
if( iCont )
|
||||
{
|
||||
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
|
||||
{
|
||||
iExit = false;
|
||||
newCommand = nullString;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if( nC == "cont" || nC == "continue" )
|
||||
{
|
||||
iCont = false;
|
||||
newCommand = nullString;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{ break; }
|
||||
}
|
||||
return ModifyToFullPathCommand(newCommand);
|
||||
}
|
||||
|
||||
void G4UIterminal::ShowCurrent( G4String newCommand )
|
||||
{
|
||||
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 G4UIterminal::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 G4UIterminal::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(ModifyToFullPathCommand(targetDir));
|
||||
if( commandTree == NULL )
|
||||
{ G4cout << "Directory <" << targetDir << "> is not found." << endl; }
|
||||
else
|
||||
{ commandTree->ListCurrent(); }
|
||||
}
|
||||
|
||||
void G4UIterminal::TerminalHelp(G4String newCommand)
|
||||
{
|
||||
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;
|
||||
cin >> i;
|
||||
if(!cin.good()){
|
||||
cin.clear();
|
||||
cin.ignore(30,'\n');
|
||||
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();
|
||||
//iFloor++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
floor[iFloor+1] = floor[iFloor]->GetTree(i);
|
||||
iFloor++;
|
||||
floor[iFloor]->ListCurrentWithNum();
|
||||
}
|
||||
}
|
||||
//G4cout << endl << "Type the number ( 0:end, -n:n level back ) : ";
|
||||
|
||||
}
|
||||
G4cout << "Exit from HELP." << endl << endl;
|
||||
G4cout << endl;
|
||||
// cin.flush();
|
||||
char temp[100];
|
||||
cin.getline( temp, 100 );
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
# $Id: GNUmakefile,v 2.2 1998/07/07 16:57:30 allison Exp $
|
||||
# -------------------------------------------------------------
|
||||
# GNUmakefile for interfaces/common library. John Allison, 6/7/98.
|
||||
|
||||
name := G4UIcommon
|
||||
|
||||
ifndef G4INSTALL
|
||||
G4INSTALL = ../../..
|
||||
endif
|
||||
|
||||
include $(G4INSTALL)/config/architecture.gmk
|
||||
include $(G4INSTALL)/config/G4UI_BUILD.gmk
|
||||
include $(G4INSTALL)/config/interactivity.gmk
|
||||
|
||||
G4TMPDIR = $(G4TMP)/$(G4SYSTEM)/$(name)
|
||||
|
||||
CPPFLAGS += -I$(G4BASE)/global/management/include
|
||||
CPPFLAGS += -I$(G4BASE)/intercoms/include
|
||||
|
||||
include $(G4INSTALL)/config/common.gmk
|
||||
@@ -0,0 +1,31 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
|
||||
#ifndef G4InteractorMessenger_h
|
||||
#define G4InteractorMessenger_h 1
|
||||
|
||||
#include "G4UImessenger.hh"
|
||||
|
||||
class G4VInteractiveSession;
|
||||
class G4UIdirectory;
|
||||
class G4UIcommand;
|
||||
|
||||
class G4InteractorMessenger : public G4UImessenger
|
||||
{
|
||||
public:
|
||||
G4InteractorMessenger (G4VInteractiveSession* session);
|
||||
~G4InteractorMessenger ();
|
||||
void SetNewValue(G4UIcommand* command,G4String newValue);
|
||||
private:
|
||||
G4VInteractiveSession* session;
|
||||
G4UIdirectory* interactorDirectory;
|
||||
G4UIcommand* addMenu;
|
||||
G4UIcommand* addButton;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,60 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4VBasicShell.hh,v 2.2 1998/07/12 03:00:16 urbi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
|
||||
#ifndef G4VBasicShell_H
|
||||
#define G4VBasicShell_H 1
|
||||
|
||||
class G4UIcommandTree;
|
||||
class G4UIcommand;
|
||||
|
||||
#include "G4UIsession.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
class G4VBasicShell : public G4UIsession
|
||||
{
|
||||
public:
|
||||
G4VBasicShell();
|
||||
virtual ~G4VBasicShell();
|
||||
|
||||
virtual G4UIsession* SessionStart() = 0;
|
||||
// null should be returned for interactive session
|
||||
|
||||
virtual void PauseSessionStart(G4String Prompt) = 0;
|
||||
// Prompt string can be ignored
|
||||
|
||||
protected:
|
||||
G4String ModifyToFullPathCommand(const char* aCommandLine);
|
||||
// convert "BeamOn 10" to "/run/BeamOn 10" if the
|
||||
// current working directory is "/run/"
|
||||
|
||||
G4String GetCurrentWorkingDirectory();
|
||||
// directory string starts with '/' and ends with '/'
|
||||
|
||||
G4bool ChangeDirectory(const char* newDir);
|
||||
// change directory to newDir
|
||||
// false will be returned if the target directory doesn't exist
|
||||
|
||||
G4UIcommandTree* FindDirectory(const char* dirName);
|
||||
// find G4UIcommandTree object
|
||||
// null returned if the taregt does not exist
|
||||
|
||||
G4UIcommand* FindCommand(const char* commandName);
|
||||
// find G4UIcommand object
|
||||
// null returned if the target does not exist
|
||||
|
||||
private:
|
||||
G4String currentDirectory;
|
||||
|
||||
G4String ModifyPath(G4String tempPath);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
|
||||
#ifndef G4VInteractiveSession_H
|
||||
#define G4VInteractiveSession_H 1
|
||||
|
||||
#include <rw/tvhdict.h>
|
||||
|
||||
#include "G4VInteractorManager.hh"
|
||||
|
||||
class G4UImessenger;
|
||||
|
||||
class G4VInteractiveSession {
|
||||
public:
|
||||
G4VInteractiveSession();
|
||||
virtual ~G4VInteractiveSession();
|
||||
virtual void AddMenu (const char*,const char*);
|
||||
virtual void AddButton (const char*,const char*,const char*);
|
||||
void AddInteractor(G4String,G4Interactor);
|
||||
G4Interactor GetInteractor(G4String);
|
||||
private:
|
||||
G4UImessenger* messenger;
|
||||
RWTValHashDictionary<G4String,G4Interactor> interactors;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4VInteractorManager.hh,v 2.3 1998/08/07 12:38:41 barrand Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
// G.Barrand
|
||||
|
||||
#ifndef G4VINTERACTORMANAGER_HH
|
||||
#define G4VINTERACTORMANAGER_HH
|
||||
|
||||
#include "globals.hh"
|
||||
|
||||
typedef void* G4Interactor;
|
||||
typedef G4bool (*G4DispatchFunction)(void*);
|
||||
typedef void (*G4SecondaryLoopAction)();
|
||||
|
||||
class G4VInteractorManager {
|
||||
public:
|
||||
G4VInteractorManager ();
|
||||
virtual ~G4VInteractorManager ();
|
||||
void SetArguments (int,char**);
|
||||
char** GetArguments (int*);
|
||||
void SetMainInteractor (G4Interactor);
|
||||
G4Interactor GetMainInteractor ();
|
||||
void AddDispatcher (G4DispatchFunction);
|
||||
void RemoveDispatcher (G4DispatchFunction);
|
||||
void AddSecondaryLoopPreAction (G4SecondaryLoopAction);
|
||||
void AddSecondaryLoopPostAction (G4SecondaryLoopAction);
|
||||
void AddShell (G4Interactor);
|
||||
void RemoveShell (G4Interactor);
|
||||
void EnableSecondaryLoop ();
|
||||
void DisableSecondaryLoop ();
|
||||
void SecondaryLoopPreActions ();
|
||||
void SecondaryLoopPostActions ();
|
||||
void RequireExitSecondaryLoop (int);
|
||||
void DispatchEvent (void*);
|
||||
void SecondaryLoop ();
|
||||
int GetExitSecondaryLoopCode ();
|
||||
void PutStringInResourceDatabase (char*);
|
||||
virtual G4bool Inited () = 0;
|
||||
virtual void* GetEvent () = 0;
|
||||
virtual void FlushAndWaitExecution () = 0;
|
||||
void SetParentInteractor (G4Interactor);
|
||||
G4Interactor GetParentInteractor ();
|
||||
void SetCreatedInteractor (G4Interactor);
|
||||
G4Interactor GetCreatedInteractor ();
|
||||
void SetCreationString (char*);
|
||||
char* GetCreationString ();
|
||||
private:
|
||||
int argc;
|
||||
char** argv;
|
||||
G4Interactor mainInteractor;
|
||||
int dispatchern;
|
||||
G4DispatchFunction* dispatchers;
|
||||
int preActionn;
|
||||
G4SecondaryLoopAction* preActions;
|
||||
int postActionn;
|
||||
G4SecondaryLoopAction* postActions;
|
||||
int shelln;
|
||||
G4Interactor* shells;
|
||||
G4bool secondaryLoopEnabled;
|
||||
G4bool alreadyInSecondaryLoop;
|
||||
int exitSecondaryLoop;
|
||||
G4Interactor parentInteractor;
|
||||
G4Interactor createdInteractor;
|
||||
char* creationString;
|
||||
};
|
||||
|
||||
#define OGL_EXIT_CODE 1
|
||||
#define OIV_EXIT_CODE 2
|
||||
#define XO_EXIT_CODE 3
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,41 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4Win32.hh,v 2.4 1998/09/19 14:45:32 barrand Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
// To unify Windows message treatment between
|
||||
// G4/interfaces Windows sessions and G4/visualizations Windows drivers.
|
||||
// G.Barrand
|
||||
|
||||
#ifndef G4WIN32_HH
|
||||
#define G4WIN32_HH
|
||||
|
||||
#if defined(G4INTY_BUILD_WIN32) || defined(G4INTY_USE_WIN32)
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "G4VInteractorManager.hh"
|
||||
|
||||
class G4Win32 : public G4VInteractorManager {
|
||||
public:
|
||||
static G4Win32* getInstance ();
|
||||
static G4Win32* getInstance (HINSTANCE,HINSTANCE,LPSTR,int);
|
||||
G4bool Inited ();
|
||||
void* GetEvent ();
|
||||
void FlushAndWaitExecution ();
|
||||
static G4bool dispatchWin32Event (void*);
|
||||
void getWinMainArguments (HINSTANCE*,HINSTANCE*,LPSTR*,int*);
|
||||
virtual ~G4Win32 ();
|
||||
private:
|
||||
G4Win32 (HINSTANCE,HINSTANCE,LPSTR,int);
|
||||
static G4Win32* instance; // Pointer to single instance.
|
||||
};
|
||||
|
||||
#endif //HAS_WIN32
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,40 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4Xt.hh,v 2.4 1998/09/19 14:45:33 barrand Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
// To unify X11 event treatment between
|
||||
// G4/interfaces Xt sessions and G4/visualizations Xt drivers.
|
||||
// G.Barrand
|
||||
|
||||
#ifndef G4XT_HH
|
||||
#define G4XT_HH
|
||||
|
||||
#if defined(G4INTY_BUILD_XT) || defined(G4INTY_USE_XT)
|
||||
|
||||
#include <X11/Intrinsic.h>
|
||||
|
||||
#include "G4VInteractorManager.hh"
|
||||
|
||||
class G4Xt : public G4VInteractorManager {
|
||||
public:
|
||||
static G4Xt* getInstance ();
|
||||
static G4Xt* getInstance (int,char**,char*);
|
||||
void PutStringInResourceDatabase (char*);
|
||||
G4bool Inited ();
|
||||
void* GetEvent ();
|
||||
void FlushAndWaitExecution ();
|
||||
virtual ~G4Xt ();
|
||||
private:
|
||||
G4Xt (int,char**,char*);
|
||||
static G4Xt* instance; // Pointer to single instance.
|
||||
};
|
||||
|
||||
#endif //HAS_XT
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,108 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
|
||||
#include <rw/ctoken.h>
|
||||
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4VInteractiveSession.hh"
|
||||
|
||||
#include "G4InteractorMessenger.hh"
|
||||
|
||||
static G4bool GetValues (G4String,int,G4String*);
|
||||
|
||||
G4InteractorMessenger::G4InteractorMessenger (
|
||||
G4VInteractiveSession* a_session
|
||||
)
|
||||
{
|
||||
session = a_session;
|
||||
|
||||
G4UIparameter* parameter;
|
||||
|
||||
interactorDirectory = new G4UIdirectory("/interactor/");
|
||||
interactorDirectory->SetGuidance("UI interactors commands.");
|
||||
|
||||
// /interactor/addMenu :
|
||||
addMenu = new G4UIcommand("/interactor/addMenu",this);
|
||||
addMenu->SetGuidance("Add a menu to menu bar.");
|
||||
parameter = new G4UIparameter("Name",'s',false);
|
||||
parameter->SetDefaultValue("dummy");
|
||||
addMenu->SetParameter (parameter);
|
||||
parameter = new G4UIparameter("Label",'s',false);
|
||||
parameter->SetDefaultValue("dummy");
|
||||
addMenu->SetParameter (parameter);
|
||||
|
||||
// /interactor/addButton :
|
||||
addButton = new G4UIcommand("/interactor/addButton",this);
|
||||
addButton->SetGuidance("Add a button to menu.");
|
||||
parameter = new G4UIparameter("Menu",'s',false);
|
||||
parameter->SetDefaultValue("dummy");
|
||||
addButton->SetParameter (parameter);
|
||||
parameter = new G4UIparameter("Label",'s',false);
|
||||
parameter->SetDefaultValue("dummy");
|
||||
addButton->SetParameter (parameter);
|
||||
parameter = new G4UIparameter("Command",'s',false);
|
||||
parameter->SetDefaultValue("");
|
||||
addButton->SetParameter (parameter);
|
||||
|
||||
}
|
||||
|
||||
G4InteractorMessenger::~G4InteractorMessenger()
|
||||
{
|
||||
delete addButton;
|
||||
delete addMenu;
|
||||
delete interactorDirectory;
|
||||
}
|
||||
|
||||
void G4InteractorMessenger::SetNewValue (
|
||||
G4UIcommand* command
|
||||
,G4String newValue
|
||||
)
|
||||
{
|
||||
int paramn = command->GetParameterEntries();
|
||||
G4String* params = new G4String [paramn];
|
||||
if(GetValues(newValue,paramn,params)==true) {
|
||||
if(command==addMenu) {
|
||||
session->AddMenu(params[0],params[1]);
|
||||
} else if(command==addButton) {
|
||||
session->AddButton(params[0],params[1],params[2]);
|
||||
}
|
||||
}
|
||||
delete [] params;
|
||||
}
|
||||
G4bool GetValues (
|
||||
G4String newValue
|
||||
,int paramn
|
||||
,G4String* params
|
||||
)
|
||||
{
|
||||
RWCTokenizer newValueToken( newValue );
|
||||
G4String aToken;
|
||||
for( int i=0; i<paramn;i++ ) {
|
||||
aToken = newValueToken();
|
||||
if( aToken(0)=='"' ) {
|
||||
while( aToken(aToken.length()-1) != '"' ) {
|
||||
G4String additionalToken = newValueToken();
|
||||
if( additionalToken.isNull() ) {
|
||||
return false;
|
||||
}
|
||||
aToken += " ";
|
||||
aToken += additionalToken;
|
||||
}
|
||||
aToken = aToken.strip(G4String::both,'"');
|
||||
}
|
||||
if( aToken.isNull() ) {
|
||||
return false;
|
||||
} else {
|
||||
params[i] = aToken;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// 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 $
|
||||
//
|
||||
|
||||
#include "G4VBasicShell.hh"
|
||||
#include "G4StateManager.hh"
|
||||
#include "G4UIcommandTree.hh"
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4UIcommandStatus.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#ifdef WIN32
|
||||
# include <Strstrea.h>
|
||||
#else
|
||||
# include <strstream.h>
|
||||
#endif
|
||||
|
||||
G4VBasicShell::G4VBasicShell()
|
||||
{
|
||||
currentDirectory = "/";
|
||||
}
|
||||
|
||||
G4VBasicShell::~G4VBasicShell()
|
||||
{;}
|
||||
|
||||
G4String G4VBasicShell::ModifyToFullPathCommand(const char* aCommandLine)
|
||||
{
|
||||
G4String rawCommandLine = aCommandLine;
|
||||
if(rawCommandLine.isNull()||rawCommandLine(0)=='\0') return rawCommandLine;
|
||||
G4String commandLine = rawCommandLine.strip(G4String::both);
|
||||
G4String commandString;
|
||||
G4String parameterString;
|
||||
int i = commandLine.index(" ");
|
||||
if( i != RW_NPOS )
|
||||
{
|
||||
commandString = commandLine(0,i);
|
||||
parameterString = " ";
|
||||
parameterString += commandLine(i+1,commandLine.length()-(i+1));
|
||||
}
|
||||
else
|
||||
{ commandString = commandLine; }
|
||||
|
||||
G4String fullPathCommandLine
|
||||
= ModifyPath( commandString )+parameterString;
|
||||
return fullPathCommandLine;
|
||||
}
|
||||
|
||||
G4String G4VBasicShell::GetCurrentWorkingDirectory()
|
||||
{
|
||||
return currentDirectory;
|
||||
}
|
||||
|
||||
G4bool G4VBasicShell::ChangeDirectory(const char* newDir)
|
||||
{
|
||||
G4String aNewPrefix = newDir;
|
||||
G4String newPrefix = aNewPrefix.strip(G4String::both);
|
||||
G4String newDirectory = ModifyPath( newPrefix );
|
||||
if( newDirectory( newDirectory.length() - 1 ) != '/' )
|
||||
{ newDirectory += "/"; }
|
||||
if( FindDirectory( newDirectory ) == NULL )
|
||||
{ return false; }
|
||||
currentDirectory = newDirectory;
|
||||
return true;
|
||||
}
|
||||
|
||||
G4UIcommandTree* G4VBasicShell::FindDirectory(const char* dirName)
|
||||
{
|
||||
G4String aDirName = dirName;
|
||||
G4String theDir = aDirName.strip(G4String::both);
|
||||
G4String targetDir = ModifyPath( theDir );
|
||||
if( targetDir( targetDir.length()-1 ) != '/' )
|
||||
{ targetDir += "/"; }
|
||||
G4UIcommandTree* comTree = G4UImanager::GetUIpointer()->GetTree();
|
||||
if( targetDir == "/" )
|
||||
{ return comTree; }
|
||||
int idx = 1;
|
||||
while( idx < targetDir.length()-1 )
|
||||
{
|
||||
int i = targetDir.index("/",idx);
|
||||
comTree = comTree->GetTree(targetDir(0,i+1));
|
||||
if( comTree == NULL )
|
||||
{ return NULL; }
|
||||
idx = i+1;
|
||||
}
|
||||
return comTree;
|
||||
}
|
||||
|
||||
G4UIcommand* G4VBasicShell::FindCommand(const char* commandName)
|
||||
{
|
||||
G4String rawCommandLine = commandName;
|
||||
G4String commandLine = rawCommandLine.strip(G4String::both);
|
||||
G4String commandString;
|
||||
int i = commandLine.index(" ");
|
||||
if( i != RW_NPOS )
|
||||
{ commandString = commandLine(0,i); }
|
||||
else
|
||||
{ commandString = commandLine; }
|
||||
|
||||
G4String targetCom = ModifyPath(commandString);
|
||||
return G4UImanager::GetUIpointer()->GetTree()->FindPath(targetCom);
|
||||
}
|
||||
|
||||
G4String G4VBasicShell::ModifyPath(G4String tempPath)
|
||||
{
|
||||
G4String newPath = currentDirectory;
|
||||
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); }
|
||||
else // swim up with ".."
|
||||
{
|
||||
while( 1 )
|
||||
{
|
||||
if( tempPath(0,2) == ".." )
|
||||
{
|
||||
if( newPath != "/" )
|
||||
{
|
||||
G4String tmpString = newPath(0,newPath.length()-1);
|
||||
newPath = newPath(0,tmpString.last('/')+1);
|
||||
}
|
||||
if( tempPath == ".." || tempPath == "../" )
|
||||
{ break; }
|
||||
tempPath = tempPath(3,tempPath.length()-3);
|
||||
}
|
||||
else
|
||||
{
|
||||
newPath += tempPath;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return newPath;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
|
||||
#include "G4InteractorMessenger.hh"
|
||||
|
||||
#include "G4VInteractiveSession.hh"
|
||||
|
||||
static unsigned InteractorsHashFun (const G4String& name) {
|
||||
return name.hash();
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4VInteractiveSession::G4VInteractiveSession (
|
||||
)
|
||||
:interactors(InteractorsHashFun)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
messenger = new G4InteractorMessenger(this);
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4VInteractiveSession::~G4VInteractiveSession()
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
delete messenger;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4VInteractiveSession::AddMenu (
|
||||
const char* a_name
|
||||
,const char* a_label
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4VInteractiveSession::AddButton (
|
||||
const char* a_menu
|
||||
,const char* a_label
|
||||
,const char* a_command
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4VInteractiveSession::AddInteractor (
|
||||
G4String a_name
|
||||
,G4Interactor a_interactor
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
interactors[a_name] = a_interactor;
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4Interactor G4VInteractiveSession::GetInteractor (
|
||||
G4String a_name
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
G4Interactor value;
|
||||
if(interactors.findValue(a_name,value)==false) return NULL;
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,383 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// 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 $
|
||||
//
|
||||
// G.Barrand
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "G4VInteractorManager.hh"
|
||||
|
||||
#define NewString(str) \
|
||||
((str) != NULL ? (strcpy((char*)malloc((unsigned)strlen(str) + 1), str)) : NULL)
|
||||
|
||||
/***************************************************************************/
|
||||
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)
|
||||
,parentInteractor(NULL)
|
||||
,createdInteractor(NULL)
|
||||
,creationString(NULL)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4VInteractorManager::~G4VInteractorManager (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(argv!=NULL) {
|
||||
for(int argi=0;argi<argc;argi++) {
|
||||
if(argv[argi]!=NULL) free(argv[argi]);
|
||||
}
|
||||
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;
|
||||
alreadyInSecondaryLoop = FALSE;
|
||||
exitSecondaryLoop = 0;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4VInteractorManager::SetArguments (
|
||||
int a_argc
|
||||
,char** a_argv
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
// Free previous values.
|
||||
if(argv!=NULL) {
|
||||
for(int argi=0;argi<argc;argi++) {
|
||||
if(argv[argi]!=NULL) free(argv[argi]);
|
||||
}
|
||||
free(argv);
|
||||
}
|
||||
argv = NULL;
|
||||
argc = 0;
|
||||
// Set new values.
|
||||
if(a_argc!=0) {
|
||||
argv = (char**)malloc(a_argc * sizeof(char*));
|
||||
if(argv!=NULL) {
|
||||
argc = a_argc;
|
||||
for(int argi=0;argi<a_argc;argi++) {
|
||||
argv[argi] = (char*)NewString (a_argv[argi]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/***************************************************************************/
|
||||
char** G4VInteractorManager::GetArguments (
|
||||
int* a_argc
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(a_argc!=NULL) *a_argc = argc;
|
||||
return argv;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4VInteractorManager::SetMainInteractor (
|
||||
G4Interactor a_main
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
mainInteractor = a_main;
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4Interactor G4VInteractorManager::GetMainInteractor (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
return mainInteractor;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4VInteractorManager::EnableSecondaryLoop (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
secondaryLoopEnabled = TRUE;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4VInteractorManager::DisableSecondaryLoop (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
secondaryLoopEnabled = FALSE;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4VInteractorManager::AddDispatcher (
|
||||
G4DispatchFunction a_dispatcher
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
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++;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4VInteractorManager::RemoveDispatcher (
|
||||
G4DispatchFunction a_dispatcher
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
for(int count=0;count<dispatchern;count++) {
|
||||
if(dispatchers[count]==a_dispatcher) {
|
||||
dispatchers[count] = NULL;
|
||||
return; // A dispatcher appears once in the List.
|
||||
}
|
||||
}
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4VInteractorManager::DispatchEvent (
|
||||
void* a_event
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
for(int count=0;count<dispatchern;count++) {
|
||||
if(
|
||||
(dispatchers[count]!=NULL) &&
|
||||
(dispatchers[count](a_event)==TRUE)
|
||||
)
|
||||
break;
|
||||
}
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4VInteractorManager::AddSecondaryLoopPreAction (
|
||||
G4SecondaryLoopAction a_preAction
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
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++;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4VInteractorManager::SecondaryLoopPreActions (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
for(int count=0;count<preActionn;count++) {
|
||||
if(preActions[count]!=NULL) preActions[count]();
|
||||
}
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4VInteractorManager::AddSecondaryLoopPostAction (
|
||||
G4SecondaryLoopAction a_postAction
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
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++;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4VInteractorManager::SecondaryLoopPostActions (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
for(int count=0;count<postActionn;count++) {
|
||||
if(postActions[count]!=NULL) postActions[count]();
|
||||
}
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4VInteractorManager::SecondaryLoop (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(Inited()==FALSE) return;
|
||||
|
||||
if(secondaryLoopEnabled==FALSE) return;
|
||||
|
||||
if (alreadyInSecondaryLoop==FALSE) {
|
||||
alreadyInSecondaryLoop = TRUE;
|
||||
exitSecondaryLoop = 0;
|
||||
SecondaryLoopPreActions ();
|
||||
// for(int count=0;count<shelln;count++) XWidgetUniconify(shells[count]);
|
||||
void* event;
|
||||
while(1) {
|
||||
event = GetEvent();
|
||||
if(event==NULL) break;
|
||||
DispatchEvent (event);
|
||||
if(exitSecondaryLoop!=0) break;
|
||||
}
|
||||
SecondaryLoopPostActions ();
|
||||
}
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4VInteractorManager::RequireExitSecondaryLoop (
|
||||
int a_code
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(secondaryLoopEnabled==FALSE) return;
|
||||
if(a_code==0) a_code = 1;
|
||||
exitSecondaryLoop = a_code;
|
||||
alreadyInSecondaryLoop = FALSE;
|
||||
// for(int count=0;count<shelln;count++) XWidgetIconify(shells[count]);
|
||||
// if(shelln!=0) XSync(XtDisplay(topWidget),False);
|
||||
}
|
||||
/***************************************************************************/
|
||||
int G4VInteractorManager::GetExitSecondaryLoopCode (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
return exitSecondaryLoop;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4VInteractorManager::AddShell (
|
||||
G4Interactor a_shell
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
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++;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4VInteractorManager::RemoveShell (
|
||||
G4Interactor a_shell
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
for(int count=0;count<shelln;count++) {
|
||||
if(shells[count]==a_shell) {
|
||||
shells[count] = NULL;
|
||||
return; // A shell appears once in the List.
|
||||
}
|
||||
}
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4VInteractorManager::SetParentInteractor (
|
||||
G4Interactor a_interactor
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
parentInteractor = a_interactor;
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4Interactor G4VInteractorManager::GetParentInteractor (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
return parentInteractor;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4VInteractorManager::SetCreatedInteractor (
|
||||
G4Interactor a_interactor
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
createdInteractor = a_interactor;
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4Interactor G4VInteractorManager::GetCreatedInteractor (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
return createdInteractor;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4VInteractorManager::SetCreationString (
|
||||
char* a_string
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
creationString = a_string;
|
||||
}
|
||||
/***************************************************************************/
|
||||
char* G4VInteractorManager::GetCreationString (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
return creationString;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// 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 $
|
||||
//
|
||||
// G.Barrand
|
||||
|
||||
#if defined(G4INTY_BUILD_WIN32) || defined(G4INTY_USE_WIN32)
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "G4ios.hh"
|
||||
|
||||
#include "G4UImanager.hh"
|
||||
|
||||
#include "G4Win32.hh"
|
||||
|
||||
static char className[] = "G4Win32";
|
||||
|
||||
G4Win32* G4Win32::instance = NULL;
|
||||
|
||||
static G4bool Win32Inited = FALSE;
|
||||
static HINSTANCE hInstance = NULL;
|
||||
static HINSTANCE hPrevInstance = NULL;
|
||||
static LPTSTR lpszCmdLine = NULL;
|
||||
static int nCmdShow = 0;
|
||||
static HWND topWindow = NULL;
|
||||
/***************************************************************************/
|
||||
G4Win32* G4Win32::getInstance (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
return G4Win32::getInstance(NULL,NULL,NULL,0);
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4Win32* G4Win32::getInstance (
|
||||
HANDLE a_hInstance
|
||||
,HANDLE a_hPrevInstance
|
||||
,LPSTR a_lpszCmdLine
|
||||
,int a_nCmdShow
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if (instance==NULL) {
|
||||
instance = new G4Win32(a_hInstance,
|
||||
a_hPrevInstance,
|
||||
a_lpszCmdLine,
|
||||
a_nCmdShow);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4Win32::G4Win32 (
|
||||
HANDLE a_hInstance
|
||||
,HANDLE a_hPrevInstance
|
||||
,LPSTR a_lpszCmdLine
|
||||
,int a_nCmdShow
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(Win32Inited==FALSE) { // Should be Done once.
|
||||
|
||||
hInstance = a_hInstance;
|
||||
hPrevInstance = a_hPrevInstance;
|
||||
lpszCmdLine = a_lpszCmdLine;
|
||||
nCmdShow = a_nCmdShow;
|
||||
|
||||
if(hInstance==NULL) {
|
||||
G4cout << "G4Win32::G4Win32 : NULL hInstance given." <<endl;
|
||||
}
|
||||
|
||||
if(hPrevInstance==NULL) {
|
||||
WNDCLASS wc;
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.lpfnWndProc = (WNDPROC)DefWindowProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = LoadIcon (NULL,IDI_APPLICATION);
|
||||
wc.hCursor = LoadCursor(NULL,IDC_ARROW);
|
||||
wc.hbrBackground = GetStockObject(BLACK_BRUSH);
|
||||
wc.lpszMenuName = className;
|
||||
wc.lpszClassName = className;
|
||||
::RegisterClass (&wc);
|
||||
}
|
||||
|
||||
topWindow = ::CreateWindow(className,className,
|
||||
WS_OVERLAPPEDWINDOW,
|
||||
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
|
||||
NULL, NULL, hInstance, NULL);
|
||||
|
||||
if(topWindow==NULL) {
|
||||
G4cout << "G4Win32 : Unable to create Win32 window." << endl;
|
||||
}
|
||||
|
||||
Win32Inited = TRUE;
|
||||
}
|
||||
|
||||
AddDispatcher ((G4DispatchFunction)G4Win32::dispatchWin32Event);
|
||||
SetMainInteractor (topWindow);
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4Win32::~G4Win32 (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(this==instance) {
|
||||
instance = NULL;
|
||||
}
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4bool G4Win32::Inited (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
return Win32Inited;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void* G4Win32::GetEvent (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
static MSG event;
|
||||
BOOL status = ::GetMessage(&event, NULL, 0, 0);
|
||||
if(status==FALSE) return NULL;
|
||||
return &event;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4Win32::FlushAndWaitExecution (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4Win32::getWinMainArguments (
|
||||
HANDLE* a_hInstance
|
||||
,HANDLE* a_hPrevInstance
|
||||
,LPSTR* a_lpszCmdLine
|
||||
,int* a_nCmdShow
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(a_hInstance!=NULL) *a_hInstance = hInstance;
|
||||
if(a_hPrevInstance!=NULL) *a_hPrevInstance = hPrevInstance;
|
||||
if(a_lpszCmdLine!=NULL) *a_lpszCmdLine = lpszCmdLine;
|
||||
if(a_nCmdShow!=NULL) *a_nCmdShow = nCmdShow;
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4bool G4Win32::dispatchWin32Event (
|
||||
void* a_event
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
::TranslateMessage((MSG*)a_event);
|
||||
::DispatchMessage ((MSG*)a_event);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif //HAS_WIN32
|
||||
|
||||
@@ -0,0 +1,214 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// 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 $
|
||||
//
|
||||
// G.Barrand
|
||||
|
||||
#if defined(G4INTY_BUILD_XT) || defined(G4INTY_USE_XT)
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "G4ios.hh"
|
||||
|
||||
#include "G4Xt.hh"
|
||||
|
||||
#define NewString(str) \
|
||||
((str) != NULL ? (strcpy((char*)malloc((unsigned)strlen(str) + 1), str)) : NULL)
|
||||
|
||||
static void XWidgetIconify (Widget);
|
||||
static void XWidgetUniconify (Widget);
|
||||
static void XDisplaySetWindowToNormalState (Display*,Window);
|
||||
|
||||
G4Xt* G4Xt::instance = NULL;
|
||||
|
||||
static G4bool XtInited = FALSE;
|
||||
static int argn = 0;
|
||||
static char** args = NULL;
|
||||
static Widget topWidget = NULL;
|
||||
/***************************************************************************/
|
||||
G4Xt* G4Xt::getInstance (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
return G4Xt::getInstance (0,NULL,"Geant4");
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4Xt* G4Xt::getInstance (
|
||||
int a_argn
|
||||
,char** a_args
|
||||
,char* a_class
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if (instance==NULL) {
|
||||
instance = new G4Xt(a_argn,a_args,a_class);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4Xt::G4Xt (
|
||||
int a_argn
|
||||
,char** a_args
|
||||
,char* a_class
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(XtInited==FALSE) { //Xt should be Inited once !
|
||||
if(a_argn!=0) { //Save args.
|
||||
args = (char**)malloc(a_argn * sizeof(char*));
|
||||
if(args!=NULL) {
|
||||
argn = a_argn;
|
||||
for(int argi=0;argi<a_argn;argi++) {
|
||||
args[argi] = (char*)NewString (a_args[argi]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#if XtSpecificationRelease == 4
|
||||
Cardinal argc;
|
||||
argc = (Cardinal)a_argn;
|
||||
#else
|
||||
int argc;
|
||||
argc = a_argn;
|
||||
#endif
|
||||
XtAppContext appContext;
|
||||
topWidget = XtAppInitialize (&appContext,a_class,
|
||||
NULL,(Cardinal)0,
|
||||
&argc,a_args,NULL,
|
||||
NULL,(Cardinal)0);
|
||||
if(topWidget==NULL) {
|
||||
G4cout << "G4Xt : Unable to init Xt." << endl;
|
||||
}
|
||||
// Restore a_args. XtAppInitialize corrupts the given ones !!!
|
||||
if( (a_argn!=0) && (args!=NULL)) {
|
||||
for(int argi=0;argi<a_argn;argi++) {
|
||||
if(args[argi]!=NULL)
|
||||
strcpy(a_args[argi],args[argi]);
|
||||
else
|
||||
a_args[argi] = NULL;
|
||||
}
|
||||
}
|
||||
// If topWidget not realized, pbs with Inventor shells.
|
||||
XtSetMappedWhenManaged (topWidget,False);
|
||||
XtRealizeWidget (topWidget);
|
||||
XtInited = TRUE;
|
||||
}
|
||||
SetArguments (argn,args);
|
||||
SetMainInteractor (topWidget);
|
||||
AddDispatcher ((G4DispatchFunction)XtDispatchEvent);
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4Xt::~G4Xt (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(this==instance) {
|
||||
instance = NULL;
|
||||
}
|
||||
}
|
||||
/***************************************************************************/
|
||||
G4bool G4Xt::Inited (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
return XtInited;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void* G4Xt::GetEvent (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
static XEvent event;
|
||||
if(topWidget==NULL) return NULL;
|
||||
XtAppContext appContext = XtWidgetToApplicationContext(topWidget);
|
||||
XtAppNextEvent (appContext, &event);
|
||||
return &event;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4Xt::PutStringInResourceDatabase (
|
||||
char* a_string
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(topWidget==NULL) return;
|
||||
if(a_string==NULL) return;
|
||||
Display* dpy = XtDisplay(topWidget);
|
||||
XrmDatabase dbres = XrmGetStringDatabase (a_string);
|
||||
if(dbres==NULL) return;
|
||||
XrmDatabase database = XrmGetDatabase (dpy);
|
||||
if(database!=NULL) {
|
||||
XrmMergeDatabases (dbres,&database);
|
||||
} else {
|
||||
XrmSetDatabase (dpy,dbres);
|
||||
}
|
||||
}
|
||||
/***************************************************************************/
|
||||
void G4Xt::FlushAndWaitExecution (
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(topWidget==NULL) return;
|
||||
XSync(XtDisplay(topWidget),False);
|
||||
}
|
||||
/***************************************************************************/
|
||||
/******* From OPACS Xx/v3 package ******************************************/
|
||||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
void XWidgetIconify (
|
||||
Widget This
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(This==NULL) return;
|
||||
if(!XtIsRealized(This)) return;
|
||||
XIconifyWindow(XtDisplay(This),XtWindow(This),XScreenNumberOfScreen(XtScreen(This)));
|
||||
}
|
||||
/***************************************************************************/
|
||||
void XWidgetUniconify (
|
||||
Widget This
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
if(This==NULL) return;
|
||||
if(!XtIsRealized(This)) return;
|
||||
XDisplaySetWindowToNormalState (XtDisplay(This),XtWindow(This));
|
||||
}
|
||||
/***************************************************************************/
|
||||
void XDisplaySetWindowToNormalState (
|
||||
Display* This
|
||||
,Window a_window
|
||||
)
|
||||
/***************************************************************************/
|
||||
/*
|
||||
Used to deiconify a window.
|
||||
*/
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
{
|
||||
XWMHints wh;
|
||||
if(This==NULL) return;
|
||||
if(a_window==0L) return;
|
||||
wh.initial_state = NormalState;
|
||||
wh.flags = StateHint;
|
||||
XSetWMHints (This,a_window,&wh);
|
||||
XMapWindow (This,a_window);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user