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
Symlink
+1
View File
@@ -0,0 +1 @@
ReleaseNotes
+202
View File
@@ -0,0 +1,202 @@
Geant4.0.1 Release Notes
------------------------
14th July 1999
This version of Geant4 is a "consolidation" of the first public
release. Its main characteristics are:
o improved reliability and robustness.
o the possibility of using granular (sub-category) libraries. We
recommend this mode of installation and use.
o the possibility of using either the Standard Template Library
(STL) or RogueWave tools.h++, selectable at installation and use
time.
o new low energy electromagnetic processes (first version).
o extension of nuclear photon-evaporation to include the calculation
of time to production for gammas.
o improvements in design of the User Action classes - see below.
Note that the next release, Geant4.1.0, will be offered only in the
STL version.
This code and some binary libraries are available through our "Source
Code" Web page - see our <A
Href="http://wwwinfo.cern.ch/asd/geant4/geant4.html">Geant4 Home
Page</A>.
Please refer to <A
Href="http://wwwinfo.cern.ch/asd/geant4/G4UsersDocuments/Overview/html/index.html">Geant4
User Documentation</A> for further information about using Geant4.
Updates to the documentation for Geant4.0.1 are still in preparation
and are expected to be published within three weeks.
Contents
--------
1. Supported and Tested Platforms
2. CLHEP 1.4
3. Using the Standard Template Library
4. Compiler Specific Problems
5. Known Run-Time Problems
6. Compilation Warnings
7. Known Run-Time Warnings
8. Changes of the Signatures of Methods of the User Action Classes
1. Supported and Tested Platforms
---------------------------------
o SUN Solaris 5.6, C++ 4.2 patch 104631-04.
o HP 10.20, aCC C++ B3910B A.01.18.
o Linux 2.0.35, gcc C++ egcs-2.91.60. There is a bug in an egcs
include file which affects compilation with STL - see comments
below. This configuration was tested in the RedHat 5.1
distribution, but versions of Geant4 have also been compiled
successfully in Debian and Suse distributions.
Platforms also tested but giving rise to some problems - see below:
o AIX 4.3, xlC compiler.
o DEC V4.0, cxx C++ V6.1-027.
o NT 4.0 with Service Pack 4 and Cygnus Tools b20 with:
Visual C++ 6.0 Service Pack 2 for either STL or RogueWave, or
Visual C++ 5.0 Service Pack 3 for the RogueWave version only.
2. CLHEP 1.4
------------
Geant4.0.1 requires the installation of <A
href="http://wwwinfo.cern.ch/asd/lhc++/INSTALLATION/clhep.html">CLHEP
1.4</A>. The following platform specific instructions apply:
DEC: Do *not* use the compiler option "-std strict_ansi".
NT: After configure, edit the file config/CLHEP-x86-cygnus-win32 and
comment out "#define HEP-USE-STD 1".
3. Using the Standard Template Library
--------------------------------------
The following versions of STL have been tested:
<A href="http://www.objectspace.com/">ObjectSpace</A> STL on: AIX,
DEC, HP, NT and SUN.
<A href="http://www.stlport.org/">STLPORT</A> STL on: NT
"Native" STL on: Linux.
This is selected at installation/compile time by environment variables
- see documentation. Be aware that this is the first implementation
of "The STL Interface" for which the emphasis has been on correct
behaviour, not on performance. Also, the size of libraries and
executables is considerably larger. These issues will be addressed in
the next release.
4. Compiler Specific Problems
-----------------------------
o Linux with egcs-1.1.1 and 1.1.2
In order to compile with STL it is necessary to edit
stl_hash_fun.h in /usr/include/g++/ or /usr/local/include/g++/.
Lines 65-67 must be removed or commented out. These are the
lines in question:
__STL_TEMPLATE_NULL struct hash<signed char> {
size_t operator()(unsigned char x) const { return x; }
};
o AIX 4.3, xlC compiler.
Geant4 does compile and link on AIX... eventually. The compiler
is very slow and the executables in debug mode are very large.
On rsplus at CERN we had to revert to a version of the archiver
corresponding to AIX 4.1 in order to have templates treated
correctly. This has limited our ability to test Geant4.
o DEC V4.0, cxx C++ V6.1-027.
We have found cases of mis-compilation of min and max templates
on DEC. We have traced those which cause serious malfunction
but there is no guarantee that there are no other cases.
Detailed inspection of assembler output suggests that this
problem might not be confined to min and max. This has been
reported to DEC/Compaq. We understand a new version 6.1A of the
compiler is on its way. However we cannot guarantee correct
execution of Geant4 on DEC with the current version of the
compiler.
o NT
- Note that the G4SYSTEM environment variable used for compiling
Geant4 on NT has changed from WIN32-VC-NICE to WIN32-VC.
Please check documentation on setting the environment.
- Testing was done using the debuggable version only.
- g3tog4 has not been ported to NT.
- During the making of dependency files during compilation there
are repeated warnings ("strstrea.h not found") - this is an
artefact of using g++ for this purpose.
- Ignore linker warnings: "conflicts with use of other libs".
- Ignore linker errors: "unresolved external symbol
__imp__MessageBoxA@16".
- There is a known problem reading the data files for neutron
scattering processes. A patch resolving this problem will
be issued soon.
5. Known Run-Time Problems
--------------------------
o Reading STEP files on DEC with optimised libraries causes a Memory
fault - but see notes on DEC above.
o exampleN04 loops on DEC with optimised libraries - but see notes
on DEC above.
o On HP, an executable which uses "integral approach"
electromagnetic processes - G4IMultipleScattering,
G4IeIonisation, G4IeBremsstrahlung, G4IeplusAnnihilation,
G4IhIonisation - has intermittently given Bus error(coredump).
6. Compilation Warnings
-----------------------
There are compilation warnings om some platforms. We do not believe
that any will lead to incorrect run-time behaviour, but we are working
on reducing them.
7. Known Run-Time Warnings
--------------------------
The following messages are written to error output while tracking. We
believe none give rise to incorrect behaviour.
o G4PropagatorInField::LocateIntersectionPoint: Warning: Integration
inaccuracy requires an adjustment in the step's endpoint Two
mid-points are further apart than their curve length difference:
Dist = xxx curve length = yyy
o Stepsize underflow in Stepper.
o Warning G4Navigator::ComputeStep found slightly inaccurate
position...
o Warning in G4Navigator::ComputeStep: The Step's starting point has
moved...
8. Changes of the Signatures of Methods of the User Action Classes
------------------------------------------------------------------
The signatures of all methods of all of the optional user action
classes have been changed. Now every method takes a constant pointer
to an appropriate G4 object. To cope with this change the user code
must be modified. The examples and documents are updated and the user
is requested to consult to them. We are sorry for this inconvenience
but we concluded that this change will provide the user with a better
and more robust code.
+1 -1
View File
@@ -1,4 +1,4 @@
# $Id: G4ODBMS_BUILD.gmk,v 2.1 1998/07/09 13:00:42 morita Exp $
# $Id: G4ODBMS_BUILD.gmk,v 1.1 1999/01/07 15:58:31 gunter Exp $
# ----------------------------------------------------------------
# GNUmakefile for CPPFLAGS for HepODBMS and Objectivity/DB.
# Youhei Morita, 9th July 1998.
+1 -1
View File
@@ -1,4 +1,4 @@
# $Id: G4UI_BUILD.gmk,v 2.7 1998/10/23 15:14:36 barrand Exp $
# $Id: G4UI_BUILD.gmk,v 1.1 1999/01/07 15:58:31 gunter Exp $
# -------------------------------------------------------------
# Interfaces-specific CPPFLAGS for BUILD phase.
# John Allison, 6th July 1998.
+1 -1
View File
@@ -1,4 +1,4 @@
# $Id: G4UI_USE.gmk,v 2.7 1998/08/26 11:05:37 allison Exp $
# $Id: G4UI_USE.gmk,v 1.1 1999/01/07 15:58:31 gunter Exp $
# -------------------------------------------------------------
# GNUmakefile for CPPFLAGS for interfaces USE phase.
# John Allison, 6th July 1998.
+1 -7
View File
@@ -1,4 +1,4 @@
# $Id: G4VIS_BUILD.gmk,v 1.2 1998/07/07 15:10:33 allison Exp $
# $Id: G4VIS_BUILD.gmk,v 1.2 1999/06/19 15:20:38 johna Exp $
# -------------------------------------------------------------
# Visualization-specific CPPFLAGS for BUILD phase.
# John Allison, 24th January 1998.
@@ -62,12 +62,6 @@ ifdef G4VIS_BUILD_OI_DRIVER
CPPFLAGS += -DG4VIS_BUILD_OI_DRIVER
endif
ifdef G4VIS_BUILD_RAYX_DRIVER
G4VIS_BUILD = 1
INC_X11 = 1
CPPFLAGS += -DG4VIS_BUILD_RAYX_DRIVER
endif
# For VRML and VRMLFILE drivers
ifdef G4VIS_BUILD_VRML_DRIVER
G4VIS_BUILD = 1
+1 -10
View File
@@ -1,4 +1,4 @@
# $Id: G4VIS_USE.gmk,v 1.7 1998/12/07 03:48:44 stanaka Exp $
# $Id: G4VIS_USE.gmk,v 1.2 1999/06/19 15:20:40 johna Exp $
# -------------------------------------------------------------
# GNUmakefile for CPPFLAGS for visualization USE phase.
# John Allison, 24th January 1998.
@@ -70,15 +70,6 @@ ifdef G4VIS_USE_OI
LOAD_IV = 1
endif
ifdef G4VIS_USE_RAYX
G4VIS_USE = 1
CPPFLAGS += -DG4VIS_USE_RAYX
CPPFLAGS += -I$(G4BASE)/visualization/G4Ray/include
VISLIBS += -lG4Ray
INC_X11 = 1
LOAD_X11 = 1
endif
ifdef G4VIS_USE_VRML
G4VIS_USE_VRML_OR_VRMLFILE = 1
CPPFLAGS += -DG4VIS_USE_VRML
+172 -2
View File
@@ -1,5 +1,5 @@
$Id: History,v 2.65 1998/12/15 19:29:12 gcosmo Exp $
$Name: geant4-00 $
$Id: History,v 1.50 1999/07/06 17:54:47 johna Exp $
$Name: geant4-00-01 $
-------------------------------------------------------------------
=========================================================
@@ -17,6 +17,176 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
6th July 1999 John Allison (config-01-00-10)
- Changed -L/usr/X11/lib to -L/usr/X11R6/lib for Linux.
6th July 1999 Gunter Folger (config-01-00-09)
- Adapt architecture.gmk for use of STL with WIN32-VC
Remove NICE from G4SYSTEM name WIN32-VC in architecture, globlib and
binmake.gmk
3rd July 1999 John Allison (config-01-00-08a)
- Added full-stop after i.e in binmake.gmk.
2nd July 1999 John Allison (config-01-00-08)
- Protected liblist against duplicate library names.
29th June 1999 Gabriele Cosmo (config-01-00-07)
- architecture.gmk: fixed bug in SUN-CC setup concerning XMLIBS and XMFLAGS.
-lXm was missing.
25th June 1999 Gabriele Cosmo
- Use $G4LIB/$G4SYSTEM instead of $G4LIBDIR in binmake.gmk for invoking
liblist and search for libname.map (granular libraries setup).
24th June 1999 John Allison
- Use liblist and libname.map in $G4LIBDIR.
19th June 1999 John Allison
- Removed references to G4Ray in G4VIS_BUILD.gmk and G4VIS_USE.gmk.
9th June 1999 Gunter Folger
- Adapt liblist.c for Windows, all changes contained withing #ifdef WIN32 blocks.
4th June 1999 John Allison
- Corrected USER_DEFINED_LDLIBS action.
- Changed `export G4TMP=$(G4TMP);' to `G4TMP=$(G4TMP); export G4TMP;'
- Added -I$(G4BASE)/geometry/solids/Boolean/include.
- Introduced LDLIBS_PREFINAL (Gunter).
2nd June 1999 John Allison
- Changed more occurrences of := to = to fix crash of liblist at startup.
1st June 1999 John Allison
- Changed LDLIBS2 := to LDLIBS2 = in binmake.gmk.
- Reverted $(G4WORKDIR)/tmp/$(G4SYSTEM)/$(G4TARGET) to $(G4TMPDIR).
- Added /$(G4TARGET) to liblist -d $(G4WORKDIR)/tmp/$(G4SYSTEM) in binmake.gmk.
31st May 1999 John Allison
- Added -I$(G4BASE)/processes/electromagnetic/lowenergy/include.
27th May 1999 Gabriele Cosmo (config-01-00-06)
- architecture.gmk: set default $G4INSTALL path to $HOME/geant4 (was still referring
to geant4beta...).
- Restored default CLHEP_BASE_DIR to /afs/cern.ch/sw/geant4/dev/CLHEP/$G4SYSTEM/pro.
- architecture.gmk: added -DG4NOT_ISO_DELETES for NT setup (G.Folger).
25th May 1999 Gabriele Cosmo
- architecture.gmk: fixed bug in SUN-CC setup. Replaced VISLIBS with LOADLIBS to
specify inclusion of socket libraries -lsocket -lnsl.
- binmake.gmk: fixed path to libname.map in the definition of LDLIBS2 for the
granular libs setup.
19th May 1999 John Allison
- Force linking of static library, libCLHEP.a.
18th May 1999 John Allison
- Specify -DG4NOT_ISO_DELETES in any case (not just G4USE_STL) and only
for HP, Sun and AIX.
17th May 1999 Gabriele Cosmo
- Added -DG4NOT_ISO_DELETES for DEC and AIX and moved inside G4USE_STL or
G4USE_OSPACE scope for all platforms which need it.
- Added path to wrappers for AIX.
17th May 1999 John Allison
- Added -DG4NOT_ISO_DELETES for Sun and HP.
- Changed order of -I$(OSPACEDIR)/ospace/std and -I$(OSPACEDIR)/ospace/stl.
13th May 1999 Gabriele Cosmo (config-01-00-05)
- architecture.gmk: G4USE_OSPACE setup is now independent from G4USE_STL which
is now devoted for generic STL setup. Added -DOS_NO_TYPEDEF_5 option to HP-aCC
for ObjectSpace.
12th May 1999 Gabriele Cosmo
- architecture.gmk: modified path to STL wrapper files directory to point to
$RWINC/wrappers/$G4SYSTEM. Wrappers are now differenciated according to
the architecture type.
11th May 1999 Gabriele Cosmo
- architecture.gmk: merged Isidro's OSPACE setup for HP-aCC.
Reorganised OSPACE options by introducing OSPACEINC variable.
10th May 1999 Guy Barrand
- interactivity.gmk ; put OpenGL things after OPACS things to have
correct link order.
10th May 1999 John Allison
- Added -I$(OSPACEDIR)/ospace/stl for Sun.
7th May 1999 John Allison
- Added GREP := grep except for SUN.
- Introduced STLInterface/wrappers directory. Testing on OSF+ObjectSpace (G.Cosmo).
6th May 1999 Gabriele Cosmo
- Introduced G4USE_OSPACE for ObjectSpace STL. If defined G4USE_STL is
set as well. Modified architecture.gmk and binmake.gmk.
6th May 1999 John Allison
- Removed extra library for circular dependencies. Now all solved!
5th May 1999 Gabriele Cosmo
- Fixed typo in architecture.gmk and defined OSPACEDIR to point to the G4
dev area where links to the ObjectSpace installations at CERN have been
created for all platforms. "pro" version points to ObjectSpace 2.1.
5th May 1999 John Allison
- Eliminated all references to RW in the case of G4USE_STL.
- Added OSPACE variables.
28th April 1999 Gabriele Cosmo (config-01-00-04)
- architecture.gmk: moved link for CLHEP to "new" to test the new version
1.4 of CLHEP. It will become "pro" again as soon as the new CLHEP will be
validated. NOTE: for DEC-cxx a custom CLHEP installation is used in order
to deactivate the ISO-ANSI options now set by default in CLHEP.
19th April 1999 Gabriele Cosmo (config-01-00-03)
- architecture.gmk: introduced CCFLAGS for all platforms. Set CCFLAGS to
"-Ae +DAportable" for HP-aCC to overcome compilation problems on liblist.c
18th April 1999 Youhei Morita
- architecture.gmk, binmake.gmk: introduced OBJY_LDLIB variable for
defining Objectivity library within G4ODBMS.
13th April 1999 Gabriele Cosmo
- architecture.gmk: added the following options in compilation:
o HP-aCC, SGI-CC: +Onolimit, -Olimit 5000 respectively.
Not suppress any optimization specifying a high or unlimited memory
limitation.
o DEC-cxx: -timplicit_local.
Get rid of the template repository by generating explicit template
instantiations used in the code with internal linkage.
13th April 1999 John Allison
- In binmake.gmk: - moved libmap target to source/GNUmakefile.
- extensive tidying.
12th April 1999 John Allison
- In liblist.c: - fixed bug to distinguish, e.g., track from tracking.
- improved printing.
- improved "Usage" comments.
- improved protection against bad input format.
- In binmake.gmk, used $(ECHO) to solve platform dependency of echo.
- In binmake.gmk for granular libraries:
- fully implemented -d option.
- Gave /tmp files a unique name.
- Removed repeated libraries - no longer necessary, all circular
dependencies seem solved.
9th April 1999 Frank Behner
- Fixed bug in liblist in -d option
- Changed binmake.gmk to use liblist -d
18th February 1999 John Allison
- Added G4USE_STL flag.
- Added code for linking granular libraries.
1st January 1999 Gunter Folger (config-01-00-02)
- Add FCLIBS for SUN.
January 29th 1999 - John Allison (config-01-00-01)
- Changed rd44 to sw/geant4.
December 15th, 1998 - G.Cosmo (config-00-04-11)
- Added G4_HAVE_BOOL to DEC-cxx.
- Cosmetic changes.
+233 -89
View File
@@ -1,4 +1,4 @@
# $Id: architecture.gmk,v 2.40 1998/12/15 19:29:13 gcosmo Exp $
# $Id: architecture.gmk,v 1.36 1999/07/06 17:54:49 johna Exp $
# ------------------------------------------------------------------------
# GEANT 4 - Architecture configuration script for GNU Make
#
@@ -25,10 +25,12 @@
#
# Linux-g++ Linux (Red Hat 5.1), egcs 1.1
#
# WIN32-VC-NICE NiceNT and Microsoft Visual C++ 5.0 installed
# locally as CD-ROM intallation
# ex. NiceNT at CERN (but CYGWIN32 installed
# locally, because not full installation on NICE)
# WIN32-VC NT and Microsoft Visual C++ 5.0 or Microsoft Visual C++ 6.0
# and using CYGWIN32 tools ( make, g++ as "makedepend", sh...)
# ( Note: you will need to set your environment, see installation
# guide.)
#
# WIN32-VC-NICE alias for the above, although NICE is not used anymore.
#
# WIN32-G++-NICE NiceNT and CYGWIN32 with g++ as base compiler
# ex. NiceNT at CERN (but CYGWIN32 and RogueWave
@@ -38,6 +40,13 @@
MAKEFLAGS= --no-print-directory
# Specify G4USE_STL when using STL, even for using our "temporary"
# STLinterface to RogueWave.
#
ifdef G4USE_STL
CPPFLAGS += -DG4USE_STL
endif
# If not specified, the default platform for G4SYSTEM is IBM-AIX ...
#
ifndef G4SYSTEM
@@ -45,10 +54,10 @@ ifndef G4SYSTEM
endif
# If not specified, the default path for G4 installation G4INSTALL is
# set to $HOME/geant4beta ...
# set to $HOME/geant4 ...
#
ifndef G4INSTALL
G4INSTALL := $(HOME)/geant4beta
G4INSTALL := $(HOME)/geant4
endif
# If not specified, the default path for G4 source G4BASE is
@@ -80,6 +89,7 @@ ifndef G4LIB
G4LIB := $(G4INSTALL)/lib
endif
G4DUMMY_VARIABLE:=$(shell [ ! -d $(G4LIB) ] && mkdir -p $(G4LIB) )
G4DUMMY_VARIABLE:=$(shell [ ! -d $(G4LIB)/$(G4SYSTEM) ] && mkdir -p $(G4LIB)/$(G4SYSTEM) )
# If not specified, the default path for G4 binaries G4BIN is
# set to $G4WORKDIR/bin/$G4SYSTEM ...
@@ -118,11 +128,11 @@ ifndef G4DEBUG
endif
#
# CLHEP path
# CLHEP path, etc.
#
ifndef CLHEP_BASE_DIR
CLHEP_BASE_DIR := /afs/cern.ch/rd44/dev/CLHEP/$(G4SYSTEM)/pro
CLHEP_BASE_DIR := /afs/cern.ch/sw/geant4/dev/CLHEP/$(G4SYSTEM)/pro
endif
CLHEP_INCLUDE_DIR := $(CLHEP_BASE_DIR)/include
CLHEP_LIB_DIR := $(CLHEP_BASE_DIR)/lib
@@ -131,33 +141,102 @@ ifndef CLHEP_LIB
endif
ifeq ($(G4SYSTEM),WIN32-VC-NICE)
#
# NiceNT policy for letter drive mapping
#
ifndef CLHEP_BASE_DIR
CLHEP_BASE_DIR := "z:\p32\lhcpp\clhep\1.1"
G4SYSTEM:=WIN32-VC
endif
CLHEP_INCLUDE_DIR := $(CLHEP_BASE_DIR)/include
CLHEP_LIB_DIR := $(CLHEP_BASE_DIR)/lib
CLHEP_LIB := libCLHEP-cl.a
ifeq ($(G4SYSTEM),WIN32-VC)
# CLHEP_BASE_DIR must be defined in the environment
CLHEP_INCLUDE_DIR := $(CLHEP_BASE_DIR)/include
CLHEP_LIB_DIR := $(CLHEP_BASE_DIR)/lib
CLHEP_LIB := CLHEP.lib
endif
#
# Rogue Wave Tools.h++ path
# Rogue Wave Tools.h++ path & ObjectSpace STL
#
ifndef RWBASE
RWBASE := /afs/cern.ch/rd44/dev/rogue/$(G4SYSTEM)
endif
RWINC := $(RWBASE)
RWLIBDIR := $(RWBASE)/lib
RWLIB := rwtool
ifeq ($(G4SYSTEM),HP-aCC)
RWBASE := /opt/aCC
RWINC := $(RWBASE)/include
RWLIBDIR := /usr/lib
endif
ifdef G4USE_OSPACE
#Object Space STL implementation
RWINC := $(G4BASE)/global/STLInterface
OSPACEDIR := /afs/cern.ch/sw/geant4/dev/ObjectSpace/$(G4SYSTEM)/pro/ToolKit
OSPACEINC := -I$(OSPACEDIR)/ospace/std -I$(OSPACEDIR)/ospace/stl
OSPACELIBS := -L$(OSPACEDIR)/lib -lospace
CPPFLAGS += -DG4USE_STL
ifeq ($(G4SYSTEM),WIN32-VC)
OSPACEDIR := $(OBJECT_SPACE_BASE)
OSPACEINC := -I$(OSPACEDIR)/ospace/std -I$(OSPACEDIR)/ospace/stl -I$(OSPACEDIR)
OSPACELIBS := '-libpath:c:\dev\ospace\lib std-2.1-vc5.0-mt.lib'
CPPFLAGS += -DG4USE_STL -DG4USE_OLDSTL
CPPFLAGS += -DOS_WIN_NT_4_0 -DOS_MULTI_THREADED -D_WIN32_WINNT $(OSPACEINC)
endif
else
ifdef G4USE_STL
# Native STL implemetation
RWINC := $(G4BASE)/global/STLInterface
else
ifdef G4USE_STLPORT
# STLport STL implementation (free) ( derived from SGI implementaion)
ifeq ($(G4SYSTEM),WIN32-VC)
RWINC := $(G4BASE)/global/STLInterface
STLPORTDIR := $(STLPORT_BASE)
OSPACEINC := -I$(STLPORTDIR)/stl
CPPFLAGS += -DG4USE_STL -DG4USE_OLDSTL
CPPFLAGS += -D_NOTHREADS -D__STL_NO_NEW_IOSTREAMS -D__STL_NO_NAMESPACES -D__STL_NO_NEW_STYLE_HEADERS
endif
endif #STLport
endif #STL
endif #OPSPACE
# default to RW if RWINC is not set...
ifndef RWINC
ifndef RWBASE
RWBASE := /afs/cern.ch/sw/geant4/dev/rogue/$(G4SYSTEM)
endif
RWINC := $(RWBASE)
RWLIBDIR := $(RWBASE)/lib
RWLIB := rwtool
ifeq ($(G4SYSTEM),HP-aCC)
RWBASE := /opt/aCC
RWINC := $(RWBASE)/include
RWLIBDIR := /usr/lib
endif
ifeq ($(G4SYSTEM),WIN32-VC)
# RWBASE must be defined in the environment
RWINC := $(RWBASE)
RWLIBDIR := $(RWBASE)"\lib"
RWLIB := mtlmt.lib
endif
ifeq ($(G4SYSTEM),WIN32-G++-NICE)
#
# locally installed RogueWave for g++ (mount mapping)
#
RWBASE := /rogue
RWINC := $(RWBASE)
RWLIBDIR := $(RWBASE)/lib
RWLIB := rwtool
endif
#
# Make dependencies files by g++ then need right RW include
#
ifdef RWINCGPP
RWINCGPP := -I$(RWINCGPP)
endif
endif # ifndef RWINC
#
# Paths for G4 data
@@ -172,33 +251,10 @@ ifndef G4LEVELGAMMADATA
G4LEVELGAMMADATA := $(G4DATA)/PhotonEvaporation
endif
ifeq ($(G4SYSTEM),WIN32-VC-NICE)
#
# NiceNT policy for letter drive mapping
#
ifndef RWBASE
RWBASE := "z:\p32\lhcpp\rw\tools\7.0.2\rogue"
endif
RWINC := $(RWBASE)
RWLIBDIR := $(RWBASE)"\lib"
RWLIB := mtldmt.lib
RWINCGPP := /rogue
endif
ifeq ($(G4SYSTEM),WIN32-G++-NICE)
#
# locally installed RogueWave for g++ (mount mapping)
#
RWBASE := /rogue
RWINC := $(RWBASE)
RWLIBDIR := $(RWBASE)/lib
RWLIB := rwtool
endif
#
# Toggle variables (positional qualifiers) between WIN32-VC and UNIX...
#
ifeq ($(G4SYSTEM),WIN32-VC-NICE)
ifeq ($(G4SYSTEM),WIN32-VC)
OUT_OBJ := -TP '-Fo'
FOR_OBJ := '-Fo'
OUT_LIB := '-out:'
@@ -226,29 +282,37 @@ else
FLIB_PATT := $(LIB_PATT)
endif
#
# Make dependencies files by g++ then need right RW include
#
ifdef RWINCGPP
RWINCGPP := -I$(RWINCGPP)
endif
#
# Variables for implicit rules, etc., as suggested in GNU Make manual...
#
CPPFLAGS += -Iinclude \
-I$(CLHEP_INCLUDE_DIR) \
-I$(RWINC)
CPPFLAGS += -Iinclude -I$(RWINC)
CPPFLAGS += -I$(CLHEP_INCLUDE_DIR)
#
# Positional qualifiers in action...
#
ifeq ($(G4SYSTEM),WIN32-VC-NICE)
LDFLAGS := -link $(LIB_PATH)$(CLHEP_LIB_DIR) $(LIB_PATH)$(RWLIBDIR)
LOADLIBS := $(CLHEP_LIB) $(RWLIB)
ifeq ($(G4SYSTEM),WIN32-VC)
LDFLAGS := -link $(LIB_PATH)$(CLHEP_LIB_DIR)
ifdef RWLIBDIR
LDFLAGS += $(LIB_PATH)$(RWLIBDIR)
endif
LOADLIBS := $(CLHEP_LIB)
ifdef RWLIB
LOADLIBS += $(RWLIB)
endif
else
LDFLAGS := -L$(CLHEP_LIB_DIR) -L$(RWLIBDIR)
LOADLIBS := -l$(CLHEP_LIB) -l$(RWLIB) -lm
## LDFLAGS := -L$(CLHEP_LIB_DIR)
LDFLAGS :=
ifdef RWLIBDIR
LDFLAGS += -L$(RWLIBDIR)
endif
## LOADLIBS := -l$(CLHEP_LIB)
LOADLIBS := $(CLHEP_LIB_DIR)/lib$(CLHEP_LIB).a
ifdef RWLIB
LOADLIBS += -l$(RWLIB)
endif
LOADLIBS += -lm
endif
#
@@ -310,6 +374,9 @@ AR := ar r
# Default echo used with makedepend. Changed for SUN-CC, Linux-g++.
ECHO:= echo
# Default grep used with source/GNUmakfile. Changed for SUN-CC.
GREP := grep
#
# Architecture dependent variables...
@@ -324,6 +391,7 @@ ifeq ($(G4SYSTEM),AIX-xlC)
else
CXXFLAGS := -g -qdbxextra -qcheck=all -qfullpath -qtwolink -+
FCFLAGS := -g
CCFLAGS := -g
endif
FC := xlf
FCFLAGS += -qextname
@@ -340,6 +408,19 @@ ifeq ($(G4SYSTEM),AIX-xlC)
ifndef OGLLIBS
OGLLIBS := -L$(OGLHOME)/lib -lGLU -lGL
endif
ifdef G4ODBMS
ifeq ($(OBJY_VERS),4.0.2)
OBJY_LDLIB := oo_shar.4.02
endif
endif
CPPFLAGS += -DG4NOT_ISO_DELETES
ifdef G4USE_STL
CPPFLAGS += -I$(RWINC)/wrappers/$(G4SYSTEM)
endif
ifdef G4USE_OSPACE
CPPFLAGS += -DOS_AIX_4 -DOS_NEW_CHECK -DOS_STL_ASSERT -DOS_NO_WSTRING -DOS_NO_ALLOCATORS
CPPFLAGS += -I$(RWINC)/wrappers/$(G4SYSTEM) $(OSPACEINC) -I$(OSPACEDIR)
endif
endif
# -------- SUN ---------
@@ -351,6 +432,7 @@ ifeq ($(G4SYSTEM),SUN-CC)
else
CXXFLAGS := -g
FCFLAGS := -g
CCFLAGS := -g
endif
# CXXFLAGS += -fnonstd
CFRONT_G4TEMPLATE_REPOSITORY := true
@@ -358,11 +440,11 @@ ifeq ($(G4SYSTEM),SUN-CC)
SHEXT := so
AR := $(CXX) -xar -ptr$(G4TREP) -o
ECHO := /bin/echo
GREP := /usr/xpg4/bin/grep
FCLIBS := -lM77 -lF77 -lsunmath
X11FLAGS := -I/usr/openwin/include/X11/extensions -I/usr/openwin/include/X11 -I/usr/openwin/include
X11LIBS := -L/usr/openwin/lib -L/usr/dt/lib -L/usr/ucblib -R/usr/openwin/lib -lXmu -lX11 -lXext
XMFLAGS := -I/usr/include/Motif1.2
XMLIBS := -L/usr/openwin/lib -L/usr/dt/lib -L/usr/ucblib -R/usr/openwin/lib -lXt -lX11
XMLIBS := -L/usr/openwin/lib -L/usr/dt/lib -L/usr/ucblib -R/usr/openwin/lib -lXt -lXm -lX11
XAWFLAGS := -I/usr/openwin/include/X11
XAWLIBS := -L/usr/openwin/lib -L/usr/dt/lib -L/usr/ucblib -R/usr/openwin/lib -lXaw -lXmu -lXt -lX11 -lXext
ifndef OGLFLAGS
@@ -371,8 +453,21 @@ ifeq ($(G4SYSTEM),SUN-CC)
ifndef OGLLIBS
OGLLIBS := -L$(OGLHOME)/lib -lGLU -lGL
endif
ifdef G4ODBMS
ifeq ($(OBJY_VERS),4.0.2)
OBJY_LDLIB := oo
endif
endif
CPPFLAGS += -DSOCKET_IRIX_SOLARIS
VISLIBS += -L/usr/lib -lsocket -lnsl
LOADLIBS += -L/usr/lib -lsocket -lnsl
CPPFLAGS += -DG4NOT_ISO_DELETES
ifdef G4USE_STL
CPPFLAGS += -I$(RWINC)/wrappers/$(G4SYSTEM)
endif
ifdef G4USE_OSPACE
CPPFLAGS += -DOS_SOLARIS_2_5 -DOS_NEW_CHECK -DOS_STL_ASSERT -DOS_NO_WSTRING -DOS_NO_ALLOCATORS
CPPFLAGS += -I$(RWINC)/wrappers/$(G4SYSTEM) $(OSPACEINC) -I$(OSPACEDIR)
endif
endif
# -------- HP ---------
@@ -380,10 +475,11 @@ endif
ifeq ($(G4SYSTEM),HP-aCC)
CXX := aCC
ifdef G4OPTIMISE
CXXFLAGS := +O2
CXXFLAGS := +O2 +Onolimit
else
CXXFLAGS := -g
CXXFLAGS := -g
FCFLAGS := -g
CCFLAGS := -g
endif
CXXFLAGS += +DAportable
CPPFLAGS += -I/usr
@@ -393,6 +489,7 @@ ifeq ($(G4SYSTEM),HP-aCC)
G4_HAVE_BOOL := yes
FC := f77
FCFLAGS += +E6 +ppu
CCFLAGS += -Ae +DAportable
X11FLAGS := -I/usr/include/X11/extensions -I/usr/contrib/X11R6/include -I/usr/contrib/X11R6/include/X11
X11LIBS := -L/usr/contrib/X11R6/lib -lXmu -L/usr/lib -lXt -lXext -lX11
XMFLAGS := -I/usr/include/Motif1.2
@@ -406,6 +503,20 @@ ifeq ($(G4SYSTEM),HP-aCC)
OGLLIBS := -L$(OGLHOME)/lib -lGLU -lGL
OGLLIBS += -L/opt/graphics/common/lib -lXwindow -lhpgfx -lXhp11 -ldld
endif
ifdef G4ODBMS
ifeq ($(OBJY_VERS),4.0.2)
OBJY_LDLIB := oo
endif
endif
CPPFLAGS += -DG4NOT_ISO_DELETES
ifdef G4USE_STL
CPPFLAGS += -I$(RWINC)/wrappers/$(G4SYSTEM) -DG4USE_EXPLICIT_TYPES_IN_TEMPLATES
endif
ifdef G4USE_OSPACE
CPPFLAGS += -DOS_HPUX_10_20 -DOS_NEW_CHECK -DOS_STL_ASSERT -DOS_NO_WSTRING -DOS_NO_ALLOCATORS
CPPFLAGS += -DOS_NO_TYPEDEF_5 -D__HPACC_NOEH -DG4USE_EXPLICIT_TYPES_IN_TEMPLATES
CPPFLAGS += -I$(RWINC)/wrappers/$(G4SYSTEM) $(OSPACEINC) -I$(OSPACEDIR)
endif
endif
# -------- SGI ---------
@@ -413,11 +524,13 @@ endif
ifeq ($(G4SYSTEM),SGI-CC)
CXX := CC
ifdef G4OPTIMISE
CXXFLAGS := -O -ptused
CXXFLAGS := -O -Olimit 5000
else
CXXFLAGS := -g -ptused
FCFLAGS := -g
CXXFLAGS := -g
FCFLAGS := -g
CCFLAGS := -g
endif
CXXFLAGS += -ptused
FC := f77
FCLIBS := -lftn
SHEXT := so
@@ -431,6 +544,10 @@ ifeq ($(G4SYSTEM),SGI-CC)
OGLLIBS := -L/usr/lib -lGLU -lGL
endif
CPPFLAGS += -DSOCKET_IRIX_SOLARIS
ifdef G4USE_OSPACE
CPPFLAGS += -DOS_IRIX_6_2 -DOS_NEW_CHECK -DOS_STL_ASSERT -DOS_NO_WSTRING -DOS_NO_ALLOCATORS
CPPFLAGS += $(OSPACEINC) -I$(OSPACEDIR)
endif
endif
# -------- DEC ---------
@@ -442,11 +559,12 @@ ifeq ($(G4SYSTEM),DEC-cxx)
else
CXXFLAGS := -gall
FCFLAGS := -g
CCFLAGS := -g
endif
CFRONT_G4TEMPLATE_REPOSITORY := true
G4_HAVE_BOOL := yes
LDFLAGS += -taso
CXXFLAGS += -ieee
CXXFLAGS += -ieee -timplicit_local
FC := f77
FCLIBS := -lUfor -lfor -lFutil -lots
X11FLAGS := -I/usr/include/X11/extensions -I/usr/include/X11
@@ -458,6 +576,15 @@ ifeq ($(G4SYSTEM),DEC-cxx)
OGLLIBS := -L$(OGLHOME)/lib -lGLU -lGL
# OGLLIBS := -lMesaGLU -lMesaGL
endif
ifdef G4USE_STL
CPPFLAGS += -I$(RWINC)/wrappers/$(G4SYSTEM)
CXXFLAGS += -nostdnew
endif
ifdef G4USE_OSPACE
CPPFLAGS += -DOS_OSF1_4 -DOS_NEW_CHECK -DOS_STL_ASSERT -DOS_NO_WSTRING -DOS_NO_ALLOCATORS -D__NO_EDG_EXCEPTION_CLASSES
CPPFLAGS += -I$(RWINC)/wrappers/$(G4SYSTEM) $(OSPACEINC) -I$(OSPACEDIR)
CXXFLAGS += -nostdnew
endif
endif
# ------ GNU/LINUX ------
@@ -470,14 +597,15 @@ ifeq ($(G4SYSTEM),Linux-g++)
CXXFLAGS += -O
else
CXXFLAGS += -g
FCFLAGS := -g
FCFLAGS := -g
CCFLAGS := -g
endif
FC := g77
FCFLAGS += -fno-automatic -fno-backslash -fno-second-underscore
FCLIBS := -lf2c
ECHO := /bin/echo
X11FLAGS := -I/usr/include/X11/extensions -I/usr/include/X11
X11LIBS := -L/usr/X11/lib -lXmu -lXt -lXext -lX11 -lSM -lICE
X11LIBS := -L/usr/X11R6/lib -lXmu -lXt -lXext -lX11 -lSM -lICE
XMFLAGS := -I/usr/X11R6/include
XMLIBS := -lXm -lXpm
ifndef OGLFLAGS
@@ -487,29 +615,41 @@ ifeq ($(G4SYSTEM),Linux-g++)
OGLLIBS := -L$(OGLHOME)/lib -lGLU -lGL
endif
OIVFLAGS += -I$(OIHOME)/include
ifdef G4USE_OSPACE
CPPFLAGS += -DOS_LINUX_2 -DOS_NEW_CHECK -DOS_STL_ASSERT -DOS_NO_WSTRING -DOS_NO_ALLOCATORS
CPPFLAGS += -I$(OSPACEDIR)/ospace/std -I$(OSPACEDIR)
endif
endif
# ------ WIN32/VC/NICE ------
# ------ WIN32/VC ------
#
ifeq ($(G4SYSTEM),WIN32-VC-NICE)
ifeq ($(G4SYSTEM),WIN32-VC)
CXX := CL
G4_HAVE_BOOL := yes
G4_NO_CBRT := yes
ifdef G4OPTIMISE
CXXFLAGS += -Ox
else
CXXFLAGS += -Od
CXXFLAGS += -Od -Zi -Fd$(G4LIBDIR)/lib$(name)
endif
CXXFLAGS += -GX -Zm200 -DWIN32 # -TP
CXXFLAGS += -MD -GX -Zm200 -nologo -DWIN32 -D_CONSOLE
CXXFLAGS += -D_WIN32 -DOS -DG4NOT_ISO_DELETES
CPPFLAGS += -DWIN32 -DRW_NO_XMSG
#
# Should set $INCLUDE environment, if not set as below
#
# CXXFLAGS += -I'\\srv1_info\v2\vc50pro1\DEVSTUDIO\VC\INCLUDE'
ifdef G4USE_OSPACE
CXXFLAGS += $(OSPACEINC)
else
ifdef G4USE_STLPORT
CXXFLAGS += $(OSPACEINC)
endif #stlport
endif #ospace
LDFLAGS += -FORCE
LDFLAGS += -FORCE /NODEFAULTLIB:MSVCRT.dll
#
# Should set $LIB environment, if not set as below
# Should set $LIB environment to include VC++ Studio lib directories, e.g.
#
# $(LIB_PATH)"c:\ProgramFiles\DevStudio\vc\lib" \
# $(LIB_PATH)'\\srv1_info\v2\vc50pro1\DEVSTUDIO\VC\LIB' \
@@ -561,7 +701,11 @@ ifdef G4_NO_CBRT
endif
# Standard Template Library (STL) not installed
CPPFLAGS += -DRW_NO_STL
ifndef G4USE_STL
ifndef G4USE_OSPACE
CPPFLAGS += -DRW_NO_STL
endif
endif
# Verbosity code can be left out (for better performance)
# by defining G4_NO_VERBOSE.
+136 -60
View File
@@ -1,4 +1,4 @@
# $Id: binmake.gmk,v 2.22 1998/12/01 22:59:47 gcosmo Exp $
# $Id: binmake.gmk,v 1.29 1999/07/06 15:19:42 gunter Exp $
# ----------------------------------------------------------
# Script defining rules and paths for making binaries.
# Gabriele Cosmo, 25/06/1998.
@@ -27,6 +27,7 @@ ifndef INCFLAGS
-I$(G4BASE)/particles/hadrons/barions/include \
-I$(G4BASE)/particles/hadrons/ions/include \
-I$(G4BASE)/particles/hadrons/mesons/include \
-I$(G4BASE)/particles/shortlived/include \
-I$(G4BASE)/processes/management/include \
-I$(G4BASE)/processes/general/include \
-I$(G4BASE)/processes/decay/include \
@@ -37,6 +38,7 @@ ifndef INCFLAGS
-I$(G4BASE)/processes/electromagnetic/muons/include \
-I$(G4BASE)/processes/electromagnetic/utils/include \
-I$(G4BASE)/processes/electromagnetic/xrays/include \
-I$(G4BASE)/processes/electromagnetic/lowenergy/include \
-I$(G4BASE)/processes/hadronic/management/include \
-I$(G4BASE)/processes/hadronic/processes/include \
-I$(G4BASE)/processes/hadronic/util/include \
@@ -58,6 +60,7 @@ ifndef INCFLAGS
-I$(G4BASE)/geometry/management/include \
-I$(G4BASE)/geometry/solids/CSG/include \
-I$(G4BASE)/geometry/solids/BREPS/include \
-I$(G4BASE)/geometry/solids/Boolean/include \
-I$(G4BASE)/geometry/solids/STEP/include \
-I$(G4BASE)/geometry/solids/STEPinterface/include \
-I$(G4BASE)/geometry/volumes/include \
@@ -92,84 +95,162 @@ ifdef G4ODBMS
-DHep_HAS_BUILDIN_BOOL_CONSTANTS
endif
ifndef LDLIBS
ifdef G4EXLIB
LDLIBS := -l$(G4TARGET) $(VISLIBS) $(UILIBS)
else
LDLIBS := $(VISLIBS) $(UILIBS)
endif
ifdef G4ODBMS
LDLIBS += -lG4persistency
endif
LDLIBS += \
-lG4readout \
-lG4run \
-lG4event \
-lG4tracking \
-lG4processes \
-lG4particles \
-lG4digits+hits \
-lG4track \
-lG4materials \
-lG4geometry \
-lG4graphics_reps \
-lG4intercoms \
-lG4global \
$(INTYLIBS)
endif
ifdef G4ODBMS
LDFLAGS += -L$(OBJY_DIR)/lib \
-L$(HEP_ODBMS_DIR)/lib
# Note: -loo_sahr.4.02 and -lHepODBMS should be placed
# _before_ -l$(CLHEP_LIB) -l$(RWLIB)
LDLIBS += -loo_shar.4.02 -lHepODBMS
endif
CPPFLAGS += $(INCFLAGS)
LDFLAGS += -L$(G4LIBDIR)
LDLIBS += $(LOADLIBS)
G4TMPDIR := $(G4TMP)/$(G4SYSTEM)/$(G4TARGET)
G4BINDIR := $(G4BIN)/$(G4SYSTEM)
ifdef G4EXLIB
G4LIBDIR := $(G4TMPDIR)
LDFLAGS += -L$(G4LIBDIR)
include $(G4INSTALL)/config/common.gmk
G4LIBDIR := $(G4TMPDIR)
LDFLAGS += -L$(G4LIBDIR)
include $(G4INSTALL)/config/common.gmk
endif
GLOBALLIBS := $(shell test -f $(G4LIB)/$(G4SYSTEM)/libG4global.a && echo yes)
ifdef LDLIBS
USER_DEFINED_LDLIBS := 1
endif
# Because of the script for granular libraries which replaces part of LDLIBS
# and because of the way user defined LDLIBS was augmented historically I
# have split LDLIBS into 4 parts...
#
ifndef USER_DEFINED_LDLIBS
# LDLIBS1 contains the very high level libraries...
#
ifdef G4EXLIB
LDLIBS1 := -l$(G4TARGET)
endif
# VISLIBS and UILIBS are now handles by the granular library script...
#
ifdef GLOBALLIBS
LDLIBS1 += $(VISLIBS) $(UILIBS)
endif
ifdef G4ODBMS
LDLIBS1 += -lG4persistency
endif
ifdef GLOBALLIBS
LDLIBS2 := -lG4readout \
-lG4run \
-lG4event \
-lG4tracking \
-lG4processes \
-lG4particles \
-lG4digits+hits \
-lG4track \
-lG4materials \
-lG4geometry \
-lG4graphics_reps \
-lG4intercoms \
-lG4global
else
# The next line specifically should read LDLIBS2 = , not LDLIBS2 :=, so
# that it is not expanded until the directory G4TMPDIR is created.
LDLIBS2 = $(shell \
G4TMP=$(G4TMP); export G4TMP; \
if [ \( -f $(G4LIB)/$(G4SYSTEM)/liblist \
-a -f $(G4LIB)/$(G4SYSTEM)/libname.map \) ]; then \
$(G4LIB)/$(G4SYSTEM)/liblist \
-d $(G4TMPDIR) \
< $(G4LIB)/$(G4SYSTEM)/libname.map; fi)
# Extra libraries to resolve remaining circular dependencies...
# LDLIBS2 +=
endif
# LDLIBS3 contains the first set of low level libraries...
#
LDLIBS3 += $(INTYLIBS)
endif # ifndef USER_DEFINED_LDLIBS
# LDLIBS4 contains the next set of low level libraries which historically
# (why?) the user is not supposed to be able to define...
#
ifdef G4ODBMS
LDFLAGS += -L$(OBJY_DIR)/lib \
-L$(HEP_ODBMS_DIR)/lib
# Note: -l$(OBJY_LDLIB) and -lHepODBMS should be placed
# _before_ -l$(CLHEP_LIB) -l$(RWLIB)
LDLIBS4 += -l$(OBJY_LDLIB) -lHepODBMS
endif
ifdef G4USE_OSPACE
LDLIBS4 += $(OSPACELIBS)
endif
LDLIBS4 += $(EXTRALIBS)
LDLIBS4 += $(LOADLIBS)
# Finally assemble libraries...
#
ifdef USER_DEFINED_LDLIBS
LDLIBS_PREFINAL := $(LDLIBS)
else
LDLIBS_PREFINAL = $(LDLIBS1) $(LDLIBS2) $(LDLIBS3)
endif
LDLIBS_PREFINAL += $(LDLIBS4)
ifeq ($(G4SYSTEM),WIN32-VC)
WIN32TMP := $(patsubst -L%,$(LIB_PATH)%,$(LDFLAGS))
LDFLAGS = $(patsubst /,$(PATH_DEL),$(WIN32TMP))
LDLIBS = $(patsubst -l%,lib%.a,$(LDLIBS_PREFINAL))
else
LDLIBS = $(LDLIBS_PREFINAL)
endif
LDLIBS += $(EXTRALIBS)
sources := $(wildcard $(G4TARGET).cc)
objects := $(patsubst %.cc,$(G4TMPDIR)/exe/%.o,$(sources))
dependencies := $(patsubst %.cc,$(G4TMPDIR)/exe/%.d,$(sources))
.PHONY: bin clean clean_bin
LINK_DEPENDENCIES := $(G4TMPDIR)/exe/obj.last
.PHONY: bin clean clean_bin debug
# Make $(G4TARGET) executable.
bin: $(G4BINDIR)/$(G4TARGET)
ifeq ($(G4SYSTEM),WIN32-VC-NICE)
WIN32TMP := $(patsubst -L%,$(LIB_PATH)%,$(LDFLAGS))
LDFLAGS = $(patsubst /,$(PATH_DEL),$(WIN32TMP))
LDLIBS := $(patsubst -l%,lib%.a,$(LDLIBS))
$(G4BINDIR)/$(G4TARGET): $(LINK_DEPENDENCIES)
ifndef USER_DEFINED_LDLIBS
ifndef GLOBALLIBS
@echo "WARNING: This assumes you are using granular libraries!"
@echo "WARNING: It looked for your global library G4global and,"
@echo " not finding it, assumes you are using granular"
@echo " libraries."
@echo "WARNING: If you did not intend this, interrupt now (CTRL-C),"
@echo " and go back and make global libraries, i.e.,"
@echo ' cd $$G4INSTALL/source'
@echo " gmake global"
@if [ ! \( -f $(G4LIB)/$(G4SYSTEM)/liblist \
-a -f $(G4LIB)/$(G4SYSTEM)/libname.map \) ]; then \
echo "ERROR: No liblist program or library map file."; \
echo " These are needed for building with granular"; \
echo " libraries."; \
echo ' cd $$G4INSTALL/source'; \
echo " gmake"; \
echo " or if you are sure you have already made all the"; \
echo " granular libraries:"; \
echo " gmake libmap"; \
exit 1; fi
endif
endif
$(G4BINDIR)/$(G4TARGET): $(G4TMPDIR)/exe/obj.last
@if [ ! -d $(G4BINDIR) ] ; then mkdir $(G4BINDIR) ;fi
ifdef CPPVERBOSE
$(CXX) $(CXXFLAGS) $(CPPFLAGS) \
-o $(G4BINDIR)/$(G4TARGET) $(objects) $(LDFLAGS) $(LDLIBS)
-o $(G4BINDIR)/$(G4TARGET) $(objects) $(LDFLAGS) \
$(LDLIBS)
else
@echo Linking $(G4TARGET) ...
@$(CXX) $(CXXFLAGS) $(CPPFLAGS) \
-o $(G4BINDIR)/$(G4TARGET) $(objects) $(LDFLAGS) $(LDLIBS)
-o $(G4BINDIR)/$(G4TARGET) $(objects) $(LDFLAGS) \
$(LDLIBS)
endif
# Touch the versioning file
@@ -197,13 +278,8 @@ $(G4TMPDIR)/exe/$(G4TARGET).d: $(G4TARGET).cc
@if [ ! -d $(G4TMPDIR) ] ; then mkdir $(G4TMPDIR) ;fi
@if [ ! -d $(G4TMPDIR)/exe ] ; then mkdir $(G4TMPDIR)/exe ;fi
@echo Making dependency for file $<...
ifeq ($(G4SYSTEM),Linux-g++)
@($(ECHO) -n $(G4TMPDIR)/exe/ ; \
@($(ECHO) $(G4TMPDIR)/exe/\\c ; \
g++ -MM $(RWINCGPP) $(CPPFLAGS) $< ) | sed 's!$(G4TMPDIR)/exe/$*.o!& $@!' >$@
else
@($(ECHO) $(G4TMPDIR)/\\c ; \
g++ -MM $(RWINCGPP) $(CPPFLAGS) $< ) | sed 's!$(G4TMPDIR)/exe/$*.o!& $@!' >$@
endif
-include $(dependencies)
clean:
+1 -1
View File
@@ -1,4 +1,4 @@
# $Id: common.gmk,v 2.7 1998/07/29 00:53:08 gcosmo Exp $
# $Id: common.gmk,v 1.1 1999/01/07 15:58:32 gunter Exp $
# ----------------------------------------------------------------
# Common part of GNUmakefile for libraries. John Allison, 5/7/95.
# ----------------------------------------------------------------
+2 -2
View File
@@ -1,4 +1,4 @@
# $Id: globlib.gmk,v 2.15 1998/12/11 00:40:21 gcosmo Exp $
# $Id: globlib.gmk,v 1.2 1999/07/06 15:19:44 gunter Exp $
# --------------------------------------------------------------
# Script for compound libraries. Gabriele Cosmo, 25/6/98.
# --------------------------------------------------------------
@@ -36,7 +36,7 @@ $(G4LIBDIR)/lib$(name).a: \
#
#
#
@if [ X$(G4SYSTEM) = XWIN32-VC-NICE ] ; i=NO; \
@if [ X$(G4SYSTEM) = XWIN32-VC ] ; i=NO; \
then \
(( for lib in $(SUBLIBS); \
do ( if [ $$i = NO ]; \
+11 -9
View File
@@ -11,7 +11,7 @@
# Other libraries
########################### OpenGL, Inventor ############
########################### Inventor ############
# Should be before OpenGL.
ifdef INC_IV
@@ -23,15 +23,8 @@ ifdef LOAD_IV
INTYLIBS += $(OIVLIBS)
endif
ifdef INC_GL
CPPFLAGS += $(OGLFLAGS)
endif
ifdef LOAD_GL
INTYLIBS += $(OGLLIBS)
endif
########################### OPACS #######################
# X11 things must come after.
# OpenGL, X11 things must come after.
ifdef INC_OPACS
CPPFLAGS += -I$(COROOT)/include -I$(XXROOT)/include -I$(WOROOT)/include
@@ -70,6 +63,15 @@ endif
endif
########################### OpenGL ###############################
ifdef INC_GL
CPPFLAGS += $(OGLFLAGS)
endif
ifdef LOAD_GL
INTYLIBS += $(OGLLIBS)
endif
########################### Motif, Athena, X11 ###################
# Motif raise X11 flags.
+512
View File
@@ -0,0 +1,512 @@
/* $Id: liblist.c,v 1.7 1999/07/02 12:27:38 stesting Exp $ */
/*
Given a "libname.map" file on standard input and a list or directory
of .d dependency files liblist produces:
a) without -l option, a library list ordered according to the libname.map,
giving a warning if conflicting dependencies are found in the .d files.
b) with -l option, another libname.map, ordered according firstly to the
original libname.map file, then reordered according to the dependencies
found in the .d files. This option is used for compiling the file
libname.map from all the dependencies.
The .d files are specfied in the argument(s).
The libname.map is on standard input.
Usage:
liblist *.d < libname.map
liblist -d <ddir> < libname.map
liblist -l *.d < libname.map
liblist -ld <ddir> < libname.map
liblist -l -d <ddir> < libname.map
where <ddir> is a directory name of a directory which is recursively
searched for dependency files.
Frank Behner, John Allison 13th February 1999.
*/
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <dirent.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#define BUFSIZE 1000000
#define TRIGSIZE 1000
#define NLIBMAX 200
extern char *optarg;
extern int optind, opterr, optopt;
char** parsedir(char *directory,int *argc)
{
DIR *actualdir;
FILE *actualfile;
struct dirent *entry;
char *buffer=0;
struct stat status;
char **targv=0,**ptr,**phelp;
int len,targc,s;
/*Open the actual directory*/
actualdir=opendir(directory);
/*Loop over all entries */
for(entry=readdir(actualdir);entry!=NULL;entry=readdir(actualdir))
{
/* Throw away . and .. */
if(strcmp(entry->d_name,".")==0 ||
strcmp(entry->d_name,"..")==0) continue;
/* Obtain the status information of that entry */
if(buffer) free(buffer);
buffer=(char*) malloc((strlen(directory)+
strlen(entry->d_name)+2)*sizeof(char));
strcpy(buffer,directory);
strcat(buffer,"/");
strcat(buffer,entry->d_name);
s=stat(buffer,&status);
if(s==0)
{
if(S_ISDIR(status.st_mode))
{
/* a directory, so we are going recursive*/
targc=0;
ptr=parsedir(buffer,&targc);
if(targc)
{
phelp=targv;
targv=(char**) malloc((*argc+targc)*sizeof(char*));
memcpy(targv,phelp,*argc*sizeof(char*));
memcpy(&targv[*argc],ptr,targc*sizeof(char*));
*argc+=targc;
free(phelp);
free(ptr);
}
}
else if(S_ISREG(status.st_mode))
{
/* a regular file is it .d? */
len=strlen(entry->d_name);
if(entry->d_name[len-2]=='.' && entry->d_name[len-1]=='d')
{
phelp=targv;
targv=(char**) malloc((*argc+1)*sizeof(char*));
memcpy(targv,phelp,*argc*sizeof(char*));
targv[*argc]=strdup(buffer);
(*argc)++;
free(phelp);
}
}
}
else
perror(" No status");
}
if(buffer) free(buffer);
closedir(actualdir);
return targv;
}
int main (int argc, char** argv) {
char buffer[BUFSIZE],*bufferPtr,workbuf[256];
char *ptr,*p,**pp,**pp1,**pp2,*directory=0;
char **rargv;
int i,optl=0,swapping,c,rargc;
FILE *fp;
#ifdef _WIN32
char *ntg4tmp=0,*ntg4tmp1=0;
int nti;
#endif
struct libmap_
{
char *lib;
char *trigger;
int used;
char **uses;
struct libmap_ *next;
};
struct libmap_ *libmap=0,*libmapPtr=0,*libmapPtr1=0,*libmapPtr2=0,
*prevPtr1,*prevPtr2,*tmpp,*userLibmapPtr;
while((c=getopt(argc,argv,"ld:"))!=EOF)
{
switch(c)
{
case 'l':
optl=1;
break;
case 'd':
directory=strdup(optarg);
break;
}
}
/*Adjust parameters after parsing options */
if(optind<argc)
{
rargv=&argv[optind];
rargc=argc-optind;
}
else
{
rargv=0;
rargc=0;
}
if(directory)
{
if(rargc==0)
{
rargv=parsedir(directory,&rargc);
}
else
{
fprintf(stderr," ERROR: If you specify a directory don't also specify files\n");
exit(-1);
}
}
if(optl)fprintf(stderr," Reading library name map file...\n");
while (!feof(stdin))
{
/* Get library name... */
gets(buffer);
if(feof(stdin)) break;
ptr=strtok(buffer,":\n");
/* Check for duplicate names... */
for(libmapPtr1=libmap;libmapPtr1;libmapPtr1=libmapPtr1->next)
{
if(strcmp(libmapPtr1->lib,ptr)==0)
{
fprintf(stderr," ERROR: Duplicate library name: %s\n",ptr);
fprintf(stderr,
" Perhaps a duplicate subdirectory with"
" a GNUmakefile with the same library name.\n"
);
exit(1);
}
}
if(libmap)
{
libmapPtr->next=(struct libmap_*) malloc(sizeof(struct libmap_));
libmapPtr=libmapPtr->next;
}
else /* First time through anchor libmapPtr to libmap. */
{
libmap=(struct libmap_*) malloc(sizeof(struct libmap_));
libmapPtr=libmap;
}
libmapPtr->next=0;
libmapPtr->lib=strdup(ptr);
libmapPtr->used=0;
libmapPtr->uses=(char**)calloc(NLIBMAX,sizeof(char*));
/* If option -l not specified, fill uses list... */
if(!optl)
{
pp=libmapPtr->uses;
if(ptr)
{
ptr=strtok(NULL," \n");
while (ptr)
{
*pp=strdup(ptr);
pp++;
ptr=strtok(NULL," \n");
}
}
}
/* Get directory name... */
gets(buffer);
ptr=strtok(buffer,"/");
if(!ptr)
{
fprintf(stderr," ERROR: \"/\" before \"source\" expected.\n");
exit(1);
}
while(ptr&&strcmp (ptr,"source"))ptr=strtok(NULL,"/");
ptr=strtok(NULL,"/");
if(!ptr)
{
fprintf(stderr," ERROR: \"source\" expected.\n");
exit(1);
}
libmapPtr->trigger=(char*)malloc(TRIGSIZE);
strcpy(libmapPtr->trigger,ptr);
ptr=strtok(NULL,"/");
while(ptr&&strcmp(ptr,"GNUmakefile"))
{
strcat(libmapPtr->trigger,"/");
strcat(libmapPtr->trigger,ptr);
ptr=strtok(NULL,"/");
}
if(!ptr)
{
fprintf(stderr," ERROR: \"source/<unique-sub-path>/GNUmakefile\" expected.\n");
exit(1);
}
}
if(optl)fprintf(stderr," Reading dependency files...\n");
#ifdef _WIN32
ntg4tmp=getenv("G4TMP");
if ( ! ntg4tmp )
{
fprintf(stderr," ERROR: Cannot find environment variable G4TMP\n");
exit(1);
}
ntg4tmp1=strdup(ntg4tmp);
#endif
for(i=0;i<rargc;i++)
{
fp=fopen(rargv[i],"r");
fgets(buffer,BUFSIZE,fp);
#ifdef _WIN32
ptr=strchr(ntg4tmp1,':');
if ( ptr ) *(ptr+1)='\0';
while ( ptr=strchr(buffer,'\\') ) *ptr='/';
while (ntg4tmp1!=NULL && (ptr=strstr(buffer,ntg4tmp1))!=NULL )
{
for(nti=0;nti<strlen(ntg4tmp1);nti++) ptr[nti]=' ';
}
#endif
/* Clip target out of dependency file... */
ptr=strtok(buffer,":");
/* Look for a "user" library... */
for(libmapPtr=libmap;libmapPtr;libmapPtr=libmapPtr->next)
{
strcpy(workbuf,libmapPtr->lib);
/* Add trailing "/" to distinguish track/ and tracking/, etc. */
strcat(workbuf,"/");
if(strstr(ptr,workbuf)) break;
}
if(libmapPtr)
{
userLibmapPtr=libmapPtr;
}
else
{
userLibmapPtr=0;
}
/* Look for a "used" library and add it to the "user" uses list... */
do
{
for(libmapPtr=libmap;libmapPtr;libmapPtr=libmapPtr->next)
{
strcpy(workbuf,libmapPtr->trigger);
strcat(workbuf,"/include");
ptr=strstr(buffer,workbuf);
if(ptr)
{
libmapPtr->used=1;
if(userLibmapPtr)
{
for(pp=userLibmapPtr->uses;*pp;pp++)
{
if(strcmp(*pp,libmapPtr->lib)==0)break;
}
if(!*pp)*pp=libmapPtr->lib;
}
}
}
fgets(buffer,BUFSIZE,fp);
#ifdef _WIN32
while ( ptr=strchr(buffer,'\\') ) *ptr='/';
while (ntg4tmp1 && (ptr=strstr(buffer,ntg4tmp1)) )
{
for(nti=0;nti<strlen(ntg4tmp1);nti++) ptr[nti]=' ';
}
#endif
} while(!feof(fp));
fclose(fp);
}
#ifdef _WIN32
free(ntg4tmp1);
#endif
if(optl) /* This option is used for compiling the file libname.map
from all the dependencies. */
{
fprintf(stderr," Checking for circular dependencies...\n");
for(libmapPtr=libmap;libmapPtr;libmapPtr=libmapPtr->next)
{
for(pp=libmapPtr->uses;*pp;pp++)
{
for(libmapPtr1=libmap;libmapPtr1!=libmapPtr;
libmapPtr1=libmapPtr1->next)
{
if(strcmp(libmapPtr1->lib,*pp)==0)
{
for(pp1=libmapPtr1->uses;*pp1;pp1++)
{
if(strcmp(*pp1,libmapPtr->lib)==0)break;
}
if(*pp1)
{
fprintf
(stderr,
" WARNING: %s and %s use each other.\n",
libmapPtr->lib,
libmapPtr1->lib);
}
}
else
{
/* Not right yet...
for(pp1=libmapPtr1->uses;*pp1;pp1++)
{
for(libmapPtr0=libmap;libmapPtr0!=libmapPtr1;
libmapPtr0=libmapPtr0->next)
{
if(libmapPtr0==*pp)
{
fprintf
(stderr,
" WARNING: triangular dependecy:\n"
" %s uses %s uses %s uses %s.\n",
libmapPtr->lib,
libmapPtr1->lib,
libmapPtr0->lib,
libmapPtr->lib);
}
}
}
*/
}
}
}
}
fprintf(stderr," Reordering according to dependencies...\n");
do
{
swapping=0;
prevPtr2=0;
for(libmapPtr=libmap;libmapPtr;libmapPtr=libmapPtr->next)
{
for(pp=libmapPtr->uses;*pp;pp++)
{
prevPtr1=0;
for(libmapPtr1=libmap;libmapPtr1!=libmapPtr;
libmapPtr1=libmapPtr1->next)
{
if(strcmp(libmapPtr1->lib,*pp)==0)
{
/* Check that 1st doesn't use 2nd... */
for(pp1=libmapPtr1->uses;*pp1;pp1++)
{
if(strcmp(*pp1,libmapPtr->lib)==0)break;
}
if(!*pp1) /* If not... */
{
swapping=1;
/* Make previous of 1st now point to 2nd... */
if(prevPtr1)
{
prevPtr1->next=libmapPtr;
}
else
{
libmap=libmapPtr;
}
/* Make 2nd now point to what 1st did, unless
it's adjacent, in which case make it point
to 1st itself... */
tmpp=libmapPtr->next;
if(libmapPtr1->next==libmapPtr)
{
libmapPtr->next=libmapPtr1;
}
else
{
libmapPtr->next=libmapPtr1->next;
}
/* Make previous of 2nd point to 1st, unless
it's adjacent, in which case leave it... */
if(libmapPtr1->next!=libmapPtr)
{
prevPtr2->next=libmapPtr1;
}
/* Make 1st now point to what 2nd did... */
libmapPtr1->next=tmpp;
break;
}
}
prevPtr1=libmapPtr1;
}
if(swapping)break;
}
prevPtr2=libmapPtr;
if(swapping)break;
}
}while(swapping);
fprintf(stderr," Writing new library map file...\n");
for(libmapPtr=libmap;libmapPtr;libmapPtr=libmapPtr->next)
{
printf("%s:",libmapPtr->lib);
for(pp=libmapPtr->uses;*pp;pp++)
{
printf(" %s",*pp);
}
printf("\n");
printf("source/%s/GNUmakefile\n",libmapPtr->trigger);
}
}
else
{
/* Add dependent libraries... */
for(libmapPtr=libmap;libmapPtr;libmapPtr=libmapPtr->next)
{
if(libmapPtr->used)
{
for(pp=libmapPtr->uses;*pp;pp++)
{
for(libmapPtr1=libmap;libmapPtr1;libmapPtr1=libmapPtr1->next)
{
if(strcmp(libmapPtr1->lib,*pp)==0)
{
libmapPtr1->used=1;
}
}
}
}
}
/* Write out library list... */
for(libmapPtr=libmap;libmapPtr;libmapPtr=libmapPtr->next)
{
if(libmapPtr->used)
{
printf("-l%s ",libmapPtr->lib);
}
}
}
exit(0);
}
+12 -1
View File
@@ -1,4 +1,4 @@
$Id: History,v 2.10 1998/12/11 20:26:05 allison Exp $
$Id: History,v 1.3 1999/05/20 10:13:46 johna Exp $
-------------------------------------------------------------------
=========================================================
@@ -17,6 +17,17 @@ committal in the CVS repository !
----------------------------------------------------------
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
envs-01-00-02 20th May 1999 John Allison
- Only OPACS and History tagged.
- Archived Momo (cvs remove) which puts it in the Attic. Can be retrieved
with cvs update -D 990519 environmants/Momo.
- OPACS development (Guy).
- XVT not currently under development.
envs-00-04-01 7th January 1999 hajime Yoshida
- New Momo with make capabilities along with library selection
- GGEmake updated for the latest g++ (egcs-1.1)
envs-00-04-01 11th December 1998 Hajime Yoshida Masayasu Nagamatu
- The latest version of GGE, the whole *.java, *.class and example files committed
-26
View File
@@ -1,26 +0,0 @@
#Momo Plug-in example
# An example of Momo/Tcl Plug-in
#1998 July 20 H Yoshida
# A line starting with # is a comment line.
# An empty line is ignored.
# Momoseparator is a separation line between menu items.
# Any Unix X-window applications can be invoked by describing
# the command name and associated arguments.
# See the example below.
# Commands are executed in the background.
# But & is not necessary at the end of a line.
java gge
#java gag
xclock
Momoseparator
xterm
Momoseparator
netscape
-5
View File
@@ -1,5 +0,0 @@
FONT -adobe-courier-bold-r-normal--14-100-100-100-m-90-iso8859-1
GUI_STYLE horizontal
GUI_POSITION left
FORE_GROUND_COLOR #000000000
BACK_GROUND_COLOR #b5bfffa3c
-73
View File
@@ -1,73 +0,0 @@
History file for the G4UIGAG class
4 Dec 1998
- ready for release
- java GAG and Tcl/tk GAG are protected against G4binary with
G4UIterminal session. They terminate the execution of
the G4binary and become ready to run other G4binaries
with G4UIGAG session.
- The above is associated with minor modification (only one line)
in G4UIterminal.cc
- many cosmetic changes, specially for Java GAG
- JDK1.2 version is yet to come.
- G4UIGAG is now completely equivalent with G4UIterminal in
the terminal mode. Including Help functions.
20 Aug
- Beta-01
6 July 1998
- ready for beta
July , 1998
-@@Ask is introduced. G4UIGAG does nothing and simply passes it to
GAG.
July, 1998
- bug fixed. (uiMode == terminal_mode)
Apr 15, 98
- sendDisableList() is fully implemented. Now the command is properly
disabled when the state transition occurs.
The state transition is detected only when entering the interaction loop
such as {preInit, Idle} state. This limitation comes from our design
choice to avoid any overhead when the beam is on.
- modified the showCurrent() to open an error message window if the
current value is not properly set. The "@@ErrResult" protocol is used.
Apr 14, 98
- fixed the "hang" bug when the current value is asked. The showCurrent()
is modified to handle the embedded null string of the current value.
Apr 06, 98
- renamed getRangeString() to getRange()
March 26, 98
- minor bug fix for the help command, terminalHelp() is modified.
March 16, 98
- bug fix for the Disable list.
- This is the stable version because the functionality is tested using a
check list.
March 13, 98
- handles the parameter update of each command, such as "on the fly"
updation of the candidate list
- handles the dynamic menu reconfigration using /test/installVis command
March 12, 98
- change the specification of @@PROMPT and @@State
- added internal routines such as "sendATclParamProperty()"
- send the range string of G4UIcommand
March 10, 98
- modify to send the protocol version string (@@Version) of GAG
- send the disable list (ad hoc version to test GUI)
- send the attributes of command/parameter even if it is not defined
-10
View File
@@ -1,10 +0,0 @@
#GGE draw macro
/vis~/create_view/new_graphics_system DAWN
/vis~/camera/viewpoint 60. 30.
/vis~/camera/zoom 2
/vis~/set/drawing_style 2
/vis~/set culling on
/vis~/set/cull_by_density on 0.01
/vis~/draw/current
/vis~/draw/axes 0 0 0 10000 mm
/vis~/show/view
@@ -1,10 +0,0 @@
#GGE draw macro
/vis~/create_view/new_graphics_system DAWNFILE
/vis~/camera/viewpoint 60. 30.
/vis~/camera/zoom 2
/vis~/set/drawing_style 2
/vis~/set culling on
/vis~/set/cull_by_density on 0.01
/vis~/draw/current
/vis~/draw/axes 0 0 0 10000 mm
/vis~/show/view
-10
View File
@@ -1,10 +0,0 @@
#GGE draw macro
/vis~/create_view/new_graphics_system OGLIX
/vis~/camera/viewpoint 60. 30.
/vis~/camera/zoom 2
/vis~/set/drawing_style 2
/vis~/set culling on
/vis~/set/cull_by_density on 0.01
/vis~/draw/current
/vis~/draw/axes 0 0 0 10000 mm
-17
View File
@@ -1,17 +0,0 @@
# $Id: GNUmakefile,v 1.2 1998/11/12 10:49:50 yhajime Exp $
# --------------------------------------------------------------
# GNUmakefile for examples module. Gabriele Cosmo, 06/04/98.
# --------------------------------------------------------------
name := myDetector
G4TARGET := $(name)
G4EXLIB := true
ifndef G4INSTALL
G4INSTALL = ../../..
endif
.PHONY: all
all: lib bin
include $(G4INSTALL)/config/binmake.gmk
@@ -1,37 +0,0 @@
# $Id: GNUmakefile.light,v 1.2 1998/11/12 10:49:52 yhajime Exp $
# --------------------------------------------------------------
# GNUmakefile for examples module. Gabriele Cosmo, 06/04/98.
# --------------------------------------------------------------
name := exampleN01
G4TARGET := $(name)
G4EXLIB := true
ifndef G4INSTALL
G4INSTALL = ../../..
endif
LDLIBS := \
-l$(G4TARGET) \
-lG4run \
-lG4event \
-lG4tracking \
-lG4bosons \
-lG4partman \
-lG4transportation \
-lG4procman \
-lG4track \
-lG4materials \
-lG4digits+hits \
-lG4csg \
-lG4geometrymng \
-lG4volumes \
-lG4magneticfield \
-lG4graphics_reps \
-lG4intercoms \
-lG4global
.PHONY: all
all: lib bin
include $(G4INSTALL)/config/binmake.gmk
-23
View File
@@ -1,23 +0,0 @@
$Id: History,v 1.2 1998/11/12 10:49:54 yhajime Exp $
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
Example N01 History file
------------------------
This file should be used by the G4 example coordinator to briefly
summarize all major modifications introduced in the code and keep
track of all tags.
----------------------------------------------------------
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
May 07, 98 M.Asai
- First commitment of all classes.
April 09, 98 G. Cosmo
- Created.
-433
View File
@@ -1,433 +0,0 @@
README of GGE; GEANT4 Geometry Editor
1998 Oct. 15
1998 Sep. 24
1998 Sep. 10
1998 Aug. 31
Hajime YOSHIDA
Naruto University of Education
1) Introduction
GGE, GEANT4 Geometry Editor, is a visual tool to "create" a
detector geometry after GEANT4's.
It provides users with tables
into which users can fill with their detector parameters. After the
data in the tables, GGE creates C++ source codes for a detector.
When a user uses default functions of GGE, C++ codes generated by GGE is a complete
description of a detector, including the definition of atoms, materials, solids, color attributes,
logical volumes and physical volumes with rotations and translations.
The C++ source codes are saved into files and can be compiled to make a GEANT4 executable.
A minimum set of files for the GEANT4 managers to visualise the detector as well as
a GNUMakefile are provided for that.
GAG is helpful to have a visualization of the whole detector.
Simple macro files are associated, too, for visualisation.
GGE consists of two editors (material and volume) which are
interrelated upon users' request. Volume editor provides Single
Positioned Volume, Repeated Volumes with incremental copy numbers
(translational arrangement or axially symmetric arrangement), Replicas (in any axis)
and Parametrized volumes(not yet).
GGE is based on Java's MVC model, or Swing so that any change or input to the tables by a user
are automatically reflected to the internal data structure of GGE and C++ codes.
2) Functions of GGE
2.1) Material Editor
a) implemented in this version
+ append, insert, edit and delete a material
+ material from scratch
+ material by combination (number or fractional ratios)
+ periodic table of atoms automatically popped up to create a material
+ default states are provided (material state, temperature, pressure)
+ canonical physical units in GEANT4 selectable from a combobox
+ "in Use" mark for materials used in user's detector
+ materials used in the logical volumes are automatically made "in Use".
+ user can add any materials "in Use" to have C++ constructors
+ persistent material file
+ load, append or save a material file
+ an exemplary persistent material database file "MaterialDB.g4mt" from the PDG
b)not yet implemented
- material from materials (coming soon)
- isotope (planned)
- protection from duplicated "in Use" instances of the same materials.
2.2) Volume Editor ; logical and physical volumes
a)implemented
+ G4Solids
+ CSG solids
+ G4box, G4tubs, G4cons, G4trd
+ parameters and canonical units
+ preview with DAWN (automatically chosen world size)
+ BREPs
+ Pcone, Pgon
+ any number of nodes and facets with parameters and canonical units
+ preview with DAWN (automatically chosen world size)
+ G4LogicalVolume
+ create, delete a logical volume
+ Its name, G4Solid, material, visualization attributes
+ selectable G4Solid among the above candidates
+ type-in materials name (drag and drop is planned)
+ Color Chooser to specify visualization attribute (color and its name)
+ Used materials link to material DB
+ G4PVPlacement ; arrangement of physical volumes
+ Type 1 constructor = rotation of the frame, physical mother volume
+ Type 2 constructor = rotation of a body, physical mother volume
+ Type 3 constructor = rotation of the frame, logical mother volume
+ Type 4 constructor = rotation of a body, logical mother volume
+ Single Positioned Volume (SPV)
+ mother volume is either
null(Master Reference System), logical or physical
+ MARS is constructed first in C++ code.
+ translation in the X, Y or Z direction (default is no translation)
+ rotation around X, Y or Z axis with an angle (frame or body)
+ Repeated Volumes with incremental copy numbers (RVArrangement)
+ translational arrangement of any number of copies of a logical volume
+ placements in the X, Y or Z direction
+ the position of the first copy and incremental step size
+ with respect to a logical or physical mother volume
+ axially symmetric arrangement
+ rotational axis is parallel to X, Y or Z axis
+ rotation of the frames or a body
+ position of the center of axial symmetry
+ radius of axially symmetric arrangement
+ starting angle and incremental step angle with number of copies
+ logical or physical mother volume
+ Replica
+ replication in the X, Y or Z direction
+ replication in rho, phi or Z direction
+ width (in length or angle) and number of replicas
+ offset (in length or angle)
+ logical or physical mother volume
b)to be implemented
- other CSG solids
- paremetrised volumes
- linear scaling
- linear rotation
2.3) Generation of C++ code ; "MyDetectorConstruction.cc"
a) implemented
+ C++ code is output to a editor widget
+ necessary header files are automatically included
+ save the file with a file chooser
+ order of creating instances;
G4Elements, G4Material, G4VisAttributes, G4Solids, G4LogicalVolume,
Single Positioned Volumes, Repeated Volumes, Replicas
x order of instantiation inside each section is decided by GGE user,
except MARS
+ return the instance name of the MARS
b)not implemented
- automatic correct ordering of constructors of volumes
2.4) GGEmake; a directory containing the GEANT4 codes to compile and visualize the detector
a) implemented
+ GNUmakefile
+ myDetector.cc ; main() with GAG session and visualization manager
+ src/ directory contains
+ MyDetectorConstruction.cc
+ MyPhysicsList.cc
+ MyPrimaryGeneratorAction.cc
+ MyVisManager.cc
+ include/ directory
2.5) compile and visualize with Momo and GAG
a) implemented
+ canonical scheme of GEANT4 to compile
+ make G4TARGET=myDetector
+ the binary is created as $G4INSTALL/bin/G4SYSTEM/myDetector
+ Momo (GAG, Compile and GGE buttons)
+ rapid cycling of GGE and GAG to edit and view the geometry
+ a macro file for visualization (OGLIX default) "DrawDAWN.g4m", etc..
b) not implemented
- automatic "calibration" of the detector with geantino
2.6) exemplary persistent detector files with *.g4dt suffix
+ 3D array of lead plates using translational RVArrangement
+ BREP Pcones trumpetss using axially symmetric RVArrangement
+ Replicas to form cylinders
-------------------------------------------------------------------------
3) Installation
The minimum set to get C++ source code
1) GGE.jar file
2) Java interpreter ; java
Additional set to compile
3) GEANT4 toolkit with compiled libraries
4) GGEmake directory
Additional set to visualise and use GUI
4) DAWN (plus Ghostview) or OGLIX or VRML
5) GAG (Java version) or GAG.jar file
Additional too to make life easy
6) Momo to use all the above ingredients; Momo.jar file
(without Momo, you have to invoke GGE, compile and GAG respectively in windows.)
3.1) Java and Swing
We have tested GGE on Unix-en (Linux and Solaris) and Windows (95/NT).
3.1.1) Unix:
+ Linux: jdk1.1.3 or later(i.,e., jdk-1.1.6) + Swing-1.0.2
1) jdk1.1.5 may have bugs, while jdk1.1.6 works
2) GGE co-works with Swing-1.0.2 and not with 1.0.1 (or maybe not
with 1.0.3).
3) we are testing the current GGE with JRE1.2-beta04. The present source can be
compiled but doesn't execute correctly. In any case
Sun has announced on 17 August that JDK1.2 will be delayed
till November!!
+ Solaris: jdk1.1.6 + swing-1.0.2
We assume that you have
1)jdk1.1.6/bin/java (Java interpreter) to which paths are set
2)Swing-1.0.2 which is defreezed and placed in $HOME/swing/swingall.jar
3.1.2) Windows:
We use JBuilder2 with Swing-1.0.2. Note that you have to
eliminate all other libraries than swing-1.0.2, after having
copied it into JBuilder2.
We are trying JDK1.2beta4 + JRE1.2 with JBuilder2.
NOTE! At present we have not Momo/GAG for Windows. So,
you can only create C++ code under the Windows.
3.2) GGE and related files
The latest product of GGE is that of Sep. 24.
All *.java, *.class and GGE.jar files are placed in
geant4beta/environments/Momo/java/Momo/GGE
Only "GGE.jar" file is necessary to run GGE.
GGE/*.java GGE source files
GGE/*.class GGE byte code files
GGE/GGE.jar jar archive file to which CLASSPATH must be set
GGE/*.g4mt material database after PDG data
GGE/*.g4dt exampleN0x detector file
C++ source codes and GNUmakefiles to compile with GEANT4 are placed in
geant4beta/environments/Momo/GGEmake.
Only geantino is instantiated in the initialization of GEANT4, so that it is quite
rapid to have a visualization of the geometry. You can choose DAWN, OpenGL or VRML system.
GGEmake/myGGEdetector.cc main() program
/GNUmakefile
/src
/src/MyDetectorConstruction.cc C++ generated by GGE
/src/MyPrimaryGeneratorAction.cc geantino gun
/src/MyVisManager.cc DAWN, DAWNFILE, OGLIX, OGLSX, VRML1, VRML1FILE
/src/MyPhysicsList.cc geantino definition
/include/*.hh
/GGEdraw.g4m default macro file to visualize with OGLIX
3.3) install, setenv and run
%set path=($path jdk1.1.6/bin) <=== add the path to java and javac
%setenv CLASSPATH .:$HOME/swing/swingall.jar:$HOME/geant4beta/environments/Momo/java/Momo/GGE/GGE.jar
Then in any directory, you can invoke GGE.
%java gge
3.4) DAWN, Tcl/Tk and Postscript for the preview of CSG or BREP solids
If you don't use GGE's preview button, these are not necessary.
If you want to preview G4Solids, you have to install
DAWN, Fukui renderer as well as Tcl/Tk wish (Tcl/Tk 8.0) for its GUI.
DAWN uses also Postscript to draw *.prim files.
For the visualization of the whole detector, DAWN or Mesa (for OGLIX)
are necessary.
3.5) GEANT4 toolkit and its environments
The visualization manager instantiates DAWN, DAWNFILE, OPENGLIX,
OPENGLSX, VRML, VRMLFILE. So, you have to setenv accordingly.
4) A First Lesson; how to use GGE.
Here is a walk-through of how to use GGE.
4.1) Visualize the prefabricated detector sample
1) In a xterm, type %java gge
2) In the "Volume window", select "Load a Volume file" menu
and double click on "trumpetBREP.g4dt"
3) Click "Makesource" and select "Make C++ code". Have a look of the generated C++ code.
4) Save the C++ code (overwrite the existing one)
in .../GGEmake/src/MyDetectorConstruction.cc" using the file chooser.
5) In another xterm, go to the directory GGEmake/ and type
%make G4TARGET=myGGEdetector
Watch if there is any compilation error. At present,
GGE is made so that it generates correct C++ codes,
if a user uses GGE correctly.
In the example of "trumpetBREP.g4dt", a few warnings are shown on BREP.
6) Check that you have "myGGEdetector" executable, in $(G4INSTALL)/bin/$(G4SYSTEM)
7) In another xterm, type
%java gag
and with the "Run GEANT4" button, choose and run "myGGEdetector".
8) Use /control/execute command and double click on "GGEdraw.g4m".
To have a better view, use vis~ commands (camera/viewpoint, zoom etc).
You can select DAWNFILE to draw and have a PS hardcopy.
4.2) Modify the prefabricated detector
Now let's change the detector configuration. Go to the "Volume" window
and change any part of it, including material.
4.2.1) Changing materials
1) First, you have to "Clear Material" in the Material editor.
2) Then, select "Load material" and double click on "MaterialDB.g4mt".
Now you have a list of materials.
3) Then, in the "Logical Volume" panel, double click the box you want to change
and type in the name of the material in the material editor.
4) Change as many materials as you like and push "Used Material" button.
You see that materials you have typed in are marked "Used" in red.
If not, you might have mistyped the name of a material.
5) If you want to use additional materials, select "Use" in the material
editor (the leftmost column).
6) Push "Makesource" and see your change has been realized in the C++ code.
NOTE!! Be careful that there are no duplicated "Used" materials, when
you load the material DB without "Clear Material".
4.2.2) Modifying the size parameters of solids
To change the sizes of G4 solids
1) click a "solid" box of the logical volume of your choice.
2) You have a pop-up window to edit the parameters. Change a parameter
or its unit, as you like.
3) Push "Makesource" and see if your changes have been correctly applied
to C++ code.
4) In case of BREP solids, the pop-up window has variable number of columns
to accept any number of nodes.
5) For complicated solids like BREPs, preview may be useful. Click "View"
button and you have a view with the DAWN renderer. Its g4.prim file
is also shown in an edit-able widget.
4.2.3) Changing the type of solid of an existing logical volume
You may want to replace the current G4Solid with another one. In the
present GGE you can't do so directly. You have to "Create" a new logical
volume with the type of solid you want and then delete the unnecessary volume.
1) Choose your new solid with "Select Solid" combo-box.
2) Push "Create" button and you have a pop-up window to input parameters.
3) Type in numbers and select their units.
4) Preview if you like and then push "OK".
5) Check the C++ code.
4.2.4) Changing visualization attributes (Color).
1) You have to "Create" a new VisAttributes
2) Upon the "Create" button, you have a Color Chooser.
3) Select RGB (not HSV). Set your color with slide-bars.
4) Give it a name, and push "OK". Then you have a color circle and name in the
VisAttrib panel.
5) Edit the VisAtb box in the LogicalVolume panel.
6) See the C++ code.
4.2.5) Changing Repeated Volumes
"exampleN01.g4dt" contains three "single positioned volumes"
and one "repeated volumes" in the X direction.
Change the parameter of repetition such as the number
or width, or you can add another "repeated volumes"
in another direction.
In "trumpetBREP.g4dt" you can edit BREPs, adding new faces etc..
b) making C++ code "MyDetectorConstruction.cc" and compile.
Finally, back to the step 3 and recompile.
Opening GGE, compile, GAG simultaneously, you can
test and improve the geometry, just like creating
HTML or TeX documents.
4) Naming conventions in GGE
Knowledge of GGE's naming convention is helpful to read the generated C++ code as
well as using GGE correctly.
4-1) Elements and materials
a) Elements are named "elementXXX", where XXX stands for the
element's symbol in the periodic table.
b) materials are named just as you have typed in the second column
of the material window.
4-2) solids and logical volumes
The "Name" typed in the first (leftmost) column of the "Logical Volume"
is used to name the corresponding solid. If the name "world" is given
to a logical volume of a Box, the G4Solid has an instance "solidworld".
4-3) logical and physical volumes
The instance of a physical volume defined by "pName" has a name prefixed
with "physical", i.,e., instance's name is "physical" + pName ( + =>
string concatenation). "logical" is added to the instance of a logical
volume.
In case of SPV (single positioned volume), the columns "pName" (instance of
physical volume) and "pLogical" may have the same strings.
In case of RVA (repeated volumes arrangement), "pName" is different from
"pLogical" whose copies are repeatedly placed.
4-4) All variables are named after their proper instances.
See for example, the control variable used in the for loop in the
RVA.
Another examples are arrays to define BREP geometry.
5) Default values and combo-boxes
5.1) Default optional values of materials
GGE provides default values in a pre-filled columns or with the
combo-boxes. "Use", "State" and "Unit" columns are equipped with
combo-boxes. Temperature and pressure column are pre-filled with
273.15 * kelvin and 1 * atmosphere.
5.2) Default values in volumes
"Mother Type" is either NULL (mother of all), logical (type 2, 4 constructors)
or physical (type 2 or 4 constructors) in G4PVPlacement.
@@ -1,31 +0,0 @@
// 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: MyDetectorConstruction.hh,v 1.2 1998/11/12 10:50:05 yhajime Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef MyDetectorConstruction_H
#define MyDetectorConstruction_H 1
class G4VPhysicalVolume;
#include "G4VUserDetectorConstruction.hh"
class MyDetectorConstruction : public G4VUserDetectorConstruction
{
public:
MyDetectorConstruction();
~MyDetectorConstruction();
public:
G4VPhysicalVolume* Construct();
};
#endif
@@ -1,47 +0,0 @@
// 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: MyPhysicsList.hh,v 1.2 1998/11/12 10:50:06 yhajime Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
//
// ExN01PhysicsList
// Construct/define particles and physics processes
//
// Particle defined in ExampleN01
// geantino
//
// Process defined in ExampleN01
// transportation
//
#ifndef MyPhysicsList_h
#define MyPhysicsList_h 1
#include "G4VUserPhysicsList.hh"
#include "globals.hh"
class MyPhysicsList: public G4VUserPhysicsList
{
public:
MyPhysicsList();
~MyPhysicsList();
protected:
// Construct particle and physics process
void ConstructParticle();
void ConstructProcess();
void SetCuts(G4double cut);
};
#endif
@@ -1,35 +0,0 @@
// 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: MyPrimaryGeneratorAction.hh,v 1.2 1998/11/12 10:50:06 yhajime Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef MyPrimaryGeneratorAction_h
#define MyPrimaryGeneratorAction_h 1
#include "G4VUserPrimaryGeneratorAction.hh"
class G4ParticleGun;
class G4Event;
class MyPrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
{
public:
MyPrimaryGeneratorAction();
~MyPrimaryGeneratorAction();
public:
void GeneratePrimaries(G4Event* anEvent);
private:
G4ParticleGun* particleGun;
};
#endif
@@ -1,50 +0,0 @@
// 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: MyVisManager.hh,v 1.2 1998/11/12 10:50:07 yhajime Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
// Example Visualization Manager implementing virtual function
// RegisterGraphicsSystems. Exploits C-pre-processor variables
// G4VIS_USE_DAWN, etc., which are set by the GNUmakefiles if
// environment variables of the same name are set.
// So all you have to do is set environment variables and compile and
// instantiate this in your main().
// Alternatively, you can implement an empty function here and just
// register the systems you want in your main(), e.g.:
// G4VisManager* myVisManager = new MyVisManager;
// myVisManager -> RegisterGraphicsSystem (new MyGraphicsSystem);
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
#ifndef MyVisManager_h
#define MyVisManager_h 1
#include "G4VisManager.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
class MyVisManager: public G4VisManager {
public:
MyVisManager ();
private:
void RegisterGraphicsSystems ();
};
#endif
-81
View File
@@ -1,81 +0,0 @@
// 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: myDetector.cc,v 1.1 1998/11/12 10:50:01 yhajime Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// --------------------------------------------------------------
// GEANT 4 - GGEVis.cc
//
// For information related to this code contact:
// CERN, IT Division, ASD Group
// --------------------------------------------------------------
// Comments
//
//
// --------------------------------------------------------------
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4UIGAG.hh"
#include "MyDetectorConstruction.hh"
#include "MyPhysicsList.hh"
#include "MyPrimaryGeneratorAction.hh"
#ifdef G4VIS_USE
#include "MyVisManager.hh"
#endif
#include "g4templates.hh"
int main()
{
// Construct the default run manager
G4RunManager* runManager = new G4RunManager;
// set mandatory initialization classes
runManager->SetUserInitialization(new MyDetectorConstruction);
runManager->SetUserInitialization(new MyPhysicsList);
#ifdef G4VIS_USE
// visualization manager
G4VisManager* visManager = new MyVisManager;
visManager->Initialize();
#endif
// set mandatory user action class
runManager->SetUserAction(new MyPrimaryGeneratorAction);
// Initialize G4 kernel
runManager->Initialize();
// get the pointer to the User Interface manager
G4UImanager* UI = G4UImanager::GetUIpointer();
G4UIsession * session = new G4UIGAG;
session->SessionStart();
delete session;
// job termination
#ifdef G4VIS_USE
delete visManager;
#endif
delete runManager;
return 0;
}
@@ -1,117 +0,0 @@
//------HeaderFile-
#include "MyDetectorConstruction.hh"
#include "G4UnitsTable.hh"
#include "G4VUserDetectorConstruction.hh"
#include "globals.hh"
#include "G4Material.hh"
#include "G4MaterialTable.hh"
#include "G4Element.hh"
#include "G4ElementTable.hh"
#include "G4Box.hh"
#include "G4Tubs.hh"
#include "G4LogicalVolume.hh"
#include "G4ThreeVector.hh"
#include "G4PVPlacement.hh"
#include "G4PVReplica.hh"
#include "G4SDManager.hh"
#include "G4VisAttributes.hh"
#include "G4Colour.hh"
MyDetectorConstruction::MyDetectorConstruction( )
{ ; }
MyDetectorConstruction::~MyDetectorConstruction( )
{ ; }
G4VPhysicalVolume* MyDetectorConstruction::Construct( )
{
// Elements
G4Element* elementN = new G4Element( "Nitrogen", "N", 7. , 14.00674*g/mole );
G4Element* elementO = new G4Element( "Oxygen", "O", 8. , 15.9994*g/mole );
G4Element* elementH = new G4Element( "Hydrogen", "H", 1. , 1.00794*g/mole );
G4Element* elementC = new G4Element( "Carbon", "C", 6. , 12.011*g/mole );
// Materials from Combination
G4Material* Air = new G4Material("Air", 1.205*g/cm3, 2, kStateGas, 293.0*kelvin, 1.0*atmosphere );
Air->AddElement( elementN, 3 );
Air->AddElement( elementO, 1 );
G4Material* Methane = new G4Material("Methane", 0.4241*g/cm3, 2, kStateLiquid, 111.7*kelvin, 1.0*atmosphere );
Methane->AddElement( elementH, 4 );
Methane->AddElement( elementC, 1 );
// Materials from Scratch
G4Material* Cu = new G4Material("Cu", 29, 63.546*g/mole, 8.96*g/cm3,kStateSolid, 293.0*kelvin, 1.0*pascal );
G4Material* Xeliquid = new G4Material("Xeliquid", 54, 131.29*g/mole, 3.52*g/cm3,kStateLiquid, 165.0*kelvin, 1.0*atmosphere );
// Visualization attributes
G4VisAttributes * blue= new G4VisAttributes( G4Colour(133,255,255 ));
G4VisAttributes * darkgray= new G4VisAttributes( G4Colour(75,84,87 ));
G4VisAttributes * trackred= new G4VisAttributes( G4Colour(234,84,87 ));
G4VisAttributes * calred= new G4VisAttributes( G4Colour(234,178,87 ));
// Logical Volumes
G4Box *solidexpHall= new G4Box("solidexpHall", 5.0*m, 2.0*m, 2.0*m );
G4LogicalVolume * logicalexpHall = new G4LogicalVolume(solidexpHall, Air, "logicalexpHall" ,0,0,0);
logicalexpHall->SetVisAttributes(blue);
G4Box *solidcalblock= new G4Box("solidcalblock", 60.0*cm, 11.0*cm, 11.0*cm );
G4LogicalVolume * logicalcalblock = new G4LogicalVolume(solidcalblock, Xeliquid, "logicalcalblock" ,0,0,0);
logicalcalblock->SetVisAttributes(darkgray);
G4Tubs *solidtracker= new G4Tubs("solidtracker", 0.0*cm, 60.0*cm, 50.0*cm, 0.0*deg, 360.0*deg );
G4LogicalVolume * logicaltracker = new G4LogicalVolume(solidtracker, Methane, "logicaltracker" ,0,0,0);
logicaltracker->SetVisAttributes(trackred);
G4Box *solidcallayer= new G4Box("solidcallayer", 1.0*cm, 10.0*cm, 10.0*cm );
G4LogicalVolume * logicalcallayer = new G4LogicalVolume(solidcallayer, Cu, "logicalcallayer" ,0,0,0);
logicalcallayer->SetVisAttributes(calred);
G4Box *solidcalstack= new G4Box("solidcalstack", 60.0*cm, 11.0*cm, 68.0*cm );
G4LogicalVolume * logicalcalstack = new G4LogicalVolume(solidcalstack, Xeliquid, "logicalcalstack" ,0,0,0);
logicalcalstack->SetVisAttributes(darkgray);
// Physical Volumes -------Single Positioned Volume, Repeated Volumes, Replicas---------------------------
// Single Positioned Volumes
G4VPhysicalVolume * physicalexpHall= new G4PVPlacement(0,G4ThreeVector(0.0*m,0.0*mm,0.0*cm), "physicalexpHall",logicalexpHall,NULL,false, 0);
G4VPhysicalVolume * physicaltracker= new G4PVPlacement(0,G4ThreeVector(-1.0*m,0.0*mm,0.0*cm), "physicaltracker",logicaltracker,physicalexpHall,false, 0);
// Repeated Volumes
G4int copycallayerx;
copycallayerx=0;
for (G4int callayerx=1; callayerx<=20; callayerx++){
G4double transcallayerx =-55.0*cm+5.0*cm*(callayerx-1);
G4VPhysicalVolume * physicalcallayerx = new G4PVPlacement(0,G4ThreeVector(transcallayerx,0.0*cm,0.0*cm), logicalcallayer,"physicalcallayerx",logicalcalblock,false,copycallayerx++);
}
G4int copystacky;
copystacky=0;
for (G4int stacky=1; stacky<=6; stacky++){
G4double transstacky =-66.0*cm+22.0*cm*(stacky-1);
G4VPhysicalVolume * physicalstacky = new G4PVPlacement(0,G4ThreeVector(0.0*cm, transstacky, 0.0*mm), logicalcalblock,"physicalstacky",logicalcalstack,false,copystacky++);
}
G4int copystackz;
copystackz=0;
for (G4int stackz=1; stackz<=6; stackz++){
G4double transstackz =-68.0*cm+22.0*cm*(stackz-1);
G4VPhysicalVolume * physicalstackz = new G4PVPlacement(0,G4ThreeVector(80.0*cm,0.0*cm,transstackz), "physicalstackz", logicalcalstack, physicalexpHall,false,copystackz++);
}
// Replicas
// return the physical World
return physicalexpHall;
}
@@ -1,47 +0,0 @@
// 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: MyPhysicsList.cc,v 1.1 1998/09/02 12:10:38 masayasu Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
#include "MyPhysicsList.hh"
#include "G4ParticleTypes.hh"
MyPhysicsList::MyPhysicsList()
{;}
MyPhysicsList::~MyPhysicsList()
{;}
void MyPhysicsList::ConstructParticle()
{
// In this method, static member functions should be called
// for all particles which you want to use.
// This ensures that objects of these particle types will be
// created in the program.
G4Geantino::GeantinoDefinition();
}
void MyPhysicsList::ConstructProcess()
{
// Define transportation process
AddTransportation();
}
void MyPhysicsList::SetCuts(G4double cut)
{
// set a cut value to all particles
SetCutValueForOthers(cut);
}
@@ -1,55 +0,0 @@
// 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: MyPrimaryGeneratorAction.cc,v 1.1 1998/09/02 12:10:39 masayasu Exp $
// GEANT4 tag $Name: geant4-00 $
//
#include "MyPrimaryGeneratorAction.hh"
#include "G4Event.hh"
#include "G4ParticleGun.hh"
#include "G4UImanager.hh"
#include "globals.hh"
MyPrimaryGeneratorAction::MyPrimaryGeneratorAction()
{
G4int n_particle = 1;
particleGun = new G4ParticleGun(n_particle);
G4UImanager* UI = G4UImanager::GetUIpointer();
UI->ApplyCommand("/gun/particle geantino");
UI->ApplyCommand("/gun/energy 1.0 GeV");
UI->ApplyCommand("/gun/position -2.0 0.0 0.0 m");
}
MyPrimaryGeneratorAction::~MyPrimaryGeneratorAction()
{
delete particleGun;
}
void MyPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
G4UImanager* UI = G4UImanager::GetUIpointer();
G4int i = anEvent->GetEventID() % 3;
switch(i)
{
case 0:
UI->ApplyCommand("/gun/direction 1.0 0.0 0.0");
break;
case 1:
UI->ApplyCommand("/gun/direction 1.0 0.1 0.0");
break;
case 2:
UI->ApplyCommand("/gun/direction 1.0 0.0 0.1");
break;
}
particleGun->GeneratePrimaryVertex(anEvent);
}
@@ -1,140 +0,0 @@
// 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: MyVisManager.cc,v 1.1 1998/09/02 12:10:40 masayasu Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// John Allison 24th January 1998.
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
#ifdef G4VIS_USE
#include "MyVisManager.hh"
// Supported drivers...
#ifdef G4VIS_USE_DAWN
#include "G4FukuiRenderer.hh"
#endif
#ifdef G4VIS_USE_DAWNFILE
#include "G4DAWNFILE.hh"
#endif
#ifdef G4VIS_USE_OPENGLX
#include "G4OpenGLImmediateX.hh"
#include "G4OpenGLStoredX.hh"
#endif
#ifdef G4VIS_USE_VRML
#include "G4VRML1.hh"
// #include "G4VRML2.hh"
#endif
#ifdef G4VIS_USE_VRMLFILE
#include "G4VRML1File.hh"
//#include "G4VRML2File.hh"
#endif
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
MyVisManager::MyVisManager () {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void MyVisManager::RegisterGraphicsSystems () {
#ifdef G4VIS_USE_DAWN
RegisterGraphicsSystem (new G4FukuiRenderer);
#endif
#ifdef G4VIS_USE_DAWNFILE
RegisterGraphicsSystem (new G4DAWNFILE);
#endif
#ifdef G4VIS_USE_OPENGLX
RegisterGraphicsSystem (new G4OpenGLImmediateX);
RegisterGraphicsSystem (new G4OpenGLStoredX);
#endif
#ifdef G4VIS_USE_VRML
RegisterGraphicsSystem (new G4VRML1);
// RegisterGraphicsSystem (new G4VRML2);
#endif
#ifdef G4VIS_USE_VRMLFILE
RegisterGraphicsSystem (new G4VRML1File);
// RegisterGraphicsSystem (new G4VRML2File);
#endif
if (fVerbose > 0) {
G4cout <<
"\nYou have successfully chosen to use the following graphics systems."
<< endl;
PrintAvailableGraphicsSystems ();
}
}
#endif
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
-449
View File
@@ -1,449 +0,0 @@
README of GGE; GEANT4 Geometry Editor
1998 Dec. 11
1998 Oct. 15
1998 Sep. 24
1998 Sep. 10
1998 Aug. 31
Hajime YOSHIDA
Naruto University of Education
0) Reference
GGE is changing day-by-day. It will be adapted to the new Java2 (ex JDK1.2).
So, after this release, we will keep the latest versions and related information in our URL;
http://erpc1.naruto-u.ac.jp/~geant4
1) Introduction
GGE, GEANT4 Geometry Editor, is a visual tool to "create" a C++ source code which
implements a detector geometry after GEANT4's norm.
It provides users with tables which users fill with their detector parameters,
such as its materials, solid shapes, visualisation attributes and placement. After the
data in the tables, GGE creates C++ source codes for a detector. The C++ codes is a complete
description of a detector, including the definition of atoms, materials, solids, color attributes,
logical volumes and physical volumes with rotations and translations.
The C++ source code is saved into a file and can be compiled to make a GEANT4 executable.
A minimum set of files for the GEANT4 managers to visualise the detector as well as
a GNUMakefile are provided for that.
GAG is helpful to have a visualization of the whole detector.
Simple macro files are associated, too, for visualisation.
GGE consists of two editors (material and volume) which are
interrelated upon users' request. Volume editor has two main functions;
first is to define logical volumes, while the second is to position or relocate them.
GGE provides users a variety of relocation; Single Placement, Multiple Copies
with incremental copy numbers (translational arrangement or axially symmetric arrangement),
Replicas (in any axis or phi direction) and Parametrized volumes(not yet).
GGE is based on Java's MVC model so that any change or input to the tables by a user
are automatically reflected to the internal data structure of GGE and C++ codes.
2) Functions of GGE
2.1) Material Editor
a) implemented in this version
+ append, insert, edit and delete a material
+ material from scratch
+ material by combination (number or fractional ratios)
+ periodic table of atoms automatically popped up to create a material
+ default states are provided (material state, temperature, pressure)
+ canonical physical units in GEANT4 selectable from a combobox
+ "in Use" mark for materials used in user's detector
+ materials used in the logical volumes are automatically made "in Use".
+ user can add any materials "in Use" to have C++ constructors
+ persistent material file
+ load, append or save a material file
+ an exemplary persistent material database file "MaterialDB.g4mt" from the PDG
b)not yet implemented
- material from materials (coming)
- isotope (planned)
- protection from duplicated "in Use" instances of the same materials.
2.2) Volume Editor ; logical and physical volumes
a)implemented
+ G4Solids
+ CSG solids
+ Box, Tube segment, Cone segment, Sphere segment, Torus segment, Parallelepiped,
Symmetric Trapezoid, HYPE
+ parameters and canonical units
+ preview with DAWN (automatically chosen world size)
+ BREPs
+ Polycone segment, Polyhedra
+ any number of nodes and facets with parameters and canonical units
+ preview with DAWN (automatically chosen world size)
+ G4LogicalVolume
+ create, delete a logical volume
+ Its name, G4Solid, material, visualization attributes
+ selectable G4Solid among the above candidates (CSGs, BREPs)
+ type-in materials name (drag and drop is planned)
+ Color Chooser to specify visualization attribute (color and its name)
+ Used materials link to material DB
+ G4PVPlacement ; Placement of physical volumes
+ Type 1 constructor = rotation of the frame, physical mother volume
+ Type 2 constructor = rotation of a body, physical mother volume
+ Type 3 constructor = rotation of the frame, logical mother volume
+ Type 4 constructor = rotation of a body, logical mother volume
+ Single Placement of a Volume (SPV)
+ mother volume is either
null(Master Reference System), logical or physical
+ MARS is constructed first in C++ code.
+ logical mother is for nested volumes
+ translation in the X, Y or Z direction (default is no translation)
+ rotation around X, Y or Z axis with an angle (frame or body)
+ Repeated Placement of a Volume with incremental copy numbers (RPV)
+ translational arrangement of any number of copies of a logical volume
+ placements in the X, Y or Z direction
+ the position of the first copy and incremental step size
+ with respect to a logical or physical mother volume
+ axially symmetric arrangement
+ rotational axis is parallel to X, Y or Z axis
+ rotation of the frames or a body
+ position of the center of axial symmetry can be set
+ radius of axially symmetric arrangement
+ starting angle and incremental step angle with number of copies
+ logical or physical mother volume
+ Slicing or Replica
+ replication in the X, Y or Z direction (cartesian coordinates)
+ replication in rho or phi direction (cylindrical coordinates)
+ width (in length or angle) and number of replicas
+ offset (in length or angle)
+ logical or physical mother volume
b)to be implemented
- paremetrised volumes (coming soon)
- linear scaling
- linear rotation
2.3) Generation of C++ code ; "MyDetectorConstruction.cc" (default naming)
a) implemented
+ C++ code is output to a editor widget
+ all necessary header files are automatically included
+ save the file with a file chooser; "GGEmake/MyDetectorConstruction.cc" (default naming)
+ order of creating instances;
G4Elements, G4Material, G4VisAttributes, G4Solids, G4LogicalVolume,
Single Positioned Volumes, Repeated Volumes, Replicas
x order of instantiation inside each section is decided by GGE user,
except MARS
+ return the instance name of the MARS
b)not implemented
- automatic correct ordering of constructors of volumes
2.4) GGEmake; a directory containing the GEANT4 codes to compile and visualize the detector
a) implemented
+ GNUmakefile
+ myDetector.cc ; main() with GAG session and visualization manager
+ src/ directory contains
+ MyDetectorConstruction.cc
+ MyPhysicsList.cc
+ MyPrimaryGeneratorAction.cc
+ MyVisManager.cc
+ include/ directory
2.5) compile and visualize with Momo and GAG
a) implemented
+ canonical scheme of GEANT4 to compile
+ make G4TARGET=myDetector
+ the binary is created as $G4INSTALL/bin/$G4SYSTEM/myDetector
+ Momo (GAG, Compile and GGE buttons)
+ rapid cycling of GGE and GAG to edit and view the geometry
+ a macro file for visualization (OGLIX default) "DrawDAWN.g4m", etc..
b) not implemented
- automatic "calibration" of the detector with geantino
2.6) exemplary persistent detector files with *.g4dt suffix
+ rotateallsolids.g4dt; all CSG except HYPE and two BREPs are placed in an axially symmetric manner
+ translateallsolids.g4dt
-------------------------------------------------------------------------
3) Installation
The minimum set to run GGE and to create the C++ source code
1) GGE.jar file
2) Java interpreter ; java
Additional set to compile and get the executable
3) GEANT4 toolkit with compiled libraries
4) GGEmake directory
Additional set to visualise and use GUI
4) DAWN (plus Ghostview) or OGLIX or VRML
5) GAG (Java version) or GAG.jar file
Additional too to make life easy
6) Momo to use all the above ingredients; Momo.jar file
(without Momo, you have to invoke GGE, compile and GAG respectively in windows.)
3.1) Java and Swing
We have tested GGE on Unix-en (Linux and Solaris) and Windows (95/NT).
3.1.1) Unix:
+ Linux: jdk1.1.3 or later(i.,e., jdk-1.1.6 or jdk-1.1.7) + Swing-1.0.2
1) GGE co-works with Swing-1.0.2 and not with 1.0.1 (or maybe not
with 1.0.3).
2) we are testing the current GGE with JRE1.2-beta04. The present source can be
compiled but doesn't execute correctly. In any case
Sun has announced on 17 August that JDK1.2 will be delayed
till November!!
+ Solaris: jdk1.1.6 + swing-1.0.2
We assume that you have
1)$JAVAHOME/jdk1.1.6/bin/java (Java interpreter) to which paths are set
2)Swing-1.0.2 which is defreezed and placed in $JAVAHOME/swing/swingall.jar
3.1.2) Windows:
We use JBuilder2 with Swing-1.0.2. Note that you have to
eliminate all other libraries other than swing-1.0.2, after having
copied it into JBuilder2.
We are trying JDK1.2beta4 + JRE1.2 with JBuilder2.
NOTE! At present you can only create C++ code under the Windows.
3.2) GGE and related files
The latest product of GGE is that of 11th December 1998.
All *.java, *.class and GGE.jar files are placed in
$G4INSTALL/environments/Momo/java/Momo/GGE
Only "GGE.jar" file is necessary to run GGE. The following files are included for
completeness.
GGE/*.java GGE source files
GGE/*.class GGE byte code files
GGE/GGE.jar jar archive file to which CLASSPATH must be set
GGE/*.g4mt material database after PDG data
GGE/*.g4dt exampleN0x detector file
A set of C++ source codes and GNUmakefiles necessary to compile with GEANT4 are placed in
$G4INSTALL/environments/Momo/GGEmake.
Only geantino is instantiated in the initialization of GEANT4, so that it is quite
rapid to have a visualization of the geometry. You can choose DAWN, OpenGL or VRML system.
GGEmake/myDetector.cc main() program
/GNUmakefile
/src
/src/MyDetectorConstruction.cc C++ generated by GGE
/src/MyPrimaryGeneratorAction.cc geantino gun
/src/MyVisManager.cc DAWN, DAWNFILE, OGLIX, OGLSX, VRML1, VRML1FILE
/src/MyPhysicsList.cc geantino definition
/include/*.hh
/DrawOGLIX.g4m macro file to visualize with OGLIX
/DrawDAWN.g4m macro file for DAWN
/DrawDAWNFILE.g4m macro file for DAWN with Postscript file
3.3) install, setenv and run
%set path=($path $JAVAHOME/jdk1.1.6/bin) <=== add the path to java and javac
%setenv CLASSPATH .:$JAVAHOME/swing/swingall.jar:$G4INSTALL/environments/Momo/java/Momo/GGE/GGE.jar
In any directory, you can invoke GGE.
%java gge
Then, the material window appears, followed by the volume window.
3.4) DAWN, Tcl/Tk and Postscript for the preview of CSG or BREP solids
If you want to preview G4Solids, you have to install
DAWN, Fukui renderer as well as Tcl/Tk wish (Tcl/Tk 8.0) for its GUI.
DAWN uses also Postscript to draw *.prim files.
If you don't use GGE's preview button, these are not necessary.
For the visualization of the whole detector, DAWN or Mesa (for OGLIX)
are necessary.
3.5) GEANT4 toolkit and its environments
The visualization manager instantiates DAWN, DAWNFILE, OPENGLIX,
OPENGLSX, VRML, VRMLFILE. So, you have to setenv accordingly.
4) A First Lesson; how to use GGE.
Here is a walk-through of how to use GGE.
4.1) Visualize the prefabricated detector sample
1) In a xterm, type %java gge
2) In the "Volume window", select "Load a Volume file" menu
and double click on "rotateallsolids.g4dt"
3) Click "Makesource" and select "Make C++ code". Have a look of the generated C++ code.
4) Save the C++ code (overwrite the existing one)
in .../GGEmake/src/MyDetectorConstruction.cc" using the file chooser.
5) In another xterm, go to the directory GGEmake/ and type
%make G4TARGET=myDetector
Watch if there is any compilation error. At present,
GGE is made so that it generates correct C++ codes,
if a user uses GGE correctly.
6) Check that you have "myDetector" executable, in $(G4INSTALL)/bin/$(G4SYSTEM)
7) In another xterm, type
%java gag
and with the "Run GEANT4" button, choose and run "myDetector".
8) Use /control/execute command and double click on "DrawOGLIX.g4m".
To have a better view, use vis commands (camera/viewpoint, zoom etc).
You can select DrawDAWNFILE to draw and have a PS hardcopy.
4.2) Modify the prefabricated detector
Now let's change the detector configuration. Go to the "Volume" window
and change any part of it, including material.
4.2.1) Changing materials
1) First, you have to "Clear Material" in the Material editor.
2) Then, select "Load material" and double click on "MaterialDB.g4mt".
Now you have a list of materials.
3) Then, in the "Logical Volume" panel, double click the box you want to change
and type in the name of the material in the material editor.
4) Change as many materials as you like and push "Used Material" button.
You see that materials you have typed in are marked "Used" in red.
If not, you might have mistyped the name of a material.
5) If you want to use additional materials, select "Use" in the material
editor (the leftmost column).
6) Push "Makesource" and see your change has been realized in the C++ code.
NOTE!! Be careful that there are no duplicated "Used" materials, when
you load the material DB without "Clear Material".
4.2.2) Modifying the size parameters of solids
To change the sizes of G4 solids
1) click a "solid" box of the logical volume of your choice.
2) You have a pop-up window to edit the parameters. Change a parameter
or its unit, as you like.
3) Push "Makesource" and see if your changes have been correctly applied
to C++ code.
4) In case of BREP solids, the pop-up window has variable number of columns
to accept any number of nodes.
5) For complicated solids like BREPs, preview may be useful. Click "View"
button and you have a view with the DAWN renderer. Its g4.prim file
is also shown in an edit-able widget.
4.2.3) Changing the type of solid of an existing logical volume
You may want to replace the current G4Solid with another one. In the
present GGE you can't do so directly. You have to "Create" a new logical
volume with the type of solid you want and then delete the unnecessary volume.
1) Choose your new solid with "Select Solid" combo-box.
2) Push "Create" button and you have a pop-up window to input parameters.
3) Type in numbers and select their units.
4) Preview if you like and then push "OK".
5) Check the C++ code.
4.2.4) Changing visualization attributes (Color).
1) You have to "Create" a new VisAttributes
2) Upon the "Create" button, you have a Color Chooser.
3) Select RGB (not HSV). Set your color with slide-bars.
4) Give it a name, and push "OK". Then you have a color circle and name in the
VisAttrib panel.
5) Edit the VisAtb box in the LogicalVolume panel.
6) See the C++ code.
4.2.5) Changing Repeated Volumes
a) "edit" the physical volumes
"translateallsolids.g4dt" contains all except HYPE CSG and two BREP volumes which are
positioned in "Pepeated Placement Volumes" in threee directions.
Change the parameter of repetition such as the number or width, or you can
add another "repeated volumes" in another direction.
b) making C++ code "MyDetectorConstruction.cc" and compile.
Finally, back to the step 3 and recompile.
If you have any compiler errors, in most cases, it is due to unfilled table, misspelled name
etc.. GGE is not yet wise enough to correct such simple mistakes.
Opening GGE, compile, GAG simultaneously, you can
test and improve the geometry, just like creating
HTML or TeX documents.
4) Naming conventions in GGE
Knowledge of GGE's naming convention is helpful to read the generated C++ code as
well as using GGE correctly.
4-1) Elements and materials
a) Elements are named "elementXXX", where XXX stands for the
element's symbol in the periodic table.
b) materials are named just as you have typed in the second column
of the material window.
4-2) solids and logical volumes
The "Name" typed in the first (leftmost) column of the "Logical Volume"
is used to name the corresponding solid. If, for example, the name "world" is given
to a logical volume of a Box, the G4Box has an instance "solidworld".
4-3) logical and physical volumes
The instance of a physical volume defined by "pName" has a name prefixed
with "physical", i.,e., instance's name is "physical" + pName ( the plus sign means
string concatenation). "logical" is added to the instance of a logical
volume.
In case of SPV (single placement of a volume), the columns "pName" (instance of
physical volume) and "pLogical" may have the same strings.
In case of RPV (repeated placement of a volume ), "pName" must be different from
"pLogical" whose copies are repeatedly placed.
4-4) All variables are named after their proper instances.
See for example, the control variable used in the for loop in the
RPV. Another examples are seen in the arrays to define BREP geometry.
5) Default values and combo-boxes
5.1) Default optional values of materials
GGE provides default values in a pre-filled columns or with the
combo-boxes. "Use", "State" and "Unit" columns are equipped with
combo-boxes. Temperature and pressure column are pre-filled with
273.15 * kelvin and 1 * atmosphere.
5.2) Default values in volumes
"Mother Type" is either NULL (mother of all), logical (type 2, 4 constructors)
or physical (type 2 or 4 constructors) in G4PVPlacement.
-194
View File
@@ -1,194 +0,0 @@
How to Install and Use GAG and Momo
1998 December 4 revised for release
1998 July 6 written for beta
Hajime YOSHIDA
1) Necessary Toolkits for GAG, GGE and Momo
1.1) Tcl/Tk and JAVA
GAG, GGE and Momo are implemented, using the popular "Open Source
Programs", or free software; Tcl/tk 8.0a or later and
JDK 1.1.3 or later and JAVA Foundation Class Swing-1.0.2.
Both are supported and freely distributed by Sun Microsystems.
As of July 6, JAVA GAG is tested on Linux with JDK-1.1.3 + Swing-1.0.2 and on
Solaris with JDK-1.1.6 + Swing-1.0.2. Tcl/Tk GAG is tested on
Linux and Solaris with Tcl8.0p2/Tk8.0p2.
As of December 4, Java GAG is running on Linux (RedHat 5.2) with JDK-1.1.7 +
Swing-1.0.2. So, replace JDK-1.1.3 below with the latest JDK-1.1.7.
JDK1.2 version is not yet delivered.
1.2) Installation
If the required toolkits as well as GAG, GGE and Momo have been installed
in your computer system by your system administrator or by your collegues,
you have only to set PATH and environment variables which
will be explained later. Such lucky few can skip the next section of
installation.
1.2.1) Installation of Tcl/tk
If you are using free Unix like Linux, the latest version (8.0a or
later) of Tcl/tk is already included. If it is installed by root to
the default destination, /usr/local/bin and /uar/local/lib,
and if you can locate wish (version 8.0) in your path, everuthing is
good.
To verify this, do as follows;
[yoshidah@ermac1 G++-Linux]$ wish
% info tclversion
8.0
% exit
[yoshidah@ermac1 G++-Linux]$
Tk command "wish" pops up a small white window. You delete it with "exit".
If not, you can install it under your home directory without root's permission.
You can get the latest version of Tcl/tk from many mirror sites world-wide.
It is easy to compile and install them.
Be careful that tcl8.0.tar.gz and tk8.0.tar.gz files are placed in the same
directory.
First attack the Tcl package. You do " ./configure" then "make"
and finally "make install".
Then, you repeat the same procedure for Tk package.
If Tcl/Tk is installed in an arbitrary destination, you have to set
path and environmental variables.
: Verify that {\tt wish} is in in your PATH and its version is correct.
: setenv TCL_LIBRARY to the directory where "libtcl.a" is placed
: setenv TK_LIBRARY to the directory where "libtk.a" is placed
1.2.2 Installation of JAVA
GAG, GGE and Momo use JDK 1.1.3 or later and Java Foundation Class,
or Swing-1.0.2 (early access version).
Note that older or newer versions of Swing are imcompatible with
the current Java GAG.
GAG, GGE anf Momo is going to be updated to JDK1.2 which has not been
released yet. JAVA Foundation Class will follow important
modifications in the JDK1.2. Thus present GUI may not work
correctly with other than Swing-1.0.2 on which it is implemented.
(Swing-1.0.2 still contains "preview" classes!! -July 1998-)
Swing is available from JAVA Developer Connection. You are requested to
register yourself as a JDC member. Please read carefully licence agreement
to use it on your computer.
For general information on JAVA, visit JavaSoft Home Page.
You may put Swing package in any directory, but you have to make the
environment variable CLASSPATH include "swingall.jar".
%setenv CLASSPATH .:/home/foo/swing1.0.2/swingall.jar:
You are recommended to check sample programs associated with it.
% cd ~foo/swing1.0.2/examples/SwingSet/classes
% java SwingSet
Wait a moment while loading many classes. If it works well, though
very slowly, you can use GAG of JAVA version.
JAVA GAG uses TextWidget, a free software which is includes as is in the
current GAG distribution. Please read and respect the copyleft written
there.
2) Install and Run GAG, GGE and Momo
After unpacking GEANT4 package you have the Momo files under the
"geant4alpha/environments/Momo/" directory.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!! Important!!!!!
Keep the following directory hierarchy. Tcl/tk
products assume that all relevant files are found under $MOMOPATH, while
JAVA products assume that all relevant classes are found in $CLASSPATH.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2.1) JAVA GUIs
2.1.1 Files
../Momo/java/Momo/ necessary hierarchy for JAVA's name space.
/Momo/GAG/ Java source codes; *.java
/Momo/GGE/ Java source codes; *.java (to come)
/Momo/GAG/GAG.jar JAVA binary archive
2.1.2) CLASSPATH
JAVA's CLASSPATH must contain the following;
JDK's class file : The path to "classes.zip" is set by default.
Otherwise let's assume /home/foo/jdk1.1.6/lib/classes.zip.
Swing-1.0: As was explained above, "swingall.jar" is the only file necessary
for Swing-1.0.2. Let us assume that you have Swing-1.0.2 in your
$HOME/swing1.0.2/swingall.jar.
GAG.jar: In the GEANT4 distribution, it is placed in
geant4alpha/environments/Momo/java/Momo/GAG/GAG.jar. So, let's
assume that it is at
$HOME/geant4alpha/environments/Momo/java/Momo/GAG/GAG.jar.
Assuming you have everything in your $HOME, CLASSPATH example for Unix
is like;
%setenv CLASSPATH .:$HOME/swing1.0.2/swingall.jar:\
$HOME/geant4alpha/environments/Momo/java/Momo/GAG/GAG.jar:
$HOME/jdk1.1.6/lib/classes.zip
2.1.3) Run JAVA GAG
To run JAVA GAG without Momo, type the following line at any directory.
% java gag
Then, choose a GEANT4 executable file.
2.2) Tcl/Tk GUIs
2.2.1) Files
../Momo/tcltk/ This is the MOMOPATH.
/tcltk/tMomo.tcl Momo script file
/tcltk/tmomo* Momo executable file
/tcltk/GAG/ GAG procedures script files
/tcltk/GAG/GAG.tcl GAG script file
/tcltk/XXXXX Other directories containing procedures used
in GAG.tcl
2.2.2) MOMOPATH
You have to setenv MOMOPATH which specifies the position of Momo/tcltk/.
For example, like;
%setenv MOMOPATH $HOME/geant4alpha/environments/Momo/tcltk
2.2.3) Run Tcl/Tk Momo and GAG
Then you can run Momo
%$MOMOPATH/tmomo
Or without using Momo, GAG can be directly invoked by
%wish $MOMOPATH/GAG/GAG.tcl
Good luck!
Binary file not shown.
@@ -1,256 +0,0 @@
/*
* @(#)ExampleFileFilter.java 1.4 98/04/14
*
* Copyright (c) 1998 Sun Microsystems, Inc. All Rights Reserved.
*
* This software is the confidential and proprietary information of Sun
* Microsystems, Inc. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Sun.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
* SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
* SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
* THIS SOFTWARE OR ITS DERIVATIVES.
*
*/
import java.io.File;
import java.util.Hashtable;
import java.util.Enumeration;
import com.sun.java.swing.*;
import com.sun.java.swing.preview.filechooser.*;
import com.sun.java.swing.preview.*;
/**
* A convenience implementation of FileFilter that filters out
* all files except for those type extensions that it knows about.
*
* Extensions are of the type ".foo", which is typically found on
* Windows and Unix boxes, but not on Macinthosh. Case is ignored.
*
* Example - create a new filter that filerts out all files
* but gif and jpg image files:
*
* JFileChooser chooser = new JFileChooser();
* ExampleFileFilter filter = new ExampleFileFilter(
* new String{"gif", "jpg"}, "JPEG & GIF Images")
* chooser.addChoosableFileFilter(filter);
* chooser.showOpenDialog(this);
*
* @version 1.4 04/14/98
* @author Jeff Dinkins
*/
public class ExampleFileFilter extends FileFilter {
private static String TYPE_UNKNOWN = "Type Unknown";
private static String HIDDEN_FILE = "Hidden File";
private Hashtable filters = null;
private String description = null;
private String fullDescription = null;
private boolean useExtensionsInDescription = true;
/**
* Creates a file filter. If no filters are added, then all
* files are accepted.
*
* @see #addExtension
*/
public ExampleFileFilter() {
this((String) null, (String) null);
}
/**
* Creates a file filter that accepts files with the given extension.
* Example: new ExampleFileFilter("jpg");
*
* @see #addExtension
*/
public ExampleFileFilter(String extension) {
this(extension,null);
}
/**
* Creates a file filter that accepts the given file type.
* Example: new ExampleFileFilter("jpg", "JPEG Image Images");
*
* Note that the "." before the extension is not needed. If
* provided, it will be ignored.
*
* @see #addExtension
*/
public ExampleFileFilter(String extension, String description) {
this(new String[] {extension}, description);
}
/**
* Creates a file filter from the given string array.
* Example: new ExampleFileFilter(String {"gif", "jpg"});
*
* Note that the "." before the extension is not needed adn
* will be ignored.
*
* @see #addExtension
*/
public ExampleFileFilter(String[] filters) {
this(filters, null);
}
/**
* Creates a file filter from the given string array and description.
* Example: new ExampleFileFilter(String {"gif", "jpg"}, "Gif and JPG Images");
*
* Note that the "." before the extension is not needed and will be ignored.
*
* @see #addExtension
*/
public ExampleFileFilter(String[] filters, String description) {
this.filters = new Hashtable(filters.length);
for (int i = 0; i < filters.length; i++) {
// add filters one by one
addExtension(filters[i]);
}
setDescription(description);
}
/**
* Return true if this file should be shown in the directory pane,
* false if it shouldn't.
*
* Files that begin with "." are ignored.
*
* @see #getExtension
* @see FileFilter#accepts
*/
public boolean accept(File f) {
if(f != null) {
if(f.isDirectory()) {
return true;
}
String extension = getExtension(f);
if(extension != null && filters.get(getExtension(f)) != null) {
return true;
};
}
return false;
}
/**
* Return the extension portion of the file's name .
*
* @see #getExtension
* @see FileFilter#accept
*/
public String getExtension(File f) {
if(f != null) {
String filename = f.getName();
int i = filename.lastIndexOf('.');
if(i>0 && i<filename.length()-1) {
return filename.substring(i+1).toLowerCase();
};
}
return null;
}
/**
* Adds a filetype "dot" extension to filter against.
*
* For example: the following code will create a filter that filters
* out all files except those that end in ".jpg" and ".tif":
*
* ExampleFileFilter filter = new ExampleFileFilter();
* filter.addExtension("jpg");
* filter.addExtension("tif");
*
* Note that the "." before the extension is not needed and will be ignored.
*/
public void addExtension(String extension) {
if(filters == null) {
filters = new Hashtable(5);
}
filters.put(extension.toLowerCase(), this);
fullDescription = null;
}
/**
* Returns the human readable description of this filter. For
* example: "JPEG and GIF Image Files (*.jpg, *.gif)"
*
* @see setDescription
* @see setExtensionListInDescription
* @see isExtensionListInDescription
* @see FileFilter#getDescription
*/
public String getDescription() {
if(fullDescription == null) {
if(description == null || isExtensionListInDescription()) {
if(description != null) {
fullDescription = description;
}
fullDescription += " (";
// build the description from the extension list
Enumeration extensions = filters.keys();
if(extensions != null) {
fullDescription += "." + (String) extensions.nextElement();
while (extensions.hasMoreElements()) {
fullDescription += ", " + (String) extensions.nextElement();
}
}
fullDescription += ")";
} else {
fullDescription = description;
}
}
return fullDescription;
}
/**
* Sets the human readable description of this filter. For
* example: filter.setDescription("Gif and JPG Images");
*
* @see setDescription
* @see setExtensionListInDescription
* @see isExtensionListInDescription
*/
public void setDescription(String description) {
this.description = description;
fullDescription = null;
}
/**
* Determines whether the extension list (.jpg, .gif, etc) should
* show up in the human readable description.
*
* Only relevent if a description was provided in the constructor
* or using setDescription();
*
* @see getDescription
* @see setDescription
* @see isExtensionListInDescription
*/
public void setExtensionListInDescription(boolean b) {
useExtensionsInDescription = b;
fullDescription = null;
}
/**
* Returns whether the extension list (.jpg, .gif, etc) should
* show up in the human readable description.
*
* Only relevent if a description was provided in the constructor
* or using setDescription();
*
* @see getDescription
* @see setDescription
* @see setExtensionListInDescription
*/
public boolean isExtensionListInDescription() {
return useExtensionsInDescription;
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,256 +0,0 @@
/*
* @(#)ExampleFileFilter.java 1.4 98/04/14
*
* Copyright (c) 1998 Sun Microsystems, Inc. All Rights Reserved.
*
* This software is the confidential and proprietary information of Sun
* Microsystems, Inc. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Sun.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
* SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
* SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
* THIS SOFTWARE OR ITS DERIVATIVES.
*
*/
import java.io.File;
import java.util.Hashtable;
import java.util.Enumeration;
import com.sun.java.swing.*;
import com.sun.java.swing.preview.filechooser.*;
import com.sun.java.swing.preview.*;
/**
* A convenience implementation of FileFilter that filters out
* all files except for those type extensions that it knows about.
*
* Extensions are of the type ".foo", which is typically found on
* Windows and Unix boxes, but not on Macinthosh. Case is ignored.
*
* Example - create a new filter that filerts out all files
* but gif and jpg image files:
*
* JFileChooser chooser = new JFileChooser();
* ExampleFileFilter filter = new ExampleFileFilter(
* new String{"gif", "jpg"}, "JPEG & GIF Images")
* chooser.addChoosableFileFilter(filter);
* chooser.showOpenDialog(this);
*
* @version 1.4 04/14/98
* @author Jeff Dinkins
*/
public class ExampleFileFilter extends FileFilter {
private static String TYPE_UNKNOWN = "Type Unknown";
private static String HIDDEN_FILE = "Hidden File";
private Hashtable filters = null;
private String description = null;
private String fullDescription = null;
private boolean useExtensionsInDescription = true;
/**
* Creates a file filter. If no filters are added, then all
* files are accepted.
*
* @see #addExtension
*/
public ExampleFileFilter() {
this((String) null, (String) null);
}
/**
* Creates a file filter that accepts files with the given extension.
* Example: new ExampleFileFilter("jpg");
*
* @see #addExtension
*/
public ExampleFileFilter(String extension) {
this(extension,null);
}
/**
* Creates a file filter that accepts the given file type.
* Example: new ExampleFileFilter("jpg", "JPEG Image Images");
*
* Note that the "." before the extension is not needed. If
* provided, it will be ignored.
*
* @see #addExtension
*/
public ExampleFileFilter(String extension, String description) {
this(new String[] {extension}, description);
}
/**
* Creates a file filter from the given string array.
* Example: new ExampleFileFilter(String {"gif", "jpg"});
*
* Note that the "." before the extension is not needed adn
* will be ignored.
*
* @see #addExtension
*/
public ExampleFileFilter(String[] filters) {
this(filters, null);
}
/**
* Creates a file filter from the given string array and description.
* Example: new ExampleFileFilter(String {"gif", "jpg"}, "Gif and JPG Images");
*
* Note that the "." before the extension is not needed and will be ignored.
*
* @see #addExtension
*/
public ExampleFileFilter(String[] filters, String description) {
this.filters = new Hashtable(filters.length);
for (int i = 0; i < filters.length; i++) {
// add filters one by one
addExtension(filters[i]);
}
setDescription(description);
}
/**
* Return true if this file should be shown in the directory pane,
* false if it shouldn't.
*
* Files that begin with "." are ignored.
*
* @see #getExtension
* @see FileFilter#accepts
*/
public boolean accept(File f) {
if(f != null) {
if(f.isDirectory()) {
return true;
}
String extension = getExtension(f);
if(extension != null && filters.get(getExtension(f)) != null) {
return true;
};
}
return false;
}
/**
* Return the extension portion of the file's name .
*
* @see #getExtension
* @see FileFilter#accept
*/
public String getExtension(File f) {
if(f != null) {
String filename = f.getName();
int i = filename.lastIndexOf('.');
if(i>0 && i<filename.length()-1) {
return filename.substring(i+1).toLowerCase();
};
}
return null;
}
/**
* Adds a filetype "dot" extension to filter against.
*
* For example: the following code will create a filter that filters
* out all files except those that end in ".jpg" and ".tif":
*
* ExampleFileFilter filter = new ExampleFileFilter();
* filter.addExtension("jpg");
* filter.addExtension("tif");
*
* Note that the "." before the extension is not needed and will be ignored.
*/
public void addExtension(String extension) {
if(filters == null) {
filters = new Hashtable(5);
}
filters.put(extension.toLowerCase(), this);
fullDescription = null;
}
/**
* Returns the human readable description of this filter. For
* example: "JPEG and GIF Image Files (*.jpg, *.gif)"
*
* @see setDescription
* @see setExtensionListInDescription
* @see isExtensionListInDescription
* @see FileFilter#getDescription
*/
public String getDescription() {
if(fullDescription == null) {
if(description == null || isExtensionListInDescription()) {
if(description != null) {
fullDescription = description;
}
fullDescription += " (";
// build the description from the extension list
Enumeration extensions = filters.keys();
if(extensions != null) {
fullDescription += "." + (String) extensions.nextElement();
while (extensions.hasMoreElements()) {
fullDescription += ", " + (String) extensions.nextElement();
}
}
fullDescription += ")";
} else {
fullDescription = description;
}
}
return fullDescription;
}
/**
* Sets the human readable description of this filter. For
* example: filter.setDescription("Gif and JPG Images");
*
* @see setDescription
* @see setExtensionListInDescription
* @see isExtensionListInDescription
*/
public void setDescription(String description) {
this.description = description;
fullDescription = null;
}
/**
* Determines whether the extension list (.jpg, .gif, etc) should
* show up in the human readable description.
*
* Only relevent if a description was provided in the constructor
* or using setDescription();
*
* @see getDescription
* @see setDescription
* @see isExtensionListInDescription
*/
public void setExtensionListInDescription(boolean b) {
useExtensionsInDescription = b;
fullDescription = null;
}
/**
* Returns whether the extension list (.jpg, .gif, etc) should
* show up in the human readable description.
*
* Only relevent if a description was provided in the constructor
* or using setDescription();
*
* @see getDescription
* @see setDescription
* @see setExtensionListInDescription
*/
public boolean isExtensionListInDescription() {
return useExtensionsInDescription;
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,618 +0,0 @@
// GAG (Geant4 Adaptive GUI)
// Requires : JDK 1.1.3 (or later) + swing-1.0.2
// Version : alpha 1998/Mar/31
// GEANT4 GUI Group, Toshiaki Kodama
// H Yoshida 1998 June , for Beta release
// Now, use swing 1.0.2 JFileChooser to select by file extensions
// Now displayed labels change color to notify busy state.
// July 1, add @@Ask to accept users key-in with showInputDialog (imcomplete)
// July 5 now use more readable fonts.
package GAG;
import TextEdit.TextEdit;
// Swing 1.0.2 ExampleFileFilter.class is in the same dir as gag.class
import ExampleFileFilter;
import com.sun.java.swing.preview.*;
import com.sun.java.swing.preview.filechooser.*;
// now use Swing-1.0.2 FileChooser, yet in the preview stage !!
import java.awt.*;
//import java.awt.Cursor.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;
import com.sun.java.swing.*;
import com.sun.java.swing.event.*;
import com.sun.java.swing.tree.*;
public class GAG extends JFrame implements TreeSelectionListener, ActionListener {
static final String gagVer = "J1.0a";
private String g4Ver, command;
private GAGpipe geant4;
private ErrStream errStream;
private GAGtextEditor textEdit;
private Hashtable paramsHash;
private Vector disableCommands;
private ParamPanel paramPanel;
private JPanel geantPanel;
private JSplitPane splitPane;
private JFileChooser geant4Chooser, historyChooser;
private JMenuItem execG4, exitG4, killG4, exitGAG, clearOneHist, clearAllHist, saveHist, htmlHelp, about;
private JTextField directField;
private JLabel promptLabel;
private String fileName;
private CardLayout cardLayout;
private boolean endGAG;
//use p1' background color to show GEANT4's busy states. Not Yet!
private JPanel p1;
// FileFilter in Swing-1.0.2 test
private ExampleFileFilter exeFilter, outFilter, g4hFilter,
g4histFilter, txtFilter, histFilter;
public GAG(){
super("GAG");
getContentPane().setLayout(cardLayout = new CardLayout());
geantPanel = new JPanel(new BorderLayout());
JMenu geantMenu = new JMenu("GEANT4");
geantMenu.setBackground(Color.orange);
geantMenu.setFont(new Font("Serif", Font.BOLD, 12));
execG4 = new JMenuItem("Exec GEANT4");
exitG4 = new JMenuItem("Exit GEANT4");
killG4 = new JMenuItem("Kill GEANT4");
exitGAG = new JMenuItem("Exit GAG");
execG4.setBackground(Color.green);
exitG4.setBackground(Color.green);
killG4.setBackground(Color.orange);
exitGAG.setFont(new Font("Serif", Font.BOLD, 12));
execG4.setFont(new Font("Serif", Font.BOLD, 12));
exitG4.setFont(new Font("Serif", Font.BOLD, 12));
killG4.setFont(new Font("Serif", Font.BOLD, 12));
exitGAG.setFont(new Font("Serif", Font.BOLD, 12));
geantMenu.add(execG4);
geantMenu.add(exitG4);
geantMenu.add(killG4);
geantMenu.addSeparator();
geantMenu.add(exitGAG);
JMenu histMenu = new JMenu("History");
histMenu.setBackground(Color.yellow);
histMenu.setFont(new Font("Serif", Font.BOLD, 12));
clearOneHist = new JMenuItem("Clear One");
clearAllHist = new JMenuItem("Clear All");
saveHist = new JMenuItem("Save history");
clearOneHist.setBackground(Color.yellow);
clearAllHist.setBackground(Color.yellow);
saveHist.setBackground(Color.green);
clearOneHist.setFont(new Font("Serif", Font.BOLD, 12));
clearAllHist.setFont(new Font("Serif", Font.BOLD, 12));
saveHist.setFont(new Font("Serif", Font.BOLD, 12));
histMenu.add(clearOneHist);
histMenu.add(clearAllHist);
histMenu.add(saveHist);
JMenu helpMenu = new JMenu("Help");
helpMenu.setBackground(Color.white);
helpMenu.setFont(new Font("Serif", Font.BOLD, 12));
helpMenu.add(htmlHelp = new JMenuItem("Help"));
helpMenu.add(about = new JMenuItem("About"));
execG4.addActionListener(this);
exitG4.addActionListener(this);
killG4.addActionListener(this);
exitGAG.addActionListener(this);
clearOneHist.addActionListener(this);
clearAllHist.addActionListener(this);
saveHist.addActionListener(this);
htmlHelp.addActionListener(this);
about.addActionListener(this);;
JMenuBar mb = new JMenuBar();
mb.add(geantMenu);
mb.add(histMenu);
mb.add(helpMenu); // mb.setHelpMenu(helpMenu);
//to the last position executingMenu(false);
setJMenuBar(mb);
directField = new JTextField();
directField.setFont(new Font("Serif", Font.BOLD, 12));
directField.addActionListener(this);
p1 = new JPanel(new BorderLayout());
promptLabel = new JLabel("****** PROMPT ******", JLabel.CENTER);
promptLabel.setForeground(Color.black);
promptLabel.setFont(new Font("Serif", Font.BOLD, 12));
p1.add("Center", directField);
p1.add("West", promptLabel);
geantPanel.add("South", p1);
JLabel idleLabel =new JLabel("Welcome to GEANT4",JLabel.CENTER);
idleLabel.setFont(new Font("Serif", Font.BOLD, 18));
getContentPane().add("idle", idleLabel);
JLabel treeLabel = new JLabel("Making command tree");
treeLabel.setFont(new Font("Serif", Font.BOLD, 18));
getContentPane().add("tree", treeLabel);
getContentPane().add("geant",geantPanel);
cardLayout.show(getContentPane(), "idle");
setSize(600,400);
setVisible(true);
geant4Chooser = new JFileChooser(".");
// Swing 1.0.2 FileFilter OK!! 1998 June 25
geant4Chooser.setDialogTitle("GEANT4 Executable");
exeFilter = new ExampleFileFilter("exe", "DOS executable");
outFilter = new ExampleFileFilter("out", "Unix executable");
geant4Chooser.addChoosableFileFilter(exeFilter);
geant4Chooser.addChoosableFileFilter(outFilter);
//
historyChooser = new JFileChooser(".");
// Swing 1.0.2 FileFilter OK!! 1998 June 25
historyChooser.setDialogTitle("Command History");
g4hFilter = new ExampleFileFilter("g4h", "Geant4 History");
g4histFilter = new ExampleFileFilter("g4hist", "Geant4 History");
txtFilter = new ExampleFileFilter("txt", "Geant4 History");
histFilter = new ExampleFileFilter("hist", "Geant4 History");
historyChooser.addChoosableFileFilter(g4hFilter);
historyChooser.addChoosableFileFilter(g4histFilter);
historyChooser.addChoosableFileFilter(txtFilter);
historyChooser.addChoosableFileFilter(histFilter);
// end of Swing test
executingMenu(false);
}
private void executingMenu(boolean b){
execG4.setEnabled(!b);
//originally exitG4.setEnabled(b);
exitG4.setEnabled(!b);
killG4.setEnabled(b);
//yoshida
// exitGAG.setEnabled(b);
clearOneHist.setEnabled(b);
clearAllHist.setEnabled(b);
saveHist.setEnabled(b);
//
//this hide allthe time p1.setVisible(!b);
if (!b) {
p1.setBackground(Color.green); repaint();
}else{
p1.setBackground(Color.red); repaint();
}
}
public void mainLoop(String args[]){
endGAG = false;
if (args.length > 0) {
fileName = args[0];
geantStart(args);
}
String[] fn = new String[1];
while(!endGAG){
waiting();
if (endGAG) return;
fn[0] = fileName;
geantStart(fn);
}
}
private synchronized void waiting(){
try{
wait();
}catch(InterruptedException e){
}
}
private synchronized void resume(){
notify();
}
private void geantStart(String[] args){
String line, prompt = "G4";
geant4 = new GAGpipe(args);
boolean paramChanged = false;
if (geant4.isError()){
JOptionPane.showMessageDialog(this, geant4.getErrorMsg(),
"Warning", JOptionPane.WARNING_MESSAGE);
geant4 = null;
return;
}
executingMenu(true);
if (textEdit == null) textEdit = new TextEdit();
errStream = new ErrStream(geant4);
errStream.start();
geant4.writeLine("@@GAGmodeJAVA");
while ((line = geant4.readStdLine()) != null){
if (line.startsWith("@@")){
if (line.equals("@@JTreeBegin")){
if (makeCommandTree()) break;
continue;
}
if (line.equals("@@JParamBegin")){
if (receiveParams()) break;
paramChanged = true;
continue;
}
if (line.equals("@@JDirGuideBegin")){
if (receiveCascade()) break;
continue;
}
if (line.equals("@@DisableListBegin")){
if (receiveDisables()) break;
paramChanged = true;
continue;
}
if (line.equals("@@Ready")){
//yoshida effective even if paramPanel is null. But PROMPT case is enough.
p1.setVisible(true);
p1.setBackground(Color.green); repaint();
if (paramPanel != null) {
paramPanel.toReady();
if (paramChanged && !command.equals("")) setParamPanel(command);
}
paramChanged = false;
textEdit.writeString(prompt + ">");
exitG4.setEnabled(true);
continue;
}
if (line.startsWith("@@PROMPT")){
prompt = line.substring(line.indexOf("\"")+1, line.lastIndexOf("\""));
promptLabel.setText(prompt);
//yoshida effective even if paramPanel is null
p1.setVisible(true);
p1.setBackground(Color.green); repaint();
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
show();
continue;
}
if (line.startsWith("@@State")){
continue;
}
// direct interaction with users
if (line.startsWith("@@Ask")){
String answer = JOptionPane.showInputDialog(this,line);
geant4.writeLine(answer);
continue;
}
//direct questionnaire
if (line.startsWith("@@CurrentValue")){
paramPanel.loadCurrentValues(line);
textEdit.writeLine(line.substring(line.indexOf(" ")+1));
continue;
}
if (line.startsWith("@@Version")){
StringTokenizer st = new StringTokenizer( line );
st.nextToken();
g4Ver = st.nextToken();
continue;
}
if (line.startsWith("@@ErrResult")){
JOptionPane.showMessageDialog(this,
line.substring(line.indexOf("\"")+1, line.lastIndexOf("\"")),
"Warning", JOptionPane.WARNING_MESSAGE);
continue;
}
}
textEdit.writeLine(line);
}
geantTerminate();
}
private void geantTerminate(){
executingMenu(false);
if (geant4 != null){
geant4.processKill();
geant4 = null;
}
paramsHash = null;
if (errStream != null){
errStream.close();
errStream = null;
}
cardLayout.show(getContentPane(), "idle");
paramPanel = null;
}
private boolean makeCommandTree() {
String pLine, label;
command = "";
DefaultMutableTreeNode topTree, nowTree, childTree;
boolean found;
cardLayout.show(getContentPane(), "tree");
if (splitPane != null) geantPanel.remove(splitPane);
int lastIndex = fileName.lastIndexOf("/");
topTree = new DefaultMutableTreeNode( (lastIndex<0) ? fileName : fileName.substring(lastIndex+1) );
while( !(pLine = geant4.readStdLine()).equals("@@JTreeEnd") ){
if (pLine == null){ return true;}
nowTree = topTree; childTree = null; found = true;
StringTokenizer stCo = new StringTokenizer(pLine,"/");
while(stCo.hasMoreTokens()){
label = stCo.nextToken();
if (found){
found = false;
for (int i=0; i<nowTree.getChildCount(); i++){
childTree = (DefaultMutableTreeNode)nowTree.getChildAt(i);
if (label.equals( (String)childTree.getUserObject() )){
found = true;
break;
}
}
}
if (found == false) nowTree.add(childTree = new DefaultMutableTreeNode(label));
nowTree = childTree;
}
}
JTree tree = new JTree(topTree);
tree.addTreeSelectionListener(this);
paramPanel = new ParamPanel(this);
splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(tree), paramPanel );
// test 1998 June 25 to keep left space
splitPane.setDividerLocation(200);
geantPanel.add("Center", splitPane);
cardLayout.show(getContentPane(), "geant");
paramsHash = new Hashtable();
disableCommands = new Vector();
return false;
}
private boolean receiveParams() {
String lines, name, guide[], range;
int guideEnts, paramEnts;
name = geant4.readStdLine();
lines = geant4.readStdLine();
try{
guideEnts = Integer.parseInt(lines);
}catch(NumberFormatException e){
return true;
}
guide = new String[guideEnts];
for (int i=0; i<guideEnts; i++){
guide[i] = geant4.readStdLine();
}
range = geant4.readStdLine();
if (geant4.isError()) return true;
lines = geant4.readStdLine();
try{
paramEnts = Integer.parseInt(lines);
}catch(NumberFormatException e){
return true;
}
GAGcommandItem ci = new GAGcommandItem(name, guide, range, paramEnts);
for (int i=0; i<ci.getParamEntries(); i++){
for (int j=0; j<ci.MAX; j++){
lines = geant4.readStdLine();
if (lines == null) return true;
ci.params[i][j]=lines;
}
}
if ( !(geant4.readStdLine()).equals("@@JParamEnd") ) return true;
paramsHash.put(name, ci);
return false;
}
private boolean receiveCascade() {
String name, guide;
name = geant4.readStdLine();
guide = geant4.readStdLine();
// System.out.println("CASCADE: "+name+" "+guide);
if ( !(geant4.readStdLine()).equals("@@JDirGuideEnd") ) return true;
paramsHash.put(name, guide);
return false;
}
private boolean receiveDisables(){
String line;
disableCommands.removeAllElements();
while(!(line = geant4.readStdLine()).equals("@@DisableListEnd")){
if (line == null) return true;
disableCommands.addElement(line);
}
return false;
}
void reqCurrent(String cmd){
sendCommand("?"+cmd);
return;
}
void sendCommand(String com){
textEdit.writeLine(com);
geant4.writeLine(com);
exitG4.setEnabled(false);
//yoshida cursor
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
p1.setBackground(Color.red); repaint();
p1.setVisible(true);
// executingMenu(true);
// too much?
}
boolean setParamPanel(String key){
GAGcommandItem ci = (GAGcommandItem)paramsHash.get(key);
if (ci == null) return false;
command = key;
paramPanel.setParamBox(ci, isEnableCommand(key));
return true;
}
public void valueChanged(TreeSelectionEvent te){
if ( te.isAddedPath() == false ) return;
String dirHelp, tempPath;
StringBuffer com = new StringBuffer();
Object path[] = te.getPath().getPath();
if (path.length > 1) {
for (int i=1; i<path.length; i++) com.append(("/"+path[i]));
command = com.toString();
}else{
command = "";
}
DefaultMutableTreeNode nowNode = (DefaultMutableTreeNode)path[path.length-1];
int childCount = nowNode.getChildCount();
if ( childCount > 0 ){
DefaultMutableTreeNode tempNode;
if (path.length > 1) {
dirHelp = (String)paramsHash.get(command+"/");
}else{
dirHelp = new String(path[0].toString());
}
JLabel[][] helpLabel = new JLabel[2][childCount];
for (int i=0; childCount > i; i++){
tempNode = (DefaultMutableTreeNode)nowNode.getChildAt(i);
tempPath = command + "/" + tempNode;
if (tempNode.getChildCount() == 0){
helpLabel[0][i] = new JLabel(tempNode+" ");
helpLabel[0][i].setForeground(isEnableCommand(tempPath) ? Color.red : Color.lightGray);
helpLabel[1][i] = new JLabel(((GAGcommandItem)(paramsHash.get(tempPath))).getTitle());
}else{
helpLabel[0][i] = new JLabel(tempNode+"/ ");
helpLabel[0][i].setForeground(isEnableCommand(tempPath+"/") ? Color.blue : Color.lightGray);
helpLabel[1][i] = new JLabel((String)paramsHash.get(tempPath +"/"));
}
}
paramPanel.setTreeHelp(dirHelp, helpLabel);
}else{
GAGcommandItem ci = (GAGcommandItem)paramsHash.get(command);
if (ci == null) return;
paramPanel.setParamBox(ci, isEnableCommand(command));
}
return;
}
boolean isEnableCommand(String command){
return !disableCommands.contains(command);
}
public void actionPerformed(ActionEvent ae){
Object o = ae.getSource();
if ( o == directField){
sendCommand(directField.getText());
paramPanel.addHistory(directField.getText());
directField.setText("");
return;
}
if (o == exitGAG){
if (geant4 != null) {
if(JOptionPane.showConfirmDialog(this, "Kill GEANT4 automatically.", "Exit GAG", JOptionPane.YES_NO_OPTION) == 1) {return;}
geantTerminate();
endGAG = true;
}else{
resume();
endGAG = true;
}
return;
}
if (o == exitG4){
sendCommand("exit");
return;
}
if (o == execG4){
if (geant4Chooser.showOpenDialog(this) == -1 )return;
// Swing1.0.2
File f = geant4Chooser.getSelectedFile();
if (f.isFile()) {
fileName = f.getPath();
resume();
}
return;
}
if (o == killG4){
geantTerminate();
return;
}
if (o == htmlHelp){
return;
}
if (o == about){
new AboutDialog(this, gagVer, g4Ver);
return;
}
if (o == clearAllHist){
paramPanel.clearAllHistory();
return;
}
if (o == clearOneHist){
paramPanel.clearOneHistory();
return;
}
if (o == saveHist){
if (historyChooser.showSaveDialog(this) == -1 ) return;
// Swing1.0.2
try{
FileOutputStream fo = new FileOutputStream(historyChooser.getSelectedFile());
PrintWriter outf = new PrintWriter(new DataOutputStream(fo));
String[] items = paramPanel.getHistoryItems();
for (int i=0; i<items.length; i++) outf.println(items[i]);
outf.close();
}catch(IOException e){ System.out.println(e.getMessage()); }
return;
}
}
}
class ErrStream extends Thread implements ActionListener {
private GAGpipe geant4;
private Frame errFrame;
private TextArea errArea;
private Button close;
ErrStream(GAGpipe geant4){
this.geant4 = geant4;
errFrame = new Frame("Std Error");
errFrame.setLayout(new BorderLayout());
errFrame.add("Center", errArea = new TextArea());
errFrame.add("South", close = new Button("Close"));
close.addActionListener(this);
errFrame.setSize(400, 200);
}
public void run(){
String line;
while((line=geant4.readErrLine())!=null){
errArea.append(line+"\n");
if (!errFrame.isVisible()) errFrame.setVisible(true);
}
}
public void actionPerformed(ActionEvent ae){
errFrame.setVisible(false);
errArea.setText("");
}
void close(){
errFrame.dispose();
stop();
}
}
class AboutDialog extends Dialog implements ActionListener {
Button ok;
public AboutDialog(Frame parent, String ver1, String ver2){
super(parent, "About GAG", true);
setForeground(Color.black);
Panel center = new Panel(new GridLayout(0,1));
center.add(new Label("GAG Version "+ ver1));
center.add(new Label("G4UIGAG Version "+ ver2));
center.add(new Label("Toshiaki Kodama, GEANT4 GUI GROUP"));
add("Center", center);
Panel p = new Panel();
ok = new Button("Ok");
ok.addActionListener(this);
p.add(ok);
add("South",p);
pack();
setVisible(true);
}
public void actionPerformed(ActionEvent event) {
if (event.getSource() == ok)
dispose();
}
}
@@ -1,61 +0,0 @@
// GAG (Geant4 Adaptive GUI)
// Requires : JDK 1.1.3 (or later) + swing-1.0.2
// Version : alpha 1998/Mar/31
// GEANT4 GUI Group, Toshiaki Kodama
// 1998 July 6 GEANT4 Beta-01
package GAG;
class GAGcommandItem extends Object {
static final int NAME=0, GUIDE=1, TYPE=2, OMITTABLE=3, DEFAULT=4, RANGE=5, CANDIDATE=6;
static final int MAX = 7;
private String name, guide[], range;
private int paramEnts;
String params[][];
GAGcommandItem(String name, String guide[], String range, int ents){
this.name = name;
this.guide = guide;
paramEnts = ents;
if (ents > 0) {
params = new String[paramEnts][MAX];
}
this.range = range;
return;
}
String getCommandName(){
return name;
}
String[] getCommandGuide(){
return guide;
}
String getTitle(){
return guide[0];
}
String getCommandRange(){
return range;
}
int getParamEntries(){
return paramEnts;
}
String getParamName(int pos){
return params[pos][NAME];
}
String getParamGuide(int pos){
return params[pos][GUIDE];
}
String getParamType(int pos){
return params[pos][TYPE];
}
boolean isOmittable(int ent){
return params[ent][OMITTABLE].equals("1");
}
String getParamDefault(int pos){
return params[pos][DEFAULT];
}
String getParamRange(int pos){
return params[pos][RANGE];
}
String getParamCandidate(int pos){
return params[pos][CANDIDATE];
}
}
Binary file not shown.
@@ -1,66 +0,0 @@
// GAG (Geant4 Adaptive GUI)
// Requires : JDK 1.1.3 (or later) + swing-1.0.2
// Version : alpha 1998/Mar/31
// GEANT4 GUI Group, Toshiaki Kodama
// 1998 July 6 GEANT4 Beta-01
package GAG;
import java.io.*;
class GAGpipe {
private Process ps;
private BufferedReader inpS, errS;
private PrintWriter outS;
private String errMsg;
private boolean isErr;
GAGpipe(String[] execFile){
errMsg = null; isErr = false;
try {
ps = Runtime.getRuntime().exec(execFile);
} catch(IOException e){
isErr = true;
errMsg = e.getMessage();
return;
}
inpS = new BufferedReader(new InputStreamReader(ps.getInputStream()));
errS = new BufferedReader(new InputStreamReader(ps.getErrorStream()));
outS = new PrintWriter(new DataOutputStream(ps.getOutputStream()));
}
String readStdLine(){
String line = null;
try{
line=inpS.readLine();
}catch(IOException e){
isErr = true;
errMsg = e.getMessage();
}
return line;
}
String readErrLine(){
String line = null;
try{
line=errS.readLine();
}catch(IOException e){
isErr = true;
errMsg = e.getMessage();
System.err.println(errMsg);
}
return line;
}
synchronized boolean writeLine(String st){
outS.println(st);
return outS.checkError();
}
synchronized void processKill(){
ps.destroy();
}
boolean isError(){
return isErr;
}
String getErrorMsg(){
if (!isErr) return "";
return errMsg;
}
}
@@ -1,13 +0,0 @@
// GAG (Geant4 Adaptive GUI)
// Requires : JDK 1.1.3 (or later) + swing-1.0.2
// Version : alpha 1998/Mar/31
// Toshiaki Kodama GEANT4 GUI Group
// 1998 July 6 GEANT4 Beta-01
// This is an junction to better TextEditor in future.
package GAG;
public interface GAGtextEditor {
public void writeString(String str);
public void writeLine(String str);
}
Binary file not shown.
@@ -1,31 +0,0 @@
// jdk-1.1.3 (or later) + swing-1.0.2
// This is not required in GAG
import com.sun.java.swing.*;
import java.awt.*;
import java.net.URL;
import java.net.MalformedURLException;
import java.io.IOException;
public class HtmlFrame extends JFrame {
public HtmlFrame() {
// setBackground(Color.white);
setLayout(new BorderLayout());
try {
URL url = new URL("http://erlt1.naruto-u.ac.jp/~geant4/README_Momo.html");
JEditorPane html = new JEditorPane(url);
JScrollPane scroller = new JScrollPane(html);
add("Center", scroller);
} catch (MalformedURLException e) {
System.out.println("Malformed URL: " + e);
} catch (IOException e) {
System.out.println("IOException: " + e);
}
setSize(400, 400);
show();
}
public static void main(String arg[]){
new HtmlFrame();
}
}
Binary file not shown.
@@ -1,416 +0,0 @@
// GAG (Geant4 Adaptive GUI)
// Requires : JDK 1.1.3 (or later) + swing-1.0.2
// Version : alpha 1998/Mar/31
// GEANT4 GUI Group, Toshiaki Kodama
// modified by H Yoshida, 1998 June 25
// use of FileFilter of Swing 1.0.2, to select after file extensions
// improvement of notification method of GEANT4 states
// by using setVisible and setBackground of relevant buttons
// specially "ok" button.
package GAG;
import com.sun.java.swing.preview.*;
//FileFilter of Swing1.0.2
import ExampleFileFilter;
import java.util.*;
import java.awt.*;
import java.io.*;
import java.awt.event.*;
import com.sun.java.swing.*;
import com.sun.java.swing.preview.filechooser.*;
// for Swing-1.0.2 FileChooser
class ParamPanel extends JPanel implements ActionListener, ItemListener {
private GAG gag;
private GridBagLayout gbl; GridBagConstraints gbc;
private JPanel paramArea;
private JButton def, current, clear, ok, fileBrowser;
private JComboBox history;
private int posY;
private GAGcommandItem ci;
private Component paraBox[];
private boolean isExecuting;
private JFileChooser fileChooser;
// FileFilter in Swing-1.0.2 test
private ExampleFileFilter g4mFilter, macroFilter, g4macroFilter,
txtFilter;
ParamPanel(GAG gag){
isExecuting = false;
this.gag = gag;
setLayout( new BorderLayout() );
gbc = new GridBagConstraints();
gbl = new GridBagLayout();
paramArea = new JPanel();
paramArea.setLayout(gbl);
paramArea.setBackground(new Color(255, 250, 230));
add("Center", new JScrollPane(paramArea));
JPanel buttons = new JPanel();
buttons.setLayout(new GridLayout( 1, 0, 2, 2));
// Yoshida color
def = new JButton("Default");
current = new JButton("Current");
clear = new JButton("Clear");
ok = new JButton("OK");
ok.setBackground(Color.green);
//no good?? ok.setFont(new Font("OK",1,12));
def.setBackground(Color.blue);
current.setBackground(Color.orange);
clear.setBackground(SystemColor.white);
// ok.setBackground(SystemColor.control);
// color
buttons.add( def );
buttons.add( current );
buttons.add( clear );
buttons.add( ok );
add("South", buttons);
history = new JComboBox();
history.addItem("# GEANT4 history macro.");
history.addItemListener(this);
add("North", history);
//yoshida setinvisible and setdisable
def.setVisible(false);
def.setEnabled(false);
def.setMargin(new Insets(1,3,1,3));
def.addActionListener(this);
//yoshida
current.setVisible(false);
current.setEnabled(false);
current.setMargin(new Insets(1,3,1,3));
current.addActionListener(this);
//yoshida
clear.setVisible(false);
clear.setEnabled(false);
clear.setMargin(new Insets(1,3,1,3));
clear.addActionListener(this);
//yoshida
ok.setVisible(false);
ok.setEnabled(false);
ok.setMargin(new Insets(1,3,1,3));
ok.addActionListener(this);
fileBrowser = new JButton("Open a Macro File");
fileBrowser.addActionListener(this);
fileChooser = new JFileChooser(".");
// Swing 1.0.2 FileFilter OK!! 1998 June 25
fileChooser.setDialogTitle("Macro File");
g4mFilter = new ExampleFileFilter("g4m", "Geant4 macro");
g4macroFilter = new ExampleFileFilter("g4macro", "Geant4 macro");
txtFilter = new ExampleFileFilter("txt", "Geant4 macro");
macroFilter = new ExampleFileFilter("macro", "Geant4 macro");
fileChooser.addChoosableFileFilter(g4mFilter);
fileChooser.addChoosableFileFilter(g4macroFilter);
fileChooser.addChoosableFileFilter(txtFilter);
fileChooser.addChoosableFileFilter(macroFilter);
// end of Swing-1.0.2 FileChooser
}
void setParamBox(GAGcommandItem ci, boolean enable){
paramArea.removeAll();
this.ci = ci;
posY = 0;
JLabel l;
if (!enable){
l = new JLabel("This command is not available.");
l.setForeground(Color.red);
addComponent(l);
}
addComponent(new JLabel(ci.getCommandName()));
String guide[] = ci.getCommandGuide();
for (int i=0; i<guide.length; i++){
addComponent(new JLabel(guide[i]));
}
if (!ci.getCommandRange().equals("")){
l = new JLabel(ci.getCommandRange());
l.setForeground(Color.green);
addComponent(l);
}
if (ci.getParamEntries() > 0){
def.setEnabled(true);
//yoshida
def.setVisible(true);
current.setEnabled(!isExecuting && enable);
//yoshida
current.setVisible(!isExecuting && enable);
clear.setEnabled(true);
//yoshida
clear.setVisible(true);
paraBox = new JComponent[ci.getParamEntries()];
String candidateList;
for (int i=0; i<ci.getParamEntries(); i++){
candidateList = ci.getParamCandidate(i);
if (candidateList.equals("")){
if (ci.getParamType(i).equals("b")){
paraBox[i] = new BooleanCombo(ci.getParamDefault(i));
}else{
paraBox[i] = new JTextField(20);
((JTextField)paraBox[i]).setText(ci.getParamDefault(i));
}
}else{
paraBox[i] = new JComboBox();
StringTokenizer st = new StringTokenizer(candidateList);
while(st.hasMoreTokens()){
((JComboBox)paraBox[i]).addItem(st.nextToken());
}
if (!ci.getParamDefault(i).equals("")){
((JComboBox)paraBox[i]).setSelectedItem(ci.getParamDefault(i));
}
}
addComponent(new JLabel(ci.getParamName(i)), paraBox[i], new JLabel("("+ci.getParamType(i) +") "+ci.getParamGuide(i) ));
if (ci.getParamName(i).equals("fileName")) addComponent(new JLabel(), fileBrowser);
}
}else{
//yoshida setinvisible and then setdisable
def.setVisible(false);
def.setEnabled(false);
current.setVisible(false);
current.setEnabled(false);
clear.setVisible(false);
clear.setEnabled(false);
}
ok.setEnabled(!isExecuting && enable);
//yoshida OK button order of enable and visible is important
ok.setVisible(!isExecuting && enable);
validate();
repaint();
return;
}
void setTreeHelp(String dirHelp, JLabel helps[][]){
//yoshida setinvisible then setdisable
ok.setVisible(false);
ok.setEnabled(false);
def.setVisible(false);
def.setEnabled(false);
current.setVisible(false);
current.setEnabled(false);
clear.setVisible(false);
clear.setEnabled(false);
//
paramArea.removeAll();
posY = 0; ci = null;
JLabel title = new JLabel(dirHelp);
title.setForeground(Color.green);
addComponent(title);
for (int i=0; i<helps[0].length; i++){
addComponent(helps[0][i], helps[1][i]);
}
validate();
repaint();
return;
}
private String makeCommandLine(){
StringBuffer param = new StringBuffer(ci.getCommandName());
if (ci.getParamEntries() > 0){
String val;
for (int i=0; i<ci.getParamEntries(); i++){
if (paraBox[i] instanceof JTextField){
val = (((JTextField)paraBox[i]).getText()).trim();
if (val.equals("")){
if (!ci.isOmittable(i)){
JOptionPane.showMessageDialog(this, ci.getParamName(i)+"\nThis parameter cannot omitted.", "Error", JOptionPane.WARNING_MESSAGE);
return null;
}else{
if (!ci.getParamDefault(i).equals(""))
val = ci.getParamDefault(i);
else{
JOptionPane.showMessageDialog(this, ci.getParamName(i)+"\nThis omittable parameter has not default value.", "Error", JOptionPane.WARNING_MESSAGE);
return null;
}
}
}else if ( val.indexOf(" ") >= 0){
JOptionPane.showMessageDialog(this, ci.getParamName(i)+"\nThis parameter cannot include SPACE character", "Error", JOptionPane.WARNING_MESSAGE);
return null;
}
}else{
val = (String)((JComboBox)paraBox[i]).getSelectedItem();
}
param.append(" "+val);
}
//yoshida
current.setVisible(false);
current.setEnabled(false);
}
//yoshida
ok.setVisible(false);
ok.setEnabled(false);
history.addItem(param.toString());
return param.toString();
}
private void addComponent(Component compo){
gbc.gridx = 0; gbc.gridy = posY++;
gbc.gridwidth = 3; gbc.gridheight = 1;
gbc.weightx = 1.0; gbc.weighty = 0.0;
gbc.anchor = GridBagConstraints.WEST;
gbl.setConstraints(compo, gbc);
paramArea.add(compo);
}
private void addComponent(Component compo1, Component compo2){
gbc.gridx = 0; gbc.gridy = posY;
gbc.gridwidth = 1; gbc.gridheight = 1;
gbc.weightx = 0.0; gbc.weighty = 0.0;
gbc.anchor = GridBagConstraints.EAST;
gbl.setConstraints(compo1, gbc);
paramArea.add(compo1);
gbc.gridx = 1;
gbc.anchor = GridBagConstraints.WEST;
gbl.setConstraints(compo2, gbc);
paramArea.add(compo2);
posY++;
}
private void addComponent(Component title, Component compo1, Component compo2){
gbc.gridx = 0; gbc.gridy = posY;
gbc.gridwidth = 1; gbc.gridheight = 1;
gbc.weightx = 0.0; gbc.weighty = 0.0;
gbc.fill = GridBagConstraints.NONE;
gbc.anchor = GridBagConstraints.EAST;
gbl.setConstraints(title, gbc);
paramArea.add(title);
gbc.gridx = 1;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbl.setConstraints(compo1, gbc);
paramArea.add(compo1);
gbc.gridx = 2;
gbc.fill = GridBagConstraints.NONE;
gbc.anchor = GridBagConstraints.WEST;
gbl.setConstraints(compo2, gbc);
paramArea.add(compo2);
posY++;
}
private void loadValue(int i, String str){
if (paraBox[i] instanceof JTextField){
((JTextField)paraBox[i]).setText(str);
}
if (paraBox[i] instanceof JComboBox){
((JComboBox)paraBox[i]).setSelectedItem(str);
}
}
void addHistory(String line){
if (line.startsWith("/")) history.addItem(line);
}
void clearAllHistory(){
history.removeAllItems();
}
void clearOneHistory(){
int ix = history.getSelectedIndex();
if (ix >= 0) history.removeItemAt(ix);
}
String[] getHistoryItems(){
String[] item = new String[history.getItemCount()];
for (int i=0; i>history.getItemCount(); i++){
item[i] = (String)history.getItemAt(i);
}
return item;
}
void loadCurrentValues(String line){
StringTokenizer st = new StringTokenizer( line );
st.nextToken();
int i=0;
while(st.hasMoreTokens()){
loadValue(i++, st.nextToken());
}
}
public void itemStateChanged(ItemEvent ie){
if (isExecuting) return;
if (ie.getStateChange() != ItemEvent.SELECTED) return;
String str = (String)ie.getItem();
if ( !str.startsWith("/") ) return;
StringTokenizer st = new StringTokenizer( str );
if (!gag.setParamPanel(st.nextToken())) return;
int i=0;
while(st.hasMoreTokens()){
loadValue(i++, st.nextToken());
if (i >= ci.getParamEntries()) return;
}
}
public void actionPerformed(ActionEvent ev){
Object source = ev.getSource();
if ( source == ok ){
String p = makeCommandLine();
if (p == null) return;
isExecuting = true;
gag.sendCommand(p);
//yoshida instead of sandwatch, ok button becomes invisible
ok.setVisible(false);
ok.setEnabled(false);
// Be careful! mouse may freeze, if setinvisible but not setdisabled!!
return;
}else if (source == def){
for (int i=0; ci.getParamEntries()>i; i++){
loadValue(i, ci.getParamDefault(i));
}
return;
}else if (source == current){
gag.reqCurrent(ci.getCommandName());
return;
}else if (source == clear){
for (int i=0; ci.getParamEntries()>i; i++){
if (paraBox[i] instanceof JTextField){
((JTextField)paraBox[i]).setText("");
}
}
return;
}else if (source == fileBrowser){
//swing102 filechooser showDialog(this, null) or the next
if (fileChooser.showOpenDialog(this) == -1 ) return;
File f = fileChooser.getSelectedFile();
if (f.isFile()) {
if (paraBox[0] instanceof JTextField){
((JTextField)paraBox[0]).setText(f.getPath());
}
}
return;
}
}
void toReady(){
isExecuting = false;
if (ci == null) return;
ok.setEnabled(true);
//yoshida setenable then setvisible
ok.setVisible(true);
if (ci.getParamEntries() == 0) return;
current.setEnabled(true);
//yoshida
current.setVisible(true);
}
}
class BooleanCombo extends JComboBox {
BooleanCombo(String str){
String def = str.toUpperCase();
if (def.equals("0") || def.equals("1")){
addItem("0");
addItem("1");
}else if (def.equals("Y") || def.equals("N")){
addItem("Y");
addItem("N");
}else if (def.equals("YES") || def.equals("NO")){
addItem("YES");
addItem("NO");
}else if (def.equals("T") || def.equals("F")){
addItem("T");
addItem("F");
} else {
addItem("FALSE");
addItem("TRUE");
}
if (!def.equals("")){
setSelectedItem(def);
}
}
}
@@ -1,24 +0,0 @@
1998 June 25 Yoshida
Improve look-and-feel of GAG by KOdama (as of 31/March/1998).
Swing-1.0.1 is used.
Swing-1.0.2 is desirable, but wait a moment. Swing-1.0.2 has
not yet frozen classes and interfaces, among them JColorChooser
and JFileChooser.
They are left as before in swing.preview package!!
Swing-1.0.2 JFileChooser is good for us since it allows file filtering,
free label on buttons etc..
But it is better to wait JDK1.2!!
So there is only minor improvements.
Font is one of the most iportant improvement.
Current fonts are too small or not beautiful.
Binary file not shown.
@@ -1,131 +0,0 @@
// jdk-1.1.3 (or later) + swing-1.0.2
// JFileChooser is to be used soon.
//
package GAG;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.URL;
import java.util.*;
import com.sun.java.swing.text.*;
import com.sun.java.swing.*;
class TextEditor extends JFrame implements ActionListener {
private JMenuItem newf, open, save, cut, copy, paste;
private JTextArea editor;
private JToolBar toolbar;
protected FileDialog fileDialog;
TextEditor() {
super("GAG TextEditor");
getContentPane().setLayout(new BorderLayout());
editor = new JTextArea();
editor.setFont(new Font("Serif", Font.BOLD, 12));
JScrollPane scroller = new JScrollPane();
//scroller.setVerticalScrollBarPolicy(JScrollPane.SCROLLBARS_ALWAYS);
JViewport port = scroller.getViewport();
port.add(editor);
port.setBackingStoreEnabled(false);
setJMenuBar( createMenubar() );
getContentPane().add("Center", scroller);
pack();
setSize(500, 600);
show();
}
JMenuBar createMenubar(){
JMenu file, edit;
JMenuBar mb = new JMenuBar();
file = new JMenu("File");
file.add(newf = new JMenuItem("New"));
file.add(open = new JMenuItem("Open"));
file.add(save = new JMenuItem("Save"));
edit = new JMenu("Edit");
edit.add(cut = new JMenuItem("Cut"));
edit.add(copy = new JMenuItem("Copy"));
edit.add(paste = new JMenuItem("Paste"));
mb.add(file);
mb.add(edit);
newf.addActionListener(this);
open.addActionListener(this);
save.addActionListener(this);
cut.addActionListener(this);
copy.addActionListener(this);
paste.addActionListener(this);
return mb;
}
void writeString(String s){
editor.append(s);
}
void writeLine(String s){
editor.append(s+"\n");
}
public static void main(String[] args) {
new TextEditor();
}
public void actionPerformed(ActionEvent e) {
Object o = e.getSource();
if (o == newf){newAction(); return;}
if (o == open){openAction(); return;}
if (o == save){saveAction(); return;}
if (o == cut){editor.cut(); return;}
if (o == copy){editor.copy(); return;}
if (o == paste){editor.paste(); return;}
}
void newAction(){
editor.setDocument(new PlainDocument());
validate();
}
void openAction(){
if (fileDialog == null) {
fileDialog = new FileDialog(this);
}
fileDialog.setMode(FileDialog.LOAD);
fileDialog.show();
String file = fileDialog.getFile();
if (file == null) {
return;
}
newAction();
String directory = fileDialog.getDirectory();
File f = new File(directory, file);
StringBuffer sb = new StringBuffer();
if (f.exists()) {
setTitle(file);
try{
Reader in = new FileReader(f);
char[] buff = new char[4096];
int nch;
while ((nch = in.read(buff, 0, buff.length)) != -1) {
sb.append(new String(buff, 0, nch));
}
}catch(IOException e){ System.err.println(e.getMessage()); }
editor.setText(sb.toString());
validate();
}
}
void saveAction(){
String saveText;
if (fileDialog == null) {
fileDialog = new FileDialog(this);
}
fileDialog.setMode(FileDialog.LOAD);
fileDialog.show();
String file = fileDialog.getFile();
if (file == null) {
return;
}
String directory = fileDialog.getDirectory();
File f = new File(directory, file);
try{
FileOutputStream fo = new FileOutputStream(f);
PrintWriter outf = new PrintWriter(new DataOutputStream(fo));
outf.println(editor.getText());
outf.close();
}catch(IOException e){ System.err.println(e.getMessage()); }
}
}
Binary file not shown.
@@ -1,61 +0,0 @@
// GAG (Geant4 Adaptive GUI)
// Requires : JDK 1.1.3 (or later) + swing-1.0.2
// Version : alpha 1998/Mar/31
// GEANT4 GUI Group, Toshiaki Kodama
// 1998 July 6 GEANT4 Beta-01
package GAG;
class GAGcommandItem extends Object {
static final int NAME=0, GUIDE=1, TYPE=2, OMITTABLE=3, DEFAULT=4, RANGE=5, CANDIDATE=6;
static final int MAX = 7;
private String name, guide[], range;
private int paramEnts;
String params[][];
GAGcommandItem(String name, String guide[], String range, int ents){
this.name = name;
this.guide = guide;
paramEnts = ents;
if (ents > 0) {
params = new String[paramEnts][MAX];
}
this.range = range;
return;
}
String getCommandName(){
return name;
}
String[] getCommandGuide(){
return guide;
}
String getTitle(){
return guide[0];
}
String getCommandRange(){
return range;
}
int getParamEntries(){
return paramEnts;
}
String getParamName(int pos){
return params[pos][NAME];
}
String getParamGuide(int pos){
return params[pos][GUIDE];
}
String getParamType(int pos){
return params[pos][TYPE];
}
boolean isOmittable(int ent){
return params[ent][OMITTABLE].equals("1");
}
String getParamDefault(int pos){
return params[pos][DEFAULT];
}
String getParamRange(int pos){
return params[pos][RANGE];
}
String getParamCandidate(int pos){
return params[pos][CANDIDATE];
}
}
Binary file not shown.
@@ -1,66 +0,0 @@
// GAG (Geant4 Adaptive GUI)
// Requires : JDK 1.1.3 (or later) + swing-1.0.2
// Version : alpha 1998/Mar/31
// GEANT4 GUI Group, Toshiaki Kodama
// 1998 July 6 GEANT4 Beta-01
package GAG;
import java.io.*;
class GAGpipe {
private Process ps;
private BufferedReader inpS, errS;
private PrintWriter outS;
private String errMsg;
private boolean isErr;
GAGpipe(String[] execFile){
errMsg = null; isErr = false;
try {
ps = Runtime.getRuntime().exec(execFile);
} catch(IOException e){
isErr = true;
errMsg = e.getMessage();
return;
}
inpS = new BufferedReader(new InputStreamReader(ps.getInputStream()));
errS = new BufferedReader(new InputStreamReader(ps.getErrorStream()));
outS = new PrintWriter(new DataOutputStream(ps.getOutputStream()));
}
String readStdLine(){
String line = null;
try{
line=inpS.readLine();
}catch(IOException e){
isErr = true;
errMsg = e.getMessage();
}
return line;
}
String readErrLine(){
String line = null;
try{
line=errS.readLine();
}catch(IOException e){
isErr = true;
errMsg = e.getMessage();
System.err.println(errMsg);
}
return line;
}
synchronized boolean writeLine(String st){
outS.println(st);
return outS.checkError();
}
synchronized void processKill(){
ps.destroy();
}
boolean isError(){
return isErr;
}
String getErrorMsg(){
if (!isErr) return "";
return errMsg;
}
}
Binary file not shown.
@@ -1,13 +0,0 @@
// GAG (Geant4 Adaptive GUI)
// Requires : JDK 1.1.3 (or later) + swing-1.0.2
// Version : alpha 1998/Mar/31
// Toshiaki Kodama GEANT4 GUI Group
// 1998 July 6 GEANT4 Beta-01
// This is an junction to better TextEditor in future.
package GAG;
public interface GAGtextEditor {
public void writeString(String str);
public void writeLine(String str);
}
Binary file not shown.
@@ -1,31 +0,0 @@
// jdk-1.1.3 (or later) + swing-1.0.2
// This is not required in GAG
import com.sun.java.swing.*;
import java.awt.*;
import java.net.URL;
import java.net.MalformedURLException;
import java.io.IOException;
public class HtmlFrame extends JFrame {
public HtmlFrame() {
// setBackground(Color.white);
setLayout(new BorderLayout());
try {
URL url = new URL("http://erlt1.naruto-u.ac.jp/~geant4/README_Momo.html");
JEditorPane html = new JEditorPane(url);
JScrollPane scroller = new JScrollPane(html);
add("Center", scroller);
} catch (MalformedURLException e) {
System.out.println("Malformed URL: " + e);
} catch (IOException e) {
System.out.println("IOException: " + e);
}
setSize(400, 400);
show();
}
public static void main(String arg[]){
new HtmlFrame();
}
}
-19
View File
@@ -1,19 +0,0 @@
1998 July 6 JAVA GAG for Beta-01 release
H. Yoshida; Naruto UE
This directory and its subdirectories contain all necessary JAVA
source codes as well as *.class files. All are archived into
GAG.jar file.
JAVA GAG uses Swing-1.0.2. Older versions based on Swing-1.0.1 can't
be compiled, and pour out "deprecated" errors on javac.
But Swing-1.0.2 has yet unfrozen classes and interfaces, among them
are JColorChooser and JFileChooser which JAVA GAG uses.
They are left as before in swing.preview package!!
Swing-1.0.3 is announced, but we will wait JDK1.2 which
is forseen in the next September (right?).
Binary file not shown.
@@ -1,416 +0,0 @@
// GAG (Geant4 Adaptive GUI)
// Requires : JDK 1.1.3 (or later) + swing-1.0.2
// Version : alpha 1998/Mar/31
// GEANT4 GUI Group, Toshiaki Kodama
// modified by H Yoshida, 1998 June 25
// use of FileFilter of Swing 1.0.2, to select after file extensions
// improvement of notification method of GEANT4 states
// by using setVisible and setBackground of relevant buttons
// specially "ok" button.
package GAG;
import com.sun.java.swing.preview.*;
//FileFilter of Swing1.0.2
import ExampleFileFilter;
import java.util.*;
import java.awt.*;
import java.io.*;
import java.awt.event.*;
import com.sun.java.swing.*;
import com.sun.java.swing.preview.filechooser.*;
// for Swing-1.0.2 FileChooser
class ParamPanel extends JPanel implements ActionListener, ItemListener {
private GAG gag;
private GridBagLayout gbl; GridBagConstraints gbc;
private JPanel paramArea;
private JButton def, current, clear, ok, fileBrowser;
private JComboBox history;
private int posY;
private GAGcommandItem ci;
private Component paraBox[];
private boolean isExecuting;
private JFileChooser fileChooser;
// FileFilter in Swing-1.0.2 test
private ExampleFileFilter g4mFilter, macroFilter, g4macroFilter,
txtFilter;
ParamPanel(GAG gag){
isExecuting = false;
this.gag = gag;
setLayout( new BorderLayout() );
gbc = new GridBagConstraints();
gbl = new GridBagLayout();
paramArea = new JPanel();
paramArea.setLayout(gbl);
paramArea.setBackground(new Color(255, 250, 230));
add("Center", new JScrollPane(paramArea));
JPanel buttons = new JPanel();
buttons.setLayout(new GridLayout( 1, 0, 2, 2));
// Yoshida color
def = new JButton("Default");
current = new JButton("Current");
clear = new JButton("Clear");
ok = new JButton("OK");
ok.setBackground(Color.green);
//no good?? ok.setFont(new Font("OK",1,12));
def.setBackground(Color.blue);
current.setBackground(Color.orange);
clear.setBackground(SystemColor.white);
// ok.setBackground(SystemColor.control);
// color
buttons.add( def );
buttons.add( current );
buttons.add( clear );
buttons.add( ok );
add("South", buttons);
history = new JComboBox();
history.addItem("# GEANT4 history macro.");
history.addItemListener(this);
add("North", history);
//yoshida setinvisible and setdisable
def.setVisible(false);
def.setEnabled(false);
def.setMargin(new Insets(1,3,1,3));
def.addActionListener(this);
//yoshida
current.setVisible(false);
current.setEnabled(false);
current.setMargin(new Insets(1,3,1,3));
current.addActionListener(this);
//yoshida
clear.setVisible(false);
clear.setEnabled(false);
clear.setMargin(new Insets(1,3,1,3));
clear.addActionListener(this);
//yoshida
ok.setVisible(false);
ok.setEnabled(false);
ok.setMargin(new Insets(1,3,1,3));
ok.addActionListener(this);
fileBrowser = new JButton("Open a Macro File");
fileBrowser.addActionListener(this);
fileChooser = new JFileChooser(".");
// Swing 1.0.2 FileFilter OK!! 1998 June 25
fileChooser.setDialogTitle("Macro File");
g4mFilter = new ExampleFileFilter("g4m", "Geant4 macro");
g4macroFilter = new ExampleFileFilter("g4macro", "Geant4 macro");
txtFilter = new ExampleFileFilter("txt", "Geant4 macro");
macroFilter = new ExampleFileFilter("macro", "Geant4 macro");
fileChooser.addChoosableFileFilter(g4mFilter);
fileChooser.addChoosableFileFilter(g4macroFilter);
fileChooser.addChoosableFileFilter(txtFilter);
fileChooser.addChoosableFileFilter(macroFilter);
// end of Swing-1.0.2 FileChooser
}
void setParamBox(GAGcommandItem ci, boolean enable){
paramArea.removeAll();
this.ci = ci;
posY = 0;
JLabel l;
if (!enable){
l = new JLabel("This command is not available.");
l.setForeground(Color.red);
addComponent(l);
}
addComponent(new JLabel(ci.getCommandName()));
String guide[] = ci.getCommandGuide();
for (int i=0; i<guide.length; i++){
addComponent(new JLabel(guide[i]));
}
if (!ci.getCommandRange().equals("")){
l = new JLabel(ci.getCommandRange());
l.setForeground(Color.green);
addComponent(l);
}
if (ci.getParamEntries() > 0){
def.setEnabled(true);
//yoshida
def.setVisible(true);
current.setEnabled(!isExecuting && enable);
//yoshida
current.setVisible(!isExecuting && enable);
clear.setEnabled(true);
//yoshida
clear.setVisible(true);
paraBox = new JComponent[ci.getParamEntries()];
String candidateList;
for (int i=0; i<ci.getParamEntries(); i++){
candidateList = ci.getParamCandidate(i);
if (candidateList.equals("")){
if (ci.getParamType(i).equals("b")){
paraBox[i] = new BooleanCombo(ci.getParamDefault(i));
}else{
paraBox[i] = new JTextField(20);
((JTextField)paraBox[i]).setText(ci.getParamDefault(i));
}
}else{
paraBox[i] = new JComboBox();
StringTokenizer st = new StringTokenizer(candidateList);
while(st.hasMoreTokens()){
((JComboBox)paraBox[i]).addItem(st.nextToken());
}
if (!ci.getParamDefault(i).equals("")){
((JComboBox)paraBox[i]).setSelectedItem(ci.getParamDefault(i));
}
}
addComponent(new JLabel(ci.getParamName(i)), paraBox[i], new JLabel("("+ci.getParamType(i) +") "+ci.getParamGuide(i) ));
if (ci.getParamName(i).equals("fileName")) addComponent(new JLabel(), fileBrowser);
}
}else{
//yoshida setinvisible and then setdisable
def.setVisible(false);
def.setEnabled(false);
current.setVisible(false);
current.setEnabled(false);
clear.setVisible(false);
clear.setEnabled(false);
}
ok.setEnabled(!isExecuting && enable);
//yoshida OK button order of enable and visible is important
ok.setVisible(!isExecuting && enable);
validate();
repaint();
return;
}
void setTreeHelp(String dirHelp, JLabel helps[][]){
//yoshida setinvisible then setdisable
ok.setVisible(false);
ok.setEnabled(false);
def.setVisible(false);
def.setEnabled(false);
current.setVisible(false);
current.setEnabled(false);
clear.setVisible(false);
clear.setEnabled(false);
//
paramArea.removeAll();
posY = 0; ci = null;
JLabel title = new JLabel(dirHelp);
title.setForeground(Color.green);
addComponent(title);
for (int i=0; i<helps[0].length; i++){
addComponent(helps[0][i], helps[1][i]);
}
validate();
repaint();
return;
}
private String makeCommandLine(){
StringBuffer param = new StringBuffer(ci.getCommandName());
if (ci.getParamEntries() > 0){
String val;
for (int i=0; i<ci.getParamEntries(); i++){
if (paraBox[i] instanceof JTextField){
val = (((JTextField)paraBox[i]).getText()).trim();
if (val.equals("")){
if (!ci.isOmittable(i)){
JOptionPane.showMessageDialog(this, ci.getParamName(i)+"\nThis parameter cannot omitted.", "Error", JOptionPane.WARNING_MESSAGE);
return null;
}else{
if (!ci.getParamDefault(i).equals(""))
val = ci.getParamDefault(i);
else{
JOptionPane.showMessageDialog(this, ci.getParamName(i)+"\nThis omittable parameter has not default value.", "Error", JOptionPane.WARNING_MESSAGE);
return null;
}
}
}else if ( val.indexOf(" ") >= 0){
JOptionPane.showMessageDialog(this, ci.getParamName(i)+"\nThis parameter cannot include SPACE character", "Error", JOptionPane.WARNING_MESSAGE);
return null;
}
}else{
val = (String)((JComboBox)paraBox[i]).getSelectedItem();
}
param.append(" "+val);
}
//yoshida
current.setVisible(false);
current.setEnabled(false);
}
//yoshida
ok.setVisible(false);
ok.setEnabled(false);
history.addItem(param.toString());
return param.toString();
}
private void addComponent(Component compo){
gbc.gridx = 0; gbc.gridy = posY++;
gbc.gridwidth = 3; gbc.gridheight = 1;
gbc.weightx = 1.0; gbc.weighty = 0.0;
gbc.anchor = GridBagConstraints.WEST;
gbl.setConstraints(compo, gbc);
paramArea.add(compo);
}
private void addComponent(Component compo1, Component compo2){
gbc.gridx = 0; gbc.gridy = posY;
gbc.gridwidth = 1; gbc.gridheight = 1;
gbc.weightx = 0.0; gbc.weighty = 0.0;
gbc.anchor = GridBagConstraints.EAST;
gbl.setConstraints(compo1, gbc);
paramArea.add(compo1);
gbc.gridx = 1;
gbc.anchor = GridBagConstraints.WEST;
gbl.setConstraints(compo2, gbc);
paramArea.add(compo2);
posY++;
}
private void addComponent(Component title, Component compo1, Component compo2){
gbc.gridx = 0; gbc.gridy = posY;
gbc.gridwidth = 1; gbc.gridheight = 1;
gbc.weightx = 0.0; gbc.weighty = 0.0;
gbc.fill = GridBagConstraints.NONE;
gbc.anchor = GridBagConstraints.EAST;
gbl.setConstraints(title, gbc);
paramArea.add(title);
gbc.gridx = 1;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbl.setConstraints(compo1, gbc);
paramArea.add(compo1);
gbc.gridx = 2;
gbc.fill = GridBagConstraints.NONE;
gbc.anchor = GridBagConstraints.WEST;
gbl.setConstraints(compo2, gbc);
paramArea.add(compo2);
posY++;
}
private void loadValue(int i, String str){
if (paraBox[i] instanceof JTextField){
((JTextField)paraBox[i]).setText(str);
}
if (paraBox[i] instanceof JComboBox){
((JComboBox)paraBox[i]).setSelectedItem(str);
}
}
void addHistory(String line){
if (line.startsWith("/")) history.addItem(line);
}
void clearAllHistory(){
history.removeAllItems();
}
void clearOneHistory(){
int ix = history.getSelectedIndex();
if (ix >= 0) history.removeItemAt(ix);
}
String[] getHistoryItems(){
String[] item = new String[history.getItemCount()];
for (int i=0; i>history.getItemCount(); i++){
item[i] = (String)history.getItemAt(i);
}
return item;
}
void loadCurrentValues(String line){
StringTokenizer st = new StringTokenizer( line );
st.nextToken();
int i=0;
while(st.hasMoreTokens()){
loadValue(i++, st.nextToken());
}
}
public void itemStateChanged(ItemEvent ie){
if (isExecuting) return;
if (ie.getStateChange() != ItemEvent.SELECTED) return;
String str = (String)ie.getItem();
if ( !str.startsWith("/") ) return;
StringTokenizer st = new StringTokenizer( str );
if (!gag.setParamPanel(st.nextToken())) return;
int i=0;
while(st.hasMoreTokens()){
loadValue(i++, st.nextToken());
if (i >= ci.getParamEntries()) return;
}
}
public void actionPerformed(ActionEvent ev){
Object source = ev.getSource();
if ( source == ok ){
String p = makeCommandLine();
if (p == null) return;
isExecuting = true;
gag.sendCommand(p);
//yoshida instead of sandwatch, ok button becomes invisible
ok.setVisible(false);
ok.setEnabled(false);
// Be careful! mouse may freeze, if setinvisible but not setdisabled!!
return;
}else if (source == def){
for (int i=0; ci.getParamEntries()>i; i++){
loadValue(i, ci.getParamDefault(i));
}
return;
}else if (source == current){
gag.reqCurrent(ci.getCommandName());
return;
}else if (source == clear){
for (int i=0; ci.getParamEntries()>i; i++){
if (paraBox[i] instanceof JTextField){
((JTextField)paraBox[i]).setText("");
}
}
return;
}else if (source == fileBrowser){
//swing102 filechooser showDialog(this, null) or the next
if (fileChooser.showOpenDialog(this) == -1 ) return;
File f = fileChooser.getSelectedFile();
if (f.isFile()) {
if (paraBox[0] instanceof JTextField){
((JTextField)paraBox[0]).setText(f.getPath());
}
}
return;
}
}
void toReady(){
isExecuting = false;
if (ci == null) return;
ok.setEnabled(true);
//yoshida setenable then setvisible
ok.setVisible(true);
if (ci.getParamEntries() == 0) return;
current.setEnabled(true);
//yoshida
current.setVisible(true);
}
}
class BooleanCombo extends JComboBox {
BooleanCombo(String str){
String def = str.toUpperCase();
if (def.equals("0") || def.equals("1")){
addItem("0");
addItem("1");
}else if (def.equals("Y") || def.equals("N")){
addItem("Y");
addItem("N");
}else if (def.equals("YES") || def.equals("NO")){
addItem("YES");
addItem("NO");
}else if (def.equals("T") || def.equals("F")){
addItem("T");
addItem("F");
} else {
addItem("FALSE");
addItem("TRUE");
}
if (!def.equals("")){
setSelectedItem(def);
}
}
}
-24
View File
@@ -1,24 +0,0 @@
1998 June 25 Yoshida
Improve look-and-feel of GAG by KOdama (as of 31/March/1998).
Swing-1.0.1 is used.
Swing-1.0.2 is desirable, but wait a moment. Swing-1.0.2 has
not yet frozen classes and interfaces, among them JColorChooser
and JFileChooser.
They are left as before in swing.preview package!!
Swing-1.0.2 JFileChooser is good for us since it allows file filtering,
free label on buttons etc..
But it is better to wait JDK1.2!!
So there is only minor improvements.
Font is one of the most iportant improvement.
Current fonts are too small or not beautiful.
@@ -1,444 +0,0 @@
/*
* Copyright (c) 1997 John Jensen. All rights reserved.
*
* This software is FREE FOR COMMERCIAL AND NON-COMMERCIAL USE,
* provided the following condition is met.
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted,
* provided that any copy or derivative of this software or documentation
* retaining the name "John Jensen" also retains this condition and the
* following disclaimer.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* CopyrightVersion 1.0
*/
package TextEdit;
import java.awt.*;
import java.awt.event.*;
import java.awt.datatransfer.*;
class EditMan extends Object implements ActionListener, ClipboardOwner
{
// remember stuff
private TextEdit textEdit;
private TextCanvas textCanvas;
private String undoString = new String("Undo");
private String redoString = new String("Redo");
private String copyString = new String("Copy");
private String cutString = new String("Cut");
private String pasteString = new String("Paste");
private String findString = new String("Find");
private String replaceString = new String("Replace");
private MenuItem undoItem;
private MenuItem redoItem;
private MenuItem copyItem;
private MenuItem cutItem;
private Clipboard clipboard;
private FindDialog findDialog = null;
private String findPattern = null;
private ReplaceDialog replaceDialog = null;
private String ReplacePattern = null;
private String ReplaceReplace = null;
// constructor puts together UI
public EditMan(TextEdit p)
{
textEdit = p;
textCanvas = textEdit.getCanvas();
clipboard = textEdit.getToolkit().getSystemClipboard();
}
public void addItems(Menu menu)
{
MenuItem item;
undoItem = new MenuItem(undoString, new MenuShortcut(KeyEvent.VK_Z,false));
undoItem.setActionCommand(undoString);
undoItem.setEnabled(false);
menu.add(undoItem);
redoItem = new MenuItem(redoString, new MenuShortcut(KeyEvent.VK_Y,false));
redoItem.setActionCommand(redoString);
redoItem.setEnabled(false);
menu.add(redoItem);
menu.addSeparator();
copyItem = new MenuItem(copyString, new MenuShortcut(KeyEvent.VK_C,false));
copyItem.setActionCommand(copyString);
copyItem.setEnabled(false);
menu.add(copyItem);
cutItem = new MenuItem(cutString, new MenuShortcut(KeyEvent.VK_X,false));
cutItem.setActionCommand(cutString);
cutItem.setEnabled(false);
menu.add(cutItem);
item = new MenuItem(pasteString, new MenuShortcut(KeyEvent.VK_V,false));
item.setActionCommand(pasteString);
menu.add(item);
menu.addSeparator();
item = new MenuItem(findString, new MenuShortcut(KeyEvent.VK_F,false));
item.setActionCommand(findString);
menu.add(item);
item = new MenuItem(replaceString, new MenuShortcut(KeyEvent.VK_H,false));
item.setActionCommand(replaceString);
menu.add(item);
menu.addActionListener(this);
textCanvas.setEditMan(this);
}
public void updateCopyItems(boolean have_selection)
{
copyItem.setEnabled(have_selection);
cutItem.setEnabled(have_selection);
}
public void updateUndoItems(boolean have_undo, boolean have_redo)
{
undoItem.setEnabled(have_undo);
redoItem.setEnabled(have_redo);
}
public void actionPerformed(ActionEvent evt)
{
String cmd = evt.getActionCommand();
if (cmd == null)
return;
if (cmd.equals(undoString))
{
textCanvas.undo(true);
}
if (cmd.equals(redoString))
{
textCanvas.undo(false);
}
else
if (cmd.equals(copyString))
{
// Implement Copy operation
String srcData = textCanvas.copy(false);
if (srcData != null)
{
StringSelection contents = new StringSelection(srcData);
clipboard.setContents(contents, this);
}
}
else
if (cmd.equals(cutString))
{
// Implement Copy operation
String srcData = textCanvas.copy(true);
if (srcData != null)
{
StringSelection contents = new StringSelection(srcData);
clipboard.setContents(contents, this);
}
}
else
if (cmd.equals(pasteString))
{
String dstData;
// Implement Paste operation
Transferable content = clipboard.getContents(this);
if (content != null)
{
try
{
dstData = (String)content.getTransferData(DataFlavor.stringFlavor);
}
catch (Exception e)
{
System.out.println("Could not read clipboard");
return;
}
textCanvas.paste(dstData);
}
}
else
if (cmd.equals(findString))
{
if (findDialog == null)
findDialog = new FindDialog(textEdit,this,findPattern);
findDialog.show();
}
else
if (cmd.equals(replaceString))
{
if (replaceDialog == null)
replaceDialog = new ReplaceDialog(textEdit,this,ReplacePattern,ReplaceReplace);
replaceDialog.show();
}
}
public void CloseFindDialog(String pat)
{
findDialog = null;
findPattern = new String(pat);
}
public void CloseReplaceDialog(String pat, String rep)
{
replaceDialog = null;
ReplacePattern = new String(pat);
ReplaceReplace = new String(rep);
}
public void lostOwnership(Clipboard clipboard, Transferable contents)
{
}
}
class FindDialog extends Frame implements WindowListener, ActionListener
{
private Button fbutton,cbutton;
private EditMan editMan;
private TextEdit textEdit;
private TextField pattern;
public FindDialog(TextEdit te, EditMan em, String pat)
{
super("Find");
setBackground(Color.lightGray);
textEdit = te;
editMan = em;
Panel p1 = new Panel();
p1.setLayout(new FlowLayout());
p1.add(new Label("Find:"));
pattern = new TextField();
pattern.setColumns(35);
if (pat != null)
pattern.setText(pat);
p1.add(pattern);
p1.doLayout();
add("North", p1);
Panel p2 = new Panel();
fbutton = new Button("Find Next");
fbutton.addActionListener(this);
p2.add(fbutton);
cbutton = new Button("Cancel");
cbutton.addActionListener(this);
p2.add(cbutton);
add("South",p2);
setSize(400,110);
addWindowListener(this);
}
public void windowDeiconified(WindowEvent event) {}
public void windowIconified(WindowEvent event) {}
public void windowActivated(WindowEvent event) {}
public void windowDeactivated(WindowEvent event) {}
public void windowOpened(WindowEvent event) {}
public void windowClosed(WindowEvent event) {}
public void windowClosing(WindowEvent event)
{
editMan.CloseFindDialog(pattern.getText());
dispose();
}
public void actionPerformed(ActionEvent evt)
{
if (evt.getSource() == cbutton)
{
editMan.CloseFindDialog(pattern.getText());
dispose();
return;
}
if (evt.getSource() == fbutton)
if (!textEdit.getCanvas().find(pattern.getText()))
{
NotFound nf = new NotFound(textEdit);
nf.show();
}
}
}
class ReplaceDialog extends Frame implements WindowListener, ActionListener
{
private Button fbutton,rbutton,cbutton;
private TextField pattern;
private TextField replace;
private TextEdit textEdit;
private EditMan editMan;
boolean foundOnce = false;
public ReplaceDialog(TextEdit p, EditMan em, String pat, String rep)
{
super("Find and Replace");
setBackground(Color.lightGray);
textEdit = p;
editMan = em;
Panel p1 = new Panel();
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints constraints = new GridBagConstraints();
p1.setLayout(gridbag);
Label flabel = new Label("Find:");
constraints.anchor = GridBagConstraints.NORTHWEST;
gridbag.setConstraints(flabel, constraints);
pattern = new TextField();
pattern.setColumns(35);
if (pat != null)
pattern.setText(pat);
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints(pattern, constraints);
p1.add(flabel);
p1.add(pattern);
Label rlabel = new Label("Replace:");
constraints.anchor = GridBagConstraints.WEST;
constraints.gridwidth = 1;
gridbag.setConstraints(rlabel, constraints);
replace = new TextField();
replace.setColumns(35);
if (rep != null)
replace.setText(rep);
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints(replace, constraints);
p1.add(rlabel);
p1.add(replace);
add("Center", p1);
Panel p3 = new Panel();
fbutton = new Button("Find Next");
fbutton.addActionListener(this);
p3.add(fbutton);
rbutton = new Button("Replace");
rbutton.addActionListener(this);
p3.add(rbutton);
cbutton = new Button("Cancel");
cbutton.addActionListener(this);
p3.add(cbutton);
add("South",p3);
setSize(400,120);
addWindowListener(this);
}
public void windowDeiconified(WindowEvent event) {}
public void windowIconified(WindowEvent event) {}
public void windowActivated(WindowEvent event) {}
public void windowDeactivated(WindowEvent event) {}
public void windowOpened(WindowEvent event) {}
public void windowClosed(WindowEvent event) {}
public void windowClosing(WindowEvent event)
{
editMan.CloseReplaceDialog(pattern.getText(),replace.getText());
dispose();
}
public void actionPerformed(ActionEvent evt)
{
if (evt.getSource() == cbutton)
{
editMan.CloseReplaceDialog(pattern.getText(),replace.getText());
dispose();
return;
}
if (evt.getSource() == fbutton)
foundOnce = textEdit.getCanvas().find(pattern.getText());
else
if (evt.getSource() == rbutton)
{
if (!foundOnce)
{
TextCanvas textCanvas = textEdit.getCanvas();
String selection= textCanvas.copy(false);
if (selection != null)
foundOnce = selection.equals(pattern.getText());
}
if (foundOnce)
textEdit.getCanvas().paste(replace.getText());
foundOnce = textEdit.getCanvas().find(pattern.getText());
}
if (!foundOnce)
{
NotFound nf = new NotFound(textEdit);
nf.show();
}
}
}
class NotFound extends Dialog implements WindowListener, ActionListener
{
private Button okButton;
public NotFound(TextEdit te)
{
super(te,"",true);
Panel north = new Panel();
north.add(new Label("String not found"));
add("North", north);
okButton = new Button("OK");
okButton.addActionListener(this);
Panel south = new Panel();
south.add(okButton);
add("South", south);
setSize(200,110);
addWindowListener(this);
}
public void windowDeiconified(WindowEvent event) {}
public void windowIconified(WindowEvent event) {}
public void windowActivated(WindowEvent event) {}
public void windowDeactivated(WindowEvent event) {}
public void windowOpened(WindowEvent event) {}
public void windowClosed(WindowEvent event) {}
public void windowClosing(WindowEvent event)
{
dispose();
}
public void actionPerformed(ActionEvent evt)
{
if (evt.getSource() == okButton)
dispose();
}
}
Binary file not shown.
@@ -1,118 +0,0 @@
/*
* Copyright (c) 1997 John Jensen. All rights reserved.
*
* This software is FREE FOR COMMERCIAL AND NON-COMMERCIAL USE,
* provided the following condition is met.
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted,
* provided that any copy or derivative of this software or documentation
* retaining the name "John Jensen" also retains this condition and the
* following disclaimer.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* CopyrightVersion 1.0
*/
package TextEdit;
import java.awt.*;
import java.awt.event.*;
// This extension of Dialog implements modal dialogs with a callback interface
// to work around the "modal dialog problem" on Windows. The "NoteListener"
// interface is used to return an action code to the parent when "continue" is
// pressed.
class Note extends Dialog implements WindowListener, ActionListener
{
int noteAction;
NoteListener noteListener;
Button accepted;
Button whatever;
// Constructor takes a string and an action. Note that action == 0 implies
// that there is only an "ok" button, while action != 0 implies a "Continue" and
// a "Cancel" button.
public Note(Frame parent, String s, int action)
{
super(parent, "Note", true);
noteListener = (NoteListener)parent;
noteAction = action;
Panel center = new Panel();
center.add(new Label(s));
add("Center", center);
Panel south = new Panel();
if (action != 0)
{
accepted = new Button("Continue");
accepted.addActionListener(this);
south.add(accepted);
whatever = new Button("Cancel");
whatever.addActionListener(this);
south.add(whatever);
}
else
{
whatever = new Button("Ok");
whatever.addActionListener(this);
south.add(whatever);
}
add("South", south);
setSize(300, 100);
addWindowListener(this);
}
// if we get a "Continue" button, call the parent's noteListener
public void actionPerformed(ActionEvent event)
{
Object source;
source = event.getSource();
if (source == accepted)
{
setVisible(false);
setModal(false);
noteListener.noteListen(noteAction);
}
if ((source == accepted) || (source == whatever))
dispose();
}
// add the 1.1 WindowListener stuff
public void windowDeiconified(WindowEvent event) {}
public void windowIconified(WindowEvent event) {}
public void windowActivated(WindowEvent event) {}
public void windowDeactivated(WindowEvent event) {}
public void windowOpened(WindowEvent event) {}
public void windowClosed(WindowEvent event) {}
public void windowClosing(WindowEvent event) {
dispose();
}
}
@@ -1,34 +0,0 @@
/*
* Copyright (c) 1997 John Jensen. All rights reserved.
*
* This software is FREE FOR COMMERCIAL AND NON-COMMERCIAL USE,
* provided the following condition is met.
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted,
* provided that any copy or derivative of this software or documentation
* retaining the name "John Jensen" also retains this condition and the
* following disclaimer.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* CopyrightVersion 1.0
*/
package TextEdit;
interface NoteListener
{
public void noteListen(int action);
}
@@ -1,154 +0,0 @@
/*
* Copyright (c) 1997 John Jensen. All rights reserved.
*
* This software is FREE FOR COMMERCIAL AND NON-COMMERCIAL USE,
* provided the following condition is met.
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted,
* provided that any copy or derivative of this software or documentation
* retaining the name "John Jensen" also retains this condition and the
* following disclaimer.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* CopyrightVersion 1.0
*/
package TextEdit;
import java.awt.*;
import java.util.*;
public class PrintMan extends Thread
{
private PrintJob pjob;
private Vector spool;
private Font font;
private Frame parent;
private String jobName;
private int tabsize;
private final int PRINT_PROGRESS = 10000;
public PrintMan(Frame p, String n, Vector lines, Font f, int t)
{
int i,max,part,tens;
parent = p;
jobName = n;
font = f;
tabsize = t;
max = lines.size();
spool = new Vector(max);
tens = max / 10;
part = 0;
Progress spoolProgress = null;
if (max > PRINT_PROGRESS)
{
spoolProgress = new Progress(parent,"Saving print copy ... ");
spoolProgress.show();
}
for (i=0;i<max;i++)
{
spool.addElement( new String((String)lines.elementAt(i)) );
if (max > PRINT_PROGRESS)
part++;
if (part > tens)
{
spoolProgress.update( (int)(100 * i / max) );
part = 0;
}
}
if (spoolProgress != null)
spoolProgress.dispose();
}
public void run()
{
pjob = parent.getToolkit().getPrintJob(parent, jobName, null);
if (pjob == null)
return;
Graphics pg = pjob.getGraphics();
if (pg != null)
{
String nextLine;
int pageHeight = pjob.getPageDimension().height;
pg.setFont(font);
FontMetrics fm = pg.getFontMetrics(font);
int fontHeight = fm.getHeight();
int fontDescent = fm.getDescent();
int curHeight = 0;
for (int i = 0; i < spool.size(); i++ )
{
curHeight += fontHeight;
if (curHeight > pageHeight)
{
pg.dispose();
pg = pjob.getGraphics();
if (pg == null)
return;
pg.setFont(font);
curHeight = fontHeight;
}
nextLine = detabbed((String)spool.elementAt(i),tabsize);
pg.drawString(nextLine, 0, curHeight - fontDescent);
}
pg.dispose();
}
pjob.end();
}
private String detabbed(String s, int tabSize)
{
if (s.indexOf('\t') < 0)
return s;
char c;
String t = new String("");
int j=0;
int tabs;
int max = s.length();
for (int i=0; i<max; i++)
{
c = s.charAt(i);
if (c == '\t')
{
tabs = tabSize - (j % tabSize);
j += tabs;
while (tabs-- > 0) t = t + ' ';
}
else
{
t = t + c;
j++;
}
}
return t;
}
}
@@ -1,67 +0,0 @@
/*
* Copyright (c) 1997 John Jensen. All rights reserved.
*
* This software is FREE FOR COMMERCIAL AND NON-COMMERCIAL USE,
* provided the following condition is met.
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted,
* provided that any copy or derivative of this software or documentation
* retaining the name "John Jensen" also retains this condition and the
* following disclaimer.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* CopyrightVersion 1.0
*/
package TextEdit;
import java.awt.*;
import java.awt.event.*;
// This extension of Dialog implements modal dialogs with a callback interface
// to work around the "modal dialog problem" on Windows. The "NoteListener"
// interface is used to return an action code to the parent when "continue" is
// pressed.
class Progress extends Dialog
{
Panel center;
public Progress(Frame parent, String s)
{
super(parent);
Panel north = new Panel();
north.add(new Label(s));
add("North", north);
center = new Panel();
add("Center", center);
setSize(300, 100);
}
public void update( int percent )
{
Dimension d = center.getSize();
Graphics g = center.getGraphics();
int fifth = d.width / 5;
int third = d.height / 3;
g.fillRect( fifth, third, (fifth * 3 * percent) / 100, third);
}
}
File diff suppressed because it is too large Load Diff
@@ -1,100 +0,0 @@
/*
* Copyright (c) 1997 John Jensen. All rights reserved.
*
* This software is FREE FOR COMMERCIAL AND NON-COMMERCIAL USE,
* provided the following condition is met.
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted,
* provided that any copy or derivative of this software or documentation
* retaining the name "John Jensen" also retains this condition and the
* following disclaimer.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* CopyrightVersion 1.0
*/
package TextEdit;
import java.awt.*;
import java.awt.event.*;
class TextCursor extends Thread
{
private TextCanvas canvas;
private boolean flash;
private boolean undraw; // true when the next draw erases
private Rectangle r;
public TextCursor(TextCanvas c)
{
canvas = c;
r = new Rectangle();
}
public void run()
{
while (true)
{
sync_draw();
try { sleep(400); }
catch(InterruptedException e) {}
}
}
private synchronized void sync_draw()
{
if (flash)
draw_or_undraw();
}
public boolean getUndraw()
{
return undraw;
}
public synchronized void pause_cursor(boolean draw)
{
// if (draw && undraw)
if (undraw)
draw_or_undraw();
flash = false;
}
public synchronized void release_cursor(boolean draw)
{
if (!undraw)
draw_or_undraw();
flash = true;
}
private boolean draw_or_undraw()
{
Graphics g = canvas.getGraphics();
if (g != null)
{
if (!undraw)
canvas.getCursorPos(g,r);
g.setXORMode(Color.white);
g.drawLine(r.x, r.y, r.x, r.y+r.height);
undraw = !undraw;
g.dispose();
}
return undraw;
}
// public static void dumpStack() {new Exception("Stack trace").printStackTrace();}
}
@@ -1,308 +0,0 @@
/*
* Copyright (c) 1997 John Jensen. All rights reserved.
*
* This software is FREE FOR COMMERCIAL AND NON-COMMERCIAL USE,
* provided the following condition is met.
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted,
* provided that any copy or derivative of this software or documentation
* retaining the name "John Jensen" also retains this condition and the
* following disclaimer.
*
* CopyrightVersion 1.0
*/
package TextEdit;
import java.awt.*;
import java.io.*;
import java.util.*;
import java.awt.event.*;
import GAG.*;
public class TextEdit extends Frame implements GAGtextEditor, NoteListener, WindowListener
{
// The NoteListen member fuction of NoteListener is overridded to support
// the following actions.
final private int NOACTION = 0;
final private int NEWFILE = 1;
final private int OPENFILE = 2;
final private int QUITAPP = 3;
// allocate standard components of TextEdit as part of initialization:
public File file = new File("Untitled");
private String openPrompt = new String("Open text file");
private String closePrompt = new String("Save file as");
// initialize some state flags
private boolean neverNamed = true;
private boolean menuBusy = false;
// these three .. no four! .. four objects form the main window
private Scrollbar horiz;
private Scrollbar vert;
private TextCanvas textCanvas;
private TextMenu textMenu;
// font
private String fontString = new String("Courier");
private int fontSize = 12;
private int tabSize = 4;
// constructor puts together UI
public TextEdit() {
this.setTitle();
vert = new Scrollbar(Scrollbar.VERTICAL);
add("East", vert);
horiz = new Scrollbar(Scrollbar.HORIZONTAL);
add("South", horiz);
textCanvas = new TextCanvas(this,horiz,vert);
add("Center", textCanvas);
textCanvas.setFont(fontString,fontSize);
addKeyListener(textCanvas);
textMenu = new TextMenu(this);
setMenuBar(textMenu);
addWindowListener(this);
setSize(500, 400);
setVisible(true);
try { Thread.sleep(400); } catch(InterruptedException e) {}
}
public void writeString(String s){
textCanvas.writeString(s);
}
public void writeLine(String s){
textCanvas.writeLine(s);
}
// allow others to go straight to the canvas
public TextCanvas getCanvas() {
return textCanvas;
}
// add current filename to window title
private void setTitle(){
super.setTitle("TextEdit - " + file.getName());
}
// add the 1.1 WindowListener stuff
public void windowDeiconified(WindowEvent event) {}
public void windowIconified(WindowEvent event) {}
public void windowActivated(WindowEvent event) {}
public void windowDeactivated(WindowEvent event) {}
public void windowOpened(WindowEvent event) {}
public void windowClosed(WindowEvent event) {}
public void windowClosing(WindowEvent event) {
if (isItSafe(QUITAPP))
System.exit(0);
}
// high level command processors (invoked my menu)
public void setFont(String fs) {
fontString = fs;
textCanvas.setFont(fontString, fontSize);
}
public void setFontSize(int s) {
fontSize = s;
textCanvas.setFont(fontString, fontSize);
}
public void setTabSize(int s) {
tabSize = s;
textCanvas.setTab(tabSize);
}
public int getTabSize() {
return tabSize;
}
public void cmdFileNew() {
if (isItSafe(NEWFILE))
newFile();
}
public void cmdFileOpen() {
if (isItSafe(OPENFILE))
openFile();
}
public void cmdFileSave() {
saveFile(false);
}
public void cmdFileSaveAs() {
saveFile(true);
}
public void cmdPrint() {
textCanvas.print(file.getName());
}
public void cmdFileQuit() {
if (isItSafe(QUITAPP))
System.exit(0);
}
// if the file has been modified (dirty), fire off a notify dialog
// and pass it the "action" you want returned to noteListen. This
// dataflow beats the "modal dialog problem" on Windows
// I believe isItSafe is what Laurence Olivier said repeatedly to
// Dustan Hoffman in Marathon Man.
private boolean isItSafe(int action) {
if (textCanvas.isDirty())
{
notify( "The current file has not been saved. ", action );
return false;
}
else
return true;
}
// implementation of the NoteListener interface - it does whatever
// action the user agreed to by pressing "Continue" on a modal dialog
public void noteListen(int action)
{
switch (action)
{
case NOACTION:
break;
case NEWFILE:
newFile();
break;
case OPENFILE:
openFile();
break;
case QUITAPP:
System.exit(0);
break;
}
}
// clear out the document
private void newFile()
{
neverNamed = true;
file = new File("Untitled");
this.setTitle();
textCanvas.clear();
textCanvas.validate();
}
// call getFile to get a file path, and if you get one open it
private void openFile()
{
if (getFile(FileDialog.LOAD))
openTheFile();
}
public void openTheFile()
{
textCanvas.read(file);
textCanvas.validate();
neverNamed = false;
this.setTitle();
}
// call getFile to get a file path, and if you get one save to it
private void saveFile(boolean As)
{
boolean ok;
if (neverNamed || As)
{
ok = getFile(FileDialog.SAVE);
neverNamed = false;
}
else
ok = true;
if (ok)
{
textCanvas.write(file);
neverNamed = false;
this.setTitle();
}
}
// use FileDialog to get a filepath
private boolean getFile(int mode)
{
String prompt;
String filename;
String pathname;
if (mode == FileDialog.LOAD)
prompt = openPrompt;
else
prompt = closePrompt;
FileDialog d = new FileDialog(this, prompt, mode);
if (mode == FileDialog.LOAD)
d.setFile("*");
else
d.setFile(file.getName());
d.setDirectory(".");
d.setVisible(true);
filename = d.getFile();
pathname = d.getDirectory() + filename;
d.dispose();
if (filename != null)
{
file = new File(pathname);
return true;
}
else
return false;
}
// launch a note
private void notify(String s, int action) {
Note note = new Note(this,s,action);
note.setVisible(true);
}
// main declares the TextEdit frame which does everything
public static void main(String[] args) {
TextEdit f = new TextEdit();
if (args.length > 0) {
f.file = new File(args[0]);
if (f.file.isFile())
f.openTheFile();
else
f.notify("File not found: "+args[0],0);
}
}
}
@@ -1,306 +0,0 @@
/*
* Copyright (c) 1997 John Jensen. All rights reserved.
*
* This software is FREE FOR COMMERCIAL AND NON-COMMERCIAL USE,
* provided the following condition is met.
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted,
* provided that any copy or derivative of this software or documentation
* retaining the name "John Jensen" also retains this condition and the
* following disclaimer.
*
* CopyrightVersion 1.0
*/
package TextEdit;
import java.awt.*;
import java.io.*;
import java.util.*;
import java.awt.event.*;
public class TextEdit extends Frame implements NoteListener, WindowListener
{
// The NoteListen member fuction of NoteListener is overridded to support
// the following actions.
final private int NOACTION = 0;
final private int NEWFILE = 1;
final private int OPENFILE = 2;
final private int QUITAPP = 3;
// allocate standard components of TextEdit as part of initialization:
public File file = new File("Untitled");
private String openPrompt = new String("Open text file");
private String closePrompt = new String("Save file as");
// initialize some state flags
private boolean neverNamed = true;
private boolean menuBusy = false;
// these three .. no four! .. four objects form the main window
private Scrollbar horiz;
private Scrollbar vert;
private TextCanvas textCanvas;
private TextMenu textMenu;
// font
private String fontString = new String("Courier");
private int fontSize = 12;
private int tabSize = 4;
// constructor puts together UI
public TextEdit() {
this.setTitle();
vert = new Scrollbar(Scrollbar.VERTICAL);
add("East", vert);
horiz = new Scrollbar(Scrollbar.HORIZONTAL);
add("South", horiz);
textCanvas = new TextCanvas(this,horiz,vert);
add("Center", textCanvas);
textCanvas.setFont(fontString,fontSize);
addKeyListener(textCanvas);
textMenu = new TextMenu(this);
setMenuBar(textMenu);
addWindowListener(this);
}
public void writeStr(String t){
textCanvas.appendLine(t);
}
public void writeText(String t){
textCanvas.appendLine(t);
}
// allow others to go straight to the canvas
public TextCanvas getCanvas() {
return textCanvas;
}
// add current filename to window title
private void setTitle(){
super.setTitle("TextEdit - " + file.getName());
}
// add the 1.1 WindowListener stuff
public void windowDeiconified(WindowEvent event) {}
public void windowIconified(WindowEvent event) {}
public void windowActivated(WindowEvent event) {}
public void windowDeactivated(WindowEvent event) {}
public void windowOpened(WindowEvent event) {}
public void windowClosed(WindowEvent event) {}
public void windowClosing(WindowEvent event) {
if (isItSafe(QUITAPP))
System.exit(0);
}
// high level command processors (invoked my menu)
public void setFont(String fs) {
fontString = fs;
textCanvas.setFont(fontString, fontSize);
}
public void setFontSize(int s) {
fontSize = s;
textCanvas.setFont(fontString, fontSize);
}
public void setTabSize(int s) {
tabSize = s;
textCanvas.setTab(tabSize);
}
public int getTabSize() {
return tabSize;
}
public void cmdFileNew() {
if (isItSafe(NEWFILE))
newFile();
}
public void cmdFileOpen() {
if (isItSafe(OPENFILE))
openFile();
}
public void cmdFileSave() {
saveFile(false);
}
public void cmdFileSaveAs() {
saveFile(true);
}
public void cmdPrint() {
textCanvas.print(file.getName());
}
public void cmdFileQuit() {
if (isItSafe(QUITAPP))
System.exit(0);
}
// if the file has been modified (dirty), fire off a notify dialog
// and pass it the "action" you want returned to noteListen. This
// dataflow beats the "modal dialog problem" on Windows
// I believe isItSafe is what Laurence Olivier said repeatedly to
// Dustan Hoffman in Marathon Man.
private boolean isItSafe(int action) {
if (textCanvas.isDirty())
{
notify( "The current file has not been saved. ", action );
return false;
}
else
return true;
}
// implementation of the NoteListener interface - it does whatever
// action the user agreed to by pressing "Continue" on a modal dialog
public void noteListen(int action)
{
switch (action)
{
case NOACTION:
break;
case NEWFILE:
newFile();
break;
case OPENFILE:
openFile();
break;
case QUITAPP:
System.exit(0);
break;
}
}
// clear out the document
private void newFile()
{
neverNamed = true;
file = new File("Untitled");
this.setTitle();
textCanvas.clear();
textCanvas.validate();
}
// call getFile to get a file path, and if you get one open it
private void openFile()
{
if (getFile(FileDialog.LOAD))
openTheFile();
}
public void openTheFile()
{
textCanvas.read(file);
textCanvas.validate();
neverNamed = false;
this.setTitle();
}
// call getFile to get a file path, and if you get one save to it
private void saveFile(boolean As)
{
boolean ok;
if (neverNamed || As)
{
ok = getFile(FileDialog.SAVE);
neverNamed = false;
}
else
ok = true;
if (ok)
{
textCanvas.write(file);
neverNamed = false;
this.setTitle();
}
}
// use FileDialog to get a filepath
private boolean getFile(int mode)
{
String prompt;
String filename;
String pathname;
if (mode == FileDialog.LOAD)
prompt = openPrompt;
else
prompt = closePrompt;
FileDialog d = new FileDialog(this, prompt, mode);
if (mode == FileDialog.LOAD)
d.setFile("*");
else
d.setFile(file.getName());
d.setDirectory(".");
d.setVisible(true);
filename = d.getFile();
pathname = d.getDirectory() + filename;
d.dispose();
if (filename != null)
{
file = new File(pathname);
return true;
}
else
return false;
}
// launch a note
private void notify(String s, int action) {
Note note = new Note(this,s,action);
note.setVisible(true);
}
// main declares the TextEdit frame which does everything
public static void main(String[] args) {
TextEdit f = new TextEdit();
f.setSize(500, 400);
f.setVisible(true);
if (args.length > 0) {
f.file = new File(args[0]);
if (f.file.isFile())
f.openTheFile();
else
f.notify("File not found: "+args[0],0);
}
}
}
@@ -1,463 +0,0 @@
/*
* Copyright (c) 1997 John Jensen. All rights reserved.
*
* This software is FREE FOR COMMERCIAL AND NON-COMMERCIAL USE,
* provided the following condition is met.
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted,
* provided that any copy or derivative of this software or documentation
* retaining the name "John Jensen" also retains this condition and the
* following disclaimer.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* CopyrightVersion 1.0
*/
package TextEdit;
import java.awt.*;
import java.util.*;
class TextJournal
{
private TextCanvas canvas; // the parent
private Vector lines; // the document
private TextJournalItem journal; // the journal
private TextJournalItem undo_list; // where we are in undo
private TextJournalItem redo_list; // where we are in redo
private boolean had_undo;
private boolean had_redo;
private String lineSeparator;
private final int REPLACE_LINE = 1;
private final int SPLIT_LINE = 2;
private final int JOIN_LINE = 3;
private final int INSERT = 4;
private final int DELETE = 5;
public TextJournal(TextCanvas c, Vector v, String ls)
{
canvas = c;
lines = v;
lineSeparator = ls;
undo_list = redo_list = null;
had_undo = had_redo = false;
}
public void clear()
{
undo_list = redo_list = null;
had_undo = had_redo = false;
}
private void updateMenus()
{
boolean got_undo;
boolean got_redo;
got_undo = undo_list != null;
got_redo = redo_list != null;
if ((had_undo != got_undo) || (had_redo != got_redo))
canvas.updateUndoItems(got_undo, got_redo);
had_undo = got_undo;
had_redo = got_redo;
}
public TextPosition undo()
{
TextJournalItem temp;
TextPosition tp = null;
if (undo_list != null)
{
temp = undo_list;
undo_list = temp.next;
switch (temp.action)
{
case REPLACE_LINE:
redo_line(temp);
break;
case SPLIT_LINE:
split_or_join(temp,true);
break;
case JOIN_LINE:
split_or_join(temp,false);
break;
case INSERT:
copy_or_cut(temp,true);
break;
case DELETE:
insert(temp);
break;
default:;
}
tp = new TextPosition(temp.line,temp.column);
temp.next = redo_list;
redo_list = temp;
}
updateMenus();
return tp;
}
public TextPosition redo()
{
TextJournalItem temp;
TextPosition tp = null;
int line, column;
if (redo_list != null)
{
temp = redo_list;
redo_list = temp.next;
line = temp.line;
column = temp.column;
switch (temp.action)
{
case REPLACE_LINE:
column = temp.text.length();
redo_line(temp);
break;
case SPLIT_LINE:
split_or_join(temp,false);
column = 0;
break;
case JOIN_LINE:
split_or_join(temp,true);
break;
case INSERT:
insert(temp);
line = temp.eline;
column = temp.ecolumn;
break;
case DELETE:
copy_or_cut(temp,true);
break;
default:;
}
tp = new TextPosition(line,column);
temp.next = undo_list;
undo_list = temp;
}
updateMenus();
return tp;
}
public void insert_char(int line, int column, char c)
{
String s;
s = (String)lines.elementAt(line);
remember_line(line,column,s);
s = s.substring(0, column) + c + s.substring(column, s.length());
lines.setElementAt(s,line);
}
public void delete_prev_char(int line, int column)
{
String s;
s = (String)lines.elementAt(line);
remember_line(line,column,s);
s = s.substring(0, column-1) + s.substring(column, s.length());
lines.setElementAt(s,line);
}
public void delete_next_char(int line, int column)
{
String s;
s = (String)lines.elementAt(line);
remember_line(line,column,s);
s = s.substring(0, column) + s.substring(column+1, s.length());
lines.setElementAt(s,line);
}
private void remember_line(int line, int column, String s)
{
boolean new_line = true;
if (undo_list != null)
new_line = (undo_list.action != REPLACE_LINE) || (undo_list.line != line);
if (new_line)
{
TextJournalItem new_journal = new TextJournalItem();
new_journal.action = REPLACE_LINE;
new_journal.line = line;
new_journal.column = column;
new_journal.text = new String(s);
new_journal.next = undo_list;
undo_list = new_journal;
}
redo_list = null;
updateMenus();
}
private void redo_line(TextJournalItem i)
{
String s;
s = (String)lines.elementAt(i.line);
lines.setElementAt(i.text,i.line);
i.text = s;
}
public void split_line(int line, int column)
{
TextJournalItem new_journal = new TextJournalItem();
new_journal.action = SPLIT_LINE;
new_journal.line = line;
new_journal.column = column;
split_or_join(new_journal,false);
new_journal.next = undo_list;
undo_list = new_journal;
redo_list = null;
updateMenus();
}
public void join_line(int line, int column)
{
TextJournalItem new_journal = new TextJournalItem();
new_journal.action = JOIN_LINE;
new_journal.line = line;
new_journal.column = column;
split_or_join(new_journal,true);
new_journal.next = undo_list;
undo_list = new_journal;
redo_list = null;
updateMenus();
}
public void split_or_join(TextJournalItem i, boolean join)
{
String s;
int line = i.line;
int column = i.column;
if (join)
{
s = (String)lines.elementAt(line);
s = s.concat((String)lines.elementAt(line+1));
lines.setElementAt(s,line);
lines.removeElementAt(line+1);
}
else
{
s = (String)lines.elementAt(line);
lines.setElementAt(s.substring(0,column),line);
lines.insertElementAt(s.substring(column,s.length()),++line);
}
}
public TextPosition insert_section(int line, int column, String s)
{
int charCt;
int saveCt;
int charMax;
char c,c2;
String s2 = null;
TextPosition tp;
// start creating journal item
TextJournalItem new_journal = new TextJournalItem();
new_journal.action = INSERT;
new_journal.text = new String(s);
new_journal.line = line; // starting line and column
new_journal.column = column;
// insert the text
tp = insert(new_journal);
// finish creating journal entry
new_journal.eline = tp.line; // updated line and column
new_journal.ecolumn = tp.column;
new_journal.next = undo_list;
undo_list = new_journal;
redo_list = null;
updateMenus();
return tp;
}
public TextPosition insert(TextJournalItem i)
{
int line = i.line;
int column = i.column;
String s = i.text;
int charCt;
int saveCt;
int charMax;
char c,c2;
String s2 = null;
// insert the text
charMax = s.length();
charCt = saveCt = 0;
while (charCt < charMax)
{
c = s.charAt(charCt);
charCt++;
if ((c == '\r') || (c == '\n'))
{
s2 = (String)lines.elementAt(line);
lines.setElementAt(s2.substring(0,column) + s.substring(saveCt,charCt-1),line);
lines.insertElementAt(s2.substring(column,s2.length()),++line);
column = 0;
if (charCt < charMax)
{
c2 = s.charAt(charCt);
if (((c == '\r') && (c2 == '\n')) || ((c2 == '\r') && (c == '\n')))
charCt++;
}
saveCt = charCt;
}
}
if (saveCt < charCt)
{
s2 = (String)lines.elementAt(line);
s = s.substring(saveCt,charCt);
if (column == 0)
s2 = s + s2;
else
s2 = s2.substring(0, column) + s + s2.substring(column, s2.length());
column += s.length();
lines.setElementAt(s2,line);
}
return new TextPosition(line,column);
}
public String delete_section(int line, int column, int eline, int ecolumn, boolean cut)
{
String text;
TextJournalItem new_journal = new TextJournalItem();
new_journal.action = DELETE;
new_journal.line = line;
new_journal.column = column;
new_journal.eline = eline;
new_journal.ecolumn = ecolumn;
text = copy_or_cut(new_journal,cut);
if (cut)
{
new_journal.text = new String(text);
new_journal.next = undo_list;
undo_list = new_journal;
redo_list = null;
updateMenus();
}
return text;
}
private String copy_or_cut(TextJournalItem i, boolean cut)
{
String s,s2;
String text = null;
int line = i.line;
int column = i.column;
int eline = i.eline;
int ecolumn = i.ecolumn;
if (line == eline)
{
s = (String)lines.elementAt(line);
text = s.substring(column,ecolumn);
if (cut)
{
s = s.substring(0, column) + s.substring(ecolumn, s.length());
lines.setElementAt(s,line);
}
}
else
{
s = (String)lines.elementAt(line);
text = s.substring(column,s.length());
s = s.substring(0, column);
int diff = eline - line;
int k = line + 1;
for (int j = 1; j < diff; j++)
{
s2 = (String)lines.elementAt(k);
text = text + lineSeparator + s2;
if (cut)
lines.removeElementAt(k);
else
k++;
}
if (k != lines.size())
{
s2 = (String)lines.elementAt(k);
text = text + lineSeparator + s2.substring(0,ecolumn);
s = s + s2.substring(ecolumn,s2.length());
if (cut)
lines.removeElementAt(k);
}
if (cut)
lines.setElementAt(s,line);
}
return text;
}
}
class TextJournalItem
{
public TextJournalItem next;
public String text;
public int action;
public int line;
public int column;
public int eline;
public int ecolumn;
}

Some files were not shown because too many files have changed in this diff Show More