Import Geant4 0.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-08 15:09:25 +02:00
parent b97f8d0df7
commit aaa409b6ee
2922 changed files with 55107 additions and 81674 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
# $Id: GNUmakefile,v 2.2 1998/07/07 16:57:13 allison Exp $
# $Id: GNUmakefile,v 1.1 1999/01/07 16:09:29 gunter Exp $
# -------------------------------------------------------------
# GNUmakefile for interfaces/GAG library. John Allison, 6/7/98.
+2 -2
View File
@@ -5,8 +5,8 @@
// 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 $
// $Id: G4UIGAG.hh,v 1.2 1999/04/13 01:26:18 yhajime Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
// G4UIGAG.hh
// GAG(Geant4 adaptive GUI) interface class
+2 -7
View File
@@ -5,8 +5,8 @@
// 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 $
// $Id: G4UIGAG.cc,v 1.3 1999/04/15 17:41:44 johna Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
// G4UIGAG.cc
// 18.Feb.98 M.Nagamatu and T.Kodama created G4UIGAG from G4UIterminal
@@ -22,11 +22,6 @@
# 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;
+1 -1
View File
@@ -1,4 +1,4 @@
# $Id: GNUmakefile,v 2.5 1998/07/08 11:29:45 allison Exp $
# $Id: GNUmakefile,v 1.1 1999/01/07 16:09:29 gunter Exp $
# -----------------------------------------------------------------------
# GNUmakefile for interfaces. John Allison, 5/7/98.
# -----------------------------------------------------------------------
+29 -1
View File
@@ -1,4 +1,4 @@
$Id: History,v 2.20 1998/12/09 08:06:43 yhajime Exp $
$Id: History,v 1.9 1999/05/31 20:48:28 barrand Exp $
-------------------------------------------------------------------
=========================================================
@@ -16,6 +16,34 @@ committal in the CVS repository !
----------------------------------------------------------
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
head 31 Mai 1999 Guy Barrand
- G4VInteractorManager::SecondaryLoop : add a message to indicate
that we enter a "viewer" secondary X event loop and that someone
add to "Escape" it from the viewer to continue.
interfaces-01-00-03 19th April 1999 John Allison
- Protected G4VBasicShell.cc with if( tempPath.length()>0 ).
interfaces-01-00-02 18th April 1999 John Allison
- Tagged.
head 11th Mai 1999 Guy Barrand
1) G4UIXm : Linux, correct geometry management of the menubar.
head 06th Mai 1999 Guy Barrand
1) G4Win32, G4UIWin32 : modifications to compile with Visual-6.0.
head 16th April 1999 Guy Barrand
1) G4VBasicShell, G4UIXm, G4UIWin32 : command completion.
2) G4InteractorMessenger, G4VInteractorManager : code polishement.
interfaces-01-00-01 15th April 1999 Hajime Yoshida/Masayasu Nagamatu
1) some code polishment after the messages by CodeWarriers (Guy)
2) Help functions in G4VBasicShell and related rearrangement of
G4UIterminal etc.. (Guy)
3) removal of ifdef for GNU_GCC in G4UIGAG. (Hajime)
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
+1 -1
View File
@@ -1,4 +1,4 @@
# $Id: GNUmakefile,v 2.2 1998/07/07 16:57:17 allison Exp $
# $Id: GNUmakefile,v 1.1 1999/01/07 16:09:30 gunter Exp $
# -------------------------------------------------------------
# GNUmakefile for interfaces/OPACS library. John Allison, 6/7/98.
+2 -2
View File
@@ -5,8 +5,8 @@
// 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 $
// $Id: G4UIWo.hh,v 1.2 1999/04/13 01:26:20 yhajime Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
#ifndef G4UIWo_h
#define G4UIWo_h
@@ -5,8 +5,8 @@
// 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 $
// $Id: G4WoMessenger.hh,v 1.2 1999/04/13 01:26:20 yhajime Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
#ifndef G4WoMessenger_h
#define G4WoMessenger_h 1
+2 -2
View File
@@ -5,8 +5,8 @@
// 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 $
// $Id: G4oCommon.hh,v 1.2 1999/04/13 01:26:21 yhajime Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
/*
Included by G4o.h.
@@ -5,8 +5,8 @@
// 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 $
// $Id: G4oCommon.icc,v 1.2 1999/04/13 01:26:21 yhajime Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
/*
Included by G4o.cc.
+2 -2
View File
@@ -5,8 +5,8 @@
// 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 $
// $Id: G4UIWo.cc,v 1.2 1999/04/13 01:26:22 yhajime Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
//G4UIWo.cc -- copied from G4UIterminal.cc
+2 -2
View File
@@ -5,8 +5,8 @@
// 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 $
// $Id: G4WoMessenger.cc,v 1.2 1999/04/13 01:26:23 yhajime Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
#ifdef G4UI_BUILD_WO_SESSION
+1 -1
View File
@@ -1,4 +1,4 @@
# $Id: GNUmakefile,v 2.2 1998/07/07 16:57:20 allison Exp $
# $Id: GNUmakefile,v 1.1 1999/01/07 16:09:32 gunter Exp $
# -------------------------------------------------------------
# GNUmakefile for interfaces/XVT library. John Allison, 6/7/98.
+2 -2
View File
@@ -5,8 +5,8 @@
// 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 $
// $Id: G4UIxvt.hh,v 1.2 1999/04/13 01:24:58 yhajime Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
////////////////////////////////////////////////////////////////////////
// XVT driver class header //
@@ -5,8 +5,8 @@
// 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 $
// $Id: G4UIxvtMessenger.hh,v 1.2 1999/04/13 01:25:01 yhajime Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
//////////////////////////////////////////////////////////////////////////////
// //
+2 -2
View File
@@ -5,8 +5,8 @@
// 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 $
// $Id: G4UIxvt.cc,v 1.2 1999/04/13 01:25:02 yhajime Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
#ifdef G4UI_BUILD_XVT_SESSION
@@ -5,8 +5,8 @@
// 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 $
// $Id: G4UIxvtMessenger.cc,v 1.2 1999/04/13 01:25:03 yhajime Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
#ifdef G4UI_BUILD_XVT_SESSION
+1 -1
View File
@@ -1,4 +1,4 @@
# $Id: GNUmakefile,v 2.2 1998/07/07 16:57:27 allison Exp $
# $Id: GNUmakefile,v 1.1 1999/01/07 16:09:33 gunter Exp $
# -------------------------------------------------------------
# GNUmakefile for interfaces/basic library. John Allison, 6/7/98.
+10 -7
View File
@@ -5,8 +5,8 @@
// 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 $
// $Id: G4UIWin32.hh,v 1.3 1999/05/06 15:20:37 barrand Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
#ifndef G4UIWin32_h
#define G4UIWin32_h
@@ -33,17 +33,15 @@ public:
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);
G4bool GetHelpChoice(G4int&);
void ExitHelp();
private:
G4VInteractorManager* interactorManager;
HWND mainWindow;
HWND textWindow,editWindow;
@@ -53,6 +51,11 @@ private:
int textRows,textCols;
static LRESULT CALLBACK MainWindowProc(HWND,UINT,WPARAM,LPARAM);
static LRESULT CALLBACK TextWindowProc(HWND,UINT,WPARAM,LPARAM);
static LRESULT CALLBACK EditWindowProc(HWND,UINT,WPARAM,LPARAM);
G4bool fHelp;
G4int fHelpChoice;
RWTValOrderedVector<G4String> fHistory;
int fHistoryPos;
};
#endif
+20 -22
View File
@@ -5,8 +5,8 @@
// 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 $
// $Id: G4UIXaw.hh,v 1.2 1999/04/13 01:26:24 yhajime Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
#ifndef G4UIXaw_h
#define G4UIXaw_h
@@ -20,26 +20,24 @@
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;
class G4UIXaw : public G4VBasicShell {
public:
G4UIXaw(int,char**);
~G4UIXaw();
G4UIsession* SessionStart();
void Prompt(G4String);
void SessionTerminate();
void PauseSessionStart(G4String);
Widget GetDialog();
private:
void SecondaryLoop(G4String);
G4bool GetHelpChoice(G4int&);
void ExitHelp();
private:
Widget shell,dialog;
G4bool fHelp;
G4int fHelpChoice;
static void Callback(Widget,XtPointer,XtPointer);
};
#endif
+10 -9
View File
@@ -5,8 +5,8 @@
// 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 $
// $Id: G4UIXm.hh,v 1.4 1999/05/11 13:26:29 barrand Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
#ifndef G4UIXm_h
#define G4UIXm_h
@@ -26,26 +26,27 @@ 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);
G4bool GetHelpChoice(G4int&);
void ExitHelp();
private:
Widget shell,command,menuBar,text;
Widget form,shell,command,menuBar,text;
RWTValHashDictionary<Widget,G4String> commands;
static void commandEnteredCallback(Widget,XtPointer,XtPointer);
static void keyHandler(Widget,XtPointer,XEvent*,Boolean*);
G4bool fHelp;
G4int fHelpChoice;
static void ButtonCallback(Widget,XtPointer,XtPointer);
};
#endif
@@ -5,8 +5,8 @@
// 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 $
// $Id: G4UIterminal.hh,v 1.2 1999/04/13 01:26:25 yhajime Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
#ifndef G4UIterminal_h
@@ -36,10 +36,8 @@ class G4UIterminal : public G4VBasicShell
private:
void ExecuteCommand(G4String);
G4String GetCommand();
void ChangeDirectoryCommand(G4String);
void ListDirectory(G4String);
void TerminalHelp(G4String);
void ShowCurrent(G4String);
G4bool GetHelpChoice(G4int&);
void ExitHelp();
};
+166 -201
View File
@@ -5,8 +5,8 @@
// 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 $
// $Id: G4UIWin32.cc,v 1.4 1999/05/06 15:21:00 barrand Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
// G.Barrand
@@ -36,6 +36,7 @@ class TextBuffer {
public:
TextBuffer():linei(0),linen(TEXT_MAX_LINES),endOfPage(0),heightOfPage(12) {
lines = new G4String[linen];
for(int count=0;count<256;count++) spaces[count] = ' ';
}
~TextBuffer() {
delete [] lines;
@@ -102,6 +103,7 @@ public:
int rowi = endOfPage - row;
short y = a_rect->bottom - charHeight * (row + 1);
if((rowi>=0)&&(rowi<linei)) {
TextOut (a_hdc,0,y,(char*)spaces,256); //Clear text background first.
const char* string = lines[rowi].data();
if(string!=NULL) {
TextOut (a_hdc,0,y,(char*)string,strlen((char*)string));
@@ -114,16 +116,18 @@ private:
int linen;
int linei;
int endOfPage,heightOfPage;
char spaces[256];
};
static char mainClassName[] = "G4UIWin32";
static char textClassName[] = "G4UIWin32/Text";
static G4bool exitSession = true;
static G4bool exitPause = true;
static G4bool exitHelp = true;
static G4UIsession* tmpSession = NULL;
static FARPROC oldEditWindowProc;
static LRESULT CALLBACK EditWindowProc(HWND,UINT,WPARAM,LPARAM);
static WNDPROC oldEditWindowProc;
static G4bool ConvertStringToInt(const char*,int&);
static int actionIdentifier = 0;
@@ -132,8 +136,8 @@ static unsigned CommandsHashFun(const int& identifier) {
}
/***************************************************************************/
G4UIWin32::G4UIWin32 (
HANDLE a_hInstance
,HANDLE a_hPrevInstance
HINSTANCE a_hInstance
,HINSTANCE a_hPrevInstance
,LPSTR a_lpszCmdLine
,int a_nCmdShow
)
@@ -145,6 +149,9 @@ G4UIWin32::G4UIWin32 (
,textBuffer(NULL)
,textCols(80)
,textRows(12)
,fHelp(false)
,fHelpChoice(0)
,fHistoryPos(-1)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
@@ -164,7 +171,7 @@ G4UIWin32::G4UIWin32 (
wc.hInstance = a_hInstance;
wc.hIcon = LoadIcon(NULL,IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground = GetStockObject(BLACK_BRUSH);
wc.hbrBackground = GetStockBrush(BLACK_BRUSH);
wc.lpszMenuName = mainClassName;
wc.lpszClassName = mainClassName;
::RegisterClass (&wc);
@@ -176,7 +183,7 @@ G4UIWin32::G4UIWin32 (
wc.hInstance = a_hInstance;
wc.hIcon = LoadIcon(NULL,IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground = GetStockObject(WHITE_BRUSH);
wc.hbrBackground = GetStockBrush(WHITE_BRUSH);
wc.lpszMenuName = textClassName;
wc.lpszClassName = textClassName;
::RegisterClass (&wc);
@@ -219,7 +226,11 @@ G4UIWin32::~G4UIWin32 (
UI->SetCoutDestination(NULL);
}
delete textBuffer;
::DestroyWindow(mainWindow);
if(textWindow!=NULL) ::SetWindowLong(textWindow,GWL_USERDATA,LONG(NULL));
if(mainWindow!=NULL) {
::SetWindowLong(mainWindow,GWL_USERDATA,LONG(NULL));
::DestroyWindow(mainWindow);
}
}
/***************************************************************************/
G4UIsession* G4UIWin32::SessionStart (
@@ -278,123 +289,14 @@ void G4UIWin32::SecondaryLoop (
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
if(interactorManager==NULL) return;
Prompt (a_prompt);
exitPause = false;
void* event;
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;
}
Prompt("session");
}
/***************************************************************************/
G4int G4UIWin32::ReceiveG4cout (
@@ -417,59 +319,35 @@ G4int G4UIWin32::ReceiveG4cerr (
return 0;
}
/***************************************************************************/
void G4UIWin32::ShowCurrent (
G4String newCommand
G4bool G4UIWin32::GetHelpChoice(
G4int& aInt
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
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;
fHelp = true;
//
if(interactorManager==NULL) return false;
Prompt("Help");
exitHelp = false;
void* event;
while((event = interactorManager->GetEvent())!=NULL) {
interactorManager->DispatchEvent(event);
if(exitHelp==true) break;
}
Prompt("session");
//
if(fHelp==false) return false;
aInt = fHelpChoice;
fHelp = false;
return true;
}
/***************************************************************************/
void G4UIWin32::ChangeDirectoryCommand (
G4String newCommand
void G4UIWin32::ExitHelp(
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
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 (
@@ -543,36 +421,36 @@ LRESULT CALLBACK G4UIWin32::MainWindowProc (
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);
if(This!=NULL) {
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 = (WNDPROC)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);
@@ -594,13 +472,15 @@ LRESULT CALLBACK G4UIWin32::MainWindowProc (
}return 0;
case WM_SETFOCUS:{
G4UIWin32* This = (G4UIWin32*)::GetWindowLong(a_window,GWL_USERDATA);
SetFocus (This->editWindow);
if(This!=NULL) 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);
if(This->fHelp==false) {
G4String command = This->GetCommand(a_wParam);
This->ApplyShellCommand (command,exitSession,exitPause);
}
}
}return 0;
case WM_DESTROY:
@@ -668,7 +548,7 @@ LRESULT CALLBACK G4UIWin32::TextWindowProc (
return (DefWindowProc(a_window,a_message,a_wParam,a_lParam));
}
/***************************************************************************/
LRESULT CALLBACK EditWindowProc (
LRESULT CALLBACK G4UIWin32::EditWindowProc (
HWND a_window
,UINT a_message
,WPARAM a_wParam
@@ -686,9 +566,78 @@ LRESULT CALLBACK EditWindowProc (
char buffer[128];
GetWindowText (a_window,buffer,128);
G4String command (buffer);
SetWindowText (a_window,"");
This->ApplyShellCommand (command);
}break;
//SetWindowText (a_window,"");
Edit_SetText(a_window,"");
Edit_SetSel(a_window,0,0);
if(This!=NULL) {
if(This->fHelp==true) {
exitHelp = true;
This->fHelp = ConvertStringToInt(command.data(),This->fHelpChoice);
} else {
This->fHistory.insert(command);
This->fHistoryPos = -1;
This->ApplyShellCommand (command,exitSession,exitPause);
}
}
}break;
case VK_TAB:{
G4UIWin32* This = (G4UIWin32*)::GetWindowLong(
GetParent(a_window),GWL_USERDATA);
if( (This!=NULL) && (This->fHelp==true) ) break;
char buffer[128];
Edit_GetText(a_window,buffer,128);
G4String command(buffer);
if(This!=NULL) {
G4String cmd = This->Complete(command);
const char* d = cmd.data();
int l = strlen(d);
Edit_SetText(a_window,d);
Edit_SetSel(a_window,l,l);
}
}break;
case VK_UP:{
G4UIWin32* This = (G4UIWin32*)::GetWindowLong(
GetParent(a_window),GWL_USERDATA);
if(This!=NULL) {
int pos = This->fHistoryPos== -1 ?
This->fHistory.entries()-1 : This->fHistoryPos-1;
if((pos>=0)&&(pos<This->fHistory.entries())) {
G4String command = This->fHistory[pos];
const char* d = command.data();
int l = strlen(d);
Edit_SetText(a_window,d);
Edit_SetSel(a_window,l,l);
//
This->fHistoryPos = pos;
}
}
}return 0; //Do not jump into oldEditProc.
case VK_DOWN:{
G4UIWin32* This = (G4UIWin32*)::GetWindowLong(
GetParent(a_window),GWL_USERDATA);
if(This!=NULL) {
int pos = This->fHistoryPos + 1;
if((pos>=0)&&(pos<This->fHistory.entries())) {
G4String command = This->fHistory[pos];
const char* d = command.data();
int l = strlen(d);
Edit_SetText(a_window,d);
Edit_SetSel(a_window,l,l);
//
This->fHistoryPos = pos;
} else if(pos>=This->fHistory.entries()) {
Edit_SetText(a_window,"");
Edit_SetSel(a_window,0,0);
//
This->fHistoryPos = -1;
}
}
}return 0; //Do not jump into oldEditProc.
}
}
return CallWindowProc(oldEditWindowProc,
@@ -718,6 +667,22 @@ void G4UIWin32::TextAppendString (
SetScrollPos(textWindow,SB_VERT,linen-1,TRUE);
}
}
//////////////////////////////////////////////////////////////////////////////
G4bool ConvertStringToInt(
const char* aString
,int& aInt
)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
aInt = 0;
if(aString==NULL) return false;
char* s;
long value = strtol(aString,&s,10);
if(s==aString) return false;
aInt = value;
return true;
}
#endif
+68 -187
View File
@@ -5,8 +5,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4UIXaw.cc,v 2.4 1998/09/19 14:45:28 barrand Exp $
// GEANT4 tag $Name: geant4-00 $
// $Id: G4UIXaw.cc,v 1.2 1999/04/13 01:26:27 yhajime Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
// G.Barrand
@@ -28,16 +28,18 @@
#include "G4UIcommandStatus.hh"
#include "G4Xt.hh"
static void Callback (Widget,XtPointer,XtPointer);
static G4bool ConvertStringToInt(const char*,int&);
static G4bool exitSession = true;
static G4bool exitPause = true;
static G4bool exitPause = true;
static G4bool exitHelp = true;
/***************************************************************************/
G4UIXaw::G4UIXaw (
int argc
,char** argv
)
:fHelp(false)
,fHelpChoice(0)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
@@ -111,16 +113,14 @@ void G4UIXaw::PauseSessionStart (
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
if(a_state=="G4_pause> ")
{
SecondaryLoop ("Pause, type continue to exit this state");
}
if(a_state=="G4_pause> ") {
SecondaryLoop ("Pause, type continue to exit this state");
}
if(a_state=="EndOfEvent")
{
// Picking with feed back in event data Done here !!!
SecondaryLoop ("End of event, type continue to exit this state");
}
if(a_state=="EndOfEvent") {
// Picking with feed back in event data Done here !!!
SecondaryLoop ("End of event, type continue to exit this state");
}
}
/***************************************************************************/
void G4UIXaw::SecondaryLoop (
@@ -140,169 +140,6 @@ void G4UIXaw::SecondaryLoop (
Prompt ("session");
}
/***************************************************************************/
void G4UIXaw::ApplyShellCommand (
G4String a_string
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4UImanager* UI = G4UImanager::GetUIpointer();
if(UI==NULL) return;
G4String command = a_string.strip(G4String::leading);
if( command(0) == '#' ) {
G4cout << command << endl;
} else if( command(0,2) == "ls" ) {
ListDirectory( command );
} else if( command == "pwd" ) {
G4cout << "Current Working Directory : "
<< GetCurrentWorkingDirectory() << endl;
} else if( command(0,2) == "cd" ) {
ChangeDirectoryCommand ( command );
} else if( command(0,4) == "help" ) {
//TerminalHelp( command );
G4cout << "Not implemented." << endl;
} else if( command(0) == '?' ) {
ShowCurrent( command );
} else if( command(0,4) == "hist" ) {
G4int nh = UI->GetNumberOfHistory();
for(int i=0;i<nh;i++) {
G4cout << i << ": " << UI->GetPreviousCommand(i) << endl;
}
} else if( command(0) == '!' ) {
G4String ss = command(1,command.length()-1);
G4int vl;
const char* tt = ss;
istrstream is((char*)tt);
is >> vl;
G4int nh = UI->GetNumberOfHistory();
if(vl>=0 && vl<nh) {
G4String prev = UI->GetPreviousCommand(vl);
G4cout << prev << endl;
ExecuteCommand (ModifyToFullPathCommand(prev));
} else {
G4cerr << "history " << vl << " is not found." << endl;
}
} else if( command(0,4) == "exit" ) {
if( exitPause == false) { //In a secondary loop.
G4cout << "You are now processing RUN." << endl;
G4cout << "Please abort it using \"/run/abort\" command first" << endl;
G4cout << " and use \"continue\" command until the application" << endl;
G4cout << " becomes to Idle." << endl;
} else {
exitSession = true;
}
} else if( command(0,4) == "cont" ) {
exitPause = true;
} else {
ExecuteCommand (ModifyToFullPathCommand(a_string));
}
}
/***************************************************************************/
void G4UIXaw::ExecuteCommand (
G4String aCommand
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
if(aCommand.length()<2) return;
G4UImanager* UI = G4UImanager::GetUIpointer();
if(UI==NULL) return;
int commandStatus = UI->ApplyCommand(aCommand);
switch(commandStatus) {
case fCommandSucceeded:
break;
case fCommandNotFound:
G4cerr << "command not found" << endl;
break;
case fIllegalApplicationState:
G4cerr << "illegal application state -- command refused" << endl;
break;
case fParameterOutOfRange:
case fParameterUnreadable:
case fParameterOutOfCandidates:
default:
G4cerr << "command refused (" << commandStatus << ")" << endl;
}
}
/***************************************************************************/
void G4UIXaw::ShowCurrent (
G4String newCommand
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4UImanager* UI = G4UImanager::GetUIpointer();
if(UI==NULL) return;
G4String comString = newCommand(1,newCommand.length()-1);
G4String theCommand = ModifyToFullPathCommand(comString);
G4String curV = UI->GetCurrentValues(theCommand);
if( ! curV.isNull() ) {
G4cout << "Current value(s) of the parameter(s) : " << curV << endl;
}
}
/***************************************************************************/
void G4UIXaw::ChangeDirectoryCommand (
G4String newCommand
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4String prefix;
if( newCommand.length() <= 3 ) {
prefix = "/";
} else {
G4String aNewPrefix = newCommand(3,newCommand.length()-3);
prefix = aNewPrefix.strip(G4String::both);
}
if(!ChangeDirectory(prefix)) {
G4cout << "directory <" << prefix << "> not found." << endl;
}
}
/***************************************************************************/
void G4UIXaw::ListDirectory(
G4String newCommand
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4String targetDir;
if( newCommand.length() <= 3 ) {
targetDir = "./";
} else {
G4String newPrefix = newCommand(3,newCommand.length()-3);
targetDir = newPrefix.strip(G4String::both);
}
G4UIcommandTree* commandTree = FindDirectory( targetDir );
if( commandTree == NULL ) {
G4cout << "Directory <" << targetDir << "> is not found." << endl;
} else {
commandTree->ListCurrent();
}
}
/***************************************************************************/
Widget G4UIXaw::GetDialog (
)
/***************************************************************************/
@@ -311,9 +148,40 @@ Widget G4UIXaw::GetDialog (
return dialog;
}
/***************************************************************************/
G4bool G4UIXaw::GetHelpChoice(
G4int& aInt
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
fHelp = true;
//
G4Xt* interactorManager = G4Xt::getInstance ();
Prompt("Help");
exitHelp = false;
void* event;
while((event = interactorManager->GetEvent())!=NULL) {
interactorManager->DispatchEvent(event);
if(exitHelp==true) break;
}
Prompt("session");
//
if(fHelp==false) return false;
aInt = fHelpChoice;
fHelp = false;
return true;
}
/***************************************************************************/
void G4UIXaw::ExitHelp(
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
}
/***************************************************************************/
/***************************************************************************/
static void Callback (
/***************************************************************************/
void G4UIXaw::Callback (
Widget a_widget
,XtPointer a_tag
,XtPointer a_data
@@ -327,7 +195,12 @@ static void Callback (
if(value==NULL) return;
G4String command (value);
This->ApplyShellCommand (command);
if(This->fHelp==true) {
exitHelp = true;
This->fHelp = ConvertStringToInt(command.data(),This->fHelpChoice);
} else {
This->ApplyShellCommand (command,exitSession,exitPause);
}
Arg args[1];
XtSetArg (args[0],XtNvalue,"");
@@ -336,13 +209,21 @@ static void Callback (
a_widget = NULL;
a_data = NULL;
}
//////////////////////////////////////////////////////////////////////////////
G4bool ConvertStringToInt(
const char* aString
,int& aInt
)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
aInt = 0;
if(aString==NULL) return false;
char* s;
long value = strtol(aString,&s,10);
if(s==aString) return false;
aInt = value;
return true;
}
#endif
+102 -168
View File
@@ -5,8 +5,8 @@
// 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 $
// $Id: G4UIXm.cc,v 1.4 1999/05/11 13:26:31 barrand Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
// G.Barrand
@@ -20,8 +20,11 @@
#include <strstream.h>
#endif
#include <string.h>
#include <X11/Intrinsic.h>
#include <X11/Shell.h>
#include <X11/keysym.h>
#include <Xm/Xm.h>
#include <Xm/Command.h>
@@ -41,13 +44,14 @@
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 ConvertStringToInt(const char*,int&);
static void ExecuteChangeSizeFunction(Widget);
static G4bool exitSession = true;
static G4bool exitPause = true;
static G4bool exitPause = true;
static G4bool exitHelp = true;
static unsigned CommandsHashFun (const Widget& interactor) {
// Is it correct to return a pointer ?
return (unsigned)(unsigned long)interactor;
@@ -62,6 +66,8 @@ G4UIXm::G4UIXm (
,menuBar(NULL)
,text(NULL)
,commands(CommandsHashFun)
,fHelp(false)
,fHelpChoice(0)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
@@ -72,22 +78,23 @@ G4UIXm::G4UIXm (
Widget top = (Widget)interactorManager->GetMainInteractor();
Arg args[9];
XtSetArg(args[0],XmNkeyboardFocusPolicy,XmPOINTER); // For completion.
shell = XtAppCreateShell ("G4UIXm","G4UIXm",
topLevelShellWidgetClass,XtDisplay(top),
NULL,0);
Widget form = XmCreateForm (shell,"form",NULL,0);
args,1);
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);
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);
@@ -117,7 +124,10 @@ G4UIXm::G4UIXm (
XtAddCallback(clearButton,XmNactivateCallback,
clearButtonCallback,(XtPointer)text);
XtAddCallback(command,XmNcommandEnteredCallback,
commandCallback,(XtPointer)this);
commandEnteredCallback,(XtPointer)this);
Widget commandText = XmCommandGetChild(command,XmDIALOG_COMMAND_TEXT);
XtAddEventHandler(commandText,KeyPressMask,False,keyHandler,(XtPointer)this);
XtRealizeWidget(shell);
XtMapWidget(shell);
@@ -211,114 +221,6 @@ void G4UIXm::SecondaryLoop (
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
)
@@ -339,59 +241,35 @@ G4int G4UIXm::ReceiveG4cerr (
return 0;
}
/***************************************************************************/
void G4UIXm::ShowCurrent (
G4String newCommand
G4bool G4UIXm::GetHelpChoice(
G4int& aInt
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
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;
fHelp = true;
// SecondaryLoop :
G4Xt* interactorManager = G4Xt::getInstance ();
Prompt("Help");
exitHelp = false;
void* event;
while((event = interactorManager->GetEvent())!=NULL) {
interactorManager->DispatchEvent(event);
if(exitHelp==true) break;
}
Prompt("session");
//
if(fHelp==false) return false;
aInt = fHelpChoice;
fHelp = false;
return true;
}
/***************************************************************************/
void G4UIXm::ChangeDirectoryCommand (
G4String newCommand
void G4UIXm::ExitHelp(
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
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 (
@@ -417,6 +295,7 @@ void G4UIXm::AddMenu (
widget = XmCreateCascadeButton (menuBar,(char*)a_name,args,2);
XmStringFree (cps);
XtManageChild (widget);
ExecuteChangeSizeFunction(form);
}
/***************************************************************************/
void G4UIXm::AddButton (
@@ -434,7 +313,7 @@ void G4UIXm::AddButton (
if(parent==NULL) return;
Widget widget = XmCreatePushButton(parent,(char*)a_label,NULL,0);
XtManageChild (widget);
XtAddCallback (widget,XmNactivateCallback,buttonCallback,(XtPointer)this);
XtAddCallback (widget,XmNactivateCallback,ButtonCallback,(XtPointer)this);
commands[widget] = a_command;
}
/***************************************************************************/
@@ -449,7 +328,7 @@ G4String G4UIXm::GetCommand (
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
void commandCallback (
void G4UIXm::commandEnteredCallback (
Widget a_widget
,XtPointer a_tag
,XtPointer a_data
@@ -464,12 +343,37 @@ void commandCallback (
G4String command (ss);
XtFree (ss);
This->ApplyShellCommand (command);
if(This->fHelp==true) {
exitHelp = true;
This->fHelp = ConvertStringToInt(command.data(),This->fHelpChoice);
} else {
This->ApplyShellCommand (command,exitSession,exitPause);
}
a_widget = NULL;
a_tag = NULL;
}
/***************************************************************************/
void G4UIXm::keyHandler (
Widget a_widget
,XtPointer a_tag
,XEvent* a_event
,Boolean* a_dispatch
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
KeySym keySym;
XLookupString(&(a_event->xkey),NULL,0,&keySym,NULL);
if(keySym!=XK_Tab) return;
G4UIXm* This = (G4UIXm*)a_tag;
char* s = XmTextGetString(a_widget);
G4String ss = This->Complete(s);
XmTextSetString(a_widget,(char*)ss.data());
XtFree(s);
XmTextSetInsertionPosition(a_widget,XmTextGetLastPosition(a_widget));
}
/***************************************************************************/
void clearButtonCallback (
Widget a_widget
,XtPointer a_tag
@@ -481,7 +385,7 @@ void clearButtonCallback (
XmTextSetString((Widget)a_tag,"");
}
/***************************************************************************/
void buttonCallback (
void G4UIXm::ButtonCallback (
Widget a_widget
,XtPointer a_tag
,XtPointer
@@ -490,9 +394,10 @@ void buttonCallback (
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4UIXm* This = (G4UIXm*)a_tag;
if(This->fHelp==true) return; // Disabled when in help.
G4String ss = This->GetCommand (a_widget);
//printf ("debug : execute:\n%s\n",ss.data());
This->ApplyShellCommand (ss);
This->ApplyShellCommand(ss,exitSession,exitPause);
}
/***************************************************************************/
/***************************************************************************/
@@ -546,5 +451,34 @@ void XmTextAppendString (
XmTextReplace(This,lastpos,lastpos,a_string);
XmTextSetInsertionPosition(This,XmTextGetLastPosition(This));
}
//////////////////////////////////////////////////////////////////////////////
G4bool ConvertStringToInt(
const char* aString
,int& aInt
)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
aInt = 0;
if(aString==NULL) return false;
char* s;
long value = strtol(aString,&s,10);
if(s==aString) return false;
aInt = value;
return true;
}
#include <X11/IntrinsicP.h>
//////////////////////////////////////////////////////////////////////////////
void ExecuteChangeSizeFunction (
Widget aWidget
)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
if(aWidget==NULL) return;
if(aWidget->core.widget_class->core_class.resize==NULL) return;
(aWidget->core.widget_class->core_class.resize)(aWidget);
}
#endif
+13 -115
View File
@@ -5,8 +5,8 @@
// 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 $
// $Id: G4UIterminal.cc,v 1.2 1999/04/13 01:26:28 yhajime Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
#include "G4UIterminal.hh"
@@ -108,7 +108,6 @@ void G4UIterminal::ExecuteCommand(G4String aCommand)
G4cerr << "command refused (" << commandStatus << ")" << endl;
}
}
G4String G4UIterminal::GetCommand()
{
G4String newCommand;
@@ -195,122 +194,21 @@ G4String G4UIterminal::GetCommand()
}
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; }
G4bool G4UIterminal::GetHelpChoice(G4int& aInt){
cin >> aInt;
if(!cin.good()){
cin.clear();
cin.ignore(30,'\n');
return false;
}
return true;
}
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;
void G4UIterminal::ExitHelp(){
// cin.flush();
char temp[100];
cin.getline( temp, 100 );
}
+1 -1
View File
@@ -1,4 +1,4 @@
# $Id: GNUmakefile,v 2.2 1998/07/07 16:57:30 allison Exp $
# $Id: GNUmakefile,v 1.1 1999/01/07 16:09:36 gunter Exp $
# -------------------------------------------------------------
# GNUmakefile for interfaces/common library. John Allison, 6/7/98.
@@ -19,7 +19,7 @@ class G4InteractorMessenger : public G4UImessenger
{
public:
G4InteractorMessenger (G4VInteractiveSession* session);
~G4InteractorMessenger ();
virtual ~G4InteractorMessenger ();
void SetNewValue(G4UIcommand* command,G4String newValue);
private:
G4VInteractiveSession* session;
@@ -5,8 +5,8 @@
// 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 $
// $Id: G4VBasicShell.hh,v 1.3 1999/04/16 10:06:05 barrand Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
#ifndef G4VBasicShell_H
@@ -50,6 +50,22 @@ class G4VBasicShell : public G4UIsession
// find G4UIcommand object
// null returned if the target does not exist
G4String Complete(G4String);
// command completion
G4String FindMatchingPath(G4UIcommandTree*,G4String);
/////////////////////////////////////////////
// Methods involving an interactive G4cout //
/////////////////////////////////////////////
virtual void ExecuteCommand(G4String);
virtual G4bool GetHelpChoice(G4int&) = 0;
virtual void ExitHelp() = 0;
void ApplyShellCommand(G4String,G4bool&,G4bool&);
void ShowCurrent(G4String);
void ChangeDirectoryCommand(G4String);
void ListDirectory(G4String);
void TerminalHelp(G4String);
private:
G4String currentDirectory;
@@ -5,8 +5,8 @@
// 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 $
// $Id: G4VInteractorManager.hh,v 1.3 1999/04/16 10:06:06 barrand Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
// G.Barrand
@@ -14,6 +14,7 @@
#define G4VINTERACTORMANAGER_HH
#include "globals.hh"
#include <rw/tvordvec.h>
typedef void* G4Interactor;
typedef G4bool (*G4DispatchFunction)(void*);
@@ -55,14 +56,10 @@ private:
int argc;
char** argv;
G4Interactor mainInteractor;
int dispatchern;
G4DispatchFunction* dispatchers;
int preActionn;
G4SecondaryLoopAction* preActions;
int postActionn;
G4SecondaryLoopAction* postActions;
int shelln;
G4Interactor* shells;
RWTValOrderedVector<G4DispatchFunction> dispatchers;
RWTValOrderedVector<G4SecondaryLoopAction> preActions;
RWTValOrderedVector<G4SecondaryLoopAction> postActions;
RWTValOrderedVector<G4Interactor> shells;
G4bool secondaryLoopEnabled;
G4bool alreadyInSecondaryLoop;
int exitSecondaryLoop;
+3 -2
View File
@@ -5,8 +5,8 @@
// 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 $
// $Id: G4Win32.hh,v 1.3 1999/05/07 10:34:11 barrand Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
// To unify Windows message treatment between
// G4/interfaces Windows sessions and G4/visualizations Windows drivers.
@@ -18,6 +18,7 @@
#if defined(G4INTY_BUILD_WIN32) || defined(G4INTY_USE_WIN32)
#include <windows.h>
#include <windowsx.h>
#include "G4VInteractorManager.hh"
+2 -2
View File
@@ -5,8 +5,8 @@
// 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 $
// $Id: G4Xt.hh,v 1.2 1999/04/13 01:26:31 yhajime Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
// To unify X11 event treatment between
// G4/interfaces Xt sessions and G4/visualizations Xt drivers.
@@ -68,9 +68,9 @@ void G4InteractorMessenger::SetNewValue (
G4String* params = new G4String [paramn];
if(GetValues(newValue,paramn,params)==true) {
if(command==addMenu) {
session->AddMenu(params[0],params[1]);
session->AddMenu((const char*)params[0],(const char*)params[1]);
} else if(command==addButton) {
session->AddButton(params[0],params[1],params[2]);
session->AddButton((const char*)params[0],(const char*)params[1],(const char*)params[2]);
}
}
delete [] params;
@@ -84,17 +84,17 @@ G4bool GetValues (
RWCTokenizer newValueToken( newValue );
G4String aToken;
for( int i=0; i<paramn;i++ ) {
aToken = newValueToken();
aToken = (G4String)newValueToken();
if( aToken(0)=='"' ) {
while( aToken(aToken.length()-1) != '"' ) {
G4String additionalToken = newValueToken();
G4String additionalToken = (G4String)newValueToken();
if( additionalToken.isNull() ) {
return false;
}
aToken += " ";
aToken += additionalToken;
}
aToken = aToken.strip(G4String::both,'"');
aToken = (G4String)aToken.strip(G4String::both,'"');
}
if( aToken.isNull() ) {
return false;
+353 -20
View File
@@ -5,8 +5,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4VBasicShell.cc,v 2.2 1998/07/12 03:00:20 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
// $Id: G4VBasicShell.cc,v 1.4 1999/05/19 17:40:56 stesting Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
#include "G4VBasicShell.hh"
@@ -22,8 +22,8 @@
#endif
G4VBasicShell::G4VBasicShell()
:currentDirectory("/")
{
currentDirectory = "/";
}
G4VBasicShell::~G4VBasicShell()
@@ -31,17 +31,17 @@ G4VBasicShell::~G4VBasicShell()
G4String G4VBasicShell::ModifyToFullPathCommand(const char* aCommandLine)
{
G4String rawCommandLine = aCommandLine;
G4String rawCommandLine = (G4String)aCommandLine;
if(rawCommandLine.isNull()||rawCommandLine(0)=='\0') return rawCommandLine;
G4String commandLine = rawCommandLine.strip(G4String::both);
G4String commandLine = (G4String)rawCommandLine.strip(G4String::both);
G4String commandString;
G4String parameterString;
int i = commandLine.index(" ");
if( i != RW_NPOS )
{
commandString = commandLine(0,i);
commandString = (G4String)commandLine(0,i);
parameterString = " ";
parameterString += commandLine(i+1,commandLine.length()-(i+1));
parameterString += (G4String)commandLine(i+1,commandLine.length()-(i+1));
}
else
{ commandString = commandLine; }
@@ -58,12 +58,12 @@ G4String G4VBasicShell::GetCurrentWorkingDirectory()
G4bool G4VBasicShell::ChangeDirectory(const char* newDir)
{
G4String aNewPrefix = newDir;
G4String newPrefix = aNewPrefix.strip(G4String::both);
G4String aNewPrefix = (G4String)newDir;
G4String newPrefix = (G4String)aNewPrefix.strip(G4String::both);
G4String newDirectory = ModifyPath( newPrefix );
if( newDirectory( newDirectory.length() - 1 ) != '/' )
{ newDirectory += "/"; }
if( FindDirectory( newDirectory ) == NULL )
if( FindDirectory( (const char*)newDirectory ) == NULL )
{ return false; }
currentDirectory = newDirectory;
return true;
@@ -71,8 +71,8 @@ G4bool G4VBasicShell::ChangeDirectory(const char* newDir)
G4UIcommandTree* G4VBasicShell::FindDirectory(const char* dirName)
{
G4String aDirName = dirName;
G4String theDir = aDirName.strip(G4String::both);
G4String aDirName = (G4String)dirName;
G4String theDir = (G4String)aDirName.strip(G4String::both);
G4String targetDir = ModifyPath( theDir );
if( targetDir( targetDir.length()-1 ) != '/' )
{ targetDir += "/"; }
@@ -83,7 +83,7 @@ G4UIcommandTree* G4VBasicShell::FindDirectory(const char* dirName)
while( idx < targetDir.length()-1 )
{
int i = targetDir.index("/",idx);
comTree = comTree->GetTree(targetDir(0,i+1));
comTree = comTree->GetTree((G4String)targetDir(0,i+1));
if( comTree == NULL )
{ return NULL; }
idx = i+1;
@@ -93,12 +93,12 @@ G4UIcommandTree* G4VBasicShell::FindDirectory(const char* dirName)
G4UIcommand* G4VBasicShell::FindCommand(const char* commandName)
{
G4String rawCommandLine = commandName;
G4String commandLine = rawCommandLine.strip(G4String::both);
G4String rawCommandLine = (G4String)commandName;
G4String commandLine = (G4String)rawCommandLine.strip(G4String::both);
G4String commandString;
int i = commandLine.index(" ");
if( i != RW_NPOS )
{ commandString = commandLine(0,i); }
{ commandString = (G4String)commandLine(0,i); }
else
{ commandString = commandLine; }
@@ -109,12 +109,16 @@ G4UIcommand* G4VBasicShell::FindCommand(const char* commandName)
G4String G4VBasicShell::ModifyPath(G4String tempPath)
{
G4String newPath = currentDirectory;
if( tempPath.length()>0 )
{
if( tempPath(0) == '/' ) // full path is given
{ newPath = tempPath; }
else if( tempPath(0) != '.' ) // add current prefix
{ newPath += tempPath; }
else if( tempPath(0,2) == "./" ) // add current prefix
{ newPath += tempPath(2,tempPath.length()-2); }
{ newPath += (G4String)tempPath(2,tempPath.length()-2); }
else // swim up with ".."
{
while( 1 )
@@ -123,12 +127,12 @@ G4String G4VBasicShell::ModifyPath(G4String tempPath)
{
if( newPath != "/" )
{
G4String tmpString = newPath(0,newPath.length()-1);
newPath = newPath(0,tmpString.last('/')+1);
G4String tmpString = (G4String)newPath(0,newPath.length()-1);
newPath = (G4String)newPath(0,tmpString.last('/')+1);
}
if( tempPath == ".." || tempPath == "../" )
{ break; }
tempPath = tempPath(3,tempPath.length()-3);
tempPath = (G4String)tempPath(3,tempPath.length()-3);
}
else
{
@@ -137,7 +141,336 @@ G4String G4VBasicShell::ModifyPath(G4String tempPath)
}
}
}
}
return newPath;
}
////////////////////////////////////////////
// Method used for command completion //////
////////////////////////////////////////////
G4String G4VBasicShell::Complete(G4String commandName)
{
G4String rawCommandLine = commandName;
G4String commandLine = rawCommandLine.strip(G4String::both);
int i = commandLine.index(" ");
if( i != RW_NPOS ) return rawCommandLine; // Already entering parameters,
// assume command path is correct.
G4String commandString = commandLine;
G4String targetCom = ModifyPath(commandString);
G4UIcommandTree* tree = G4UImanager::GetUIpointer()->GetTree();
G4String value = FindMatchingPath(tree,targetCom);
if(value=="") return rawCommandLine;
return value;
}
G4String G4VBasicShell::FindMatchingPath(
G4UIcommandTree* aTree
,G4String aCommandPath
)
// From intercoms/src/G4UIcommandTree::FindPath.
{
G4String empty = "";
if(aTree==NULL) return empty;
G4String pathName = aTree->GetPathName();
if( aCommandPath.index( pathName ) == RW_NPOS ) return empty;
G4String remainingPath = aCommandPath;
remainingPath.remove(0,pathName.length());
int i = remainingPath.first('/');
if( i == RW_NPOS ) {
// Look for number of matching commands :
RWTPtrOrderedVector<G4UIcommand> commands;
int n_commandEntry = aTree->GetCommandEntry();
for( int i_thCommand = 1; i_thCommand <= n_commandEntry; i_thCommand++ ) {
G4UIcommand* cmd = aTree->GetCommand(i_thCommand);
G4String ss = cmd->GetCommandName();
ss.resize(remainingPath.length());
if( remainingPath == ss ) commands.insert(cmd);
}
n_commandEntry = commands.entries();
if(n_commandEntry==1) {
return (pathName + commands[0]->GetCommandName());
} else if (n_commandEntry>=2) {
G4cout << "Matching commands :" << endl;
for( int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ ) {
G4UIcommand* cmd = commands[i_thCommand];
G4cout << cmd->GetCommandName() << endl;
}
return empty;
}
// Look for sub tree :
RWTPtrOrderedVector<G4UIcommandTree> trees;
G4String nextPath = pathName;
nextPath.append(remainingPath);
int n_treeEntry = aTree->GetTreeEntry();
for( int i_thTree = 1; i_thTree <= n_treeEntry; i_thTree++ ) {
G4UIcommandTree* tree = aTree->GetTree(i_thTree);
G4String ss = tree->GetPathName();
ss.resize(nextPath.length());
if( nextPath == ss ) trees.insert(tree);
}
n_treeEntry = trees.entries();
if(n_treeEntry==1) {
return trees[0]->GetPathName();
} else if (n_treeEntry>=2) {
G4cout << "Matching directories :" << endl;
for( int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ ) {
G4UIcommandTree* tree = trees[i_thTree];
G4cout << tree->GetPathName() << endl;
}
return empty;
} else {
return empty; // No match.
}
} else {
// Find path
G4String nextPath = pathName;
nextPath.append(remainingPath(0,i+1));
int n_treeEntry = aTree->GetTreeEntry();
for( int i_thTree = 1; i_thTree <= n_treeEntry; i_thTree++ ) {
G4UIcommandTree* tree = aTree->GetTree(i_thTree);
if( nextPath == tree->GetPathName() ) {
return FindMatchingPath(tree,aCommandPath );
}
}
}
return empty;
}
////////////////////////////////////////////
// Method involving an interactive G4cout //
////////////////////////////////////////////
/***************************************************************************/
void G4VBasicShell::ExecuteCommand (
G4String aCommand
)
/***************************************************************************/
// Should be put in G4VBasicShell.
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
if(aCommand.length()<2) return;
G4UImanager* UI = G4UImanager::GetUIpointer();
if(UI==NULL) return;
int commandStatus = UI->ApplyCommand(aCommand);
switch(commandStatus) {
case fCommandSucceeded:
break;
case fCommandNotFound:
G4cerr << "command not found" << endl;
break;
case fIllegalApplicationState:
G4cerr << "illegal application state -- command refused" << endl;
break;
case fParameterOutOfRange:
case fParameterUnreadable:
case fParameterOutOfCandidates:
default:
G4cerr << "command refused (" << commandStatus << ")" << endl;
}
}
/***************************************************************************/
void G4VBasicShell::ApplyShellCommand (
G4String a_string
,G4bool& exitSession
,G4bool& exitPause
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4UImanager* UI = G4UImanager::GetUIpointer();
if(UI==NULL) return;
G4String command = a_string.strip(G4String::leading);
if( command(0) == '#' ) {
G4cout << command << endl;
} else if( command == "ls" || command(0,3) == "ls " ) {
ListDirectory( command );
} else if( command == "pwd" ) {
G4cout << "Current Working Directory : "
<< GetCurrentWorkingDirectory() << endl;
} else if( command(0,2) == "cd" ) {
ChangeDirectoryCommand ( command );
} else if( command(0,4) == "help" ) {
TerminalHelp( command );
} else if( command(0) == '?' ) {
ShowCurrent( command );
} else if( command(0,4) == "hist" ) {
G4int nh = UI->GetNumberOfHistory();
for(int i=0;i<nh;i++) {
G4cout << i << ": " << UI->GetPreviousCommand(i) << endl;
}
} else if( command(0) == '!' ) {
G4String ss = command(1,command.length()-1);
G4int vl;
const char* tt = ss;
istrstream is((char*)tt);
is >> vl;
G4int nh = UI->GetNumberOfHistory();
if(vl>=0 && vl<nh) {
G4String prev = UI->GetPreviousCommand(vl);
G4cout << prev << endl;
ExecuteCommand (ModifyToFullPathCommand(prev));
} else {
G4cerr << "history " << vl << " is not found." << endl;
}
} else if( command(0,4) == "exit" ) {
if( exitPause == false) { //In a secondary loop.
G4cout << "You are now processing RUN." << endl;
G4cout << "Please abort it using \"/run/abort\" command first" << endl;
G4cout << " and use \"continue\" command until the application" << endl;
G4cout << " becomes to Idle." << endl;
} else {
exitSession = true;
}
} else if( command(0,4) == "cont" ) {
exitPause = true;
} else {
ExecuteCommand (ModifyToFullPathCommand(a_string));
}
}
void G4VBasicShell::ShowCurrent(G4String newCommand)
{
G4UImanager* UI = G4UImanager::GetUIpointer();
if(UI==NULL) return;
G4String comString = newCommand(1,newCommand.length()-1);
G4String theCommand = ModifyToFullPathCommand(comString);
G4String curV = UI->GetCurrentValues(theCommand);
if( ! curV.isNull() ) {
G4cout << "Current value(s) of the parameter(s) : " << curV << endl;
}
}
void G4VBasicShell::ChangeDirectoryCommand(G4String newCommand)
{
G4String prefix;
if( newCommand.length() <= 3 ) {
prefix = "/";
} else {
G4String aNewPrefix = newCommand(3,newCommand.length()-3);
prefix = aNewPrefix.strip(G4String::both);
}
if(!ChangeDirectory(prefix)) {
G4cout << "directory <" << prefix << "> not found." << endl;
}
}
void G4VBasicShell::ListDirectory(G4String newCommand)
{
G4String targetDir;
if( newCommand.length() <= 3 ) {
targetDir = GetCurrentWorkingDirectory();
} else {
G4String newPrefix = newCommand(3,newCommand.length()-3);
targetDir = newPrefix.strip(G4String::both);
}
G4UIcommandTree* commandTree = FindDirectory( targetDir );
if( commandTree == NULL ) {
G4cout << "Directory <" << targetDir << "> is not found." << endl;
} else {
commandTree->ListCurrent();
}
}
void G4VBasicShell::TerminalHelp(G4String newCommand)
{
G4UImanager* UI = G4UImanager::GetUIpointer();
if(UI==NULL) return;
G4UIcommandTree * treeTop = UI->GetTree();
int i = newCommand.index(" ");
if( i != RW_NPOS )
{
G4String newValue = newCommand(i+1,newCommand.length()-(i+1));
newValue.strip(G4String::both);
G4String targetCom = ModifyToFullPathCommand( newValue );
G4UIcommand* theCommand = treeTop->FindPath( targetCom );
if( theCommand != NULL )
{
theCommand->List();
return;
}
else
{
G4cout << "Command <" << newValue << " is not found." << endl;
return;
}
}
G4UIcommandTree * floor[10];
floor[0] = treeTop;
int iFloor = 0;
int prefixIndex = 1;
G4String prefix = GetCurrentWorkingDirectory();
while( prefixIndex < prefix.length()-1 )
{
int ii = prefix.index("/",prefixIndex);
floor[iFloor+1] =
floor[iFloor]->GetTree(prefix(0,ii+1));
prefixIndex = ii+1;
iFloor++;
}
floor[iFloor]->ListCurrentWithNum();
// 1998 Oct 2 non-number input
while(1){
//G4cout << endl << "Type the number ( 0:end, -n:n level back ) : "<<flush;
G4cout << endl << "Type the number ( 0:end, -n:n level back ) : "<<endl;
G4int i;
if(!GetHelpChoice(i)){
G4cout << endl << "Not a number, once more" << endl;
continue;
} else if( i < 0 ){
iFloor += i;
if( iFloor < 0 ) iFloor = 0;
floor[iFloor]->ListCurrentWithNum();
continue;
} else if(i == 0) {
break;
} else if( i > 0 ) {
int n_tree = floor[iFloor]->GetTreeEntry();
if( i > n_tree )
{
if( i <= n_tree + floor[iFloor]->GetCommandEntry() )
{
floor[iFloor]->GetCommand(i-n_tree)->List();
}
}
else
{
floor[iFloor+1] = floor[iFloor]->GetTree(i);
iFloor++;
floor[iFloor]->ListCurrentWithNum();
}
}
}
G4cout << "Exit from HELP." << endl << endl;
//G4cout << endl;
ExitHelp();
}
@@ -5,8 +5,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4VInteractorManager.cc,v 2.3 1998/08/07 12:39:53 barrand Exp $
// GEANT4 tag $Name: geant4-00 $
// $Id: G4VInteractorManager.cc,v 1.5 1999/05/31 20:47:42 barrand Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
// G.Barrand
@@ -24,14 +24,6 @@ G4VInteractorManager::G4VInteractorManager (
:argc(0)
,argv(NULL)
,mainInteractor(NULL)
,dispatchern(0)
,dispatchers(NULL)
,preActionn(0)
,preActions(NULL)
,postActionn(0)
,postActions(NULL)
,shelln(0)
,shells(NULL)
,secondaryLoopEnabled(TRUE)
,alreadyInSecondaryLoop(FALSE)
,exitSecondaryLoop(0)
@@ -54,24 +46,15 @@ G4VInteractorManager::~G4VInteractorManager (
}
free (argv);
}
argv = NULL;
argc = 0;
if(dispatchers!=NULL) free(dispatchers);
dispatchers = NULL;
dispatchern = 0;
if(preActions!=NULL) free(preActions);
preActions = NULL;
preActionn = 0;
if(postActions!=NULL) free(postActions);
postActions = NULL;
postActionn = 0;
if(shells!=NULL) free(shells);
shells = NULL;
shelln = 0;
secondaryLoopEnabled = TRUE;
argv = NULL;
argc = 0;
dispatchers.clear();
preActions.clear();
postActions.clear();
shells.clear();
secondaryLoopEnabled = TRUE;
alreadyInSecondaryLoop = FALSE;
exitSecondaryLoop = 0;
exitSecondaryLoop = 0;
}
/***************************************************************************/
void G4VInteractorManager::SetArguments (
@@ -152,15 +135,8 @@ void G4VInteractorManager::AddDispatcher (
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
if(a_dispatcher==NULL) return;
for(int count=0;count<dispatchern;count++) {
if(dispatchers[count]==a_dispatcher) return; // Done.
}
if(dispatchern==0) dispatchers = (G4DispatchFunction*)malloc( sizeof(G4DispatchFunction));
else dispatchers = (G4DispatchFunction*)realloc(dispatchers,
(dispatchern+1) * sizeof(G4DispatchFunction));
if(dispatchers==NULL) return;
dispatchers[dispatchern] = a_dispatcher;
dispatchern++;
if(dispatchers.contains(a_dispatcher)==TRUE) return;
dispatchers.insert(a_dispatcher);
}
/***************************************************************************/
void G4VInteractorManager::RemoveDispatcher (
@@ -169,12 +145,7 @@ void G4VInteractorManager::RemoveDispatcher (
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
for(int count=0;count<dispatchern;count++) {
if(dispatchers[count]==a_dispatcher) {
dispatchers[count] = NULL;
return; // A dispatcher appears once in the List.
}
}
dispatchers.removeAll(a_dispatcher);
}
/***************************************************************************/
void G4VInteractorManager::DispatchEvent (
@@ -183,12 +154,14 @@ void G4VInteractorManager::DispatchEvent (
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
int dispatchern = dispatchers.entries();
G4DispatchFunction func;
G4bool status;
for(int count=0;count<dispatchern;count++) {
if(
(dispatchers[count]!=NULL) &&
(dispatchers[count](a_event)==TRUE)
)
break;
func = dispatchers[count];
if(func!=NULL) {
if(func(a_event)==true) return;
}
}
}
/***************************************************************************/
@@ -199,17 +172,8 @@ void G4VInteractorManager::AddSecondaryLoopPreAction (
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
if(a_preAction==NULL) return;
for(int count=0;count<preActionn;count++) {
if(preActions[count]==a_preAction) return; // Done.
}
if(preActionn==0)
preActions = (G4SecondaryLoopAction*)malloc( sizeof(G4SecondaryLoopAction));
else
preActions = (G4SecondaryLoopAction*)realloc(preActions,
(preActionn+1) * sizeof(G4SecondaryLoopAction));
if(preActions==NULL) return;
preActions[preActionn] = a_preAction;
preActionn++;
if(preActions.contains(a_preAction)==TRUE) return;
preActions.insert(a_preAction);
}
/***************************************************************************/
void G4VInteractorManager::SecondaryLoopPreActions (
@@ -217,6 +181,7 @@ void G4VInteractorManager::SecondaryLoopPreActions (
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
int preActionn = preActions.entries();
for(int count=0;count<preActionn;count++) {
if(preActions[count]!=NULL) preActions[count]();
}
@@ -229,17 +194,8 @@ void G4VInteractorManager::AddSecondaryLoopPostAction (
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
if(a_postAction==NULL) return;
for(int count=0;count<postActionn;count++) {
if(postActions[count]==a_postAction) return; // Done.
}
if(postActionn==0)
postActions = (G4SecondaryLoopAction*)malloc( sizeof(G4SecondaryLoopAction));
else
postActions = (G4SecondaryLoopAction*)realloc(postActions,
(postActionn+1) * sizeof(G4SecondaryLoopAction));
if(postActions==NULL) return;
postActions[postActionn] = a_postAction;
postActionn++;
if(postActions.contains(a_postAction)==TRUE) return;
postActions.insert(a_postAction);
}
/***************************************************************************/
void G4VInteractorManager::SecondaryLoopPostActions (
@@ -247,6 +203,7 @@ void G4VInteractorManager::SecondaryLoopPostActions (
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
int postActionn = postActions.entries();
for(int count=0;count<postActionn;count++) {
if(postActions[count]!=NULL) postActions[count]();
}
@@ -262,10 +219,13 @@ void G4VInteractorManager::SecondaryLoop (
if(secondaryLoopEnabled==FALSE) return;
if (alreadyInSecondaryLoop==FALSE) {
G4cout << "------------------------------------------" << endl;
G4cout << "You have entered a viewer secondary X event loop." << endl;
G4cout << "Quit it with an 'Escape' viewer button" << endl;
alreadyInSecondaryLoop = TRUE;
exitSecondaryLoop = 0;
SecondaryLoopPreActions ();
// for(int count=0;count<shelln;count++) XWidgetUniconify(shells[count]);
//for(int count=0;count<shelln;count++) XWidgetUniconify(shells[count]);
void* event;
while(1) {
event = GetEvent();
@@ -306,14 +266,8 @@ void G4VInteractorManager::AddShell (
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
if(a_shell==NULL) return;
for(int count=0;count<shelln;count++) {
if(shells[count]==a_shell) return; // Done.
}
if(shelln==0) shells = (G4Interactor*)malloc( sizeof(G4Interactor));
else shells = (G4Interactor*)realloc(shells, (shelln+1) * sizeof(G4Interactor));
if(shells==NULL) return;
shells[shelln] = a_shell;
shelln++;
if(shells.contains(a_shell)==TRUE) return;
shells.insert(a_shell);
}
/***************************************************************************/
void G4VInteractorManager::RemoveShell (
@@ -322,12 +276,7 @@ void G4VInteractorManager::RemoveShell (
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
for(int count=0;count<shelln;count++) {
if(shells[count]==a_shell) {
shells[count] = NULL;
return; // A shell appears once in the List.
}
}
shells.removeAll(a_shell);
}
/***************************************************************************/
void G4VInteractorManager::SetParentInteractor (
+11 -11
View File
@@ -5,8 +5,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4Win32.cc,v 2.5 1998/09/19 14:45:38 barrand Exp $
// GEANT4 tag $Name: geant4-00 $
// $Id: G4Win32.cc,v 1.4 1999/05/11 12:34:38 barrand Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
// G.Barrand
@@ -39,8 +39,8 @@ G4Win32* G4Win32::getInstance (
}
/***************************************************************************/
G4Win32* G4Win32::getInstance (
HANDLE a_hInstance
,HANDLE a_hPrevInstance
HINSTANCE a_hInstance
,HINSTANCE a_hPrevInstance
,LPSTR a_lpszCmdLine
,int a_nCmdShow
)
@@ -57,8 +57,8 @@ G4Win32* G4Win32::getInstance (
}
/***************************************************************************/
G4Win32::G4Win32 (
HANDLE a_hInstance
,HANDLE a_hPrevInstance
HINSTANCE a_hInstance
,HINSTANCE a_hPrevInstance
,LPSTR a_lpszCmdLine
,int a_nCmdShow
)
@@ -85,7 +85,7 @@ G4Win32::G4Win32 (
wc.hInstance = hInstance;
wc.hIcon = LoadIcon (NULL,IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground = GetStockObject(BLACK_BRUSH);
wc.hbrBackground = GetStockBrush(BLACK_BRUSH);
wc.lpszMenuName = className;
wc.lpszClassName = className;
::RegisterClass (&wc);
@@ -103,8 +103,8 @@ G4Win32::G4Win32 (
Win32Inited = TRUE;
}
AddDispatcher ((G4DispatchFunction)G4Win32::dispatchWin32Event);
SetMainInteractor (topWindow);
AddDispatcher((G4DispatchFunction)G4Win32::dispatchWin32Event);
SetMainInteractor(topWindow);
}
/***************************************************************************/
G4Win32::~G4Win32 (
@@ -144,8 +144,8 @@ void G4Win32::FlushAndWaitExecution (
}
/***************************************************************************/
void G4Win32::getWinMainArguments (
HANDLE* a_hInstance
,HANDLE* a_hPrevInstance
HINSTANCE* a_hInstance
,HINSTANCE* a_hPrevInstance
,LPSTR* a_lpszCmdLine
,int* a_nCmdShow
)
+2 -2
View File
@@ -5,8 +5,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4Xt.cc,v 2.5 1998/08/25 12:23:53 barrand Exp $
// GEANT4 tag $Name: geant4-00 $
// $Id: G4Xt.cc,v 1.2 1999/04/13 01:26:33 yhajime Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
// G.Barrand