Import Geant4 0.0.0 source tree
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
# $Id: G4ODBMS_BUILD.gmk,v 2.1 1998/07/09 13:00:42 morita Exp $
|
||||
# ----------------------------------------------------------------
|
||||
# GNUmakefile for CPPFLAGS for HepODBMS and Objectivity/DB.
|
||||
# Youhei Morita, 9th July 1998.
|
||||
#--------------------------------------------------------------------
|
||||
# Objectivity and HepODBMS definitions
|
||||
|
||||
ifdef OBJY_DIR
|
||||
CPPFLAGS += -I$(OBJY_DIR)/include
|
||||
endif
|
||||
|
||||
ifdef HEP_ODBMS_DIR
|
||||
CPPFLAGS += -I$(HEP_ODBMS_DIR)/include \
|
||||
-DHep_HAS_BUILDIN_BOOL_CONSTANTS
|
||||
endif
|
||||
#--------------------------------------------------------------------
|
||||
@@ -0,0 +1,69 @@
|
||||
# $Id: G4UI_BUILD.gmk,v 2.7 1998/10/23 15:14:36 barrand Exp $
|
||||
# -------------------------------------------------------------
|
||||
# Interfaces-specific CPPFLAGS for BUILD phase.
|
||||
# John Allison, 6th July 1998.
|
||||
# Include this *after* architecture.gmk
|
||||
# Include this *before* interactivity.gmk
|
||||
|
||||
########################### interfaces/basic #######################
|
||||
|
||||
ifndef G4UI_BUILD_TERMINAL_SESSION
|
||||
G4UI_BUILD_TERMINAL_SESSION = 1
|
||||
endif
|
||||
|
||||
ifdef G4UI_BUILD_TERMINAL_SESSION
|
||||
G4UI_BUILD = 1
|
||||
G4UI_BUILD_BASIC_SESSION = 1
|
||||
CPPFLAGS += -DG4UI_BUILD_TERMINAL_SESSION
|
||||
endif
|
||||
|
||||
ifdef G4UI_BUILD_XM_SESSION
|
||||
G4UI_BUILD = 1
|
||||
G4UI_BUILD_BASIC_SESSION = 1
|
||||
G4INTY_BUILD_XT = 1
|
||||
INC_XM = 1
|
||||
CPPFLAGS += -DG4UI_BUILD_XM_SESSION
|
||||
endif
|
||||
|
||||
ifdef G4UI_BUILD_XAW_SESSION
|
||||
G4UI_BUILD = 1
|
||||
G4UI_BUILD_BASIC_SESSION = 1
|
||||
G4INTY_BUILD_XT = 1
|
||||
INC_XAW = 1
|
||||
CPPFLAGS += -DG4UI_BUILD_XAW_SESSION
|
||||
endif
|
||||
|
||||
ifdef G4UI_BUILD_WIN32_SESSION
|
||||
G4UI_BUILD = 1
|
||||
G4UI_BUILD_BASIC_SESSION = 1
|
||||
G4INTY_BUILD_WIN32 = 1
|
||||
CPPFLAGS += -DG4UI_BUILD_WIN32_SESSION
|
||||
endif
|
||||
|
||||
########################### interfaces/GAG #######################
|
||||
|
||||
ifdef G4UI_BUILD_GAG_SESSION
|
||||
G4UI_BUILD = 1
|
||||
CPPFLAGS += -DG4UI_BUILD_GAG_SESSION
|
||||
endif
|
||||
|
||||
########################### interfaces/OPACS #######################
|
||||
|
||||
ifdef G4UI_BUILD_WO_SESSION
|
||||
G4UI_BUILD = 1
|
||||
G4INTY_BUILD_XT = 1
|
||||
INC_OPACS = 1
|
||||
CPPFLAGS += -DG4UI_BUILD_WO_SESSION
|
||||
endif
|
||||
|
||||
########################### interfaces/XVT - not currently implemented #####
|
||||
|
||||
############################################################################
|
||||
|
||||
ifdef G4UI_BUILD
|
||||
CPPFLAGS += -DG4UI_BUILD
|
||||
endif
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
# $Id: G4UI_USE.gmk,v 2.7 1998/08/26 11:05:37 allison Exp $
|
||||
# -------------------------------------------------------------
|
||||
# GNUmakefile for CPPFLAGS for interfaces USE phase.
|
||||
# John Allison, 6th July 1998.
|
||||
|
||||
########################### interfaces/basic #######################
|
||||
|
||||
UILIBS :=
|
||||
|
||||
ifndef G4UI_USE_TERMINAL
|
||||
G4UI_USE_TERMINAL = 1
|
||||
endif
|
||||
|
||||
ifdef G4UI_USE_TERMINAL
|
||||
G4UI_USE = 1
|
||||
G4UI_USE_BASIC = 1
|
||||
CPPFLAGS += -DG4UI_USE_TERMINAL
|
||||
endif
|
||||
|
||||
ifdef G4UI_USE_XM
|
||||
G4UI_USE = 1
|
||||
G4UI_USE_BASIC = 1
|
||||
G4INTY_USE_XT = 1
|
||||
INC_XM = 1
|
||||
LOAD_XM = 1
|
||||
CPPFLAGS += -DG4UI_USE_XM
|
||||
endif
|
||||
|
||||
ifdef G4UI_USE_XAW
|
||||
G4UI_USE = 1
|
||||
G4UI_USE_BASIC = 1
|
||||
G4INTY_USE_XT = 1
|
||||
INC_XAW = 1
|
||||
LOAD_XAW = 1
|
||||
CPPFLAGS += -DG4UI_USE_XAW
|
||||
endif
|
||||
|
||||
ifdef G4UI_USE_WIN32
|
||||
G4UI_USE = 1
|
||||
G4UI_USE_BASIC = 1
|
||||
G4INTY_USE_WIN32 = 1
|
||||
CPPFLAGS += -DG4UI_USE_WIN32
|
||||
endif
|
||||
|
||||
ifdef G4UI_USE_BASIC
|
||||
CPPFLAGS += -I$(G4BASE)/interfaces/basic/include
|
||||
UILIBS += -lG4UIbasic
|
||||
endif
|
||||
|
||||
########################### interfaces/GAG #######################
|
||||
|
||||
ifdef G4UI_USE_GAG
|
||||
G4UI_USE = 1
|
||||
CPPFLAGS += -DG4UI_USE_GAG
|
||||
CPPFLAGS += -I$(G4BASE)/interfaces/GAG/include
|
||||
UILIBS += -lG4UIGAG
|
||||
endif
|
||||
|
||||
########################### interfaces/OPACS #######################
|
||||
|
||||
ifdef G4UI_USE_WO
|
||||
G4UI_USE = 1
|
||||
G4INTY_USE_XT = 1
|
||||
CPPFLAGS += -DG4UI_USE_WO
|
||||
CPPFLAGS += -I$(G4BASE)/interfaces/OPACS/include
|
||||
UILIBS += -lG4UIOPACS
|
||||
INC_OPACS = 1
|
||||
LOAD_OPACS = 1
|
||||
endif
|
||||
|
||||
########################### interfaces/XVT - not currently implemented #####
|
||||
|
||||
########################### and finally... #######################
|
||||
|
||||
ifdef G4UI_USE
|
||||
CPPFLAGS += -DG4UI_USE
|
||||
CPPFLAGS += -I$(G4BASE)/interfaces/common/include
|
||||
UILIBS += -lG4UIcommon
|
||||
endif
|
||||
@@ -0,0 +1,86 @@
|
||||
# $Id: G4VIS_BUILD.gmk,v 1.2 1998/07/07 15:10:33 allison Exp $
|
||||
# -------------------------------------------------------------
|
||||
# Visualization-specific CPPFLAGS for BUILD phase.
|
||||
# John Allison, 24th January 1998.
|
||||
# Include this *after* architecture.gmk
|
||||
# Include this *before* interactivity.gmk
|
||||
|
||||
|
||||
# For DAWN and DAWNFILE drivers
|
||||
ifdef G4VIS_BUILD_DAWN_DRIVER
|
||||
G4VIS_BUILD = 1
|
||||
CPPFLAGS += -DG4VIS_BUILD_DAWN_DRIVER
|
||||
endif
|
||||
ifdef G4VIS_BUILD_DAWNFILE_DRIVER
|
||||
G4VIS_BUILD = 1
|
||||
CPPFLAGS += -DG4VIS_BUILD_DAWNFILE_DRIVER
|
||||
endif
|
||||
# End of DAWN and DAWNFILE drivers
|
||||
|
||||
ifdef G4VIS_BUILD_OPACS_DRIVER
|
||||
G4VIS_BUILD = 1
|
||||
G4INTY_BUILD_XT = 1
|
||||
CPPFLAGS += -DG4VIS_BUILD_OPACS_DRIVER
|
||||
INC_OPACS = 1
|
||||
endif
|
||||
|
||||
ifdef G4VIS_BUILD_OPENGLX_DRIVER
|
||||
G4VIS_BUILD_OPENGL_DRIVER = 1
|
||||
INC_X11 = 1
|
||||
CPPFLAGS += -DG4VIS_BUILD_OPENGLX_DRIVER
|
||||
endif
|
||||
ifdef G4VIS_BUILD_OPENGLWIN32_DRIVER
|
||||
G4VIS_BUILD_OPENGL_DRIVER = 1
|
||||
G4INTY_BUILD_WIN32 = 1
|
||||
CPPFLAGS += -DG4VIS_BUILD_OPENGLWIN32_DRIVER
|
||||
endif
|
||||
ifdef G4VIS_BUILD_OPENGLXM_DRIVER
|
||||
G4VIS_BUILD_OPENGL_DRIVER = 1
|
||||
G4INTY_BUILD_XT = 1
|
||||
INC_XM = 1
|
||||
CPPFLAGS += -DG4VIS_BUILD_OPENGLXM_DRIVER
|
||||
endif
|
||||
ifdef G4VIS_BUILD_OPENGL_DRIVER
|
||||
G4VIS_BUILD = 1
|
||||
INC_GL = 1
|
||||
CPPFLAGS += -DG4VIS_BUILD_OPENGL_DRIVER
|
||||
endif
|
||||
|
||||
ifdef G4VIS_BUILD_OIX_DRIVER
|
||||
G4VIS_BUILD_OI_DRIVER = 1
|
||||
G4INTY_BUILD_XT = 1
|
||||
CPPFLAGS += -DG4VIS_BUILD_OIX_DRIVER
|
||||
endif
|
||||
ifdef G4VIS_BUILD_OIWIN32_DRIVER
|
||||
G4VIS_BUILD_OI_DRIVER = 1
|
||||
G4INTY_BUILD_WIN32 = 1
|
||||
CPPFLAGS += -DG4VIS_BUILD_OIWIN32_DRIVER
|
||||
endif
|
||||
ifdef G4VIS_BUILD_OI_DRIVER
|
||||
G4VIS_BUILD = 1
|
||||
INC_IV = 1
|
||||
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
|
||||
CPPFLAGS += -DG4VIS_BUILD_VRML_DRIVER
|
||||
endif
|
||||
ifdef G4VIS_BUILD_VRMLFILE_DRIVER
|
||||
G4VIS_BUILD = 1
|
||||
CPPFLAGS += -DG4VIS_BUILD_VRMLFILE_DRIVER
|
||||
endif
|
||||
# End of VRML and VRMLFILE drivers
|
||||
|
||||
ifdef G4VIS_BUILD
|
||||
CPPFLAGS += -DG4VIS_BUILD
|
||||
endif
|
||||
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
# $Id: G4VIS_USE.gmk,v 1.7 1998/12/07 03:48:44 stanaka Exp $
|
||||
# -------------------------------------------------------------
|
||||
# GNUmakefile for CPPFLAGS for visualization USE phase.
|
||||
# John Allison, 24th January 1998.
|
||||
|
||||
ifndef VISLIBS
|
||||
VISLIBS :=
|
||||
endif
|
||||
|
||||
ifdef G4VIS_USE_DAWN
|
||||
G4VIS_USE_DAWN_OR_DAWNFILE = 1
|
||||
CPPFLAGS += -DG4VIS_USE_DAWN
|
||||
endif
|
||||
ifdef G4VIS_USE_DAWNFILE
|
||||
G4VIS_USE_DAWN_OR_DAWNFILE = 1
|
||||
CPPFLAGS += -DG4VIS_USE_DAWNFILE
|
||||
endif
|
||||
ifdef G4VIS_USE_DAWN_OR_DAWNFILE
|
||||
G4VIS_USE = 1
|
||||
CPPFLAGS += -I$(G4BASE)/visualization/FukuiRenderer/include
|
||||
VISLIBS += -lG4FR
|
||||
endif
|
||||
|
||||
ifdef G4VIS_USE_OPACS
|
||||
G4VIS_USE = 1
|
||||
INC_OPACS = 1
|
||||
LOAD_OPACS = 1
|
||||
CPPFLAGS += -DG4VIS_USE_OPACS
|
||||
CPPFLAGS += -I$(G4BASE)/visualization/OPACS/include
|
||||
VISLIBS += -lG4OPACS
|
||||
endif
|
||||
|
||||
ifdef G4VIS_USE_OPENGLX
|
||||
G4VIS_USE_OPENGL = 1
|
||||
CPPFLAGS += -DG4VIS_USE_OPENGLX
|
||||
INC_X11 = 1
|
||||
LOAD_X11 = 1
|
||||
endif
|
||||
ifdef G4VIS_USE_OPENGLXM
|
||||
G4VIS_USE_OPENGL = 1
|
||||
CPPFLAGS += -DG4VIS_USE_OPENGLXM
|
||||
INC_XM = 1
|
||||
LOAD_XM = 1
|
||||
endif
|
||||
ifdef G4VIS_USE_OPENGL
|
||||
G4VIS_USE = 1
|
||||
CPPFLAGS += -DG4VIS_USE_OPENGL
|
||||
CPPFLAGS += -I$(G4BASE)/visualization/OpenGL/include
|
||||
VISLIBS += -lG4OpenGL
|
||||
INC_GL = 1
|
||||
LOAD_GL = 1
|
||||
endif
|
||||
|
||||
ifdef G4VIS_USE_OIX
|
||||
G4VIS_USE_OI = 1
|
||||
CPPFLAGS += -DG4VIS_USE_OIX
|
||||
INC_XM = 1
|
||||
LOAD_XM = 1
|
||||
endif
|
||||
ifdef G4VIS_USE_OIWIN32
|
||||
G4VIS_USE_OI = 1
|
||||
CPPFLAGS += -DG4VIS_USE_OIWIN32
|
||||
endif
|
||||
ifdef G4VIS_USE_OI
|
||||
G4VIS_USE = 1
|
||||
CPPFLAGS += -DG4VIS_USE_OI
|
||||
CPPFLAGS += -I$(G4BASE)/visualization/OpenInventor/include
|
||||
VISLIBS += -lG4OpenInventor
|
||||
INC_IV = 1
|
||||
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
|
||||
endif
|
||||
ifdef G4VIS_USE_VRMLFILE
|
||||
G4VIS_USE_VRML_OR_VRMLFILE = 1
|
||||
CPPFLAGS += -DG4VIS_USE_VRMLFILE
|
||||
endif
|
||||
ifdef G4VIS_USE_VRML_OR_VRMLFILE
|
||||
G4VIS_USE = 1
|
||||
CPPFLAGS += -I$(G4BASE)/visualization/VRML/include
|
||||
VISLIBS += -lG4VRML
|
||||
endif
|
||||
|
||||
ifdef G4VIS_USE
|
||||
ifdef G4_SOLVE_TEMPLATES
|
||||
G4_SOLVE_VIS_TEMPLATES = 1
|
||||
endif
|
||||
ifdef GNU_GCC
|
||||
G4_SOLVE_VIS_TEMPLATES = 1
|
||||
endif
|
||||
ifdef G4_SOLVE_VIS_TEMPLATES
|
||||
CPPFLAGS += -DG4_SOLVE_VIS_TEMPLATES
|
||||
endif
|
||||
CPPFLAGS += -DG4VIS_USE
|
||||
CPPFLAGS += -I$(G4BASE)/visualization/management/include
|
||||
CPPFLAGS += -I$(G4BASE)/visualization/modeling/include
|
||||
VISLIBS += -lG4vis_management
|
||||
VISLIBS += -lG4modeling
|
||||
endif
|
||||
|
||||
+236
@@ -0,0 +1,236 @@
|
||||
$Id: History,v 2.65 1998/12/15 19:29:12 gcosmo Exp $
|
||||
$Name: geant4-00 $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
|
||||
=========================================================
|
||||
|
||||
Category History file
|
||||
---------------------
|
||||
|
||||
History file for Geant4 configuration scripts.
|
||||
It DOES NOT substitute the CVS log-message one should put at every
|
||||
committal in the CVS repository !
|
||||
|
||||
----------------------------------------------------------
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
|
||||
December 15th, 1998 - G.Cosmo (config-00-04-11)
|
||||
- Added G4_HAVE_BOOL to DEC-cxx.
|
||||
- Cosmetic changes.
|
||||
|
||||
December 12th, 1998 - J.Allison (config-00-04-10)
|
||||
- Fixed bug in OGLFLAGS and OGLLIBS user override mechanism.
|
||||
|
||||
December 11th, 1998 - J.Allison (config-00-04-09)
|
||||
- Removed -fnonstd for SUN-CC.
|
||||
|
||||
December 10th, 1998 - G.Cosmo (config-00-04-08)
|
||||
- architecture.gmk: introduced $G4DATA variable which can be user
|
||||
defined. Default is set to $G4INSTALL/data.
|
||||
- architecture.gmk: introduced $G4LEVELGAMMADATA set as default to
|
||||
$G4DATA/PhotonEvaporation.
|
||||
- globlib.gmk: fixed minor bug (courtesy of V.Krylov).
|
||||
|
||||
December 10th, 1998 - J.Allison (config-00-04-07)
|
||||
- architecture.gmk: allowed environment variables OGLFLAGS and OGLLIBS.
|
||||
|
||||
December 7th, 1998 - S.Tanaka, G.Cosmo (config-00-04-06)
|
||||
- architecture.gmk: fixed setting of VISLIBS.
|
||||
|
||||
December 7th, 1998 - S.Tanaka
|
||||
- Update of architecture.gmk and G4VIS_USE.gmk:
|
||||
In SUN-CC, "-L/usr/lib -lsocket -lnsl" is moved from X11LIBS to VISLIBS.
|
||||
|
||||
December 5th, 1998 - G.Cosmo (config-00-04-05)
|
||||
- architecture.gmk: introduced -fnonstd compiler option for SUN-CC.
|
||||
This option causes non-standard initialization of floating-point
|
||||
arithmetic hardware; it enables hardware traps for floating-point
|
||||
overflow, division by zero, and invalid operation exceptions.
|
||||
|
||||
December 4th, 1998 - G.Barrand
|
||||
- architecture.gmk: corrected paths for HepVis and HepInventor.
|
||||
- interactivity.gmk: fixed setup for LOAD_IV.
|
||||
|
||||
December 3rd, 1998 - S.Tanaka
|
||||
- Revision to make compilation of DAWN (network) driver
|
||||
at Solaris and IRIX automatic. See below.
|
||||
- Added the following line to SUN-CC and SGI-CC
|
||||
CPPFLAGS += -DSOCKET_IRIX_SOLARIS
|
||||
- Added -L/usr/lib -lsocket -lnsl in X11LIBS for SUN-CC.
|
||||
(This place is strange. But I cannot think of a better place.)
|
||||
|
||||
December 3rd, 1998 - J.Allison (config-00-04-04)
|
||||
- Set G4STREAM for all platforms.
|
||||
- Set G4STREAM_STREAMBUF_IMPLEMENTATION for selected platforms.
|
||||
|
||||
December 3rd, 1998 - S.Sadilov
|
||||
- Updated architecture.gmk : G4STREAM_STREAMBUF_IMPLEMENTATION for WIN32.
|
||||
- Updated globlib.gmk : right incremental LIB for WIN32.
|
||||
|
||||
December 1st, 1998 - G.Cosmo (config-00-04-03)
|
||||
- Updated architecture.gmk and binmake.gmk: G4SYSTEM revision.
|
||||
- Added +DAportable compiler option to HP-aCC setup to support HPPA 2.0
|
||||
for PA8000 CPUs.
|
||||
|
||||
December 1st, 1998 - J.Allison (config-00-04-02)
|
||||
- Added generators/include to binmake.gmk.
|
||||
|
||||
November 30th, 1998 - J.Allison (config-00-04-01)
|
||||
- Added neutron_hp/include to binmake.gmk.
|
||||
- CLHEP_BASE_DIR and RWBASE for WIN32 (Serguei Sadilov).
|
||||
|
||||
November 18th, 1998 - J.Allison (config-00-03-06)
|
||||
- Changed CXXFLAGS for DEC6-AFS debug from -g to -gall.
|
||||
|
||||
October 30th, 1998 - G.Cosmo (config-00-03-05)
|
||||
- architecture.gmk: added G4STREAM_STREAMBUF_IMPLEMENTATION variable. (G.Barrand)
|
||||
- G4UI_BUILD.gmk: removed G4UI_BUILD_XM_REDIRECT_COUT. (G.Barrand)
|
||||
|
||||
October 13th, 1998 J.Allison (config-00-03-04)
|
||||
- Changed ifdef G4_USE_G4STREAM to ifneq ($(findstring AIX,$(G4SYSTEM)),AIX)
|
||||
|
||||
October 13th, 1998 J.Allison (config-00-03-03)
|
||||
- Removed G4VIS_DONT_USE. (G.Barrand)
|
||||
- Added if G4_USE_G4STREAM, CPPFLAGS += -DG4STREAM. (M.Nagamatu)
|
||||
|
||||
October 9th J.Allison (config-00-03-02)
|
||||
- Tagged.
|
||||
|
||||
October 2nd, 1998 - M.Asai
|
||||
- G4_NO_STORE_TRAJECTORY option is added to architecture.gmk.
|
||||
|
||||
September 30th, 1998 - G.Barrand
|
||||
- G4VIS_USE.gmk: bracket everything with "ifndef G4VIS_DONT_USE" in order
|
||||
to be able to disconnect easily visualization for tests programs.
|
||||
|
||||
September 18th, 1998 - G.Cosmo (config-00-03-01)
|
||||
- architecture.gmk: introduced G4DUMMY_VARIABLE to hide $(shell)
|
||||
command not compatible with the new version 3.77 of GMAKE (G.Folger).
|
||||
|
||||
September 14th, 1998 - G.Cosmo
|
||||
- binmake.gmk: placed digits+hits library in the correct link order
|
||||
according to the category diagram.
|
||||
|
||||
August 31st, 1998 - G.Cosmo (config-00-02-05)
|
||||
- architecture.gmk: Changed first CPPFLAGS statement from := to +=,
|
||||
to allow additional CPPFLAGS to be defined by the user. Needed for test
|
||||
(F.Behner)
|
||||
- binmake.gmk: Added EXTRALIBS to allow a user to add own libraries in the
|
||||
link path. Needed for test.
|
||||
(F.Behner)
|
||||
- binmake.gmk: inverted link order of processes and particles libraries
|
||||
which was wrong. (G.Cosmo)
|
||||
|
||||
August 26th, 1998 - John Allison (config-00-02-04)
|
||||
- Backed out 22nd August change (G4UIGAG as default) - G4UIterminal
|
||||
is now default.
|
||||
|
||||
August 24th, 1998 - Y.Morita (config-00-02-03)
|
||||
- globlib.gmk: added $(G4LIBDIR)/lib$(name).a for target "global".
|
||||
|
||||
August 22nd, 1998 - J.Allison (config-00-02-02)
|
||||
- Set GAG variables by default.
|
||||
|
||||
August 11th, 1998 - G.Cosmo (config-00-02-01)
|
||||
- Tagged.
|
||||
|
||||
August 7th, 1998 - John Allison/Michel Maire.
|
||||
- Added -I/usr/include before -I/usr/local/include to OGLFLAGS for DEC-AFS.
|
||||
- Changed -lGl to -lMesaGL, etc., for DEC-AFS.
|
||||
|
||||
August 6th, 1998 - John Allison
|
||||
- Added UILIBS := to G4UI_USE.gmk and VISLIBS := to G4VIS_USE.gmk.
|
||||
|
||||
August 5th, 1998 - Guy Barrand
|
||||
- Added LOAD_XM = 1 and LOAD_XAW = 1 to G4UI_USE.gmk.
|
||||
|
||||
July 30th, 1998 - G.Cosmo (config-b01)
|
||||
- globlib.gmk: added phony target "wipe_libs". Now target "global"
|
||||
effectively deletes all existent granular libraries.
|
||||
- common.gmk: archiving of libraries is silent now by default.
|
||||
|
||||
July 23th, 1998 - Y.Morita (config-00-01-16)
|
||||
- globlib.gmk: fixed target "global" for G4ODBMS
|
||||
- binmake.gmk: fixes for Win/NT.
|
||||
|
||||
July 20th, 1998 - John Allison (config-00-01-15)
|
||||
- Removed LDFLAGS += -Wl,-Bstatic for G++-Linux introduced by Larry
|
||||
Felawka on July 10th for g++ 2.8. No longer thought to be necessary.
|
||||
|
||||
July 19th, 1998 - G.Cosmo (config-00-01-14)
|
||||
- common.gmk: introduced CPPVERBOSE flag.
|
||||
- architecture.gmk: protected creation of $G4SCHEMA_DIR and
|
||||
$G4EXAMPLE_BOOT_DIR directories with G4ODBMS.
|
||||
- binmake.gmk: fixed bug in creation of $G4TARGET.
|
||||
|
||||
July 18th, 1998 - G.Cosmo (config-00-01-13)
|
||||
- Added fix to binmake.gmk for WIN32-VC-NICE (G.Folger)
|
||||
|
||||
July 16th, 1998 - John Allison
|
||||
- Added GNU_GCC makefile flags where omitted.
|
||||
|
||||
July 15th, 1998 - Youhei Morita (config-00-01-12)
|
||||
- architecture.gmk added G4EXAMPLE_BOOT_DIR and G4EXAMPLE_BOOT
|
||||
- globlib.gmk revised cleandb target
|
||||
|
||||
July 14th, 1998 - Peter Urban (config-00-01-11)
|
||||
- added two Perl scripts that correct STEP exchange files.
|
||||
|
||||
July 14th, 1998 - Youhei Morita (config-00-01-10)
|
||||
- architecture.gmk added definition of G4SCHEMA_DIR
|
||||
- globlib.gmk added new target G4SCHEMA.FDDB for G4ODBMS
|
||||
|
||||
July 10th, 1998 - Youhei Morita (config-00-01-09)
|
||||
- binmake.gmk added following to INCFLAGS
|
||||
-I$(G4BASE)/persistency/digits+hits/hits/include \
|
||||
-I$(G4TMP)/$(G4SYSTEM)/G4phits \
|
||||
- binmake.gmk moved persistency include path to ifdef G4ODBMS block
|
||||
|
||||
July 10th, 1998 - John Allison??
|
||||
- binmake.gmk added geometry/solids/STEPinterface/include
|
||||
|
||||
July 10th, 1998 - Youehi Morita (config-00-01-08)
|
||||
- globlib.gmk added new targets 'headers' and 'd_files' for G4ODBMS
|
||||
- common.gmk added new target 'headers'
|
||||
added $(schema_hh) dependency to $(G4TMPDIR)/%.o
|
||||
- binmake.gmk added INCFLAGS, LDLIBS and LDFLAGS for G4ODBMS
|
||||
|
||||
July 10th, 1998 - L.Felawka
|
||||
- architecture.gmk: updated compilation flags for g++.
|
||||
|
||||
July 9th, 1998 - G.Cosmo (config-00-01-07)
|
||||
- Removed bug in "all" target in globlib.gmk, introduced recently.
|
||||
- Modified "all" target in globlib.gmk to handle G4ODBMS.
|
||||
- Added fix for G4ODBMS to common.gmk.
|
||||
|
||||
July 9th, 1998 - Youehi Morita
|
||||
- Added G4ODBMS_BUILD.gmk for HepODBMS and Objectivity/DB CPPFLAGS.
|
||||
|
||||
July 7th, 1998 - John Allison (config-00-01-06)
|
||||
- Incorporated Makoto's patches for ifndef G4UI_BUILD_TERMINAL_SESSION and
|
||||
ifndef G4UI_USE_TERMINAL.
|
||||
|
||||
July 7th, 1998 - G.Cosmo (config-00-01-05)
|
||||
- Added $(schema_hh) target and dependency to it in case of G4ODBMS
|
||||
set when building .d files.
|
||||
|
||||
July 7th, 1998 - John Allison (config-00-01-04)
|
||||
- Tagged.
|
||||
|
||||
July 7th, 1998 - Guy Barrand
|
||||
- Introduced interactivity.gmk.
|
||||
|
||||
July 6th, 1998 - J.Allison (config-00-01-03)
|
||||
- Added G4UI_BUILD.gmk and G4UI_BUILD.gmk.
|
||||
|
||||
July 6th, 1998 - G.Cosmo (config-00-01-02)
|
||||
- Introduced "glob" and "objs" targets in globlib.gmk. Modified
|
||||
rule to build global library, does not depend anymore on "libs".
|
||||
(by J.Allison)
|
||||
- Moved G4VIS_USE.gmk and G4VIS_BUILD.gmk from source/visualization.
|
||||
|
||||
July 3rd, 1998 - G.Cosmo (config-00-01-01)
|
||||
- Created
|
||||
@@ -0,0 +1,632 @@
|
||||
# $Id: architecture.gmk,v 2.40 1998/12/15 19:29:13 gcosmo Exp $
|
||||
# ------------------------------------------------------------------------
|
||||
# GEANT 4 - Architecture configuration script for GNU Make
|
||||
#
|
||||
# First implementation: July 7th 1995
|
||||
#
|
||||
# Description
|
||||
# -----------
|
||||
# to override variables defined in this script, use "gmake -e", this will
|
||||
# cause environment variables to take precedence. In this case watch for
|
||||
# inadvertant overrides!
|
||||
#
|
||||
# List of the supported architectures/compilers and related flavors for
|
||||
# the environment variable G4SYSTEM:
|
||||
#
|
||||
# AIX-xlC AIX 4.3, (xlC) C Set ++ for AIX (default)
|
||||
#
|
||||
# SUN-CC SunOS 5.6, CC 4.2 compiler
|
||||
#
|
||||
# HP-aCC HP-UX 10.20, aCC A.01.09 compiler
|
||||
#
|
||||
# SGI-CC SGI-IRIX 6.2, C++ 7.2 compiler
|
||||
#
|
||||
# DEC-cxx DEC-OSF/1 4.0, DEC C++ 6.1
|
||||
#
|
||||
# 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-G++-NICE NiceNT and CYGWIN32 with g++ as base compiler
|
||||
# ex. NiceNT at CERN (but CYGWIN32 and RogueWave
|
||||
# for g++ installed locally, because not full
|
||||
# installation on NICE)
|
||||
#
|
||||
|
||||
MAKEFLAGS= --no-print-directory
|
||||
|
||||
# If not specified, the default platform for G4SYSTEM is IBM-AIX ...
|
||||
#
|
||||
ifndef G4SYSTEM
|
||||
G4SYSTEM := AIX-xlC
|
||||
endif
|
||||
|
||||
# If not specified, the default path for G4 installation G4INSTALL is
|
||||
# set to $HOME/geant4beta ...
|
||||
#
|
||||
ifndef G4INSTALL
|
||||
G4INSTALL := $(HOME)/geant4beta
|
||||
endif
|
||||
|
||||
# If not specified, the default path for G4 source G4BASE is
|
||||
# set to $G4INSTALL/source ...
|
||||
#
|
||||
ifndef G4BASE
|
||||
G4BASE := $(G4INSTALL)/source
|
||||
endif
|
||||
|
||||
# If not specified, the default path for the user's workdir is the same
|
||||
# as G4INSTALL ...
|
||||
#
|
||||
ifndef G4WORKDIR
|
||||
G4WORKDIR := $(G4INSTALL)
|
||||
endif
|
||||
|
||||
# If not specified, the default path for temporary files G4TMP is
|
||||
# set to $G4WORKDIR/tmp/$G4SYSTEM ...
|
||||
#
|
||||
ifndef G4TMP
|
||||
G4TMP := $(G4WORKDIR)/tmp
|
||||
endif
|
||||
G4DUMMY_VARIABLE:=$(shell [ ! -d $(G4TMP) ] && mkdir -p $(G4TMP) )
|
||||
|
||||
# If not specified, the default path for G4 libraries G4LIB is
|
||||
# set to $G4INSTALL/lib/$G4SYSTEM ...
|
||||
#
|
||||
ifndef G4LIB
|
||||
G4LIB := $(G4INSTALL)/lib
|
||||
endif
|
||||
G4DUMMY_VARIABLE:=$(shell [ ! -d $(G4LIB) ] && mkdir -p $(G4LIB) )
|
||||
|
||||
# If not specified, the default path for G4 binaries G4BIN is
|
||||
# set to $G4WORKDIR/bin/$G4SYSTEM ...
|
||||
#
|
||||
ifndef G4BIN
|
||||
G4BIN := $(G4WORKDIR)/bin
|
||||
endif
|
||||
G4DUMMY_VARIABLE:=$(shell [ ! -d $(G4BIN) ] && mkdir -p $(G4BIN) )
|
||||
|
||||
# If not specified, the default path for G4 schema G4SCHEMA_DIR is
|
||||
# set to $G4WORKDIR/schema ...
|
||||
#
|
||||
ifndef G4SCHEMA_DIR
|
||||
G4SCHEMA_DIR := $(G4WORKDIR)/schema
|
||||
G4SCHEMA_FDID := 207
|
||||
endif
|
||||
ifdef G4ODBMS
|
||||
G4DUMMY_VARIABLE:=$(shell [ ! -d $(G4SCHEMA_DIR) ] && mkdir -p $(G4SCHEMA_DIR) )
|
||||
endif
|
||||
|
||||
# If not specified, the default path for G4 example federated database is
|
||||
# set to $HOME/G4EXAMPLE ...
|
||||
#
|
||||
ifndef G4EXAMPLE_BOOT_DIR
|
||||
G4EXAMPLE_BOOT_DIR := $(HOME)/G4EXAMPLE
|
||||
G4EXAMPLE_BOOT := $(G4EXAMPLE_BOOT_DIR)/G4EXAMPLE
|
||||
endif
|
||||
ifdef G4ODBMS
|
||||
G4DUMMY_VARIABLE:=$(shell [ ! -d $(G4EXAMPLE_BOOT_DIR) ] && mkdir -p $(G4EXAMPLE_BOOT_DIR) )
|
||||
endif
|
||||
|
||||
# If G4DEBUG not specified, the default compilation is optimised ...
|
||||
#
|
||||
ifndef G4DEBUG
|
||||
G4OPTIMISE := 1
|
||||
endif
|
||||
|
||||
#
|
||||
# CLHEP path
|
||||
#
|
||||
|
||||
ifndef CLHEP_BASE_DIR
|
||||
CLHEP_BASE_DIR := /afs/cern.ch/rd44/dev/CLHEP/$(G4SYSTEM)/pro
|
||||
endif
|
||||
CLHEP_INCLUDE_DIR := $(CLHEP_BASE_DIR)/include
|
||||
CLHEP_LIB_DIR := $(CLHEP_BASE_DIR)/lib
|
||||
ifndef CLHEP_LIB
|
||||
CLHEP_LIB := CLHEP
|
||||
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"
|
||||
endif
|
||||
CLHEP_INCLUDE_DIR := $(CLHEP_BASE_DIR)/include
|
||||
CLHEP_LIB_DIR := $(CLHEP_BASE_DIR)/lib
|
||||
CLHEP_LIB := libCLHEP-cl.a
|
||||
endif
|
||||
|
||||
#
|
||||
# Rogue Wave Tools.h++ path
|
||||
#
|
||||
|
||||
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
|
||||
|
||||
#
|
||||
# Paths for G4 data
|
||||
#
|
||||
|
||||
ifndef G4DATA
|
||||
G4DATA := $(G4INSTALL)/data
|
||||
endif
|
||||
|
||||
# Photon evaporation data
|
||||
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)
|
||||
OUT_OBJ := -TP '-Fo'
|
||||
FOR_OBJ := '-Fo'
|
||||
OUT_LIB := '-out:'
|
||||
OUT_EXE := '-Fe'
|
||||
LIB_PATH := '-libpath:'
|
||||
CERNLIB_PATH := "z:\p32\cern\new\df\lib"
|
||||
PATH_DEL := \\
|
||||
#
|
||||
# pattern for next substitution
|
||||
#
|
||||
LIB_PATT := lib(LibName).a
|
||||
FLIB_PATT := (LibName).lib
|
||||
else
|
||||
OUT_OBJ := -o
|
||||
FOR_OBJ := -o
|
||||
OUT_LIB :=
|
||||
OUT_EXE := -o
|
||||
LIB_PATH := -L
|
||||
CERNLIB_PATH := /cern/pro/lib
|
||||
PATH_DEL := /
|
||||
#
|
||||
# pattern for next substitution
|
||||
#
|
||||
LIB_PATT := -l(LibName)
|
||||
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)
|
||||
#
|
||||
# Positional qualifiers in action...
|
||||
#
|
||||
ifeq ($(G4SYSTEM),WIN32-VC-NICE)
|
||||
LDFLAGS := -link $(LIB_PATH)$(CLHEP_LIB_DIR) $(LIB_PATH)$(RWLIBDIR)
|
||||
LOADLIBS := $(CLHEP_LIB) $(RWLIB)
|
||||
else
|
||||
LDFLAGS := -L$(CLHEP_LIB_DIR) -L$(RWLIBDIR)
|
||||
LOADLIBS := -l$(CLHEP_LIB) -l$(RWLIB) -lm
|
||||
endif
|
||||
|
||||
#
|
||||
# Graphic variables...
|
||||
#
|
||||
ifndef VISLIBS
|
||||
VISLIBS :=
|
||||
endif
|
||||
# ------------------ X11 ---------------------
|
||||
X11FLAGS :=
|
||||
X11LIBS := -lXmu -lXt -lXext -lX11
|
||||
# ----------------- Motif --------------------
|
||||
XMFLAGS :=
|
||||
XMLIBS := -lXm
|
||||
# ---------------- Athena --------------------
|
||||
XAWFLAGS :=
|
||||
XAWLIBS := -lXaw
|
||||
# ---------------- OpenGL --------------------
|
||||
# The user can define his own values of OGLFLAGS and OGLLIBS.
|
||||
# OGLFLAGS gives the directory containing include files.
|
||||
# E.g.: OGLFLAGS := -I$(OGLHOME)/include
|
||||
# OGLLIBS gives the libraries.
|
||||
# E.g.: OGLLIBS := -L$(OGLHOME)/lib -lGLU -lGL
|
||||
# Or : OGLLIBS := -L$(OGLHOME)/lib -lMesaGLU -lMesaGL
|
||||
# OGLHOME is often /usr or /usr/local. Or it can point to a special
|
||||
# installation.
|
||||
# If the user does not set his/her own values, system-dependent values
|
||||
# are set below. Most system-dependent code assumes OGLHOME is set.
|
||||
# ------------- OpenInventor -----------------
|
||||
ifndef HEPVISINC
|
||||
HEPVISINC := $(HEPVISDIR)/include
|
||||
endif
|
||||
ifndef HEPVISLIB
|
||||
HEPVISLIB := $(HEPVISDIR)/source
|
||||
endif
|
||||
ifndef OIVFLAGS
|
||||
OIVFLAGS := -I${HEPVISINC}
|
||||
endif
|
||||
ifndef OIVLIBS
|
||||
OIVLIBS := -L${HEPVISLIB} -lHEPVis -lInventorXt -lInventor -lGLU -lGL
|
||||
endif
|
||||
# ----------------- OPACS --------------------
|
||||
ifndef G4_OPACS_WIDGET_SET
|
||||
G4_OPACS_WIDGET_SET := Xm
|
||||
endif
|
||||
|
||||
#
|
||||
# For cfront compilers the repository location is set to
|
||||
# $G4TMP/$G4SYSTEM/g4.ptrepository.
|
||||
#
|
||||
|
||||
G4TEMPLATE_REPOSITORY := $(G4SYSTEM)/g4.ptrepository
|
||||
G4TEMPEXEC_REPOSITORY := $(G4TEMPLATE_REPOSITORY)/exec
|
||||
G4TREP := $(G4TMP)/$(G4TEMPLATE_REPOSITORY)
|
||||
|
||||
# Default archive call. Changed for: SUN-CC.
|
||||
AR := ar r
|
||||
|
||||
# Default echo used with makedepend. Changed for SUN-CC, Linux-g++.
|
||||
ECHO:= echo
|
||||
|
||||
|
||||
#
|
||||
# Architecture dependent variables...
|
||||
#
|
||||
|
||||
# -------- AIX ----------
|
||||
#
|
||||
ifeq ($(G4SYSTEM),AIX-xlC)
|
||||
CXX := xlC
|
||||
ifdef G4OPTIMISE
|
||||
CXXFLAGS := -O3 -qtwolink -+
|
||||
else
|
||||
CXXFLAGS := -g -qdbxextra -qcheck=all -qfullpath -qtwolink -+
|
||||
FCFLAGS := -g
|
||||
endif
|
||||
FC := xlf
|
||||
FCFLAGS += -qextname
|
||||
FCLIBS := -lxlf90 -lxlf
|
||||
X11FLAGS := -I/usr/include/X11/extensions -I/usr/include/X11
|
||||
X11LIBS := -L/usr/lib -lXmu -lX11 -lXext
|
||||
XMFLAGS := -I/usr/include/Motif1.2
|
||||
XMLIBS := -L/usr/lib -lXm -lXt -lX11
|
||||
XAWFLAGS := -I/usr/include/X11
|
||||
XAWLIBS := -L/usr/lib -lXaw -lXmu -lXt -lX11 -lXext
|
||||
ifndef OGLFLAGS
|
||||
OGLFLAGS := -I$(OGLHOME)/include
|
||||
endif
|
||||
ifndef OGLLIBS
|
||||
OGLLIBS := -L$(OGLHOME)/lib -lGLU -lGL
|
||||
endif
|
||||
endif
|
||||
|
||||
# -------- SUN ---------
|
||||
#
|
||||
ifeq ($(G4SYSTEM),SUN-CC)
|
||||
CXX := CC
|
||||
ifdef G4OPTIMISE
|
||||
CXXFLAGS := -O
|
||||
else
|
||||
CXXFLAGS := -g
|
||||
FCFLAGS := -g
|
||||
endif
|
||||
# CXXFLAGS += -fnonstd
|
||||
CFRONT_G4TEMPLATE_REPOSITORY := true
|
||||
FC := f77
|
||||
SHEXT := so
|
||||
AR := $(CXX) -xar -ptr$(G4TREP) -o
|
||||
ECHO := /bin/echo
|
||||
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
|
||||
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
|
||||
OGLFLAGS := -I$(OGLHOME)/include
|
||||
endif
|
||||
ifndef OGLLIBS
|
||||
OGLLIBS := -L$(OGLHOME)/lib -lGLU -lGL
|
||||
endif
|
||||
CPPFLAGS += -DSOCKET_IRIX_SOLARIS
|
||||
VISLIBS += -L/usr/lib -lsocket -lnsl
|
||||
endif
|
||||
|
||||
# -------- HP ---------
|
||||
#
|
||||
ifeq ($(G4SYSTEM),HP-aCC)
|
||||
CXX := aCC
|
||||
ifdef G4OPTIMISE
|
||||
CXXFLAGS := +O2
|
||||
else
|
||||
CXXFLAGS := -g
|
||||
FCFLAGS := -g
|
||||
endif
|
||||
CXXFLAGS += +DAportable
|
||||
CPPFLAGS += -I/usr
|
||||
ifdef G4MAKESHLIB
|
||||
CXXFLAGS += +Z
|
||||
endif
|
||||
G4_HAVE_BOOL := yes
|
||||
FC := f77
|
||||
FCFLAGS += +E6 +ppu
|
||||
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
|
||||
XMLIBS := -L/usr/lib/Motif1.2_R6 -lXm
|
||||
XAWFLAGS := -I/usr/contrib/X11R6/include -I/usr/contrib/X11R6/include/X11
|
||||
XAWLIBS := -L/usr/contrib/X11R6/lib -lXaw
|
||||
ifndef OGLFLAGS
|
||||
OGLFLAGS := -I$(OGLHOME)/include
|
||||
endif
|
||||
ifndef OGLLIBS
|
||||
OGLLIBS := -L$(OGLHOME)/lib -lGLU -lGL
|
||||
OGLLIBS += -L/opt/graphics/common/lib -lXwindow -lhpgfx -lXhp11 -ldld
|
||||
endif
|
||||
endif
|
||||
|
||||
# -------- SGI ---------
|
||||
#
|
||||
ifeq ($(G4SYSTEM),SGI-CC)
|
||||
CXX := CC
|
||||
ifdef G4OPTIMISE
|
||||
CXXFLAGS := -O -ptused
|
||||
else
|
||||
CXXFLAGS := -g -ptused
|
||||
FCFLAGS := -g
|
||||
endif
|
||||
FC := f77
|
||||
FCLIBS := -lftn
|
||||
SHEXT := so
|
||||
X11FLAGS := -I/usr/include/X11/extensions -I/usr/include/X11
|
||||
X11LIBS := -L/usr/lib -lXmu -lXt -lXext -lX11
|
||||
XMLIBS := -L/usr/lib -lXm
|
||||
ifndef OGLFLAGS
|
||||
OGLFLAGS :=
|
||||
endif
|
||||
ifndef OGLLIBS
|
||||
OGLLIBS := -L/usr/lib -lGLU -lGL
|
||||
endif
|
||||
CPPFLAGS += -DSOCKET_IRIX_SOLARIS
|
||||
endif
|
||||
|
||||
# -------- DEC ---------
|
||||
#
|
||||
ifeq ($(G4SYSTEM),DEC-cxx)
|
||||
CXX := cxx
|
||||
ifdef G4OPTIMISE
|
||||
CXXFLAGS := -O
|
||||
else
|
||||
CXXFLAGS := -gall
|
||||
FCFLAGS := -g
|
||||
endif
|
||||
CFRONT_G4TEMPLATE_REPOSITORY := true
|
||||
G4_HAVE_BOOL := yes
|
||||
LDFLAGS += -taso
|
||||
CXXFLAGS += -ieee
|
||||
FC := f77
|
||||
FCLIBS := -lUfor -lfor -lFutil -lots
|
||||
X11FLAGS := -I/usr/include/X11/extensions -I/usr/include/X11
|
||||
ifndef OGLFLAGS
|
||||
OGLFLAGS := -I$(OGLHOME)/include
|
||||
# OGLFLAGS := -I/usr/include -I/usr/local/include
|
||||
endif
|
||||
ifndef OGLLIBS
|
||||
OGLLIBS := -L$(OGLHOME)/lib -lGLU -lGL
|
||||
# OGLLIBS := -lMesaGLU -lMesaGL
|
||||
endif
|
||||
endif
|
||||
|
||||
# ------ GNU/LINUX ------
|
||||
#
|
||||
ifeq ($(G4SYSTEM),Linux-g++)
|
||||
CXX := g++
|
||||
GNU_GCC = 1
|
||||
CXXFLAGS := -pipe -fno-for-scope -DGNU_GCC
|
||||
ifdef G4OPTIMISE
|
||||
CXXFLAGS += -O
|
||||
else
|
||||
CXXFLAGS += -g
|
||||
FCFLAGS := -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
|
||||
XMFLAGS := -I/usr/X11R6/include
|
||||
XMLIBS := -lXm -lXpm
|
||||
ifndef OGLFLAGS
|
||||
OGLFLAGS := -I$(OGLHOME)/include
|
||||
endif
|
||||
ifndef OGLLIBS
|
||||
OGLLIBS := -L$(OGLHOME)/lib -lGLU -lGL
|
||||
endif
|
||||
OIVFLAGS += -I$(OIHOME)/include
|
||||
endif
|
||||
|
||||
# ------ WIN32/VC/NICE ------
|
||||
#
|
||||
ifeq ($(G4SYSTEM),WIN32-VC-NICE)
|
||||
CXX := CL
|
||||
G4_HAVE_BOOL := yes
|
||||
G4_NO_CBRT := yes
|
||||
ifdef G4OPTIMISE
|
||||
CXXFLAGS += -Ox
|
||||
else
|
||||
CXXFLAGS += -Od
|
||||
endif
|
||||
CXXFLAGS += -GX -Zm200 -DWIN32 # -TP
|
||||
#
|
||||
# Should set $INCLUDE environment, if not set as below
|
||||
#
|
||||
# CXXFLAGS += -I'\\srv1_info\v2\vc50pro1\DEVSTUDIO\VC\INCLUDE'
|
||||
|
||||
LDFLAGS += -FORCE
|
||||
|
||||
#
|
||||
# Should set $LIB environment, if not set as below
|
||||
#
|
||||
# $(LIB_PATH)"c:\ProgramFiles\DevStudio\vc\lib" \
|
||||
# $(LIB_PATH)'\\srv1_info\v2\vc50pro1\DEVSTUDIO\VC\LIB' \
|
||||
# $(LIB_PATH)'\\srv1_info\v2\DecFtn5\x86\df\lib'
|
||||
|
||||
AR := LIB
|
||||
ECHO := echo -e
|
||||
FC := f77
|
||||
# FCLIBS := -lf2c
|
||||
ifndef OGLFLAGS
|
||||
OGLFLAGS :=
|
||||
endif
|
||||
ifndef OGLLIBS
|
||||
OGLLIBS := -lGLU -lGL
|
||||
endif
|
||||
endif
|
||||
|
||||
# ------ WIN32/G++/NICE ------
|
||||
#
|
||||
ifeq ($(G4SYSTEM),WIN32-G++-NICE)
|
||||
CXX := g++
|
||||
CXXFLAGS := -fno-for-scope
|
||||
G4_HAVE_BOOL := yes
|
||||
ifdef G4OPTIMISE
|
||||
CXXFLAGS += -O
|
||||
else
|
||||
CXXFLAGS += -g
|
||||
endif
|
||||
CXXFLAGS += -DCYGWIN32
|
||||
ECHO := echo -e
|
||||
FC := g77
|
||||
FCLIBS := -lf2c
|
||||
ifndef OGLFLAGS
|
||||
OGLFLAGS :=
|
||||
endif
|
||||
ifndef OGLLIBS
|
||||
OGLLIBS := -lGLU -lGL
|
||||
endif
|
||||
endif
|
||||
|
||||
# If compiler recognises implicit C++ type bool...
|
||||
ifdef G4_HAVE_BOOL
|
||||
CPPFLAGS += -DG4_HAVE_BOOL
|
||||
endif
|
||||
|
||||
# If there is no cbrt() function...
|
||||
ifdef G4_NO_CBRT
|
||||
CPPFLAGS += -DG4_NO_CBRT
|
||||
endif
|
||||
|
||||
# Standard Template Library (STL) not installed
|
||||
CPPFLAGS += -DRW_NO_STL
|
||||
|
||||
# Verbosity code can be left out (for better performance)
|
||||
# by defining G4_NO_VERBOSE.
|
||||
|
||||
ifndef G4_NO_VERBOSE
|
||||
CPPFLAGS += -DG4VERBOSE
|
||||
endif
|
||||
|
||||
# Trajectory related classes can be left out (for better performance)
|
||||
# by defining G4_NO_STORE_TRAJECTORY.
|
||||
|
||||
ifndef G4_NO_STORE_TRAJECTORY
|
||||
CPPFLAGS += -DG4_STORE_TRAJECTORY
|
||||
endif
|
||||
|
||||
#
|
||||
# Enable/disable G4cout/G4cerr
|
||||
#
|
||||
|
||||
# Set G4STREAM for all platforms.
|
||||
|
||||
G4STREAM = 1
|
||||
|
||||
# Set G4STREAM_STREAMBUF_IMPLEMENTATION for selected platforms.
|
||||
|
||||
ifeq ($(findstring AIX,$(G4SYSTEM)),AIX)
|
||||
G4STREAM_STREAMBUF_IMPLEMENTATION = 1
|
||||
endif
|
||||
|
||||
ifeq ($(findstring WIN32,$(G4SYSTEM)),WIN32)
|
||||
G4STREAM_STREAMBUF_IMPLEMENTATION = 1
|
||||
endif
|
||||
|
||||
ifdef G4STREAM
|
||||
CPPFLAGS += -DG4STREAM
|
||||
endif
|
||||
|
||||
ifdef G4STREAM_STREAMBUF_IMPLEMENTATION
|
||||
CPPFLAGS += -DG4STREAM_STREAMBUF_IMPLEMENTATION
|
||||
endif
|
||||
|
||||
#
|
||||
# Template setup - repositories, special options etc
|
||||
#
|
||||
ifdef CFRONT_G4TEMPLATE_REPOSITORY
|
||||
ifeq ($(findstring DEC,$(G4SYSTEM)),DEC)
|
||||
ifdef G4EXEC_BUILD
|
||||
CXXTEMPLATE_FLAGS := -ptr $(G4TREP)/exec -ptr $(G4TREP)
|
||||
else
|
||||
CXXTEMPLATE_FLAGS := -ptr $(G4TREP)
|
||||
endif
|
||||
else
|
||||
ifdef G4EXEC_BUILD
|
||||
CXXTEMPLATE_FLAGS := -ptr$(G4TREP)/exec -ptr$(G4TREP)
|
||||
else
|
||||
CXXTEMPLATE_FLAGS := -ptr$(G4TREP)
|
||||
endif
|
||||
endif
|
||||
CXXFLAGS += $(CXXTEMPLATE_FLAGS)
|
||||
CFRONT := true
|
||||
endif
|
||||
ifdef CFRONT
|
||||
G4TEMPLATE_REPOSITORY_PARENT := $(shell echo $(G4TREP) | sed 's!/[^/][^/]*/*$$!!' )
|
||||
G4DUMMY_VARIABLE:=$(shell [ ! -d $(G4TEMPLATE_REPOSITORY_PARENT) ] && mkdir -p $(G4TEMPLATE_REPOSITORY_PARENT) )
|
||||
G4DUMMY_VARIABLE:=$(shell [ ! -d $(G4TREP) ] && mkdir -p $(G4TREP) )
|
||||
G4DUMMY_VARIABLE:=$(shell [ ! -d $(G4TREP)/exec ] &&mkdir -p $(G4TREP)/exec )
|
||||
endif
|
||||
|
||||
@@ -0,0 +1,222 @@
|
||||
# $Id: binmake.gmk,v 2.22 1998/12/01 22:59:47 gcosmo Exp $
|
||||
# ----------------------------------------------------------
|
||||
# Script defining rules and paths for making binaries.
|
||||
# Gabriele Cosmo, 25/06/1998.
|
||||
# ----------------------------------------------------------
|
||||
|
||||
ifndef LDFLAGS
|
||||
include $(G4INSTALL)/config/architecture.gmk
|
||||
endif
|
||||
|
||||
G4LIBDIR := $(G4LIB)/$(G4SYSTEM)
|
||||
|
||||
include $(G4INSTALL)/config/G4UI_USE.gmk
|
||||
include $(G4INSTALL)/config/G4VIS_USE.gmk
|
||||
include $(G4INSTALL)/config/interactivity.gmk
|
||||
|
||||
ifndef INCFLAGS
|
||||
INCFLAGS := \
|
||||
-I$(G4BASE)/global/management/include \
|
||||
-I$(G4BASE)/global/HEPRandom/include \
|
||||
-I$(G4BASE)/global/HEPGeometry/include \
|
||||
-I$(G4BASE)/run/include \
|
||||
-I$(G4BASE)/materials/include \
|
||||
-I$(G4BASE)/particles/management/include \
|
||||
-I$(G4BASE)/particles/bosons/include \
|
||||
-I$(G4BASE)/particles/leptons/include \
|
||||
-I$(G4BASE)/particles/hadrons/barions/include \
|
||||
-I$(G4BASE)/particles/hadrons/ions/include \
|
||||
-I$(G4BASE)/particles/hadrons/mesons/include \
|
||||
-I$(G4BASE)/processes/management/include \
|
||||
-I$(G4BASE)/processes/general/include \
|
||||
-I$(G4BASE)/processes/decay/include \
|
||||
-I$(G4BASE)/processes/optical/include \
|
||||
-I$(G4BASE)/processes/transportation/include \
|
||||
-I$(G4BASE)/processes/parameterisation/include \
|
||||
-I$(G4BASE)/processes/electromagnetic/standard/include \
|
||||
-I$(G4BASE)/processes/electromagnetic/muons/include \
|
||||
-I$(G4BASE)/processes/electromagnetic/utils/include \
|
||||
-I$(G4BASE)/processes/electromagnetic/xrays/include \
|
||||
-I$(G4BASE)/processes/hadronic/management/include \
|
||||
-I$(G4BASE)/processes/hadronic/processes/include \
|
||||
-I$(G4BASE)/processes/hadronic/util/include \
|
||||
-I$(G4BASE)/processes/hadronic/cross_sections/include \
|
||||
-I$(G4BASE)/processes/hadronic/models/generator/de_excitation/include \
|
||||
-I$(G4BASE)/processes/hadronic/models/generator/diffractive_string/include \
|
||||
-I$(G4BASE)/processes/hadronic/models/generator/high_energy/include \
|
||||
-I$(G4BASE)/processes/hadronic/models/generator/kinetic_model/include \
|
||||
-I$(G4BASE)/processes/hadronic/models/generator/management/include \
|
||||
-I$(G4BASE)/processes/hadronic/models/generator/pre_equilibrium/include \
|
||||
-I$(G4BASE)/processes/hadronic/models/generator/quark_gluon_string/include \
|
||||
-I$(G4BASE)/processes/hadronic/models/generator/string_common/include \
|
||||
-I$(G4BASE)/processes/hadronic/models/generator/string_fragmentation/include \
|
||||
-I$(G4BASE)/processes/hadronic/models/generator/util/include \
|
||||
-I$(G4BASE)/processes/hadronic/models/high_energy/include \
|
||||
-I$(G4BASE)/processes/hadronic/models/low_energy/include \
|
||||
-I$(G4BASE)/processes/hadronic/models/neutron_hp/include \
|
||||
-I$(G4BASE)/processes/hadronic/stopping/include \
|
||||
-I$(G4BASE)/geometry/management/include \
|
||||
-I$(G4BASE)/geometry/solids/CSG/include \
|
||||
-I$(G4BASE)/geometry/solids/BREPS/include \
|
||||
-I$(G4BASE)/geometry/solids/STEP/include \
|
||||
-I$(G4BASE)/geometry/solids/STEPinterface/include \
|
||||
-I$(G4BASE)/geometry/volumes/include \
|
||||
-I$(G4BASE)/geometry/magneticfield/include \
|
||||
-I$(G4BASE)/track/include \
|
||||
-I$(G4BASE)/tracking/include \
|
||||
-I$(G4BASE)/digits+hits/detector/include \
|
||||
-I$(G4BASE)/digits+hits/hits/include \
|
||||
-I$(G4BASE)/digits+hits/digits/include \
|
||||
-I$(G4BASE)/readout/include \
|
||||
-I$(G4BASE)/event/include \
|
||||
-I$(G4BASE)/graphics_reps/include \
|
||||
-I$(G4BASE)/intercoms/include
|
||||
endif
|
||||
|
||||
ifdef G4ODBMS
|
||||
INCFLAGS += \
|
||||
-I$(G4BASE)/persistency/management/include \
|
||||
-I$(G4BASE)/persistency/events/include \
|
||||
-I$(G4BASE)/persistency/digits+hits/hits/include \
|
||||
-I$(G4BASE)/persistency/geometry/management/include \
|
||||
-I$(G4BASE)/persistency/geometry/volumes/include \
|
||||
-I$(G4BASE)/persistency/geometry/solids/CSG/include \
|
||||
-I$(G4TMP)/$(G4SYSTEM)/G4pmanagement \
|
||||
-I$(G4TMP)/$(G4SYSTEM)/G4pevents \
|
||||
-I$(G4TMP)/$(G4SYSTEM)/G4phits \
|
||||
-I$(G4TMP)/$(G4SYSTEM)/G4pgeomn \
|
||||
-I$(G4TMP)/$(G4SYSTEM)/G4pvol \
|
||||
-I$(G4TMP)/$(G4SYSTEM)/G4pcsg \
|
||||
-I$(OBJY_DIR)/include \
|
||||
-I$(HEP_ODBMS_DIR)/include \
|
||||
-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
|
||||
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
|
||||
|
||||
# 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))
|
||||
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)
|
||||
else
|
||||
@echo Linking $(G4TARGET) ...
|
||||
@$(CXX) $(CXXFLAGS) $(CPPFLAGS) \
|
||||
-o $(G4BINDIR)/$(G4TARGET) $(objects) $(LDFLAGS) $(LDLIBS)
|
||||
endif
|
||||
|
||||
# Touch the versioning file
|
||||
ifdef G4EXLIB
|
||||
$(G4TMPDIR)/exe/obj.last: lib $(objects)
|
||||
else
|
||||
$(G4TMPDIR)/exe/obj.last: $(objects)
|
||||
endif
|
||||
@touch $@
|
||||
|
||||
# Make the $(G4TARGET).o file.
|
||||
$(G4TMPDIR)/exe/$(G4TARGET).o : $(G4TARGET).cc
|
||||
ifdef CPPVERBOSE
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(APPFLAGS) \
|
||||
-c $(OUT_OBJ)$(G4TMPDIR)/exe/$(G4TARGET).o $(G4TARGET).cc
|
||||
else
|
||||
@echo Compiling $(G4TARGET).cc ...
|
||||
@$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(APPFLAGS) \
|
||||
-c $(OUT_OBJ)$(G4TMPDIR)/exe/$(G4TARGET).o $(G4TARGET).cc
|
||||
endif
|
||||
|
||||
# Make the $(G4TARGET).d file and include it.
|
||||
$(G4TMPDIR)/exe/$(G4TARGET).d: $(G4TARGET).cc
|
||||
@if [ ! -d $(G4TMP)/$(G4SYSTEM) ] ; then mkdir $(G4TMP)/$(G4SYSTEM) ;fi
|
||||
@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/ ; \
|
||||
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:
|
||||
@echo Cleaning up ...
|
||||
@rm -f ./core
|
||||
@rm -rf $(G4TMPDIR)
|
||||
@rm -f $(G4LIBDIR)/lib$(G4TARGET).a
|
||||
@rm -f $(G4BINDIR)/$(G4TARGET)
|
||||
ifdef CFRONT
|
||||
@rm -rf $(G4TREP)/exec
|
||||
endif
|
||||
|
||||
clean_bin:
|
||||
@echo Removing application $(G4TARGET) ...
|
||||
@rm -f ./core
|
||||
@rm -f $(G4BINDIR)/$(G4TARGET)
|
||||
@@ -0,0 +1,143 @@
|
||||
# $Id: common.gmk,v 2.7 1998/07/29 00:53:08 gcosmo Exp $
|
||||
# ----------------------------------------------------------------
|
||||
# Common part of GNUmakefile for libraries. John Allison, 5/7/95.
|
||||
# ----------------------------------------------------------------
|
||||
# Libraries are created according to G4SYSTEM. G.Cosmo, 11/6/96.
|
||||
# Introduced G4LIBDIR and G4TMPDIR. G.Cosmo, 23/6/98.
|
||||
|
||||
ifndef G4LIBDIR
|
||||
G4LIBDIR := $(G4LIB)/$(G4SYSTEM)
|
||||
endif
|
||||
G4TMPDIR := $(G4TMP)/$(G4SYSTEM)/$(name)
|
||||
|
||||
sources := $(wildcard src/*.cc)
|
||||
schema_ddl := $(wildcard include/*.ddl)
|
||||
schema_hh := $(patsubst include/%.ddl,$(G4TMPDIR)/%.hh,$(schema_ddl))
|
||||
objects := $(patsubst src/%.cc,$(G4TMPDIR)/%.o,$(sources))
|
||||
dependencies := $(patsubst src/%.cc,$(G4TMPDIR)/%.d,$(sources))
|
||||
|
||||
# output of ooddlx in G4TMPDIR (.hh, _ref.hh, _ddl.cc)
|
||||
#
|
||||
temporaries := $(patsubst include/%.ddl,$(G4TMPDIR)/%.hh,$(schema_ddl))
|
||||
|
||||
# output of ooddlx in the current directory (if the process does not finish)
|
||||
#
|
||||
temporaries2 := $(patsubst include/%.ddl,%.hh,$(schema_ddl))
|
||||
|
||||
ifdef G4ODBMS
|
||||
temporaries += $(patsubst include/%.ddl,$(G4TMPDIR)/%_ddl.cc,$(schema_ddl)) \
|
||||
$(patsubst include/%.ddl,$(G4TMPDIR)/%_ref.hh,$(schema_ddl))
|
||||
temporaries2 += $(patsubst include/%.ddl,%_ddl.cc,$(schema_ddl)) \
|
||||
$(patsubst include/%.ddl,%_ref.hh,$(schema_ddl))
|
||||
objects += $(patsubst include/%.ddl,$(G4TMPDIR)/%_ddl.o,$(schema_ddl))
|
||||
endif
|
||||
|
||||
ifneq ($(G4MAKESHLIB),)
|
||||
# Make shared library.
|
||||
$(G4LIBDIR)/lib$(name).$(SHEXT): $(G4LIBDIR)/lib$(name).a
|
||||
@cp $(objects) $(G4LIBDIR)/.
|
||||
sh $(G4MAKESHLIB) $(G4LIBDIR) $(name)
|
||||
$(RM) $(G4LIBDIR)/*.o
|
||||
endif
|
||||
|
||||
# Make library.
|
||||
$(G4LIBDIR)/lib$(name).a: $(G4TMPDIR)/obj.last
|
||||
@if [ ! -d $(G4LIBDIR) ] ; then mkdir $(G4LIBDIR) ;fi
|
||||
@echo Creating/replacing object files in $(G4LIBDIR)/lib$(name).a
|
||||
@rm -f $(G4LIBDIR)/lib$(name).a
|
||||
@$(AR) $(OUT_LIB)$(G4LIBDIR)/lib$(name).a $(G4TMPDIR)/*.o
|
||||
@if [ -f /usr/bin/ranlib -o -f /bin/ranlib ] ; then ranlib $(G4LIBDIR)/lib$(name).a ;fi
|
||||
|
||||
# Touch the versioning file
|
||||
$(G4TMPDIR)/obj.last: $(objects)
|
||||
@touch $@
|
||||
|
||||
# Make the .o files.
|
||||
ifdef G4ODBMS
|
||||
$(G4TMPDIR)/%.o: src/%.cc $(schema_hh)
|
||||
else
|
||||
$(G4TMPDIR)/%.o: src/%.cc
|
||||
endif
|
||||
ifdef CPPVERBOSE
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(OUT_OBJ)$(G4TMPDIR)/$(*F).o src/$*.cc
|
||||
else
|
||||
@echo Compiling $*.cc ...
|
||||
@$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(OUT_OBJ)$(G4TMPDIR)/$(*F).o src/$*.cc
|
||||
endif
|
||||
ifdef G4ODBMS
|
||||
$(G4TMPDIR)/%.o: $(G4TMPDIR)/%.cc
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $(G4TMPDIR)/$(*F).o $(G4TMPDIR)/$*.cc
|
||||
endif
|
||||
# Make the temporary files.
|
||||
.PRECIOUS: $(G4TMPDIR)/%_ddl.cc ddl/%.hh $(G4TMPDIR)/%_ref.hh
|
||||
|
||||
ifdef G4ODBMS
|
||||
$(G4TMPDIR)/%_ddl.cc $(G4TMPDIR)/%.hh $(G4TMPDIR)/%_ref.hh: include/%.ddl
|
||||
@if [ ! -d $(G4TMP)/$(G4SYSTEM) ] ; then mkdir $(G4TMP)/$(G4SYSTEM) ;fi
|
||||
@if [ ! -d $(G4TMPDIR) ] ; then mkdir $(G4TMPDIR) ;fi
|
||||
ooddlx -notitle -header_suffix .hh -ref_suffix _ref.hh -c++_suffix _ddl.cc \
|
||||
-DRW_NO_CONST_OVERLOAD -DRW_NO_STL -DTEMPLATEP_HIDES_FNCD \
|
||||
$(CPPFLAGS) $< $(G4EXAMPLE_BOOT)
|
||||
mv -f $*.hh $(G4TMPDIR)/
|
||||
mv -f $*_ref.hh $(G4TMPDIR)/
|
||||
mv -f $*_ddl.cc $(G4TMPDIR)/
|
||||
else
|
||||
$(G4TMPDIR)/%.hh: include/%.ddl
|
||||
@if [ ! -d $(G4TMP)/$(G4SYSTEM) ] ; then mkdir $(G4TMP)/$(G4SYSTEM) ;fi
|
||||
@if [ ! -d $(G4TMPDIR) ] ; then mkdir $(G4TMPDIR) ;fi
|
||||
ln -s -f ../$< $(G4TMPDIR)/$*.hh
|
||||
endif
|
||||
|
||||
# Make the .d file(s) and include it(them).
|
||||
# g++ -MM is good at this, except it forgets the subdirectory
|
||||
# (hence the use of $G4TMP/).
|
||||
|
||||
ifdef G4ODBMS
|
||||
$(G4TMPDIR)/%.d: src/%.cc $(schema_hh)
|
||||
else
|
||||
$(G4TMPDIR)/%.d: src/%.cc
|
||||
endif
|
||||
@if [ ! -d $(G4TMP)/$(G4SYSTEM) ] ; then mkdir $(G4TMP)/$(G4SYSTEM) ;fi
|
||||
@if [ ! -d $(G4TMPDIR) ] ; then mkdir $(G4TMPDIR) ;fi
|
||||
@echo Making dependency for file $< ...
|
||||
@($(ECHO) $(G4TMPDIR)/\\c ; \
|
||||
g++ -MM $(RWINCGPP) $(CPPFLAGS) $< ) | sed 's!$(G4TMPDIR)/$*.o!& $@!' >$@
|
||||
ifdef G4ODBMS
|
||||
ifdef G4ODBMS_DEPEND
|
||||
-include $(dependencies)
|
||||
endif
|
||||
else
|
||||
-include $(dependencies)
|
||||
endif
|
||||
|
||||
# .PHONY targets are executed regardless of time-stamp of any file of
|
||||
# same name.
|
||||
.PHONY: all obj lib clean clean_libs
|
||||
|
||||
obj: $(G4TMPDIR)/obj.last
|
||||
|
||||
ifdef G4ODBMS
|
||||
headers: $(schema_hh)
|
||||
|
||||
d_files: $(dependencies)
|
||||
|
||||
$(schema_hh): $(schema_ddl)
|
||||
endif
|
||||
|
||||
ifneq ($(G4MAKESHLIB),)
|
||||
lib: $(G4LIBDIR)/lib$(name).$(SHEXT)
|
||||
else
|
||||
lib: $(G4LIBDIR)/lib$(name).a
|
||||
endif
|
||||
|
||||
ifndef G4EXLIB
|
||||
clean:
|
||||
@echo Cleaning up ...
|
||||
@rm -f $(G4LIBDIR)/lib$(name).a
|
||||
@rm -rf $(G4TMPDIR)
|
||||
endif
|
||||
|
||||
clean_libs:
|
||||
@if [ -f $(G4LIBDIR)/lib$(name).a ] ; then \
|
||||
$(ECHO) Removing library lib$(name).a ... ; \
|
||||
$(RM) -f $(G4LIBDIR)/lib$(name).a ; fi
|
||||
Executable
+98
@@ -0,0 +1,98 @@
|
||||
#!/usr/local/bin/perl
|
||||
|
||||
sub usage {
|
||||
print STDERR "This script takes a STEP file (from STDIN)\n";
|
||||
print STDERR "and writes it to STDOUT with the data section\n";
|
||||
print STDERR "sorted by ID.\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
sub error {
|
||||
print STDERR $_[0]."\n";
|
||||
exit 2;
|
||||
}
|
||||
|
||||
if ($#ARGV >= 0) {
|
||||
&usage();
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
|
||||
$entry= "";
|
||||
while (<STDIN>) {
|
||||
while ($_ ne "") {
|
||||
|
||||
if (/[;']/) { #']){
|
||||
|
||||
$entry.= $`.$&;
|
||||
$_= $';
|
||||
if ($& eq ";") {
|
||||
|
||||
# end of entry
|
||||
$lof= $_;
|
||||
&processEntry($entry);
|
||||
$entry= "";
|
||||
$_= $lof;
|
||||
|
||||
} else {
|
||||
|
||||
# start of string
|
||||
/[']/ || &error("String does not end within the line!"); #'];
|
||||
$entry.= $`.$&;
|
||||
$_= $';
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
$entry.= $_;
|
||||
$_= "";
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/^[ \t\n]*$/m || &error("File does not end with ';' !");
|
||||
print "$_\n";
|
||||
exit 0;
|
||||
|
||||
##########################################################################
|
||||
|
||||
sub processEntry {
|
||||
local($e)= @_;
|
||||
|
||||
if (!$inData) {
|
||||
|
||||
print $e;
|
||||
if ($e =~ /^(\s|\n)*DATA(\s|\n)*;$/m) {
|
||||
$inData= 1;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if ($e =~ /^(\s|\n)*\#([0-9]+)\=/m) {
|
||||
|
||||
$id= $2;
|
||||
$entries[$id]= $e;
|
||||
|
||||
} else {
|
||||
|
||||
$e =~ /^(\s|\n)*ENDSEC(\s|\n)*;$/m ||
|
||||
&error("Data section does not end with ENDSEC;");
|
||||
$inData= 0;
|
||||
for ($id=0; $id<=$#entries; $id++) {
|
||||
$en= $entries[$id];
|
||||
if ($en ne "") {
|
||||
print $en;
|
||||
}
|
||||
}
|
||||
print $e;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
##########################################################################
|
||||
##########################################################################
|
||||
|
||||
|
||||
Executable
+41
@@ -0,0 +1,41 @@
|
||||
#!/usr/local/bin/perl
|
||||
|
||||
$filename = $ARGV[0];
|
||||
open(INFILE, $filename) || die "\nSTEP file ".$filename." not found.";
|
||||
print "Opening file ".$filename;
|
||||
@filebuf = <INFILE>;
|
||||
close(INFILE);
|
||||
|
||||
$g4 = "G4";
|
||||
$outputfile = $g4 . $filename;
|
||||
open(OUTFILE, ">$outputfile");
|
||||
print "\nModifying STEP file for NIST toolkit...";
|
||||
|
||||
foreach (@filebuf)
|
||||
{
|
||||
if(/.*VERTEX\_POINT.*/)
|
||||
{
|
||||
s/VERTEX\_POINT\(\'\'\,/VERTEX\_POINT\(\'\'\,\'\'\,/g ;
|
||||
}
|
||||
elsif(/.*EDGE\_LOOP.*/)
|
||||
{
|
||||
s/EDGE\_LOOP\(\'\'\,/EDGE\_LOOP\(\'\'\,\'\'\,/g;
|
||||
}
|
||||
elsif(/.*ADVANCED\_FACE.*/)
|
||||
{
|
||||
($a,$b,$c) = split('\)',$&);
|
||||
s//$a\)\,\'\' $b\)$c\n/;
|
||||
}
|
||||
elsif(/.*EDGE\_CURVE.*/)
|
||||
{
|
||||
($a,$b,$c,$d,$e) = split(",",$&);
|
||||
s//$a\, $b\,$c\,\'\'\,$d\,$e\n/;
|
||||
}
|
||||
|
||||
print OUTFILE;
|
||||
}
|
||||
|
||||
close(OUTFILE);
|
||||
print "\nOutput written to ".$outputfile."\n";
|
||||
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
# $Id: globlib.gmk,v 2.15 1998/12/11 00:40:21 gcosmo Exp $
|
||||
# --------------------------------------------------------------
|
||||
# Script for compound libraries. Gabriele Cosmo, 25/6/98.
|
||||
# --------------------------------------------------------------
|
||||
|
||||
ifndef G4INSTALL
|
||||
G4INSTALL = ..
|
||||
endif
|
||||
|
||||
include $(G4INSTALL)/config/architecture.gmk
|
||||
|
||||
G4LIBDIR = $(G4LIB)/$(G4SYSTEM)
|
||||
|
||||
.PHONY : all glob global objs clean clean_libs wipe_libs
|
||||
|
||||
all:
|
||||
ifndef G4ODBMS
|
||||
@for dir in $(SUBDIRS); do (cd $$dir; $(MAKE)); done
|
||||
else
|
||||
@for dir in $(SUBDIRS); do (cd $$dir; $(MAKE) headers); done
|
||||
@for dir in $(SUBDIRS); do (cd $$dir; $(MAKE) d_files); done
|
||||
@for dir in $(SUBDIRS); do (cd $$dir; G4ODBMS_DEPEND=1; export G4ODBMS_DEPEND; $(MAKE)); done
|
||||
endif
|
||||
|
||||
ifndef G4ODBMS
|
||||
glob global: objs wipe_libs $(G4LIBDIR)/lib$(name).a
|
||||
else
|
||||
glob global: all $(G4LIBDIR)/lib$(name).a $(G4SCHEMA_DIR)/G4SCHEMA.FDDB
|
||||
endif
|
||||
|
||||
$(G4LIBDIR)/lib$(name).a: \
|
||||
$(foreach dir,$(SUBLIBS),$(G4TMP)/$(G4SYSTEM)/$(dir)/obj.last)
|
||||
@if [ ! -d $(G4LIBDIR) ] ; then mkdir $(G4LIBDIR) ; fi
|
||||
@echo Merging object files in $(G4LIBDIR)/lib$(name).a
|
||||
@$(RM) $(G4LIBDIR)/lib$(name).a
|
||||
#
|
||||
#
|
||||
#
|
||||
@if [ X$(G4SYSTEM) = XWIN32-VC-NICE ] ; i=NO; \
|
||||
then \
|
||||
(( for lib in $(SUBLIBS); \
|
||||
do ( if [ $$i = NO ]; \
|
||||
then \
|
||||
$(AR) $(OUT_LIB)$(G4LIBDIR)/lib$(name).lib \
|
||||
$(G4TMP)/$(G4SYSTEM)/$$lib/*.o ; \
|
||||
else \
|
||||
$(AR) $(G4LIBDIR)/lib$(name).lib $(G4TMP)/$(G4SYSTEM)/$$lib/*.o; \
|
||||
fi ); \
|
||||
i=YES; \
|
||||
done ) ; \
|
||||
mv $(G4LIBDIR)/lib$(name).lib $(G4LIBDIR)/lib$(name).a); \
|
||||
else \
|
||||
(for lib in $(SUBLIBS); \
|
||||
do ($(AR) $(OUT_LIB)$(G4LIBDIR)/lib$(name).a \
|
||||
$(G4TMP)/$(G4SYSTEM)/$$lib/*.o); \
|
||||
done);\
|
||||
fi
|
||||
#
|
||||
#
|
||||
#
|
||||
@if [ -f /usr/bin/ranlib -o -f /bin/ranlib ] ; then \
|
||||
ranlib $(G4LIBDIR)/lib$(name).a ; fi
|
||||
|
||||
##
|
||||
## make shared libraries
|
||||
##
|
||||
ifneq ($(G4MAKESHLIB),)
|
||||
@for lib in $(SUBLIBS); do (cp $(G4TMP)/$(G4SYSTEM)/$$lib/*.o $(G4LIBDIR)/.); done
|
||||
@sh $(G4MAKESHLIB) $(G4LIBDIR) $(name)
|
||||
$(RM) $(G4LIBDIR)/*.o
|
||||
endif
|
||||
|
||||
ifdef G4ODBMS
|
||||
headers:
|
||||
@for dir in $(SUBDIRS); do (cd $$dir; $(MAKE) headers); done
|
||||
|
||||
d_files:
|
||||
@for dir in $(SUBDIRS); do (cd $$dir; $(MAKE) d_files); done
|
||||
|
||||
$(G4SCHEMA_DIR)/G4SCHEMA.FDDB: $(G4EXAMPLE_BOOT_DIR)/G4EXAMPLE.FDDB
|
||||
ifdef G4SCHEMA_DIR
|
||||
@rm -f $(G4SCHEMA_DIR)/G4SCHEMA
|
||||
@rm -f $(G4SCHEMA_DIR)/G4SCHEMA.FDDB
|
||||
@echo Copying schema file to $(G4SCHEMA_DIR) for FDID $(G4SCHEMA_FDID)
|
||||
@$(HEP_ODBMS_DIR)/etc/getdb $(G4EXAMPLE_BOOT) \
|
||||
$(G4SCHEMA_DIR)/G4SCHEMA $(G4SCHEMA_FDID)
|
||||
endif
|
||||
endif
|
||||
|
||||
objs:
|
||||
@for dir in $(SUBDIRS); \
|
||||
do (cd $$dir; $(MAKE) -q obj && ok=yes; \
|
||||
if [ $$ok ]; \
|
||||
then echo Nothing to be done for lib$(name).a in $$dir/.; \
|
||||
else $(MAKE) clean_libs; $(MAKE) obj; \
|
||||
fi; ) \
|
||||
done
|
||||
|
||||
wipe_libs:
|
||||
@for lib in $(SUBLIBS); do (rm -f $(G4LIBDIR)/lib$$lib.a); done
|
||||
|
||||
clean:
|
||||
@echo Cleaning up ...
|
||||
@for lib in $(SUBLIBS); do (rm -rf $(G4TMP)/$(G4SYSTEM)/$$lib; rm -f $(G4LIBDIR)/lib$$lib.a); done
|
||||
@rm -f $(G4LIBDIR)/lib$(name).a
|
||||
|
||||
clean_libs:
|
||||
@echo Removing lib$(name).a and sub-libraries ...
|
||||
@for lib in $(SUBLIBS); do (rm -f $(G4LIBDIR)/lib$$lib.a); done
|
||||
@rm -f $(G4LIBDIR)/lib$(name).a
|
||||
@@ -0,0 +1,120 @@
|
||||
# GNUmakefile for CPPFLAGS, LDFLAGS for interactivy,
|
||||
# ie interfaces and visualization.
|
||||
#
|
||||
# Here we really set the CCPFLAGS, LDFLAGS for X11, Motif,...
|
||||
# according various INC_xxx, LOAD_xxx flags setted in
|
||||
# G4[UI, VIS]_[USE, BUILD].gmk. With this logic the
|
||||
# flags for one product (X11, Motif,...) will appear once
|
||||
# in the compilation/load command line.
|
||||
#
|
||||
# Guy Barrand, 7th July 1998.
|
||||
|
||||
# Other libraries
|
||||
|
||||
########################### OpenGL, Inventor ############
|
||||
|
||||
# Should be before OpenGL.
|
||||
ifdef INC_IV
|
||||
INC_GL = 1
|
||||
CPPFLAGS += $(OIVFLAGS)
|
||||
endif
|
||||
ifdef LOAD_IV
|
||||
LOAD_GL = 1
|
||||
INTYLIBS += $(OIVLIBS)
|
||||
endif
|
||||
|
||||
ifdef INC_GL
|
||||
CPPFLAGS += $(OGLFLAGS)
|
||||
endif
|
||||
ifdef LOAD_GL
|
||||
INTYLIBS += $(OGLLIBS)
|
||||
endif
|
||||
|
||||
########################### OPACS #######################
|
||||
# X11 things must come after.
|
||||
|
||||
ifdef INC_OPACS
|
||||
CPPFLAGS += -I$(COROOT)/include -I$(XXROOT)/include -I$(WOROOT)/include
|
||||
# Let Wo knows Xm (or Xaw) and Xo widget sets
|
||||
ifeq ($(G4_OPACS_WIDGET_SET),Xm)
|
||||
INC_XM = 1
|
||||
CPPFLAGS += -DHAS_XM
|
||||
else
|
||||
INC_XAW = 1
|
||||
CPPFLAGS += -DHAS_XAW
|
||||
endif
|
||||
CPPFLAGS += -DHAS_XO -DHAS_GO -I$(GOROOT)/include -I$(HOROOT)/include -I$(XOROOT)/include
|
||||
endif
|
||||
|
||||
ifdef LOAD_OPACS
|
||||
ifeq ($(G4_OPACS_WIDGET_SET),Xm)
|
||||
INC_XM = 1
|
||||
LOAD_XM = 1
|
||||
INTYLIBS += -L$(WOROOT)/$(OCONFIG) -lWoXm
|
||||
else
|
||||
INC_XAW = 1
|
||||
LOAD_XAW = 1
|
||||
INTYLIBS += -L$(WOROOT)/$(OCONFIG) -lWoXaw
|
||||
endif
|
||||
INTYLIBS += -L$(WOROOT)/$(OCONFIG) -lWo
|
||||
INTYLIBS += -L$(XOROOT)/$(OCONFIG) -lXo
|
||||
INTYLIBS += -L$(GOROOT)/$(OCONFIG) -lGo
|
||||
INTYLIBS += -L$(HOROOT)/$(OCONFIG) -lHo
|
||||
INTYLIBS += -L$(W3OROOT)/$(OCONFIG) -lW3o
|
||||
INTYLIBS += -L$(HTMLOROOT)/$(OCONFIG) -lHTMLo
|
||||
ifndef LOAD_GL
|
||||
INTYLIBS += -L$(GLOROOT)/$(OCONFIG) -lGLXo -lGLUo -lGLo
|
||||
endif
|
||||
INTYLIBS += -L$(XXROOT)/$(OCONFIG) -lXx
|
||||
INTYLIBS += -L$(COROOT)/$(OCONFIG) -lCo
|
||||
endif
|
||||
|
||||
|
||||
########################### Motif, Athena, X11 ###################
|
||||
# Motif raise X11 flags.
|
||||
|
||||
# Should be before X11.
|
||||
ifdef INC_XM
|
||||
INC_X11 = 1
|
||||
CPPFLAGS += $(XMFLAGS)
|
||||
endif
|
||||
ifdef LOAD_XM
|
||||
LOAD_X11 = 1
|
||||
INTYLIBS += $(XMLIBS)
|
||||
endif
|
||||
|
||||
# Should be before X11.
|
||||
ifdef INC_XAW
|
||||
INC_X11 = 1
|
||||
CPPFLAGS += $(XAWFLAGS)
|
||||
endif
|
||||
ifdef LOAD_XAW
|
||||
LOAD_X11 = 1
|
||||
INTYLIBS += $(XAWLIBS)
|
||||
endif
|
||||
|
||||
ifdef INC_X11
|
||||
CPPFLAGS += $(X11FLAGS)
|
||||
endif
|
||||
ifdef LOAD_X11
|
||||
INTYLIBS += $(X11LIBS)
|
||||
endif
|
||||
|
||||
########################### and finally... #######################
|
||||
|
||||
ifdef G4INTY_BUILD_XT
|
||||
CPPFLAGS += -DG4INTY_BUILD_XT
|
||||
endif
|
||||
|
||||
ifdef G4INTY_USE_XT
|
||||
CPPFLAGS += -DG4INTY_USE_XT
|
||||
endif
|
||||
|
||||
ifdef G4INTY_BUILD_WIN32
|
||||
CPPFLAGS += -DG4INTY_BUILD_WIN32
|
||||
endif
|
||||
|
||||
ifdef G4INTY_USE_WIN32
|
||||
CPPFLAGS += -DG4INTY_USE_WIN32
|
||||
endif
|
||||
|
||||
Executable
+113
@@ -0,0 +1,113 @@
|
||||
#!/bin/sh -f
|
||||
############################################
|
||||
#### To build GEANT4 sheared libraries #####
|
||||
############# G.Barrand ####################
|
||||
############################################
|
||||
if test $# -eq 2 ; then
|
||||
g4system=$1
|
||||
name=$2
|
||||
liba=lib$name.a
|
||||
#echo $g4system
|
||||
#echo $name
|
||||
############################################
|
||||
##### build libs ###########################
|
||||
############################################
|
||||
if test -f $g4system/$liba ; then
|
||||
|
||||
if test `uname` = "OSF1" ; then
|
||||
cd $g4system
|
||||
# Need to specify a path, so that at run time loader
|
||||
# is able to find the so lib. This path is put in the
|
||||
# binaries at link time. In principle a relative
|
||||
# path from the binary is ok, but we will have
|
||||
# more than one binary at different places; so
|
||||
# we have to specify an absolute path.
|
||||
rpath=`pwd`
|
||||
#echo $rpath
|
||||
libso=lib$name.so
|
||||
/bin/rm -f $libso
|
||||
/bin/rm -f so_locations
|
||||
ld -expect_unresolved '*' -shared -o $libso -all $liba -rpath $rpath
|
||||
cd ..
|
||||
echo "$libso built."
|
||||
fi
|
||||
|
||||
if test `uname` = "HP-UX" ; then
|
||||
cd $g4system
|
||||
libso=lib$name.sl
|
||||
/bin/rm -f $libso
|
||||
# get .o files
|
||||
objs=`ls *.o`
|
||||
#ld -b -a shared -o $libso $objs
|
||||
# CC does more than ld.
|
||||
CC -b -o $libso $objs
|
||||
cd ..
|
||||
echo "$libso built."
|
||||
fi
|
||||
|
||||
if test `uname` = "IRIX" ; then
|
||||
cd $g4system
|
||||
# For path same remarks as for OSF1.
|
||||
rpath=`pwd`
|
||||
libso=lib$name.so
|
||||
/bin/rm -f $libso
|
||||
/bin/rm -f so_locations
|
||||
#ld -shared -o $libso -all $liba -rpath $rpath
|
||||
# CC does more than ld.
|
||||
CC -Wl,-rpath,$rpath -shared -o $libso -all $liba
|
||||
cd ..
|
||||
echo "$libso built."
|
||||
fi
|
||||
|
||||
if test `uname` = "AIX" ; then
|
||||
# Not yet ready.
|
||||
exit
|
||||
#set -x
|
||||
cd $g4system
|
||||
libso=lib$name'.so'
|
||||
/bin/rm -f lib$name.o
|
||||
/bin/rm -f $libso
|
||||
/bin/rm -f lib$name.exp
|
||||
# Get .o files
|
||||
objs=`ls *.o`
|
||||
# Determine how to invoke nm depending on AIX version
|
||||
AIXVERSION=`uname -v`
|
||||
case ${AIXVERSION}
|
||||
{
|
||||
3*)
|
||||
NM=/usr/ucb/nm
|
||||
;;
|
||||
4*)
|
||||
NM='/usr/bin/nm -B'
|
||||
;;
|
||||
*)
|
||||
echo "Error in g4makeshlib.sh!"
|
||||
exit 1
|
||||
;;
|
||||
}
|
||||
# Build export file (from Mesa mklib.aix).
|
||||
echo "#! lib$name.so " > lib$name.exp
|
||||
echo "noentry" >> lib$name.exp
|
||||
$NM $objs | awk '/ [BD] /{print $3}' | sort | uniq >> lib$name.exp
|
||||
# Below command from Mesa mklib.aix.
|
||||
#cc -o lib$name.o $objs $3 -bE:lib$name.exp -bM:SRE -enoentry
|
||||
# Unnecessary option -enoentry that produces
|
||||
# noentry file that contains exported symbols
|
||||
cc -o lib$name.o $objs $3 -bE:lib$name.exp -bM:SRE
|
||||
if test -f lib$name.o ; then
|
||||
ar r $libso lib$name.o
|
||||
/bin/rm -f lib$name.o
|
||||
else
|
||||
echo "Can't create lib$name.o."
|
||||
fi
|
||||
#cp $libso lib$name.a
|
||||
cd ..
|
||||
echo "$libso treated."
|
||||
fi
|
||||
|
||||
|
||||
fi
|
||||
############################################
|
||||
else
|
||||
echo 'Give name of binaray directory and library'
|
||||
fi
|
||||
@@ -0,0 +1,66 @@
|
||||
$Id: History,v 2.10 1998/12/11 20:26:05 allison Exp $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
|
||||
=========================================================
|
||||
|
||||
Super-Category History file
|
||||
---------------------------
|
||||
|
||||
This file should be used by G4 developers and category coordinators
|
||||
to briefly summarize all major modifications introduced in the code
|
||||
at this level and keep track of all relavant tags.
|
||||
It DOES NOT substitute the CVS log-message one should put at every
|
||||
committal in the CVS repository !
|
||||
|
||||
----------------------------------------------------------
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
envs-00-04-01 11th December 1998 Hajime Yoshida Masayasu Nagamatu
|
||||
- The latest version of GGE, the whole *.java, *.class and example files committed
|
||||
|
||||
10th December Hajime Yoshida
|
||||
- Tcl/Tk GAG warns to the binaries compiled with G4UIterminal session
|
||||
and stops it.
|
||||
|
||||
envs-00-03-04 12th November 1998 John Allison
|
||||
- Tagged (what was envs-00-30-03?).
|
||||
|
||||
12th Nov. 1998 Hajime Yoshida
|
||||
-many new features added to Momo/java/Momo/GGE
|
||||
-minor modification to Momo/GGEmake
|
||||
-addition of Momo/java/Momo/Momo
|
||||
|
||||
envs-00-03-02 14th Sep 1998 Hajime Yoshida
|
||||
- minor updates in GGE
|
||||
envs-00-03-01 13th Sep 1998 Hajime Yoshida
|
||||
-Momo/GGEmake added README and a macro file
|
||||
-Momo/java/Momo/GGE updated.
|
||||
BREPs, sample persistent files etc.
|
||||
envs-00-02-01 3rd Sep 1998 Hajime Yoshida
|
||||
Momo/GGEmake
|
||||
Momo/java/Momo/GGE
|
||||
GGE committed
|
||||
envs-00-01-03 17th Aug 1998 Hajime Yoshida
|
||||
- touched many files in Momo Tcl/Tk and Java
|
||||
|
||||
envs-00-01-02 15th July 1998 John Allison
|
||||
- Removed some files in OPACS for beta01 - see OPACS/History.
|
||||
|
||||
envs-00-01-01 8th July 1998 John Allison
|
||||
- Added XVT (moved from interfaces/xvt_standalone_test).
|
||||
- Forced revision 2.0 on Momo.
|
||||
|
||||
6th July 1998 Satoshi Tanaka
|
||||
- Added Momo (moved from interfaces/standalone_test).
|
||||
|
||||
^^^^^^^^^^^^^^^^^^^^ geant4beta ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
=========================================================================
|
||||
vvvvvvvvvvvvvvvvvvvv geant4alpha vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
|
||||
|
||||
envs-00-05-01 23rd April 1998 Gabriele Cosmo
|
||||
- Added OPACS directory tagged as OPACS-00-05-01.
|
||||
|
||||
envs-00-05-00 19th March 1998 John Allison
|
||||
- First creation of this super-category.
|
||||
@@ -0,0 +1,26 @@
|
||||
#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
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
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
|
||||
@@ -0,0 +1,73 @@
|
||||
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
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#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
|
||||
@@ -0,0 +1,10 @@
|
||||
#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
|
||||
@@ -0,0 +1,10 @@
|
||||
#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
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
# $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
|
||||
@@ -0,0 +1,37 @@
|
||||
# $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
|
||||
@@ -0,0 +1,23 @@
|
||||
$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.
|
||||
@@ -0,0 +1,433 @@
|
||||
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.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $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
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
// 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
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
// 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
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
// 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
|
||||
@@ -0,0 +1,81 @@
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
//------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;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
// 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....
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,449 @@
|
||||
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.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
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.
@@ -0,0 +1,256 @@
|
||||
/*
|
||||
* @(#)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.
Binary file not shown.
@@ -0,0 +1,256 @@
|
||||
/*
|
||||
* @(#)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.
Binary file not shown.
@@ -0,0 +1,618 @@
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,61 @@
|
||||
// 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.
@@ -0,0 +1,66 @@
|
||||
// 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.
@@ -0,0 +1,13 @@
|
||||
// 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.
@@ -0,0 +1,31 @@
|
||||
// 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.
@@ -0,0 +1,416 @@
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
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.
@@ -0,0 +1,131 @@
|
||||
// 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.
@@ -0,0 +1,61 @@
|
||||
// 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.
@@ -0,0 +1,66 @@
|
||||
// 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.
@@ -0,0 +1,13 @@
|
||||
// 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.
@@ -0,0 +1,31 @@
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
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.
@@ -0,0 +1,416 @@
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
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.
Binary file not shown.
@@ -0,0 +1,444 @@
|
||||
/*
|
||||
* 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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* 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();}
|
||||
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,308 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,306 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,463 @@
|
||||
/*
|
||||
* 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
Reference in New Issue
Block a user