#######################################################################
#  MACRO FILE NAME: exN03Vis14.mac                                    #
#                                                                     #
#  AUTHOR(S): Laurent Garnier                                         #
#                                                                     #
#  DATE: July 13, 2007                                                #
#                                                                     #
#  CONTENTS: A basic macro for visualization of detector geometry     #
#                                                                     #
#  USAGE:  % gmake visclean                                           #
#          % $G4BINDIR/exampleN03                                     #
#          Idle> /control/execute visTutor/exN03Vis14.mac             #
#                                                                     #
#  REQUIRED PLATFORMS & SOFTWARES: Unix, X-window, OpenGL,Qt          #
#                                  DAWN (version 3.85 or after)       #
#                                  gv (Ghostview), Tcl/Tk             #
#                                                                     #
#  ENVIRONMENTAL VARIABLES (C-MACROS) FOR INSTALLATION:               #
#  (See geant4/source/visualization/README for details.)              #
#                                                                     #
#    % setenv OGLHOME     ... (e.g. /usr/X11R6)                       #
#    % setenv G4VIS_BUILD_OPENGLQT_DRIVER   1                         # 
#                                                                     #
#  ENVIRONMENTAL VARIABLES (C-MACROS) FOR COMPILATION:                #
#  (See geant4/source/visualization/README for details.)              #
#                                                                     #
#    % setenv G4VIS_USE_OPENGLQT           1                          #
#                                                                     # 
#  ADDITIONAL NOTES:                                                  #
#    The compound command "/vis/open "               #
#    is equivalent to the following set of commands:                  #
#                                                                     #
#      /vis/sceneHandler/create $1                                    #
#      /vis/viewer/create                                             #
#                                                                     #
#    The compound command "/vis/drawVolume "    #
#    is equivalent to the following set of commands:                  #
#                                                                     #
#      /vis/scene/create                                              #
#      /vis/scene/add/volume $1                                       #
#      /vis/sceneHandler/attach                                       #
#                                                                     #
#######################################################################

###########################################
# Visualization of detector geometry 
#  with the OGLSQT (OpenGL Stored QT) driver
###########################################

# Invoke the OGLSQt driver 
/vis/open OGLSQt

# Bird's-eye view of the detector geometry 
#
#  viewpoint  : (theta,phi) = (20*deg, 70*deg), 
#  zoom factor: 0.8 of the full screen size
#
/vis/viewer/reset
/vis/viewer/set/viewpointThetaPhi  20 70
/vis/viewer/zoom               0.8 
/vis/drawVolume

# The following two commands "flush" 
#  the action of the current viewer.
#  They are required for the post-processing drivers 
#  such as DAWNFILE, VRMLFILE, HepRep drivers, etc.
#  For OpenGL drivers, these commands are not required
#  but harmless even if they are described.
/vis/viewer/flush

##########################################################
# Visualization with the DAWNFILE driver
#
#  * Each visualized view is saved to a file "g4_XX.eps"  
#    with the "vectorized" PostScript format.
#
#  * Set an environmental variable if you wish to 
#    skip DAWN GUI:
#     % setenv G4DAWNFILE_VIEWER "dawn -d"
##########################################################

# Invoke the DAWNFILE driver 
/vis/open DAWNFILE

# Bird's-eye view of a detector component (Absorber)
#  viewpoint  : (theta,phi) = (35*deg, 35*deg), 
#  zoom factor: 1.1 of the full screen size
#  coordinate axes:
#     x-axis:red,  y-axis:green,  z-axis:blue
#     origin: (0,0,0),  length: 500
#  Scale: length = 10 cm, Orientation = z, color = red, 
#         placing_algorithm = manual, 
#         center = (-2.5 cm , -5 cm, 0 cm)
#
/vis/viewer/reset
/vis/viewer/zoom               1.1
/vis/viewer/set/viewpointThetaPhi  35 35
/vis/drawVolume           Absorber 
/vis/scene/add/axes      0 0 0 500 mm
/vis/scene/add/text      0 0 0 mm  40 -100 -140   Absorber 
/vis/scene/add/scale     10 cm z 1 0 0 manual -2.5 -5 0  cm

# "Flush the action of all the existing viewers.
#   Note: You should execute these commands, e.g.,  
#         when the current scene is modified.
/vis/scene/notifyHandlers
/vis/viewer/update

# FOR FUTURE UPDATION
#/vis/viewer/flushAll

# Bird's-eye view of a detector component (Gap)
/vis/viewer/reset
/vis/viewer/zoom               1.1
/vis/viewer/set/viewpointThetaPhi  35 35
/vis/drawVolume                Gap 
/vis/scene/add/axes  	  0 0 0 500 mm
/vis/scene/add/text       0 0 0 mm  50 -100 -140   Gap 
/vis/scene/add/scale      10 cm z 1 0 0 manual -2.5 -5  0 cm

# "Flush the action of all the existing viewers.
/vis/scene/notifyHandlers
/vis/viewer/update

# FOR FUTURE UPDATION
#/vis/viewer/flushAll


# Bird's-eye view of the whole detector components (world)
#  * The argument "world" of the command 
#    "/vis/scene/add/volume" is omittable.
#  * "/vis/viewer/set/culling false" makes the invisible 
#    world volume visible.
#    (The invisibility of the world volume is set 
#     in ExN03DetectorConstruction.cc.)
/vis/viewer/reset
/vis/viewer/zoom               1.1
/vis/viewer/set/viewpointThetaPhi  35 35
/vis/viewer/set/culling         global false
/vis/drawVolume 
/vis/scene/add/axes      0 0 0 500 mm
/vis/scene/add/text      0 0 0 mm 50 -100 -240   World
/vis/scene/add/scale     10 cm x 1 0 0 

# "Flush the action of all the existing viewers.
/vis/scene/notifyHandlers
/vis/viewer/update

# FOR FUTURE UPDATION
#/vis/viewer/flushAll


# Make the culling on for next visualization
#  Note: You may also use "/vis/viewer/reset" 
#        for this initialization. 
/vis/viewer/set/culling       global true