Import Geant4 0.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-01 15:25:35 +02:00
parent 54d6b71f95
commit b97f8d0df7
3237 changed files with 807095 additions and 0 deletions
@@ -0,0 +1,22 @@
# $Id: GNUmakefile,v 2.2 1998/07/07 17:11:06 allison Exp $
name := G4FR
ifndef G4INSTALL
G4INSTALL = ../../..
endif
include $(G4INSTALL)/config/architecture.gmk
include $(G4INSTALL)/config/G4VIS_BUILD.gmk
include $(G4INSTALL)/config/interactivity.gmk
CPPFLAGS += -I$(G4BASE)/visualization/management/include
CPPFLAGS += -I$(G4BASE)/visualization/modeling/include
CPPFLAGS += -I$(G4BASE)/global/management/include
CPPFLAGS += -I$(G4BASE)/graphics_reps/include
CPPFLAGS += -I$(G4BASE)/global/HEPGeometry/include
CPPFLAGS += -I$(G4BASE)/geometry/solids/CSG/include
CPPFLAGS += -I$(G4BASE)/geometry/management/include
CPPFLAGS += -I$(G4BASE)/geometry/volumes/include
include $(G4INSTALL)/config/common.gmk
@@ -0,0 +1,56 @@
DAWN-00-03-06 Satoshi TANAKA Dec 04, 1998
- Maximun number of generated g4.prim files in the destination
directory is customizable as: "setenv G4DAWNFILE_MAX_FILE_NUM N"
(N is the integer greater than or equal to 1. The default value is 1.)
DAWN-00-03-05 Satoshi TANAKA Dec 04, 1998
- Revised G4FRSocketConfig.hh together with architecture.gmk.
Compilation at SUN-CC was made automatic
DAWN-00-03-04 Satoshi TANAKA Dec 04, 1998
- Bug fix
DAWN-00-03-03 Satoshi TANAKA Nov 30, 1998
- Destination directiory of g4.prim and g4.eps is customizable
with the environmental variable "G4DAWNFILE_DEST_DIR".
Unix:
% setenv G4DAWNFILE_DEST_DIR directory_name/
For example,
% setenv G4DAWNFILE_DEST_DIR /tmp/
Do not forget to add "/" at the end of the directory name.
NT:
DOS> set G4DAWNFILE_DEST_DIR directory_name\
Do not forget to add "\" at the end of the directory name.
- Auto incremetaion of output file names is supported.
Names of generated files are:
DAWN-format files: g4.prim, g4_1.prim, g4_2.prim, ... , g4_100.prim
EPS files : g4.eps , g4_1.eps , g4_2.eps , ... , g4_100.eps
Maximal number of files in one directory is restricted in order to
avoid explosion of your hard disk. The maximal number is hard-coded.
You can revise is by editing enum of G4DAWNFILEScene.hh.
Note that the incrementation is done as follows (pseudo codes)
filename = "g4.prim" // initialization
while( filename already exists in the dest directory )
{
increment filename
}
It means that if you delete file "g4.prim" in the destination directory,
the file name in the next generation is still g4.prim.
DAWN-00-03-02 Satoshi TANAKA Nov 30, 1998
- Backup before going on to tag DAWN-00-03-03.
+31
View File
@@ -0,0 +1,31 @@
<< Portability >>
(1) --- Linux, DEC, HP, AIX, Solaris, IRIX ---
OK by default.
For Solaris, we assume that you use SUN-CC as G4SYSTEM.
For IRIX, we assume that you use SGI-CC as G4SYSTEM.
#endif
@@ -0,0 +1,43 @@
// 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: G4DAWNFILE.hh,v 2.1 1998/11/06 13:41:37 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
// Satoshi TANAKA
// DAWNFILE driver factory.
//=================//
#if defined (G4VIS_BUILD_DAWNFILE_DRIVER) || defined (G4VIS_USE_DAWNFILE)
//=================//
#ifndef G4DAWNFILE_HH
#define G4DAWNFILE_HH
#include "G4VGraphicsSystem.hh"
//----- prototype
class G4VScene ;
//----------------------------//
//----- class G4DAWNFILE -----//
//----------------------------//
class G4DAWNFILE: public G4VGraphicsSystem {
public:
G4DAWNFILE ();
~G4DAWNFILE ();
G4VScene* CreateScene (const G4String& name = "");
G4VView* CreateView (G4VScene&, const G4String& name = "");
private:
};
#endif
#endif
@@ -0,0 +1,215 @@
// 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: G4DAWNFILEScene.hh,v 2.4 1998/12/04 07:31:03 stanaka Exp $
// GEANT4 tag $Name: geant4-00 $
//
// Satoshi TANAKA
//=================//
#ifdef G4VIS_BUILD_DAWNFILE_DRIVER
//=================//
#ifndef G4DAWNFILE_SCENE_HH
#define G4DAWNFILE_SCENE_HH
#include "globals.hh"
#include "G4VScene.hh"
#include "G4FRofstream.hh"
#include "G4FRConst.hh"
class G4VisAttributes ;
class G4DAWNFILE;
//-----
class G4DAWNFILEScene: public G4VScene {
public:
//----- constructor and destructor
G4DAWNFILEScene (G4DAWNFILE& system, const G4String& name = "");
~G4DAWNFILEScene ();
//----- overriding base class methods
void AddPrimitive (const G4Polyline& line);
void AddPrimitive (const G4Polyhedron& p);
void AddPrimitive (const G4NURBS& nurb);
void AddPrimitive (const G4Text&);
void AddPrimitive (const G4Circle&);
void AddPrimitive (const G4Square&);
void AddPrimitive (const G4Polymarker& polymarker)
{ G4VScene::AddPrimitive (polymarker); }
virtual void BeginModeling () ;
virtual void EndModeling () { G4VScene::EndModeling ();}
virtual void BeginPrimitives (const G4Transform3D& objectTransformation);
virtual void EndPrimitives ();
void AddThis ( const G4Box& box );
void AddThis ( const G4Cons& cons );
void AddThis ( const G4Tubs& tubs );
void AddThis ( const G4Trd& trd );
void AddThis ( const G4Trap& trap );
void AddThis ( const G4Sphere& sphere );
void AddThis ( const G4Para& para );
void AddThis ( const G4Torus& torus );
void AddThis ( const G4VSolid& solid );
void ClearStore (){}
//----- public methods inherent to this class
static G4int GetSceneCount ();
void FREndModeling () ;
G4bool IsInModeling () { return flag_in_modeling ; }
G4bool IsSavingG4Prim ( void ) { return flag_saving_g4_prim ; }
void BeginSavingG4Prim( void );
void EndSavingG4Prim ( void ) ;
void SetG4PrimFileName() ;
G4DAWNFILE& GetSystem () { return fSystem ; }
void SendBoundingBox ( void );
const char* GetG4PrimFileName () { return fG4PrimFileName ; }
private:
//----- Utilities etc (common to DAWN and DAWNFILE drivers )
G4bool SendVisAttributes ( const G4VisAttributes* pAV );
G4bool IsVisible ( void ) ;
G4bool InitializeFR ( void ) ;
void SendTransformedCoordinates( void ) ;
void SendPhysVolName ( void ) ;
//----- public methods common to DAWN and DAWNFILE drivers
public:
void SendStr ( const char* char_string ) ;
void SendStrInt( const char* char_string ,
G4int ival );
void SendStrInt3( const char* char_string ,
G4int ival1 ,
G4int ival2 ,
G4int ival3 );
void SendStrInt4( const char* char_string ,
G4int ival1 ,
G4int ival2 ,
G4int ival3 ,
G4int ival4 );
void SendStrDouble( const char* char_string ,
G4double dval );
void SendStrDouble2( const char* char_string ,
G4double dval1 ,
G4double dval2 );
void SendStrDouble3( const char* char_string ,
G4double dval1 ,
G4double dval2 ,
G4double dval3 );
void SendStrDouble4( const char* char_string ,
G4double dval1 ,
G4double dval2 ,
G4double dval3 ,
G4double dval4 );
void SendStrDouble5( const char* char_string ,
G4double dval1 ,
G4double dval2 ,
G4double dval3 ,
G4double dval4 ,
G4double dval5 );
void SendStrDouble6( const char* char_string ,
G4double dval1 ,
G4double dval2 ,
G4double dval3 ,
G4double dval4 ,
G4double dval5 ,
G4double dval6 );
void SendStrDouble7( const char* char_string ,
G4double dval1 ,
G4double dval2 ,
G4double dval3 ,
G4double dval4 ,
G4double dval5 ,
G4double dval6 ,
G4double dval7 );
void SendStrDouble11( const char* char_string ,
G4double dval1 ,
G4double dval2 ,
G4double dval3 ,
G4double dval4 ,
G4double dval5 ,
G4double dval6 ,
G4double dval7 ,
G4double dval8 ,
G4double dval9 ,
G4double dval10 ,
G4double dval11 ) ;
void SendIntDouble3( G4int ival ,
G4double dval1 ,
G4double dval2 ,
G4double dval3 );
void SendInt3Str( G4int ival1 ,
G4int ival2 ,
G4int ival3 ,
const char* char_string );
void SendInt4Str( G4int ival1 ,
G4int ival2 ,
G4int ival3 ,
G4int ival4 ,
const char* char_string );
void SendStrDouble6Str( const char* char_string1 ,
G4double dval1 ,
G4double dval2 ,
G4double dval3 ,
G4double dval4 ,
G4double dval5 ,
G4double dval6 ,
const char* char_string2 );
void SendInt ( G4int val );
void SendDouble( G4double val );
private:
G4DAWNFILE& fSystem; // Graphics system for this scene.
static G4int fSceneIdCount;
static G4int fSceneCount; // No. of existing scenes.
G4FRofstream fPrimDest ; // defined here
G4bool flag_in_modeling ;
// true: FR_BEGIN_MODELING has sent to DAWN, and
// FR_END_MODELING has not sent yet.
// false: otherwise
//
// The flag flag_in_modeling is set to "true"
// in BeginModeling(), and to "false"
// in FREndModeling().
// ( EndModeling() is not used.)
G4bool flag_saving_g4_prim ;
const int COMMAND_BUF_SIZE ;
char fG4PrimDestDir [256] ;
char fG4PrimFileName[256] ;
G4int fMaxFileNum ;
};
#endif
#endif //G4VIS_BUILD_DAWNFILE_DRIVER
@@ -0,0 +1,60 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4DAWNFILEView.hh,v 2.1 1998/11/06 13:41:39 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
// Satoshi TANAKA
// DAWNFILE view - opens window, hard copy, etc.
//=================//
#ifdef G4VIS_BUILD_DAWNFILE_DRIVER
//=================//
#ifndef G4DAWNFILE_VIEW_HH
#define G4DAWNFILE_VIEW_HH
#include "G4VView.hh"
#include "globals.hh"
class G4DAWNFILEScene ;
class G4DAWNFILEView: public G4VView {
enum FRDEV {FRDEV_PS=1, FRDEV_XWIN=2, FRDEV_PS2=3, FRDEV_XWIN2=4, FRDEV_OPEN_GL=5, FRDEV_DEVICE_END=6} ;
public:
//----- constructor and destructor
G4DAWNFILEView (G4DAWNFILEScene& scene, const G4String& name = "");
~G4DAWNFILEView ();
//----- overriding base class methods
void SetView (); // Do nothing. SendViewParameters will do its job.
void ClearView ();
void DrawView ();
void ShowView ();
void FlushView (); // ShowView() without calling Wait()
//---- methods inherent to this class
void SendViewParameters () ;
const char* GetG4PrimViewer () { return fG4PrimViewer ;}
const char* GetG4PrimViewerInvocation() { return fG4PrimViewerInvocation ;}
const char* GetPSViewer () { return fPSViewer ;}
void SendDrawingStyleToDAWNGUI( ostream& out ) ;
private:
G4DAWNFILEScene& fScene; // Reference to Graphics Scene for this view.
char fG4PrimViewer [32] ;
char fG4PrimViewerInvocation[64] ;
char fPSViewer [32] ;
};
#endif
#endif //G4VIS_BUILD_DAWNFILE_DRIVER
@@ -0,0 +1,124 @@
// 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: G4FRClientServer.hh,v 2.2 1998/07/13 17:10:54 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
// Satoshi TANAKA, Wed Jul 3 14:13:52 JST 1996
////////////////////////////////
///// G4FRClientServer.h /////
////////////////////////////////
//=================//
#if defined (G4VIS_BUILD_DAWN_DRIVER) || defined (G4VIS_USE_DAWN)
//=================//
#if !defined G4FR_CLIENT_SERVER_H
#define G4FR_CLIENT_SERVER_H
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<netdb.h>
#include<sys/un.h>
#include<unistd.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include"G4ios.hh"
//----- constants
const char FR_ENV_SERVER_HOST_NAME[] = "G4DAWN_HOST_NAME" ;
const char FR_ENV_NAMED_PIPE_CONNECTION[] = "G4DAWN_NAMED_PIPE" ;
//-----------------------------------//
//----- class G4FRClientServer -----//
//-----------------------------------//
class G4FRClientServer {
public:
enum { SEND_BUFMAX = 1024 , RECV_BUFMAX = 1024 };
enum { SUN_PATH_MAX = 16 };
protected:
const char TERMINATOR ;
const char END_OF_LINE;
char SUN_PATH[ SUN_PATH_MAX ];
int PORT_NUMBER ;
int fSocketFd ;
char fReceivedMessage [ RECV_BUFMAX ];
char fSendingMessage [ SEND_BUFMAX ];
protected:
void Err( char* message ) { perror(message) ;}
void SetSendingMessage( const char* message )
{ strcpy( fSendingMessage, message );}
void Send() ; // send command in fSendingMessage
public:
//----- Server
int AcceptUnix(){ return 0;} // made unfunctioned
int AcceptINET(){ return 0 ;} // made unfunctioned
//----- Client
int ConnectUnix();
int ConnectINET();
//----- Common to server and client
//---------- (1)
G4FRClientServer ( char terminator = '.' ,
char end_line = '\n' ) ;
virtual ~G4FRClientServer () {;}
void SetSunPath( const char* sun_path )
{ strcpy ( SUN_PATH, sun_path ); }
void SetPortNumber( int port_num )
{ PORT_NUMBER = port_num ; }
void IncrementPortNumber( int incr = 1 )
{ PORT_NUMBER += incr ; }
const char* GetSendingMessage() const
{ return fSendingMessage ;}
int GetSendingMessageLength() const
{ return strlen(fSendingMessage) ;}
void SetReceivedMessage( const char* message )
{ strcpy( fReceivedMessage, message );}
const char* GetReceivedMessage() const
{ return fReceivedMessage ;}
int GetReceivedMessageLength() const
{ return strlen(fReceivedMessage) ;}
int GetSofd() const { return fSocketFd ; }
int GetPortNumber () const { return PORT_NUMBER ; }
void ClearReceivedMessage ()
{ memset(fReceivedMessage, '\0', RECV_BUFMAX) ; }
int IsTerminator(char ch ) { return ( ch == TERMINATOR ); }
char GetTerminator() const { return TERMINATOR ; }
int IsEndOfLine (char ch ) { return ( ch == END_OF_LINE ); }
char GetEndOfLine() const { return END_OF_LINE ; }
void DisConnect();
void Clear();
void WaitSendBack( const char* command_string ) ;
//---------- (2) send and receive
virtual void Send ( const char* message ) ;
virtual void SendLine ( const char* message ) ;
// Add END_OF_LINE if the message does not
// Terminate with it. And then send the message.
virtual void Receive() ;
virtual void ReceiveLine() ;
}; // G4FRClientServer
#endif
#endif //G4VIS_BUILD_DAWN_DRIVER
@@ -0,0 +1,176 @@
// 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: G4FRConst.hh,v 2.0 1998/07/02 16:42:01 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
// Satoshi TANAKA, Tue Jul 2 15:30:49 JST 1996
///////////////////////////////////
///// G4FRConst.hh /////
///////////////////////////////////
#if !defined G4_FR_COMMAND_LIST_HH
#define G4_FR_COMMAND_LIST_HH
//----- Header comment
const char FR_G4_PRIM_HEADER [] = "##G4.PRIM-FORMAT-2.4" ;
//const char FR_PHYSICAL_VOLUME_NAME [] = "#/PhysicalVolumeName" ;
const char FR_PHYSICAL_VOLUME_NAME [] = "#/PVName" ;
//----- Execution control (beginning with !)
const char FR_GUI [] = "!GraphicalUserInterface" ;
const char FR_DEVICE [] = "!Device" ;
const char FR_SET_CAMERA [] = "!SetCamera" ;
const char FR_OPEN_DEVICE [] = "!OpenDevice" ;
const char FR_CLOSE_DEVICE [] = "!CloseDevice" ;
const char FR_DRAW_ALL [] = "!DrawAll" ;
const char FR_CLEAR_DATA [] = "!ClearData" ;
const char FR_QUIT [] = "!Quit" ;
const char FR_DISCONNECT_DAWND [] = "!DisconnectDawnd" ;
const char FR_TERMINATE_DAWND [] = "!TerminateDawnd" ;
const char FR_SAVE [] = "!Save" ;
const char FR_END_SAVE [] = "!EndSave" ;
const char FR_WAIT [] = "!Wait" ;
const char FR_PAUSE [] = "!Pause" ;
//----- Drawing Style
const char FR_WIREFRAME [] = "/Wireframe" ;
const char FR_SURFACE [] = "/Surface" ;
const char FR_LINES [] = "/Lines" ;
//----- Begin and End of Modeling
const char FR_BEGIN_MODELING [] = "!BeginModeling" ;
const char FR_END_MODELING [] = "!EndModeling" ;
//----- Bounding box
const char FR_BOUNDING_BOX [] = "/BoundingBox" ;
const char FR_BOUNDING_BOX_UNIT [] = "/BoundingBox -0.5 -0.5 -0.5 0.5 0.5 0.5" ;
//----- Number of divising curved surface
const char FR_NDIV [] = "/Ndiv" ;
const char FR_NDIV_DEFAULT [] = "/Ndiv 24" ;
const char FR_NDIV_3 [] = "/Ndiv 3" ;
const char FR_NDIV_4 [] = "/Ndiv 4" ;
const char FR_NDIV_8 [] = "/Ndiv 8" ;
const char FR_NDIV_16 [] = "/Ndiv 16" ;
const char FR_NDIV_24 [] = "/Ndiv 24" ;
const char FR_NDIV_48 [] = "/Ndiv 48" ;
const char FR_NDIV_96 [] = "/Ndiv 96" ;
//----- Camera information
const char FR_CAMERA_POSITION[] = "/CameraPosition" ;
const char FR_CAMERA_POSITION_DEFAULT[] = "/CameraPosition 100000.0 0.0 0.0" ;
// see from far upward position
const char FR_TARGET_POINT [] = "/TargetPoint";
const char FR_ZOOM_FACTOR [] = "/ZoomFactor";
const char FR_SCALE [] = "/Scale";
const char FR_FOCAL_DISTANCE [] = "/FocalDistance";
//----- Body coordinate information
const char FR_BASE_VECTOR [] = "/BaseVector" ;
// Give e1 and e2. Then e3 is calculated.
const char FR_BASE_VECTOR_DEFAULT [] = "/BaseVector 1.0 0.0 0.0 0.0 1.0 0.0" ;
const char FR_ORIGIN [] = "/Origin" ;
const char FR_ORIGIN_DEFAULT [] = "/Origin 0.0 0.0 0.0" ;
//----- Attribute information
const char FR_DIFFUSE_RGB [] = "/DiffuseRGB" ;
// old name of /ColorRGB
const char FR_COLOR_RGB [] = "/ColorRGB" ;
const char FR_COLOR_RGB_DEFAULT [] = "/ColorRGB 1.0 1.0 1.0" ;
const char FR_COLOR_RGB_WHITE [] = "/ColorRGB 1.0 1.0 1.0" ;
const char FR_COLOR_RGB_RED [] = "/ColorRGB 1.0 0.0 0.0" ;
const char FR_COLOR_RGB_GREEN [] = "/ColorRGB 0.0 1.0 0.0" ;
const char FR_COLOR_RGB_BLUE [] = "/ColorRGB 0.0 0.0 1.0" ;
const char FR_COLOR_RGB_CYAN [] = "/ColorRGB 0.0 1.0 1.0" ;
const char FR_COLOR_RGB_MAGENTA [] = "/ColorRGB 1.0 0.0 1.0" ;
const char FR_COLOR_RGB_YELLOW [] = "/ColorRGB 1.0 1.0 0.0" ;
const char FR_SPECULAR_RGB [] = "/SpecularRGB" ;
const char FR_SPECULAR_RGB_DEFAULT [] = "/SpecularRGB 1.0 1.0 1.0" ;
const char FR_SPECULAR_RGB_WHITE [] = "/SpecularRGB 1.0 1.0 1.0" ;
const char FR_PHONG_POWER [] = "/PhongPower" ;
const char FR_PHONG_POWER_DEFAULT [] = "/PhongPower 3" ;
const char FR_TRANSPARENCY [] = "/Transparency" ;
const char FR_TRANSPARENCY_ON [] = "/Transparency 1 " ; // transparent
const char FR_TRANSPARENCY_OFF [] = "/Transparency 0 " ; // non-transparent
const char FR_FORCE_WIREFRAME [] = "/ForceWireframe" ;
const char FR_FORCE_WIREFRAME_ON [] = "/ForceWireframe 1" ;
const char FR_FORCE_WIREFRAME_OFF [] = "/ForceWireframe 0" ;
const char FR_VISIBILITY [] = "/Visibility" ;
const char FR_VISIBILITY_ON [] = "/Visibility 1" ; // visible
const char FR_VISIBILITY_OFF [] = "/Visibility 0" ; // invisible
//----- 3D Primitives
const char FR_POLYHEDRON [] = "/Polyhedron" ;
const char FR_VERTEX [] = "/Vertex" ;
const char FR_FACET [] = "/Facet" ;
const char FR_END_POLYHEDRON [] = "/EndPolyhedron" ;
const char FR_BOX [] = "/Box" ;
const char FR_BOX_UNIT [] = "/Box 0.5 0.5 0.5" ; // dx, dy, dz
const char FR_COLUMN [] = "/Column" ;
const char FR_COLUMN_UNIT [] = "/Column 0.5 0.5" ; // R dz
const char FR_POLYLINE [] = "/Polyline" ;
const char FR_PL_VERTEX [] = "/PLVertex" ;
const char FR_PL_VERTEX_OLD [] = "PLVertex" ;
const char FR_END_POLYLINE [] = "/EndPolyline" ;
const char FR_TRD [] = "/Trd" ;
// /Trd dx1 dx2 dy1 dy2 dz ;
const char FR_TRAP [] = "/Trap" ;
// /Trap dz theta phi h1 bl1 tl1 alpha1 h2 bl2 tl2 alpha2
const char FR_TUBS [] = "/Tubs" ;
// /Tubs rmin rmax dz sphi dphi
const char FR_CONS [] = "/Cons" ;
// /Cons rmin1 rmax1 rmin2 rmax2 dz sphi dphi
const char FR_SPHERE [] = "/Sphere" ;
// /Sphere R
const char FR_SPHERE_SEG [] = "/SphereSeg" ;
// /SphereSeg rmin rmax s_theta d_theta s_phi d_phi
const char FR_PARA [] = "/Parallelepiped" ;
// /Parallelepiped dx dy dz tanAlpha tanTheta_cosPhi tanTheta_sinPhi
const char FR_PCON [] = "/PolyCone" ;
// /PolyCone sphi dphi nz z[nz] rmin[nz] rmax[nz]
const char FR_PGON [] = "/PolyGon" ;
// /PolyGon sphi dphi ndiv nz z[nz] rmin[nz] rmax[nz]
const char FR_TORUS [] = "/Torus" ;
// /PolyGon sphi dphi ndiv nz z[nz] rmin[nz] rmax[nz]
//----- Marks I (arg: x y z half_size_3d)
const char FR_FONT_NAME [] = "/FontName" ;
//----- Marks I (arg: x y z half_size_3d)
const char FR_MARK_CIRCLE_2D [] = "/MarkCircle2D" ;
const char FR_MARK_SQUARE_2D [] = "/MarkSquare2D" ;
const char FR_MARK_TEXT_2D [] = "/MarkText2D" ;
// /MarkText2D x y z size_world x_offset_world y_offset_world string
//----- Marks II (arg: x y z half_size_2d)
const char FR_MARK_CIRCLE_2DS [] = "/MarkCircle2DS" ;
const char FR_MARK_SQUARE_2DS [] = "/MarkSquare2DS" ;
const char FR_MARK_TEXT_2DS [] = "/MarkText2DS" ;
// /MarkText2DS x y z size_pt x_offset_pt y_offset_pt string
//----- Text
const char FR_TEXT_2DS [] = "/Text2DS" ;
//----- For DAWNCUT
const char FR_CLIPPING_PLANE [] = "/ClippingPlane" ;
// /ClippingPlaneMarkCross2D a b c d
// for plane ax + by + cz + d = 0
#endif
@@ -0,0 +1,41 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4FRFeatures.hh,v 2.2 1998/07/12 03:09:10 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
#if !defined G4_FR_FEATURES_HH
#define G4_FR_FEATURES_HH
const char FR_DAWN_FEATURES[] = "High quality technical renderer.\
\n Features: exact hidden line, hidden surface algorithms.\
\n high (unlimited) resolution.\
\n renders to PostScript for viewing and/or hardcopy.\
\n remote rendering.\
\n off-line rendering.\
\n graphical user interface.\
\n connection via TCP/IP socket or named pipe Fukui Renderer DAWN.\
\n Disadvantages: compute intensive, takes time (use a fast graphics\
\n system, such as OpenGL, to select view, then copy\
\n to this renderer - /vis~/copy/view, /vis~/set/view).";
const char FR_DAWNFILE_FEATURES[] ="High quality technical renderer.\
\n Features: exact hidden line, hidden surface algorithms.\
\n high (unlimited) resolution.\
\n renders to PostScript for viewing and/or hardcopy.\
\n remote rendering.\
\n off-line rendering.\
\n graphical user interface.\
\n connection via g4.prim file to Fukui Renderer DAWN,\
\n DAVID (DAwn's Visual Intersection Debugger, etc.\
\n Disadvantages: compute intensive, takes time (use a fast graphics\
\n system, such as OpenGL, to select view, then copy\
\n to this renderer - /vis~/copy/view, /vis~/set/view).";
#endif
@@ -0,0 +1,40 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4FRSocketConfig.hh,v 2.2 1998/12/03 22:07:21 stanaka Exp $
// GEANT4 tag $Name: geant4-00 $
//
////////////////////////////////
///// G4FRSocketConfig.h /////
////////////////////////////////
//=================//
#ifdef G4VIS_BUILD_DAWN_DRIVER
//=================//
#if !defined SOCKET_CONFIG_H
#define SOCKET_CONFIG_H
//----------------------------------//
// Select one from the List below ////
//----------------------------------//
#if defined SOCKET_IRIX_SOLARIS
#define FR_SOCKET_IRIX_SOLARIS
#else
#define FR_SOCKET_DEFAULT
#endif
///// NOT IMPLEMENTED //////////
//#define SOCKET_NT
#endif
#endif // G4VIS_BUILD_DAWN_DRIVER
@@ -0,0 +1,33 @@
// 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: G4FRSocketMacro.hh,v 2.0 1998/07/02 16:42:05 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
///////////////////////////////
///// G4FRSocketMacro.hh /////
///////////////////////////////
//----- MACRO for portability -----//
//=================//
#ifdef G4VIS_BUILD_DAWN_DRIVER
//=================//
#if !defined FR_SOCKET_MACRO_H
#define FR_SOCKET_MACRO_H
//----- gethostname
#if defined FR_SOCKET_IRIX_SOLARIS
#include <sys/systeminfo.h>
#define GET_HOSTNAME( hostname, length ) sysinfo( SI_HOSTNAME, hostname, length )
#else
#define GET_HOSTNAME( hostname, length ) gethostname( hostname, length )
#endif
#endif
#endif //G4VIS_BUILD_DAWN_DRIVER
@@ -0,0 +1,107 @@
// 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: G4FRofstream.hh,v 2.0 1998/07/02 16:42:06 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
#include<fstream.h>
#if !defined G4_FR_OFSTREAM_HH
#define G4_FR_OFSTREAM_HH
#include "globals.hh"
/////////////////////
//typedef int G4bool ;
//#define false 0 ;
//#define true 1 ;
////////////////////
class G4FRofstream {
public:
enum { SEND_BUFMAX = 1024 };
public:
// constructors
G4FRofstream () { flag_file_open = false ; }
G4FRofstream ( const char* filename ) ;
// destructor
virtual ~G4FRofstream ();
// open and close
void Open ( const char* filename );
void Close() ;
G4bool IsOpen() { return flag_file_open ;}
// utilities
void SendLine( const char* string ) ; // save string with new line
// static functions
static G4bool DoesFileExist( const char* filename ) ;
protected:
G4bool flag_file_open ;
ofstream fout ;
} ;
inline void G4FRofstream::Open ( const char* filename )
{
if( !IsOpen() ) {
fout.open( filename ) ;
flag_file_open = true ;
}
}
inline void G4FRofstream::Close ()
{
if( IsOpen() ) {
fout.close();
flag_file_open = false ;
}
}
inline void G4FRofstream::SendLine ( const char* message )
{
if ( IsOpen() ) {
fout << message << endl;
}
}
inline G4bool G4FRofstream::DoesFileExist ( const char* filename )
{
G4bool status = false ;
ifstream fout_tmp( filename ) ;
if( fout_tmp ) { status = true ; }
fout_tmp.close();
return status ;
}
inline
G4FRofstream::G4FRofstream ( const char* filename )
{
flag_file_open = false ;
Open( filename );
}
inline
G4FRofstream::~G4FRofstream ()
{
Close() ;
}
#endif
@@ -0,0 +1,65 @@
// 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: G4FukuiRenderer.hh,v 2.1 1998/11/06 13:41:39 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Satoshi TANAKA
// Fukui Renderer factory.
//=================//
#if defined (G4VIS_BUILD_DAWN_DRIVER) || defined (G4VIS_USE_DAWN)
//=================//
#ifndef G4FUKUI_RENDERER_HH
#define G4FUKUI_RENDERER_HH
#include "G4VGraphicsSystem.hh"
#include "G4FRClientServer.hh"
//----- prototype
class G4VScene ;
//---------------------------------//
//----- class G4FukuiRenderer -----//
//---------------------------------//
class G4FukuiRenderer: public G4VGraphicsSystem {
public:
G4FukuiRenderer ();
~G4FukuiRenderer ();
G4VScene* CreateScene (const G4String& name = "");
G4VView* CreateView (G4VScene&, const G4String& name = "");
G4FRClientServer& GetPrimDest() { return fPrimDest ; }
//----- inter-process communication
enum { IP_UNIX, IP_INET };
enum { FR_MAX_PORT_INCR = 10 };
G4bool IsUnixDomain() const { return (fIPMode == G4FukuiRenderer::IP_UNIX); }
G4bool IsInetDomain() const { return (fIPMode == G4FukuiRenderer::IP_INET); }
void UseInetDomainAuto();
void UseInetDomain();
void UseBSDUnixDomainAuto();
void ConnectPort( int max_port_incr = FR_MAX_PORT_INCR);
G4bool IsGUIMode (void) { return flag_use_gui ; }
G4bool IsConnected (void) { return flag_connected ; }
public:
//----- inter-process communication
G4FRClientServer fPrimDest ;
private:
int fIPMode ;
G4bool flag_use_gui ;
G4int flag_connected ;
};
#endif
#endif //G4VIS_BUILD_DAWN_DRIVER
@@ -0,0 +1,284 @@
// 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: G4FukuiRendererScene.hh,v 2.3 1998/11/06 13:41:40 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Satoshi TANAKA, Fri Jun 28 11:19:19 JST 1996
//=================//
#ifdef G4VIS_BUILD_DAWN_DRIVER
//=================//
#ifndef G4FUKUI_RENDERER_SCENE_HH
#define G4FUKUI_RENDERER_SCENE_HH
#include "globals.hh"
#include "G4VScene.hh"
#include "G4FRClientServer.hh"
#include "G4FRConst.hh"
class G4VisAttributes ;
class G4FukuiRenderer;
////////////////////////////////////////////////////////////////////////
//
// ===== About AddPrimitive() functions =====
//
// Any graphics driver should prepare AddPrimitive() functions
// for the following visualizable primitives:
//
// G4Polyline,
// G4NURBS (not supported by DAWN),
// G4Text, G4Circle, G4Square,
// G4Polyhedron
//
// A drawing function G4VisManager::Draw(...) is prepared for each
// of these primitives.
//
// These primitives have visualization attributes by themselves.
// AddPrimitive() functions use these assinged visualization attributes
// for visualization.
//
// Local coordinates to locate these primitives are set to the current in
// BeginPrimitive() functions.
// See G4VisManager::Draw( const G4Polyline&), for example.
//
//////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
//
// ========== About AddThis() functions =======
//
// AddThis() functions are usually used to visualize a physical volume.
// The are called when G4VisManager::Draw( void ) is used.
//
// Current local coordinates and current visualization attributes
// are set to the current in the inherited PreAddThis() function.
// PreAddThis() is called in G4PhysicalVolumeModel::DescribeAndDescend():
//
// // Make decision to Draw.
// G4bool thisToBeDrawn = !IsThisCulled (pLV);
// if (thisToBeDrawn) {
// scene.PreAddThis (theNewAT, *(pLV -> GetVisAttributes ()));
// pSol -> DescribeYourselfTo (scene);
// scene.PostAddThis ();
// }
//
// where G4VSolid::DescribeYourselfTo ( G4VScene& ) calls
// a proper AddThis() function. See G4Box.cc, for example.
//
// For shapes for which AddThis() functions are not prepered explicitly,
// AddThis (const G4VSolid& ) is called automatically.
// Then the following chain of calling is Done:
//
// AddThis ( const G4VSolid& )
// ==> G4VScene::AddThis ( const G4VSolid& )
// ==> G4VScene::RequestPrimitives( const G4VSolid& )
// ==> AddPrimitive ( const G4Polyhedron& )
//
// Therefore, AddPrimitive( const G4Polyhedron& ) is used for
// visualization finally. Note that G4Polyhedron is automatically
// created in G4VScene::RequestPrimitives( const G4VSolid& ) and
// current visualization attributes are assigned there.
//
///////////////////////////////////////////////////////////////////////
//-----
class G4FukuiRendererScene: public G4VScene {
public:
//----- constructor and destructor
G4FukuiRendererScene (G4FukuiRenderer& system, const G4String& name = "");
~G4FukuiRendererScene ();
//----- overriding base class methods
void AddPrimitive (const G4Polyline& line);
void AddPrimitive (const G4Polyhedron& p);
void AddPrimitive (const G4NURBS& nurb);
void AddPrimitive (const G4Text&);
void AddPrimitive (const G4Circle&);
void AddPrimitive (const G4Square&);
void AddPrimitive (const G4Polymarker& polymarker)
{ G4VScene::AddPrimitive (polymarker); }
virtual void BeginModeling () ;
virtual void EndModeling () { G4VScene::EndModeling ();}
virtual void BeginPrimitives (const G4Transform3D& objectTransformation);
virtual void EndPrimitives ();
void AddThis ( const G4Box& box );
void AddThis ( const G4Cons& cons );
void AddThis ( const G4Tubs& tubs );
void AddThis ( const G4Trd& trd );
void AddThis ( const G4Trap& trap );
void AddThis ( const G4Sphere& sphere );
void AddThis ( const G4Para& para );
void AddThis ( const G4Torus& torus );
void AddThis ( const G4VSolid& solid );
void ClearStore (){}
//----- methods inherent to this class
static G4int GetSceneCount ();
void FREndModeling () ;
G4bool IsInModeling () { return flag_in_modeling ; }
G4bool IsSavingG4Prim ( void ) { return flag_saving_g4_prim ; }
void BeginSavingG4Prim( void )
{
if( !IsSavingG4Prim() )
{
SendStr( FR_SAVE ) ;
SendStr( FR_G4_PRIM_HEADER ) ;
flag_saving_g4_prim = true ;
}
}
void EndSavingG4Prim ( void )
{ if( IsSavingG4Prim() ) { SendStr( FR_END_SAVE ); flag_saving_g4_prim = false ; } }
G4FRClientServer& GetPrimDest () { return fPrimDest ; }
G4FukuiRenderer& GetSystem () { return fSystem ; }
void SendBoundingBox ( void );
private:
//----- Utilities etc
G4bool SendVisAttributes ( const G4VisAttributes* pAV );
G4bool IsVisible ( void ) ;
G4bool InitializeFR ( void ) ;
void SendTransformedCoordinates( void ) ;
void SendPhysVolName ( void ) ;
public:
void SendStr ( const char* char_string ) ;
void SendStrInt( const char* char_string ,
G4int ival );
void SendStrInt3( const char* char_string ,
G4int ival1 ,
G4int ival2 ,
G4int ival3 );
void SendStrInt4( const char* char_string ,
G4int ival1 ,
G4int ival2 ,
G4int ival3 ,
G4int ival4 );
void SendStrDouble( const char* char_string ,
G4double dval );
void SendStrDouble2( const char* char_string ,
G4double dval1 ,
G4double dval2 );
void SendStrDouble3( const char* char_string ,
G4double dval1 ,
G4double dval2 ,
G4double dval3 );
void SendStrDouble4( const char* char_string ,
G4double dval1 ,
G4double dval2 ,
G4double dval3 ,
G4double dval4 );
void SendStrDouble5( const char* char_string ,
G4double dval1 ,
G4double dval2 ,
G4double dval3 ,
G4double dval4 ,
G4double dval5 );
void SendStrDouble6( const char* char_string ,
G4double dval1 ,
G4double dval2 ,
G4double dval3 ,
G4double dval4 ,
G4double dval5 ,
G4double dval6 );
void SendStrDouble7( const char* char_string ,
G4double dval1 ,
G4double dval2 ,
G4double dval3 ,
G4double dval4 ,
G4double dval5 ,
G4double dval6 ,
G4double dval7 );
void SendStrDouble11( const char* char_string ,
G4double dval1 ,
G4double dval2 ,
G4double dval3 ,
G4double dval4 ,
G4double dval5 ,
G4double dval6 ,
G4double dval7 ,
G4double dval8 ,
G4double dval9 ,
G4double dval10 ,
G4double dval11 ) ;
void SendIntDouble3( G4int ival ,
G4double dval1 ,
G4double dval2 ,
G4double dval3 );
void SendInt3Str( G4int ival1 ,
G4int ival2 ,
G4int ival3 ,
const char* char_string );
void SendInt4Str( G4int ival1 ,
G4int ival2 ,
G4int ival3 ,
G4int ival4 ,
const char* char_string );
void SendStrDouble6Str( const char* char_string1 ,
G4double dval1 ,
G4double dval2 ,
G4double dval3 ,
G4double dval4 ,
G4double dval5 ,
G4double dval6 ,
const char* char_string2 );
void SendInt ( G4int val );
void SendDouble( G4double val );
private:
G4FukuiRenderer& fSystem; // Graphics system for this scene.
static G4int fSceneIdCount;
static G4int fSceneCount; // No. of existing scenes.
G4FRClientServer& fPrimDest ; // defined in G4FukuiRenderer
G4bool flag_in_modeling ;
// true: FR_BEGIN_MODELING has sent to DAWN, and
// FR_END_MODELING has not sent yet.
// false: otherwise
//
// The flag flag_in_modeling is set to "true"
// in BeginModeling(), and to "false"
// in FREndModeling().
// ( EndModeling() is not used.)
G4bool flag_saving_g4_prim ;
const int COMMAND_BUF_SIZE ;
};
#endif
#endif //G4VIS_BUILD_DAWN_DRIVER
@@ -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: G4FukuiRendererView.hh,v 2.1 1998/11/06 13:41:41 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Satoshi TANAKA, Fri Jun 28 12:10:14 JST 1996
// FukuiRenderer view - opens window, hard copy, etc.
//=================//
#ifdef G4VIS_BUILD_DAWN_DRIVER
//=================//
#ifndef G4FUKUI_RENDERER_VIEW_HH
#define G4FUKUI_RENDERER_VIEW_HH
#include "G4VView.hh"
#include "globals.hh"
class G4FukuiRendererScene ;
class G4FukuiRendererView: public G4VView {
enum FRDEV {FRDEV_PS=1, FRDEV_XWIN=2, FRDEV_PS2=3, FRDEV_XWIN2=4, FRDEV_OPEN_GL=5, FRDEV_DEVICE_END=6} ;
public:
//----- constructor and destructor
G4FukuiRendererView (G4FukuiRendererScene& scene, const G4String& name);
~G4FukuiRendererView ();
//----- overriding base class methods
void SetView (); // Do nothing. SendViewParameters will do its job.
void ClearView ();
void DrawView ();
void ShowView ();
void FlushView (); // ShowView() without calling Wait()
//---- methods inherent to this class
void Wait() ;
void SendViewParameters () ;
private:
void SendDevice( FRDEV dev );
void SendDrawingStyle() ;
G4FukuiRendererScene& fScene; // Reference to Graphics Scene for this view.
};
#endif
#endif //G4VIS_BUILD_DAWN_DRIVER
@@ -0,0 +1,64 @@
// 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: G4DAWNFILE.cc,v 2.2 1998/11/06 13:41:44 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
// Satoshi TANAKA
// DAWNFILE factory.
//=================//
#ifdef G4VIS_BUILD_DAWNFILE_DRIVER
//=================//
#include "G4DAWNFILE.hh"
#define __G_ANSI_C__
//#include "G4VisFeaturesOfDAWNFILE.hh"
#include "G4FRFeatures.hh"
#include "G4VScene.hh"
#include "G4DAWNFILEScene.hh"
#include "G4DAWNFILEView.hh"
#include "G4FRConst.hh"
//----- G4DAWNFILE, constructor
G4DAWNFILE::G4DAWNFILE ():
G4VGraphicsSystem ("DAWNFILE",
"DAWNFILE",
FR_DAWNFILE_FEATURES,
G4VGraphicsSystem::threeD)
{}
//----- G4DAWNFILE, destructor
G4DAWNFILE::~G4DAWNFILE ()
{}
//----- G4DAWNFILE::CreateScene (const G4String& name)
G4VScene* G4DAWNFILE::CreateScene (const G4String& name)
{
G4VScene* p = new G4DAWNFILEScene (*this, name);
G4cout << G4DAWNFILEScene::GetSceneCount ()
<< ' ' << fName << " scenes extanct." << endl;
return p;
}
//----- G4DAWNFILE::CreateView ()
G4VView* G4DAWNFILE::CreateView (G4VScene& scene, const G4String& name)
{
G4VView* pView =
new G4DAWNFILEView ((G4DAWNFILEScene&) scene, name);
return pView;
}
#endif // G4VIS_BUILD_DAWNFILE_DRIVER
@@ -0,0 +1,198 @@
// 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: G4DAWNFILEScene.cc,v 2.6 1998/12/04 07:31:12 stanaka Exp $
// GEANT4 tag $Name: geant4-00 $
//
// Satoshi TANAKA
// DAWNFILE scene.
//=================//
#ifdef G4VIS_BUILD_DAWNFILE_DRIVER
//=================//
#define __G_ANSI_C__
//#define DEBUG_FR_SCENE
//----- header files
#include <fstream.h>
#include <stdlib.h>
#include <string.h>
#include "globals.hh"
#include "G4FRConst.hh"
#include "G4DAWNFILE.hh"
#include "G4DAWNFILEScene.hh"
#include "G4DAWNFILEView.hh"
#include "G4Point3D.hh"
#include "G4VisAttributes.hh"
#include "G4Transform3D.hh"
#include "G4Polyhedron.hh"
#include "G4Box.hh"
#include "G4Cons.hh"
#include "G4Polyline.hh"
#include "G4Trd.hh"
#include "G4Tubs.hh"
#include "G4Text.hh"
#include "G4Circle.hh"
#include "G4Square.hh"
#include "G4ModelingParameters.hh"
#include "G4VPhysicalVolume.hh"
//----- constants
const char FR_ENV_CULL_INVISIBLE_OBJECTS [] = "G4DAWN_CULL_INVISIBLE_OBJECTS";
const char G4PRIM_FILE_HEADER [] = "g4_";
const char DEFAULT_G4PRIM_FILE_NAME[] = "g4.prim";
///////////////////////////
// Driver-dependent part //
///////////////////////////
//----- G4DAWNFILEScene, constructor
G4DAWNFILEScene::G4DAWNFILEScene (G4DAWNFILE& system, const G4String& name):
fSystem (system) ,
G4VScene (system, fSceneIdCount++, name) ,
fPrimDest () ,
flag_in_modeling (false) ,
flag_saving_g4_prim (false) ,
COMMAND_BUF_SIZE (G4FRofstream::SEND_BUFMAX)
{
// count instantiated scenes
fSceneCount++;
// g4.prim filename and its directory
if ( getenv( "G4DAWNFILE_DEST_DIR" ) == NULL ) {
strcpy( fG4PrimDestDir , "" );
strcpy( fG4PrimFileName, DEFAULT_G4PRIM_FILE_NAME );
} else {
strcpy( fG4PrimDestDir , getenv( "G4DAWNFILE_DEST_DIR" ) );
strcpy( fG4PrimFileName, DEFAULT_G4PRIM_FILE_NAME );
}
// maximum number of g4.prim files in the dest directory
fMaxFileNum = 1 ; // initialization
if ( getenv( "G4DAWNFILE_MAX_FILE_NUM" ) != NULL ) {
sscanf( getenv("G4DAWNFILE_MAX_FILE_NUM"), "%d", &fMaxFileNum ) ;
} else {
fMaxFileNum = 1 ;
}
if( fMaxFileNum < 1 ) { fMaxFileNum = 1 ; }
}
//----- G4DAWNFILEScene, destructor
G4DAWNFILEScene::~G4DAWNFILEScene ()
{
#if defined DEBUG_FR_SCENE
G4cerr << "***** ~G4DAWNFILEScene" << endl;
#endif
fSceneCount--;
ClearStore (); // clear current scene
}
void G4DAWNFILEScene::SetG4PrimFileName()
{
// g4.prim, g4_1.prim, ..., g4_MAX_FILE_INDEX.prim
const int MAX_FILE_INDEX = fMaxFileNum - 1 ;
// dest directory (null if no environmental variables is set)
strcpy ( fG4PrimFileName, fG4PrimDestDir) ;
// create full path name (default)
strcat ( fG4PrimFileName, DEFAULT_G4PRIM_FILE_NAME );
// Automatic updation of file names
for( int i = 0 ; i < fMaxFileNum ; i++) {
// Message
if( fMaxFileNum > 1 && i == MAX_FILE_INDEX ) {
G4cerr << "===========================================" << endl;
G4cerr << "WARNING MESSAGE from DAWNFILE driver: " << endl;
G4cerr << " This file name is the final one in the " << endl;
G4cerr << " automatic updation of the output file name." << endl;
G4cerr << " You may overwrite an existing file of " << endl;
G4cerr << " the same name. " << endl;
G4cerr << "===========================================" << endl;
}
// re-determine file to G4DAWNFILE_DEST_DIR/g4_i.prim for i>0
if( i > 0 ) {
sprintf( fG4PrimFileName, "%s%s%d.prim" , fG4PrimDestDir, G4PRIM_FILE_HEADER, i );
}
// check validity of the file name
ifstream fin ;
fin.open(fG4PrimFileName) ;
if(!fin) {
// new file
fin.close(); // error recovery
break;
} else {
// already exists (try next)
fin.close();
}
} // for
G4cerr << "===========================================" << endl;
G4cerr << "Output file: " << fG4PrimFileName << endl;
G4cerr << "Muximal number of file in the destination directory: " << fMaxFileNum << endl;
G4cerr << " (Customizable as: setenv G4DAWNFILE_MAX_FILE_NUM number) " << endl;
G4cerr << "===========================================" << endl;
} // G4DAWNFILEScene::SetG4PrimFileName()
void G4DAWNFILEScene::BeginSavingG4Prim( void )
{
if( !IsSavingG4Prim() )
{
SetG4PrimFileName() ; // returned to fG4PrimFileName
fPrimDest.Open(fG4PrimFileName) ;
SendStr( FR_G4_PRIM_HEADER ) ;
flag_saving_g4_prim = true ;
}
}
void G4DAWNFILEScene::EndSavingG4Prim ( void )
{
if( IsSavingG4Prim() )
{
fPrimDest.Close() ;
flag_saving_g4_prim = false ;
}
}
/////////////////////////////////////////
// Common to DAWN and DAWNFILE drivers //
/////////////////////////////////////////
#define G4FRSCENE G4DAWNFILEScene
#include "G4FRSceneFunc.icc"
#undef G4FRSCENE
//////////////////////
// static variables //
//////////////////////
//----- static variables
G4int G4DAWNFILEScene::fSceneIdCount = 0;
G4int G4DAWNFILEScene::fSceneCount = 0;
// num of existing instances
#endif // G4VIS_BUILD_DAWNFILE_DRIVER
@@ -0,0 +1,381 @@
// 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: G4DAWNFILEView.cc,v 2.5 1998/11/29 21:33:12 stanaka Exp $
// GEANT4 tag $Name: geant4-00 $
//
// Satoshi TANAKA
// DAWNFILE view - opens window, hard copy, etc.
//=================//
#ifdef G4VIS_BUILD_DAWNFILE_DRIVER
//=================//
#define __G_ANSI_C__
#define G4DAWNFILE_STRUCTURE_PRIORITY 1.
// #define DEBUG_FR_VIEW
#include "G4ios.hh"
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "G4SceneData.hh"
#include "G4Vector3D.hh"
#include "G4VisExtent.hh"
#include "G4LogicalVolume.hh"
#include "G4VSolid.hh"
#include "G4FRConst.hh"
#include "G4DAWNFILE.hh"
#include "G4DAWNFILEScene.hh"
#include "G4DAWNFILEView.hh"
//----- constants
const char FR_ENV_MULTI_WINDOW[] = "G4DAWN_MULTI_WINDOW" ;
//----- G4DAWNFILEView, constructor
G4DAWNFILEView::G4DAWNFILEView (G4DAWNFILEScene& scene,
const G4String& name):
G4VView (scene, scene.IncrementViewCount (), name), fScene (scene)
{
// Set a g4.prim-file viewer
strcpy( fG4PrimViewer, "dawn" );
if( getenv( "G4DAWNFILE_VIEWER" ) != NULL ) {
strcpy( fG4PrimViewer, getenv( "G4DAWNFILE_VIEWER" ) ) ;
}
// string for viewer invocation
if ( !strcmp( fG4PrimViewer, "NONE" ) ) {
strcpy( fG4PrimViewerInvocation, "" );
} else {
strcpy( fG4PrimViewerInvocation, fG4PrimViewer );
strcat( fG4PrimViewerInvocation, " ");
strcat( fG4PrimViewerInvocation, fScene.GetG4PrimFileName() );
}
// Set a PostScript Viewer
strcpy( fPSViewer, "ghostview" );
if( getenv( "G4DAWNFILE_PS_VIEWER" ) != NULL ) {
strcpy( fPSViewer, getenv( "G4DAWNFILE_PS_VIEWER" ) ) ;
}
}
//----- G4DAWNFILEView, destructor
G4DAWNFILEView::~G4DAWNFILEView ()
{}
//----- G4DAWNFILEView::SetView ()
void G4DAWNFILEView::SetView ()
{
#if defined DEBUG_FR_VIEW
G4cerr << "***** G4DAWNFILEView::SetView()\n";
#endif
// Do nothing, since DAWN is running as a different process.
// SendViewParameters () will do this job instead.
}
//----- G4DAWNFILEView::ClearView()
void
G4DAWNFILEView::ClearView( void )
{
#if defined DEBUG_FR_VIEW
G4cerr << "***** G4DAWNFILEView::ClearView () " << endl;
#endif
//----- Begin saving data to g4.prim
fScene.BeginSavingG4Prim();
//----- Clear old data
fScene.SendStr( FR_CLEAR_DATA );
}
//----- G4DAWNFILEView::DrawView ()
void G4DAWNFILEView::DrawView ()
{
#if defined DEBUG_FR_VIEW
G4cerr << "***** G4DAWNFILEView::DrawView () " << endl;
#endif
//----- Error recovery
if( fScene.IsInModeling() ) {
G4cerr << "WARNING from DAWNFILE driver:" << endl;
G4cerr << " You've invoked a drawing command before " << endl;
G4cerr << " completing your previous visualization." << endl;
// G4cerr << " You should have invoked command, /vis~/show/view," << endl;
// G4cerr << " to complete it." << endl;
FlushView();
}
//----- Begin Saving g4.prim file
fScene.BeginSavingG4Prim();
//----- set view if necessary
SendViewParameters();
// Camera data should be sent at every time, even if
// the setting is unchanged at GEANT 4 side.
//----- Always visit G4 kernel
NeedKernelVisit ();
//----- Draw
ProcessView () ;
} // G4DAWNFILEView::DrawView ()
//----- G4DAWNFILEView::ShowView()
void G4DAWNFILEView::ShowView( void )
{
#if defined DEBUG_FR_VIEW
G4cerr << "***** G4DAWNFILEView::ShowView () " << endl;
#endif
if( fScene.IsInModeling() ) // if( fScene.flag_in_modeling )
{
//----- End of Data
fScene.FREndModeling();
//----- Draw all
fScene.SendStr( FR_DRAW_ALL );
//----- Close device
fScene.SendStr( FR_CLOSE_DEVICE );
//----- End saving data to g4.prim
fScene.EndSavingG4Prim() ;
//----- string for viewer invocation
if ( !strcmp( fG4PrimViewer, "NONE" ) ) {
strcpy( fG4PrimViewerInvocation, "" );
} else {
strcpy( fG4PrimViewerInvocation, fG4PrimViewer );
strcat( fG4PrimViewerInvocation, " ");
strcat( fG4PrimViewerInvocation, fScene.GetG4PrimFileName() );
}
//----- Invoke DAWN
if( false == G4FRofstream::DoesFileExist( fScene.GetG4PrimFileName() ) )
{
G4cout << "ERROR: Failed to generate file ";
G4cout << fScene.GetG4PrimFileName() << endl;
} else if( strcmp( GetG4PrimViewerInvocation(), "" ) )
{
G4cout << "File " << fScene.GetG4PrimFileName() ;
G4cout << " is generated." << endl;
G4cout << GetG4PrimViewerInvocation() << endl;
system( GetG4PrimViewerInvocation() );
} else { // no view, i.e., only file generation
G4cout << "File " << fScene.GetG4PrimFileName() ;
G4cout << " is generated." << endl;
G4cout << "No viewer is invoked." << endl;
}
}
} // G4DAWNFILEView::ShowView()
//----- G4DAWNFILEView::FlushView()
void G4DAWNFILEView::FlushView( void )
{
#if defined DEBUG_FR_VIEW
G4cerr << "***** G4DAWNFILEView::Flush () " << endl;
#endif
ShowView();
}
//----- G4DAWNFILEView::SendDrawingStyleToDAWNGUI( ostream& out )
void G4DAWNFILEView::SendDrawingStyleToDAWNGUI( ostream& out )
{
#if defined DEBUG_FR_VIEW
G4cerr << "***** G4DAWNFILEView::SendDrawingStyle() " << endl;
#endif
G4int style = fVP.GetDrawingStyle();
enum { FR_WIREFRAME = 1, FR_WF_STORED = 2, FR_HID =3 , \
FR_HID2 = 4, FR_HID3 = 5, FR_DRAWING_MODE_END = 6 };
switch( style )
{
case G4ViewParameters::wireframe:
out << FR_WIREFRAME << endl;
break;
case G4ViewParameters::hlr:
out << FR_HID2 << endl; // LINE
break;
case G4ViewParameters::hsr:
case G4ViewParameters::hlhsr:
out << FR_HID << endl; // SURFACE
break;
default:
out << FR_WIREFRAME << endl;
break;
}
} // G4DAWNFILEView::SendDrawingStyle()
//----- G4DAWNFILEView::SendViewParameters ()
void G4DAWNFILEView::SendViewParameters ()
{
// Calculates view representation based on extent of object being
// viewed and (initial) direction of camera. (Note: it can change
// later due to user interaction via visualization system's GUI.)
#if defined DEBUG_FR_VIEW
G4cerr << "***** G4DAWNFILEView::SendViewParameters()\n";
#endif
//----- Magic number to decide camera distance automatically
const G4double HOW_FAR = 1000.0 ; // to define "infinity"
const G4double MIN_HALF_ANGLE = 0.01 ;
const G4double MAX_HALF_ANGLE = 0.499 * M_PI ;
//----- Send Bounding Box
fScene.SendBoundingBox();
//----- CALC camera distance
//..... Note: Camera cannot enter inside object
G4double camera_distance ;
G4double radius = fScene.GetSceneData().GetExtent().GetExtentRadius();
G4double half_view_angle = fabs ( fVP.GetFieldHalfAngle () ) ;
if( half_view_angle > MAX_HALF_ANGLE ) {
half_view_angle = MAX_HALF_ANGLE ;
}
if( half_view_angle < MIN_HALF_ANGLE ) {
//----- infinity (or ortho projection)
camera_distance = radius * HOW_FAR ;
} else {
//----- Calc camera distance from half view angle
camera_distance = radius / sin ( half_view_angle );
camera_distance -= fVP.GetDolly();
}
if ( camera_distance < radius ) {
G4cerr << "WARNING from DAWNFILE driver:" << endl;
G4cerr << " Camera cannot enter inside objects" << endl;
camera_distance = radius ;
}
//----- CALC camera direction
const G4Vector3D& camera_direction \
= fVP.GetViewpointDirection().unit();
const G4double v_angle = (180.0 / M_PI) * camera_direction.theta() ;
const G4double h_angle = (180.0 / M_PI) * camera_direction.phi () ;
//########### Generation of the file .DAWN.history for DAWN GUI
//-----
ofstream gui_out (".DAWN.history") ;
// ######### P1
//----- camera position
gui_out << camera_distance << endl;
gui_out << v_angle << endl ;
gui_out << h_angle << endl ;
gui_out << "0" << endl ; // auto target
//----- target point
const G4Point3D& target_point = fVP.GetCurrentTargetPoint();
gui_out << target_point.x() << endl ;
gui_out << target_point.y() << endl ;
gui_out << target_point.z() << endl ;
//----- Magnification
const G4double zoom_factor = fVP.GetZoomFactor();
if( half_view_angle < MIN_HALF_ANGLE ) {
gui_out << zoom_factor << endl;
} else {
const G4double FR_HALF_SCREEN_SIZE = 0.5 ;
G4double focal_distance \
= FR_HALF_SCREEN_SIZE / tan( half_view_angle );
focal_distance *= zoom_factor ;
gui_out << "fd" << focal_distance << endl;
}
SendDrawingStyleToDAWNGUI( gui_out ) ; // gui_out, viewing mode
gui_out << "0.001" << endl ; // 3D Tolerance
gui_out << "0" << endl ; // not display parameters
// ######### P2
gui_out << 1 << endl; // Source light
gui_out << 1 << endl;
gui_out << 1 << endl;
gui_out << 0.5 << endl; // Ambient light
gui_out << 0.5 << endl;
gui_out << 0.5 << endl;
gui_out << 19.0 << endl; // Light direction (Polar)
gui_out << 71.0 << endl; // Light direction (Azimuthal)
// ######### P3
gui_out << 0.1 << endl; // Real edge width
gui_out << 0.1 << endl; // outline width
gui_out << 0.1 << endl; // aux edge width
gui_out << 3 << endl; // aux edge style
gui_out << 70.0<< endl; // aux-edge threshold angle
gui_out << 0.1 << endl; // line width
gui_out << 0 << endl; // haloing
gui_out << 1 << endl; // Dashed edged for back faces
//######### P4
//----- drawing device
// enum {PS=1, XWIN=2, PS2=3, XWIN2=4, OPEN_GL=5, DEVICE_END=6};
if( ( getenv( FR_ENV_MULTI_WINDOW ) != NULL ) && \
( strcmp( getenv( FR_ENV_MULTI_WINDOW ),"0" ) ) )
{
gui_out << 2 << endl; // OpenWindow
} else {
gui_out << 1 << endl; // Invoke PS viewer
}
gui_out << GetPSViewer() << endl; // PS viewer
gui_out << 0; // Add showpage
gui_out.close();
//########### end of generating file .DAWN.history
//----- SET CAMERA
fScene.SendStr( FR_SET_CAMERA );
} // G4DAWNFILEView::SendViewParameters ()
#endif // G4VIS_BUILD_DAWNFILE_DRIVER
@@ -0,0 +1,318 @@
// 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: G4FRClientServer.cc,v 2.1 1998/07/13 17:11:01 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
// Satoshi TANAKA, Wed Jul 3 14:14:29 JST 1996
////////////////////////////////
///// G4FRClientServer.cc /////
////////////////////////////////
//=================//
#ifdef G4VIS_BUILD_DAWN_DRIVER
//=================//
#include "G4FRSocketConfig.hh"
#include "G4FRSocketMacro.hh"
#include "G4FRClientServer.hh"
// #define DEBUG_CLIENT_SERVER
#include<sys/param.h>
//----- const
const char DEFAULT_SUN_PATH[] = "FR_TMP3" ;
const int DEFAULT_PORT_NUMBER = 40701 ;
//const char FR_ENV_SERVER_HOST_NAME[] = "G4DAWN_HOST_NAME" ; // moved to .hh
const int MAX_BINDING_TRIAL = 10 ;
const int BINDING_TRIAL_INTERVAL = 5 ;
const int MAX_CONNECT_TRIAL = 10 ;
//----- G4FRClientServer::G4FRClientServer ()
G4FRClientServer::G4FRClientServer ( char terminator , char end_line ) :
TERMINATOR ( terminator ) ,
END_OF_LINE( end_line ) ,
fSocketFd ( -1 )
{
SetSunPath ( DEFAULT_SUN_PATH ) ; // for Unix domain
SetPortNumber ( DEFAULT_PORT_NUMBER ) ;
ClearReceivedMessage () ;
}
//----- G4FRClientServer::ConnectUnix()
int G4FRClientServer::ConnectUnix()
{
//----- local
int flag_connected = 0 ;
struct sockaddr_un server_address ;
//----- make socket
fSocketFd = socket( AF_UNIX, SOCK_STREAM, 0 );
if( fSocketFd < 0 ) { Err("G4FRClientServer::ConnectUnix(),socket"); }
//----- set server address
memset( (char *)&server_address, '\0', sizeof(server_address)) ;
server_address.sun_family = AF_UNIX ;
strcpy( server_address.sun_path, SUN_PATH );
//----- connection
int connection_status = -1 ;
int num_trial = 0 ;
while( connection_status < 0 && num_trial <= MAX_CONNECT_TRIAL ) {
num_trial++ ;
connection_status = connect( fSocketFd, (struct sockaddr * )(&server_address), sizeof( server_address ) ) ;
if( connection_status <0 )
{
#if defined DEBUG_CLIENT_SERVER
Err("G4FRClientServer::ConnectUnix(),connect => RETRY");
#endif
flag_connected = 0 ;
} else {
flag_connected = 1 ;
break ;
}
sleep(1);
} // while(connection_status...)
//----- return status of connection
return flag_connected ;
} // G4FRClientServer::ConnectUnix()
//----- G4FRClientServer::Receive()
void G4FRClientServer::Receive()
{
//-----
ClearReceivedMessage () ;
if( recv( fSocketFd, fReceivedMessage, G4FRClientServer::RECV_BUFMAX , 0 ) < 0 )
{
Err("G4FRClientServer::Receive(), recv");
}
#if defined DEBUG_CLIENT_SERVER
G4cerr << ">>>>> receivedMessage = " << fReceivedMessage << endl;
#endif
}
//----- G4FRClientServer::ReceiveLine()
void G4FRClientServer::ReceiveLine()
{
//----- local
char buf[1];
int index = 0 ;
//----- receive a line (until newline)
memset(fReceivedMessage, '\0', RECV_BUFMAX) ;
while( read( fSocketFd, buf, 1 ) == 1 ) {
fReceivedMessage[index++] = buf[0];
if( IsEndOfLine(buf[0]) ) { break ;}
}
} // G4FRClientServer::ReceiveLine()
//----- G4FRClientServer::Send()
void G4FRClientServer::Send()
{
if( send( fSocketFd, fSendingMessage, strlen(fSendingMessage) , 0 ) < 0 )
{
Err("G4FRClientServer::Send(), send");
}
#if defined DEBUG_CLIENT_SERVER
G4cerr << "<<<<< SentMessage = " << fSendingMessage << endl;
#endif
} // G4FRClientServer::Send()
//----- G4FRClientServer::Send( message )
void G4FRClientServer::Send( const char* message )
{
this->SetSendingMessage( message ) ;
this->Send();
} // G4FRClientServer::Send( message )
//----- G4FRClientServer::SendLine()
void G4FRClientServer::SendLine( const char* message )
{
//----- local
int smsg_length ;
//----- set message to sending buf
this->SetSendingMessage( message ) ;
smsg_length = GetSendingMessageLength() ;
//----- add newline if necessary
if( !IsEndOfLine( fSendingMessage[ (smsg_length - 1)] ) ) {
fSendingMessage[ smsg_length ] = GetEndOfLine() ;
fSendingMessage[ (smsg_length +1) ] = '\0' ;
smsg_length = GetSendingMessageLength();
}
//----- send
this->Send();
}// G4FRClientServer::SendLine()
//----- G4FRClientServer::DisConnect()
void G4FRClientServer::DisConnect()
{
//----- close connection
if( shutdown(fSocketFd,2) < 0 ) {
Err("G4FRClientServer::DisConnect,shutdown");
}
close( fSocketFd );
this->Clear();
}
//----- G4FRClientServer::Clear()
void G4FRClientServer::Clear()
{
unlink(SUN_PATH) ;
fSocketFd = -1 ;
}
//----- G4FRClientServer::ConnectINET()
int G4FRClientServer::ConnectINET()
{
//----- local
int flag_connected = 0 ;
sockaddr_in server_address ;
char server_hostname[32] ;
hostent* server_host_p ;
//----- make socket
fSocketFd = socket( AF_INET, SOCK_STREAM, 0 );
if( fSocketFd < 0 ) {
#if defined DEBUG_CLIENT_SERVER
Err("G4FRClientServer::ConnectINET(),socket");
#endif
}
//----- get IP address of server from its name
if( getenv( FR_ENV_SERVER_HOST_NAME ) != NULL )
{
//----- get server name
strcpy( server_hostname, getenv( FR_ENV_SERVER_HOST_NAME ) );
//----- get IP address of server from its name,
//..... reading /etc/hosts
server_host_p = gethostbyname( server_hostname ) ;
//----- If the host specified by FR_ENV_SERVER_HOST_NAME
//..... is not written in /etc/hosts,
//...... server host is set to the same as the
//...... client host
if( !server_host_p ) {
#if defined DEBUG_CLIENT_SERVER
Err("G4FRClientServer::ConnectINET(), gethostbyname");
#endif
//----- get server name
if( GET_HOSTNAME( server_hostname, sizeof( server_hostname ) ) < 0 )
{ Err("G4FRClientServer::ConnectNET(), GET_HOSTNAME");}
//----- get IP address of server from its name
if( !(server_host_p = gethostbyname( server_hostname ) ) )
{ Err("G4FRClientServer::ConnectINET(), gethostbyname");}
}
} else {
//----- If FR_ENV_SERVER_HOST_NAME is not set,
//...... server host is set to the same as the
//...... client host.
//----- get server name
if( GET_HOSTNAME( server_hostname, sizeof( server_hostname ) ) < 0 )
{ Err("G4FRClientServer::ConnectNET(), GET_HOSTNAME");}
//----- get IP address of server from its name
if( !(server_host_p = gethostbyname( server_hostname ) ) )
{ Err("G4FRClientServer::ConnectINET(), gethostbyname");}
}
// #if defined DEBUG_CLIENT_SERVER
G4cerr << "***** Trying connection to " << server_hostname << endl;
// #endif
//----- connection and binding
memset( (char *)&server_address, '\0', sizeof(server_address)) ;
// clear server_address
server_address.sin_family = AF_INET ;
server_address.sin_port = htons( PORT_NUMBER );
memcpy( (char *)(&server_address.sin_addr ),
(char *)( server_host_p->h_addr ),
server_host_p->h_length );
int connection_status = -1 ;
int num_trial = 0 ;
while( connection_status < 0 && num_trial <= MAX_CONNECT_TRIAL ) {
num_trial++ ;
connection_status = connect( fSocketFd, (struct sockaddr * )(&server_address), sizeof( server_address ) ) ;
if( connection_status <0 )
{
#if defined DEBUG_CLIENT_SERVER
Err("G4FRClientServer::ConnectINET(),connect => RETRY");
#endif
flag_connected = 0 ;
} else {
flag_connected = 1 ;
break ;
}
sleep(1);
} // while(connection_status...)
//----- return status of connection
return flag_connected ;
} // G4FRClientServer::ConnectINET()
//----- G4FRClientServer::WaitSendBack()
void G4FRClientServer::WaitSendBack( const char* command_string )
{
//----- wait for sending back
while(1) {
this->ReceiveLine();
if( !strncmp( this->GetReceivedMessage(), \
command_string , \
(strlen(command_string)) ) )
{
break;
} else {
sleep(2);
}
} // while
//----- clear buffer to receive message
this->ClearReceivedMessage();
} // G4FRClientServer::WaitSendBack()
#endif // G4VIS_BUILD_DAWN_DRIVER
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,238 @@
// 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: G4FukuiRenderer.cc,v 2.3 1998/11/06 13:41:46 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Satoshi TANAKA
// FukuiRenderer factory.
//=================//
#ifdef G4VIS_BUILD_DAWN_DRIVER
//=================//
//#define DEBUG_FR_SYSTEM
#include "G4FukuiRenderer.hh"
#define __G_ANSI_C__
//#include "G4VisFeaturesOfFukuiRenderer.hh"
#include "G4VScene.hh"
#include "G4FukuiRendererScene.hh"
#include "G4FukuiRendererView.hh"
#include "G4FRClientServer.hh"
#include "G4FRConst.hh"
#include "G4FRFeatures.hh"
//----- constant
const int FR_DEFAULT_CONNECTION_TIME = 5 ;
const char FR_ENV_CONNECTION_TIME [] = "G4DAWN_CONNECTION_TIME";
const char FR_ENV_DAWN_GUI_ALWAYS [] = "G4DAWN_GUI_ALWAYS";
//----- G4FukuiRenderer, constructor
G4FukuiRenderer::G4FukuiRenderer ():
G4VGraphicsSystem ("FukuiRenderer",
"DAWN",
FR_DAWNFILE_FEATURES,
G4VGraphicsSystem::threeD),
fPrimDest() ,
fIPMode( G4FukuiRenderer::IP_UNIX ),
flag_use_gui (false) ,
flag_connected (0)
{
//----- sorting of objects
if( ( getenv( FR_ENV_DAWN_GUI_ALWAYS ) != NULL ) && \
( strcmp( getenv( FR_ENV_DAWN_GUI_ALWAYS ),"0" ) ) )
{
flag_use_gui = true ;
}
}
//----- G4FukuiRenderer, destructor
G4FukuiRenderer::~G4FukuiRenderer ()
{
if( flag_connected ) {
//----- Terminate FukuiRenderer
fPrimDest.SendLine( FR_TERMINATE_DAWND ) ;
//----- disconnection
fPrimDest.DisConnect();
flag_connected = 0 ;
}
}
//----- G4FukuiRenderer::CreateScene ()
G4VScene* G4FukuiRenderer::CreateScene (const G4String& name)
{
G4VScene* p = new G4FukuiRendererScene (*this, name);
if(!flag_connected) { delete p ; p = NULL ; }
G4cout << G4FukuiRendererScene::GetSceneCount ()
<< ' ' << fName << " scenes extanct." << endl;
return p;
}
//----- G4FukuiRenderer::CreateView ()
G4VView* G4FukuiRenderer::CreateView (G4VScene& scene, const G4String& name)
{
if(!flag_connected) return NULL;
G4VView* pView =
new G4FukuiRendererView ((G4FukuiRendererScene&) scene, name);
return pView;
}
//----- G4FukuiRenderer::UseInetDomainAuto()
void G4FukuiRenderer::UseInetDomainAuto()
{
int pid ;
#if defined DEBUG_FR_SYSTEM
G4cerr << "***** Unix Inet Domain (AUTO mode)" << endl;
#endif
fIPMode = G4FukuiRenderer::IP_UNIX ;
if( ( pid = fork() ) == 0 ) { // child
if ( execlp ( "dawn", "dawn", "-G" , (char *)0 ) < 0 )
{
perror("dawn") ;
}
} else { // parent
//----- Set waiting time to ensure connection
int connection_time = FR_DEFAULT_CONNECTION_TIME ;
if( getenv( FR_ENV_CONNECTION_TIME ) != NULL ) {
int sscanf_status = \
sscanf( getenv( FR_ENV_CONNECTION_TIME ), "%d", &connection_time) ;
if ( sscanf_status == EOF ) {
connection_time = FR_DEFAULT_CONNECTION_TIME ;
}
}
//----- Wait for starting up of FukuiRenderer
sleep(connection_time);
//----- establish connection
this->ConnectPort();
}
if(!flag_connected) {
G4cerr << "***** ERROR: Connection failed" << endl;
}
else {
G4cerr << "***** GEANT4 is connected to FukuiRenderer DAWN ";
G4cerr << "in the same host" << endl;
}
} // G4FukuiRenderer::UseInetDomainAuto()
//----- G4FukuiRenderer::UseInetDomain()
void
G4FukuiRenderer::UseInetDomain()
{
#if defined DEBUG_FR_SYSTEM
G4cerr << "***** INET Domain " << endl;
#endif
fIPMode = G4FukuiRenderer::IP_INET ;
this->ConnectPort();
if(!flag_connected) {
G4cerr << "***** ERROR: Connection failed" << endl;
}
else {
G4cerr << "GEANT4 is connected to FukuiRenderer DAWN via socket" ;
G4cerr << endl;
}
} // G4FukuiRenderer::UseInetDomain()
void
G4FukuiRenderer::ConnectPort( int max_port_incr )
{
//----- establish connection
int connect_trial = 0 ;
while(1) {
if ( ++connect_trial > max_port_incr ) {
this->flag_connected = 0 ;
G4cerr << "***** INET Connection failed." << endl;
G4cerr << " Maybe, you have not invoked DAWN yet," << endl;
G4cerr << " or too many DAWN's are already running" << endl;
G4cerr << " in the server host." << endl;
fPrimDest.IncrementPortNumber( (- FR_MAX_PORT_INCR) );
return ;
} else if ( fPrimDest.ConnectINET() ) {
// INET domain connection is established
this->flag_connected = 1 ;
G4cerr << "***** GEANT4 is connected to port " ;
G4cerr << fPrimDest.GetPortNumber() ;
G4cerr << " of server" << endl;
break ;
} else {
// Connection failed. Try the next port.
this->flag_connected = 0 ;
fPrimDest.IncrementPortNumber();
G4cerr << "***** GEANT4 incremented targeting port to " ;
G4cerr << fPrimDest.GetPortNumber() << endl;
} // if-elseif-else
} // while (1)
}
//----- G4FukuiRenderer::UseBSDUnixDomainAuto()
void G4FukuiRenderer::UseBSDUnixDomainAuto()
{
int pid ;
#if defined DEBUG_FR_SYSTEM
G4cerr << "***** UseBSDUnixDomainAuto " << endl;
#endif
fIPMode = G4FukuiRenderer::IP_UNIX ; // Unix domain
if( ( pid = fork() ) == 0 ) { // child
if ( execlp ( "dawn", "dawn", "-g" , (char *)0 ) < 0 )
{
perror("dawn") ;
}
} else { // parent
//----- Sleep for a while to make sure that
//..... FukuiRenderer is ready
int connection_time = FR_DEFAULT_CONNECTION_TIME ;
if( getenv( FR_ENV_CONNECTION_TIME ) != NULL ) {
int sscanf_status = \
sscanf( getenv( FR_ENV_CONNECTION_TIME ), "%d", &connection_time) ;
if ( sscanf_status == EOF ) { connection_time = FR_DEFAULT_CONNECTION_TIME ;}
}
sleep(connection_time);
//----- connect GEANT4 to FukuiRenderer
this->flag_connected = fPrimDest.ConnectUnix();
//----- display status
if(!flag_connected) {
G4cerr << "***** ERROR: Connection failed" << endl;
} else {
G4cerr << "*** GEANT4 is connected to FukuiRenderer DAWN ";
G4cerr << "in the same host" << endl;
}
} // if--else
}// G4FukuiRenderer::UseBSDUnixDomainAuto()
#endif // G4VIS_BUILD_DAWN_DRIVER
@@ -0,0 +1,125 @@
// 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: G4FukuiRendererScene.cc,v 2.3 1998/11/06 13:41:47 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Satoshi TANAKA, Fri Jun 28 11:34:24 JST 1996
// FukuiRenderer scene.
//=================//
#ifdef G4VIS_BUILD_DAWN_DRIVER
//=================//
#define __G_ANSI_C__
//#define DEBUG_FR_SCENE
//----- header files
#include <fstream.h>
//#include <strstream.h>
#include <string.h>
#include "globals.hh"
#include "G4FRConst.hh"
#include "G4FukuiRenderer.hh"
#include "G4FukuiRendererScene.hh"
#include "G4FukuiRendererView.hh"
#include "G4Point3D.hh"
#include "G4VisAttributes.hh"
#include "G4Transform3D.hh"
#include "G4Polyhedron.hh"
#include "G4Box.hh"
#include "G4Cons.hh"
#include "G4Polyline.hh"
#include "G4Trd.hh"
#include "G4Tubs.hh"
#include "G4Text.hh"
#include "G4Circle.hh"
#include "G4Square.hh"
#include "G4ModelingParameters.hh"
#include "G4VPhysicalVolume.hh"
//----- constants
const char FR_ENV_CULL_INVISIBLE_OBJECTS [] = "G4DAWN_CULL_INVISIBLE_OBJECTS";
///////////////////////////
// Driver-dependent part //
///////////////////////////
//----- G4FukuiRendererScene, constructor
G4FukuiRendererScene::G4FukuiRendererScene (G4FukuiRenderer& system,
const G4String& name):
fSystem (system) ,
G4VScene (system, fSceneIdCount++, name) ,
fPrimDest (system.GetPrimDest() ) ,
flag_in_modeling (false) ,
flag_saving_g4_prim (false) ,
COMMAND_BUF_SIZE (G4FRClientServer::SEND_BUFMAX)
{
//----- Connection to FukuiRenderer is set in the first scene
if( !fSystem.IsConnected() )
{
if ( getenv( FR_ENV_NAMED_PIPE_CONNECTION ) != NULL &&\
strcmp( getenv( FR_ENV_NAMED_PIPE_CONNECTION ), "0" ) )
{
// Invoke DAWN locally and make connection
// via named pipe (not supported in AIX etc)
fSystem.UseBSDUnixDomainAuto();
} else if( getenv( FR_ENV_SERVER_HOST_NAME ) == NULL )
{
// Invoke DAWN locally and make connection
// via socket
fSystem.UseInetDomainAuto();
} else {
// Connect to remote DAWN via socket
fSystem.UseInetDomain();
}
}
//----- count instantiated scenes
fSceneCount++;
} // G4FukuiRendererScene, constructor
//----- G4FukuiRendererScene, destructor
G4FukuiRendererScene::~G4FukuiRendererScene ()
{
#if defined DEBUG_FR_SCENE
G4cerr << "***** ~G4FukuiRendererScene" << endl;
#endif
fSceneCount--;
ClearStore (); // clear current scene
}
/////////////////////////////////////////
// Common to DAWN and DAWNFILE drivers //
/////////////////////////////////////////
#define G4FRSCENE G4FukuiRendererScene
#include "G4FRSceneFunc.icc"
#undef G4FRSCENE
//////////////////////
// static variables //
//////////////////////
//----- static variables
G4int G4FukuiRendererScene::fSceneIdCount = 0;
G4int G4FukuiRendererScene::fSceneCount = 0;
// num of existing instances
#endif // G4VIS_BUILD_DAWN_DRIVER
@@ -0,0 +1,359 @@
// 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: G4FukuiRendererView.cc,v 2.4 1998/11/06 13:41:48 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Satoshi TANAKA, Fri Jun 28 12:09:11 JST 1996
// FukuiRenderer view - opens window, hard copy, etc.
//=================//
#ifdef G4VIS_BUILD_DAWN_DRIVER
//=================//
#define __G_ANSI_C__
#define G4FukuiRenderer_STRUCTURE_PRIORITY 1.
// #define DEBUG_FR_VIEW
#include "G4ios.hh"
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "G4SceneData.hh"
#include "G4Vector3D.hh"
#include "G4VisExtent.hh"
#include "G4LogicalVolume.hh"
#include "G4VSolid.hh"
#include "G4FRConst.hh"
#include "G4FukuiRenderer.hh"
#include "G4FukuiRendererScene.hh"
#include "G4FukuiRendererView.hh"
//----- constants
const char FR_ENV_MULTI_WINDOW[] = "G4DAWN_MULTI_WINDOW" ;
//----- G4FukuiRendererView, constructor
G4FukuiRendererView::G4FukuiRendererView (G4FukuiRendererScene& scene,
const G4String& name):
G4VView (scene, scene.IncrementViewCount (), name), fScene (scene)
{}
//----- G4FukuiRendererView, destructor
G4FukuiRendererView::~G4FukuiRendererView ()
{}
//----- G4FukuiRendererView::SetView ()
void G4FukuiRendererView::SetView ()
{
#if defined DEBUG_FR_VIEW
G4cerr << "***** G4FukuiRendererView::SetView()\n";
#endif
// Do nothing, since DAWN is running as a different process.
// SendViewParameters () will do this job instead.
}
//----- G4FukuiRendererView::ClearView()
void
G4FukuiRendererView::ClearView( void )
{
#if defined DEBUG_FR_VIEW
G4cerr << "***** G4FukuiRendererView::ClearView () " << endl;
#endif
//----- Begin saving data to g4.prim
fScene.BeginSavingG4Prim();
//----- Clear old data
fScene.SendStr( FR_CLEAR_DATA );
}
//----- G4FukuiRendererView::DrawView ()
void G4FukuiRendererView::DrawView ()
{
#if defined DEBUG_FR_VIEW
G4cerr << "***** G4FukuiRendererView::DrawView () " << endl;
#endif
//----- Error recovery
if( fScene.IsInModeling() ) {
G4cerr << "WARNING from FukuiRenderer (DAWN) driver:" << endl;
G4cerr << " You've invoked a drawing command before " << endl;
G4cerr << " completing your previous visualization." << endl;
// G4cerr << " You should have invoked command, /vis~/show/view," << endl;
// G4cerr << " to complete it." << endl;
FlushView();
}
//----- Begin Saving g4.prim file
fScene.BeginSavingG4Prim();
//----- drawing device
if( ( getenv( FR_ENV_MULTI_WINDOW ) != NULL ) && \
( strcmp( getenv( FR_ENV_MULTI_WINDOW ),"0" ) ) )
{
SendDevice( FRDEV_XWIN ) ;
} else {
SendDevice( FRDEV_PS ) ;
}
//----- drawing style
SendDrawingStyle() ;
//----- set view if necessary
SendViewParameters();
// Camera data should be sent at every time, even if
// the setting is unchanged at GEANT 4 side.
//----- Always visit G4 kernel
NeedKernelVisit ();
//----- Draw
ProcessView () ;
} // G4FukuiRendererView::DrawView ()
//----- G4FukuiRendererView::ShowView()
void G4FukuiRendererView::ShowView( void )
{
#if defined DEBUG_FR_VIEW
G4cerr << "***** G4FukuiRendererView::ShowView () " << endl;
#endif
if( fScene.IsInModeling() ) // if( fScene.flag_in_modeling )
{
//----- End of Data
fScene.FREndModeling();
//----- Draw all
fScene.SendStr( FR_DRAW_ALL );
//----- Close device
fScene.SendStr( FR_CLOSE_DEVICE );
//----- End saving data to g4.prim
fScene.EndSavingG4Prim() ;
//----- Wait user clicks drawing Area
this->Wait();
}
} // G4FukuiRendererView::ShowView()
//----- G4FukuiRendererView::FlushView()
void G4FukuiRendererView::FlushView( void )
{
#if defined DEBUG_FR_VIEW
G4cerr << "***** G4FukuiRendererView::Flush () " << endl;
#endif
if( fScene.IsInModeling() ) // if( fScene.flag_in_modeling )
{
//----- End of Data
fScene.FREndModeling();
//----- Draw all
fScene.SendStr( FR_DRAW_ALL );
//----- Close device
fScene.SendStr( FR_CLOSE_DEVICE );
//----- End saving data to g4.prim
fScene.EndSavingG4Prim() ;
}
} // G4FukuiRendererView::FlushView()
//----- G4FukuiRendererView::Wait()
void
G4FukuiRendererView::Wait()
{
#if defined DEBUG_FR_VIEW
G4cerr << "***** G4FukuiRendererView::Wait () " << endl;
#endif
fScene.SendStr ( FR_WAIT );
fScene.GetPrimDest().WaitSendBack( FR_WAIT );
#if defined DEBUG_FR_VIEW
G4cerr << "***** G4FukuiRendererView::Wait () : end" << endl;
#endif
}
//----- G4FukuiRendererView::SendDevice()
void
G4FukuiRendererView::SendDevice( FRDEV dev )
{
#if defined DEBUG_FR_VIEW
G4cerr << "***** G4FukuiRendererView::SendDevice() " << endl;
#endif
// enum {PS=1, XWIN=2, PS2=3, XWIN2=4, OPEN_GL=5, DEVICE_END=6};
if( dev >= FRDEV_PS || dev < FRDEV_DEVICE_END ) {
fScene.SendStrInt ( FR_DEVICE, dev );
}
}
//----- G4FukuiRendererView::SendDrawingStyle()
void G4FukuiRendererView::SendDrawingStyle()
{
#if defined DEBUG_FR_VIEW
G4cerr << "***** G4FukuiRendererView::SendDrawingStyle() " << endl;
#endif
G4int style = fVP.GetDrawingStyle();
switch( style )
{
case G4ViewParameters::wireframe:
fScene.SendStr( FR_WIREFRAME );
break;
case G4ViewParameters::hlr:
fScene.SendStr( FR_LINES );
break;
case G4ViewParameters::hsr:
case G4ViewParameters::hlhsr:
fScene.SendStr( FR_SURFACE );
break;
default:
fScene.SendStr( FR_WIREFRAME );
break;
}
} // G4FukuiRendererView::SendDrawingStyle()
//----- G4FukuiRendererView::SendViewParameters ()
void G4FukuiRendererView::SendViewParameters ()
{
// Calculates view representation based on extent of object being
// viewed and (initial) direction of camera. (Note: it can change
// later due to user interaction via visualization system's GUI.)
#if defined DEBUG_FR_VIEW
G4cerr << "***** G4FukuiRendererView::SendViewParameters()\n";
#endif
//----- Magic number to decide camera distance automatically
const G4double HOW_FAR = 1000.0 ; // to define "infinity"
const G4double MIN_HALF_ANGLE = 0.01 ;
const G4double MAX_HALF_ANGLE = 0.499 * M_PI ;
//----- Send Bounding Box
fScene.SendBoundingBox();
//----- (2A) CALC camera distance
//..... Note: Camera cannot enter inside object
G4double camera_distance ;
G4double radius = fScene.GetSceneData().GetExtent().GetExtentRadius();
G4double half_view_angle = fabs ( fVP.GetFieldHalfAngle () ) ;
if( half_view_angle > MAX_HALF_ANGLE ) {
half_view_angle = MAX_HALF_ANGLE ;
}
if( half_view_angle < MIN_HALF_ANGLE ) {
//----- infinity (or ortho projection)
camera_distance = radius * HOW_FAR ;
} else {
//----- Calc camera distance from half view angle
camera_distance = radius / sin ( half_view_angle );
camera_distance -= fVP.GetDolly();
}
if ( camera_distance < radius ) {
G4cerr << "WARNING from FukuiRenderer (DAWN) driver:" << endl;
G4cerr << " Camera cannot enter inside objects" << endl;
camera_distance = radius ;
}
//----- (3A) CALC camera direction
const G4Vector3D& camera_direction \
= fVP.GetViewpointDirection().unit();
const G4double v_angle = (180.0 / M_PI) * camera_direction.theta() ;
const G4double h_angle = (180.0 / M_PI) * camera_direction.phi () ;
//----- (2B), (3B) SEND camera position
fScene.SendStrDouble3( FR_CAMERA_POSITION,
camera_distance,
v_angle,
h_angle );
//----- (4A) CALC target point
const G4Point3D& target_point = fVP.GetCurrentTargetPoint();
//----- (4B) SEND target point
fScene.SendStrDouble3( FR_TARGET_POINT,
target_point.x(),
target_point.y(),
target_point.z() );
//----- (5A) CALC zoom factor
const G4double zoom_factor = fVP.GetZoomFactor();
//----- (5B) SEND zoom factor or focal length
if( half_view_angle < MIN_HALF_ANGLE ) {
const G4Point3D& std_target_point \
= fScene.GetSceneData().GetStandardTargetPoint();
fScene.SendStrDouble4( FR_ZOOM_FACTOR,
zoom_factor ,
std_target_point.x(),
std_target_point.y(),
std_target_point.z());
// Note that target point, camera position,
// and bounding box have already been sent above.
// The std_target_point is necessary to
// Calc focal distance from the zoom factor.
} else {
const G4double FR_HALF_SCREEN_SIZE = 0.5 ;
G4double focal_distance \
= FR_HALF_SCREEN_SIZE / tan( half_view_angle );
focal_distance *= zoom_factor ;
fScene.SendStrDouble ( FR_FOCAL_DISTANCE, focal_distance );
}
//----- INVOKE GUI: not executed in the default setting
if( fScene.GetSystem().IsGUIMode() ) {
//----- send GUI command
fScene.SendStr( FR_GUI );
//----- wait the same command is sent back:
//..... This avoids to send many data before
//..... GUI session is over.
fScene.GetPrimDest().WaitSendBack( FR_GUI );
}
//----- SET CAMERA
fScene.SendStr( FR_SET_CAMERA );
} // G4FukuiRendererView::SendViewParameters ()
#endif // G4VIS_BUILD_DAWN_DRIVER
+37
View File
@@ -0,0 +1,37 @@
# $Id: GNUmakefile,v 2.4 1998/11/25 16:19:32 allison Exp $
name := G4Ray
ifndef G4INSTALL
G4INSTALL = ../../..
endif
include $(G4INSTALL)/config/architecture.gmk
include $(G4INSTALL)/config/G4VIS_BUILD.gmk
include $(G4INSTALL)/config/interactivity.gmk
CPPFLAGS += -I$(G4BASE)/visualization/management/include
CPPFLAGS += -I$(G4BASE)/visualization/modeling/include
CPPFLAGS += -I$(G4BASE)/global/management/include
CPPFLAGS += -I$(G4BASE)/global/HEPRandom/include
CPPFLAGS += -I$(G4BASE)/global/HEPGeometry/include
CPPFLAGS += -I$(G4BASE)/geometry/management/include
CPPFLAGS += -I$(G4BASE)/geometry/volumes/include
CPPFLAGS += -I$(G4BASE)/geometry/solids/CSG/include
CPPFLAGS += -I$(G4BASE)/event/include
CPPFLAGS += -I$(G4BASE)/processes/management/include
CPPFLAGS += -I$(G4BASE)/processes/electromagnetic/utils/include
CPPFLAGS += -I$(G4BASE)/materials/include
CPPFLAGS += -I$(G4BASE)/particles/management/include
CPPFLAGS += -I$(G4BASE)/graphics_reps/include
CPPFLAGS += -I$(G4BASE)/intercoms/include
CPPFLAGS += -I$(G4BASE)/tracking/include
CPPFLAGS += -I$(G4BASE)/track/include
CPPFLAGS += -I$(G4BASE)/digits+hits/detector/include
CPPFLAGS += -I$(G4BASE)/digits+hits/hits/include
CPPFLAGS += -I$(G4BASE)/digits+hits/digits/include
CPPFLAGS += -I$(G4BASE)/run/include
CPPFLAGS += $(X11FLAGS)
include $(G4INSTALL)/config/common.gmk
@@ -0,0 +1,72 @@
// 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: G4OwnColormapXView.hh,v 2.1 1998/10/23 17:58:21 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// John Allison 1st June 1997
// Loosely based on G4OpenGLXView by Andrew Walkden 7th February 1997
// G4OwnColormapXView : Class to provide X Windows with its own colormap
// for a GEANT4 view. The derived view must define the colormap.
#ifdef G4VIS_BUILD_RAYX_DRIVER
#ifndef G4OWNCOLORMAPXVIEW_HH
#define G4OWNCOLORMAPXVIEW_HH
#include "G4VView.hh"
#include <X11/Xlib.h>
#include <X11/Intrinsic.h>
class G4VScene;
class G4OwnColormapXView: virtual public G4VView {
public:
G4OwnColormapXView (G4VScene& scene);
~G4OwnColormapXView ();
void ClearView ();
void FinishView ();
protected:
char* fcharViewName;
Display* fpDisplay;
int fScreen;
int fDepth;
G4String fVisualName;
G4bool fTrueColor;
Visual* fpVisual;
int fMapEntries;
Window fRootW;
int fRedShift;
int fGreenShift;
int fBlueShift;
float fRedMax;
float fGreenMax;
float fBlueMax;
Colormap fColormap;
XWindowAttributes fRootWA;
GC fGC;
XSetWindowAttributes fSWA;
Window fWindow;
XTextProperty fWindowName;
XTextProperty fIconName;
XSizeHints* fSize_hints;
XWMHints* fWM_hints;
XClassHint* fClass_hints;
XWindowAttributes fWA;
int fWidth;
int fHeight;
Pixmap fIcon_pixmap;
XEvent fEvent;
};
#endif
#endif
@@ -0,0 +1,43 @@
// 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: G4RayMessenger.hh,v 2.2 1998/07/12 03:44:31 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// GEANT4 Ray tracing Messenger - John Allison 5th June 1997
#ifndef G4RAYMESSENGER_HH
#define G4RAYMESSENGER_HH
#include "G4UImessenger.hh"
#include "globals.hh"
class G4RayX;
class G4RayScene;
class G4RayView;
class G4UIcommand;
class G4RayMessenger: public G4UImessenger {
public:
G4RayMessenger ();
~G4RayMessenger ();
void SetNewValue (G4UIcommand* command, G4String newValues);
G4String GetCurrentValue (G4UIcommand* command);
void RegisterScene (G4RayScene* pScene);
void RegisterView (G4RayView* pView);
private:
G4RayScene* fpScene;
G4RayView* fpView;
G4UIcommand* fpVisRayCommandDirectory;
G4UIcommand* fpResolutionCommand;
};
#include "G4RayMessenger.icc"
#endif
@@ -0,0 +1,20 @@
// 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: G4RayMessenger.icc,v 2.0 1998/07/02 16:42:42 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// GEANT4 Ray tracing Messenger - John Allison 5th June 1997
inline void G4RayMessenger::RegisterScene (G4RayScene* pScene) {
fpScene = pScene;
}
inline void G4RayMessenger::RegisterView (G4RayView* pView) {
fpView = pView;
}
@@ -0,0 +1,36 @@
// 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: G4RayPrimaryGeneratorAction.hh,v 2.1 1998/07/12 03:09:19 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef G4RayPrimaryGeneratorAction_h
#define G4RayPrimaryGeneratorAction_h 1
#include "G4VUserPrimaryGeneratorAction.hh"
class G4ParticleGun;
class G4Event;
class G4RayPrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
{
public:
G4RayPrimaryGeneratorAction();
~G4RayPrimaryGeneratorAction();
public:
void GeneratePrimaries(G4Event* anEvent);
G4ParticleGun* GetParticleGun();
private:
G4ParticleGun* particleGun;
};
#endif
@@ -0,0 +1,52 @@
// 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: G4RayScene.hh,v 2.2 1998/11/06 13:41:50 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Nikos Savvas 1st June 1997
// GEANT4 Ray Tracing scene.
#ifndef G4RAYSCENE_HH
#define G4RAYSCENE_HH
#include "G4VScene.hh"
class G4RayScene: public G4VScene {
public:
G4RayScene (G4VGraphicsSystem& system, const G4String& name = "");
~G4RayScene ();
static G4int GetSceneCount ();
// The following functions don't make sense for G4Ray...
void AddPrimitive (const G4Polyline&);
void AddPrimitive (const G4Text&);
void AddPrimitive (const G4Circle&);
void AddPrimitive (const G4Square&);
void AddPrimitive (const G4Polymarker&);
void AddPrimitive (const G4Polyhedron&);
void AddPrimitive (const G4NURBS&);
void AddThis (const G4Box&);
void AddThis (const G4Cons&);
void AddThis (const G4Tubs&);
void AddThis (const G4Trd&);
void AddThis (const G4Trap&);
void AddThis (const G4Sphere&);
void AddThis (const G4Para&);
void AddThis (const G4Torus&);
void AddThis (const G4VSolid&);
private:
static G4int fSceneIdCount; // static counter for Ray scenes.
static G4int fSceneCount; // No. of extanct scenes.
};
#include "G4RayScene.icc"
#endif
@@ -0,0 +1,53 @@
// 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: G4RayScene.icc,v 2.1 1998/08/07 08:17:02 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Nikos Savvas 1st June 1997
// GEANT4 Ray Tracing scene.
inline void G4RayScene::AddThis (const G4Box& box) {
G4VScene::AddThis (box);
}
inline void G4RayScene::AddThis (const G4Cons& cons) {
G4VScene::AddThis (cons);
}
inline void G4RayScene::AddThis (const G4Tubs& tubs) {
G4VScene::AddThis (tubs);
}
inline void G4RayScene::AddThis (const G4Trd& trd) {
G4VScene::AddThis (trd);
}
inline void G4RayScene::AddThis (const G4Trap& trap) {
G4VScene::AddThis (trap);
}
inline void G4RayScene::AddThis (const G4Sphere& sphere) {
G4VScene::AddThis (sphere);
}
inline void G4RayScene::AddThis (const G4Para& para) {
G4VScene::AddThis (para);
}
inline void G4RayScene::AddThis (const G4Torus& torus) {
G4VScene::AddThis (torus);
}
inline void G4RayScene::AddThis (const G4VSolid& vsolid) {
G4VScene::AddThis (vsolid);
}
inline void G4RayScene::AddPrimitive (const G4Polymarker& polymarker) {
G4VScene::AddPrimitive (polymarker);
}
@@ -0,0 +1,40 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4RaySteppingAction.hh,v 2.0 1998/07/02 16:42:50 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// 16/Apr/1997 J. Allison: For visualization/test/test19.
// moved here and renamed 14/April/1997
#ifndef MYSTEPPINGACTION_HH
#define MYSTEPPINGACTION_HH
#include "G4UserSteppingAction.hh"
#include "G4Normal3D.hh"
class G4RaySteppingAction: public G4UserSteppingAction {
public:
G4RaySteppingAction();
void UserSteppingAction();
G4bool WeHaveContact () const {return weHaveContact;}
G4Normal3D GetSurfaceNormal () const {return normal;}
const G4VisAttributes* GetVisAttributes () const {return pVisAttribs;}
G4VPhysicalVolume* GetPhysicalVolume () const {return pVPV;}
G4LogicalVolume* GetLogicalVolume () const {return pLV;}
G4VSolid* GetSolid () const {return pSol;}
private:
G4bool weHaveContact;
G4Normal3D normal;
const G4VisAttributes* pVisAttribs;
G4VPhysicalVolume* pVPV;
G4LogicalVolume* pLV;
G4VSolid* pSol;
};
#endif
@@ -0,0 +1,168 @@
// 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: G4RayView.hh,v 2.2 1998/11/06 13:41:51 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Nikos Savvas 1st June 1997
// GEANT4 Ray Tracing view.
#include "G4RunManager.hh"
#include "G4RaySteppingAction.hh"
#include "G4RayPrimaryGeneratorAction.hh"
#ifndef G4RAYVIEW_HH
#define G4RAYVIEW_HH
#include "G4VView.hh"
#include "G4Colour.hh"
#include "G4VPhysicalVolume.hh"
#include <rw/tvordvec.h>
#include <rw/tvhdict.h>
class G4RayScene;
class G4RaySteppingAction;
class G4RayColourCell {
public:
G4RayColourCell (): red (0), green (0), blue (0), nHits (0) {}
G4RayColourCell (float rr, float gg, float bb, G4int ii):
red (rr), green (gg), blue (bb), nHits (ii) {}
float red, green, blue;
G4int nHits; // No. of ray hits using this colour.
G4bool operator == (const G4RayColourCell& h) const {
return this == &h;
}
};
class G4RayCoordinate {
public:
G4RayCoordinate (): coord (0) {}
G4RayCoordinate (G4double x, G4double y):
coord (((unsigned int) (0x7fff * (x + 1.0))) |
((unsigned int) (0x7fff * (1.0 - y)) << 16)) {}
// Assumes -1.0 <= x, y <= 1.0. Assigns 16 bits each.
unsigned int coord;
G4bool operator == (const G4RayCoordinate& c) const {
return coord == c.coord;
}
};
class G4RayHitColour {
public:
G4RayHitColour (): colour (0) {}
G4RayHitColour (float r, float g, float b):
colour ((((unsigned int) (0x3ff * r)) << 20) |
(((unsigned int) (0x3ff * g)) << 10) |
((unsigned int) (0x3ff * b))) {}
// Assumes 0.0 <= r, g, b <= 1.0. Assigns 10 bits each.
unsigned int colour;
G4bool operator == (const G4RayHitColour& h) const {
return colour == h.colour;
}
float GetRed () {return (float ((colour >> 20) )) / 0x3ff;}
float GetGreen () {return (float ((colour >> 10) & 0x3ff)) / 0x3ff;}
float GetBlue () {return (float ((colour ) & 0x3ff)) / 0x3ff;}
};
class G4RayView: virtual public G4VView {
public:
G4RayView (G4RayScene& scene, const G4String& name = "");
~G4RayView();
G4double GetResolution () const;
void SetResolution (G4double resolution);
protected:
void SetView ();
void InitialiseImage ();
void TriggerRedraw ();
G4bool Scan (int& i, int& j, int& k,
float& red, float& green, float& blue,
int& iPixVal);
// Iterate over window, return false when finished. Return i, j,
// and k which define a coloured Square of side k whose upper left
// corner is (i, j). Note origin is at upper left corner of window
// - X and PostScript convention. iPixVal is the pixel value for
// this colour, i.e., the key in fRayHitColourIndex.
// The following static members define an image. They are static so
// that (a) there is only ever one of them (they can take a lot of
// memory) and (b) any object of the class or its descendants can
// access it. It is *not* cleared by ClearView (). It is only
// cleared by a change of view parameters and some other crucial
// parameters. It can be progressively refined by multiple calls to
// DrawView.
static G4ViewParameters fImageViewParameters;
static G4double fInitialResolution;
static G4double fRequestedResolution;
static G4double fCurrentResolution;
static G4float fMaxMinColourSeparation;
static G4int fImageWidth, fImageHeight;
static G4int fMaxImageMapEntries;
static G4bool fImageMapRejigged;
static G4bool fTriggerRescan;
static G4int fWaitLimit; // Waits between refresh.
static G4int fWaitCount;
static RWTValOrderedVector <G4RayColourCell> fRayHitColourMap;
static RWTValHashDictionary <G4RayCoordinate, G4RayHitColour> fRayHits;
static unsigned int RayCoordHash (const G4RayCoordinate& rayCoord);
static RWTValHashDictionary <G4RayHitColour, G4int> fRayHitColourIndex;
static unsigned int RayColourHash (const G4RayHitColour& rayColour);
private:
void Trace (G4double x, G4double y, float& red, float& green, float& blue);
// Trace the ray from (x, y) in screen coordinates (-1 <= x,y <= 1)
// and fill colour.
void CompactColour (G4bool Print);
float ColourSeparation (float ri, float gi, float bi,
float rj, float gj, float bj);
static void ChangePixVals (const G4RayHitColour& colour,
G4int& index, void* ij);
static void DecrementPixVals (const G4RayHitColour& colour,
G4int& index, void* ij);
static void PrintPixVals (const G4RayHitColour& colour,
G4int& index, void* ij);
G4RayScene& fScene; // Graphics Scene for this view.
G4Vector3D fXprime;
G4Vector3D fYprime;
G4Point3D fCenterofscreen;
G4Point3D fCamerapoint;
G4RunManager* fG4RayRunManager ;
G4RaySteppingAction* fG4RaySteppingAction;
G4RayPrimaryGeneratorAction* fG4RayGenerator;
G4ParticleGun * fG4RayGun ;
G4VPhysicalVolume * fpWorld;
};
#include "G4RayView.icc"
#endif
@@ -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: G4RayView.icc,v 2.0 1998/07/02 16:42:54 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Nikos Savvas 1st June 1997
// GEANT4 Ray Tracing view.
inline G4double G4RayView::GetResolution () const {
return fRequestedResolution;
}
inline void G4RayView::SetResolution (G4double resolution) {
fRequestedResolution = resolution;
}
inline unsigned int G4RayView::RayCoordHash
(const G4RayCoordinate& rayCoord) {
return rayCoord.coord;
}
inline unsigned int G4RayView::RayColourHash
(const G4RayHitColour& rayColour) {
return rayColour.colour;
}
@@ -0,0 +1,37 @@
// 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: G4RayX.hh,v 2.1 1998/11/06 13:41:52 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Nikos Savvas 1st June 1997
// GEANT4 Ray Tracing graphics system factory.
#if defined (G4VIS_BUILD_RAYX_DRIVER) || defined (G4VIS_USE_RAYX)
#ifndef G4RAYX_HH
#define G4RAYX_HH
#include "G4VGraphicsSystem.hh"
class G4RayXMessenger;
class G4RayX: public G4VGraphicsSystem {
public:
G4RayX ();
~G4RayX ();
G4VScene* CreateScene (const G4String& name = "");
G4VView* CreateView (G4VScene&, const G4String& name = "");
private:
static G4int fInstances;
G4RayXMessenger* fpMessenger; // Pointer to messenger.
};
#endif
#endif
@@ -0,0 +1,36 @@
// 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: G4RayXMessenger.hh,v 2.2 1998/07/12 03:44:33 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// GEANT4 Ray tracing for X windows Messenger - John Allison 5th June 1997
#ifdef G4VIS_BUILD_RAYX_DRIVER
#ifndef G4RAYXMESSENGER_HH
#define G4RAYXMESSENGER_HH
#include "G4RayMessenger.hh"
class G4RayX;
class G4UIcommand;
class G4RayXMessenger: public G4RayMessenger {
public:
G4RayXMessenger (G4RayX* pRayX);
~G4RayXMessenger ();
void SetNewValue (G4UIcommand* command, G4String newValues);
G4String GetCurrentValue (G4UIcommand* command);
private:
G4RayX* fpRayX;
};
#endif
#endif
@@ -0,0 +1,46 @@
// 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: G4RayXView.hh,v 2.1 1998/11/06 13:41:53 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Nikos Savvas 1st June 1997
// GEANT4 Ray Tracing X window view.
#ifdef G4VIS_BUILD_RAYX_DRIVER
#ifndef G4RAYXVIEW_HH
#define G4RAYXVIEW_HH
#include "G4RayView.hh"
#include "G4OwnColormapXView.hh"
class G4RayScene;
class G4RayXView: public G4RayView, public G4OwnColormapXView {
public:
G4RayXView (G4RayScene& scene, const G4String& name = "");
void DrawView ();
private:
int ncells;
/*****************************
// An RGB map for now
int red_max;
int green_max;
int blue_max;
int red_mult;
int green_mult;
int blue_mult;
********************************/
};
#endif
#endif
@@ -0,0 +1,245 @@
// 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: G4OwnColormapXView.cc,v 2.4 1998/10/23 17:58:22 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// John Allison 1st June 1997
// Loosely based on G4OpenGLXView by Andrew Walkden 7th February 1997
// G4OwnColormapXView : Class to provide X Windows with its own colormap
// for a GEANT4 view. The derived view must define the colormap.
#ifdef G4VIS_BUILD_RAYX_DRIVER
#include "G4OwnColormapXView.hh"
#include <X11/Xatom.h>
#include <X11/Xutil.h>
#include <iomanip.h>
#include <stdlib.h>
#include <string.h>
#define NewString(str) \
((str) != NULL ? (strcpy((char*)malloc((unsigned)strlen(str) + 1), str)) : (char*)NULL)
static Bool WaitForNotify (Display* d, XEvent* e, char* arg) {
return (e->type == MapNotify) && (e->xmap.window == (Window) arg);
}
G4OwnColormapXView::G4OwnColormapXView (G4VScene& scene):
G4VView (scene, -1),
fRedShift (0),
fGreenShift (0),
fBlueShift (0),
fRedMax (1),
fGreenMax (1),
fBlueMax (1)
{
fpDisplay = XOpenDisplay (0);
if (!fpDisplay) {
G4cerr << "G4OwnColormapXView::G4OwnColormapXView couldn't open display." << endl;
fViewId = -1; // This flags an error.
return;
}
fScreen = XDefaultScreen (fpDisplay);
fDepth = XDefaultDepth (fpDisplay, fScreen);
if (fDepth < 8) {
G4cerr << "G4OwnColormapXView::G4OwnColormapXView: too few pixel"
"\nplanes - need at least 8 for own colormap." << endl;
fViewId = -1; // This flags an error.
return;
}
XVisualInfo vinfo;
if (XMatchVisualInfo (fpDisplay, fScreen, fDepth, PseudoColor, &vinfo)) {
G4cout << "G4OwnColormapXView::G4OwnColormapXView: PseudoColor." << endl;
fVisualName = "PseudoColor";
fTrueColor = false;
}
else if
(XMatchVisualInfo (fpDisplay, fScreen, fDepth, DirectColor, &vinfo)) {
G4cout << "G4OwnColormapXView::G4OwnColormapXView: DirectColor." << endl;
fVisualName = "DirectColor";
fTrueColor = false;
}
else if
(XMatchVisualInfo (fpDisplay, fScreen, fDepth, TrueColor, &vinfo)) {
G4cout << "G4OwnColormapXView::G4OwnColormapXView: TrueColor." << endl;
fVisualName = "TrueColor";
fTrueColor = true;
}
else {
G4cerr << "G4OwnColormapXView::G4OwnColormapXView: neither a PseudoColor nor"
"\na DirectColor nor a TrueColor visual - needs to be one of these"
"\nfor own colormap."
<< endl;
fViewId = -1; // This flags an error.
return;
}
fpVisual = vinfo.visual;
if (!fpVisual) {
G4cerr << "G4OwnColormapXView::G4OwnColormapXView couldn't get a visual."
<< endl;
fViewId = -1; // This flags an error.
return;
}
fMapEntries = fpVisual -> map_entries;
fRootW = XRootWindow (fpDisplay, fScreen);
if (fTrueColor) {
// Set up parameters for masks etc.
unsigned long oneBit;
oneBit = 1;
while (!(fpVisual->red_mask & oneBit)) {oneBit <<= 1; fRedShift++;}
while (fpVisual->red_mask & oneBit) {oneBit <<= 1; fRedMax *= 2.;}
fRedMax -= 1.;
oneBit = 1;
while (!(fpVisual->green_mask & oneBit)) {oneBit <<= 1; fGreenShift++;}
while (fpVisual->green_mask & oneBit) {oneBit <<= 1; fGreenMax *= 2.;}
fGreenMax -= 1.;
oneBit = 1;
while (!(fpVisual->blue_mask & oneBit)) {oneBit <<= 1; fBlueShift++;}
while (fpVisual->blue_mask & oneBit) {oneBit <<= 1; fBlueMax *= 2.;}
fBlueMax -= 1.;
}
else {
// Own colour map.
fColormap = XCreateColormap (fpDisplay, fRootW, fpVisual, AllocAll);
if (!fColormap || fColormap == XDefaultColormap (fpDisplay, fScreen)) {
G4cerr << "G4OwnColormapXView::G4OwnColormapXView failed to create"
"\na own Colormap." << endl;
fViewId = -1; // This flags an error.
return;
}
}
fGC = XDefaultGC (fpDisplay, fScreen); // Graphics Context for XDraw...
XGetWindowAttributes (fpDisplay, fRootW, &fRootWA); // Get root window atts.
//Choose a preferred window size.
G4int requestWinSize_x;
G4int requestWinSize_y;
if (fRootWA.width > fRootWA.height) {
requestWinSize_x = (fRootWA.height)/2;
requestWinSize_y = (fRootWA.height)/2;
}
else {
requestWinSize_x = (fRootWA.width)/2;
requestWinSize_y = (fRootWA.width)/2;
}
if (requestWinSize_x < fVP.GetWindowSizeHintX ())
requestWinSize_x = fVP.GetWindowSizeHintX ();
if (requestWinSize_y < fVP.GetWindowSizeHintY ())
requestWinSize_y = fVP.GetWindowSizeHintY ();
// Choose an origin (the window manager will ignore it!)
G4int x_origin;
G4int y_origin;
x_origin = fRootWA.x;
y_origin = fRootWA.y;
if (!fTrueColor) {
fSWA.colormap = fColormap;
}
fSWA.background_pixel = 0;
fSWA.border_pixel = 0;
fSWA.event_mask = ExposureMask | ButtonPressMask | StructureNotifyMask;
fSWA.backing_store = WhenMapped;
unsigned int mask = CWBackPixel | CWBorderPixel |
CWEventMask | CWBackingStore;
if (!fTrueColor) mask = mask | CWColormap;
fWindow = XCreateWindow (fpDisplay, fRootW, x_origin,
y_origin, requestWinSize_x, requestWinSize_y, 0,
fDepth, InputOutput, fpVisual,
mask,
&fSWA);
G4cout << "Window name: " << fName << endl;
fcharViewName = new char [100];
strncpy (fcharViewName, fName, 100);
XStringListToTextProperty (&fcharViewName, 1, &fWindowName);
XStringListToTextProperty (&fcharViewName, 1, &fIconName);
fSize_hints = XAllocSizeHints();
fSize_hints -> flags = PPosition | PSize | PMinSize;
fSize_hints -> min_width = 300;
fSize_hints -> min_height = 300;
fWM_hints = XAllocWMHints();
fWM_hints -> initial_state = NormalState;
fWM_hints -> input = True;
fWM_hints -> icon_pixmap = fIcon_pixmap;
fWM_hints -> flags = StateHint | IconPixmapHint | InputHint;
fClass_hints = XAllocClassHint();
fClass_hints -> res_name = NewString("G4SimpleX");
fClass_hints -> res_class = NewString("G4SimpleX");
XSetWMProperties (fpDisplay, fWindow, &fWindowName, &fIconName, 0, 0,
fSize_hints, fWM_hints, fClass_hints);
// request X to Draw window on screen.
XMapWindow (fpDisplay, fWindow);
// Wait for window to appear (wait for an "expose" event).
XIfEvent (fpDisplay, &fEvent, WaitForNotify, (char*) fWindow);
XGetWindowAttributes (fpDisplay, fWindow, &fWA);
fWidth = fWA.width;
fHeight = fWA.height;
G4cout << "G4OwnColormapXView instantiated."
"\n A simple X window of visual type "
<< fVisualName
<< ",\n size " << fWidth << 'x' << fHeight << ", depth " << fDepth;
if (fTrueColor) {
G4cout << "\nRed shift : " << setw(2) << fRedShift
<< ", red max : " << fRedMax;
G4cout << "\nGreen shift: " << setw(2) << fGreenShift
<< ", green max: " << fGreenMax;
G4cout << "\nBlue shift : " << setw(2) << fBlueShift
<< ", blue max : " << fBlueMax;
}
else {
G4cout << ",\n with " << fMapEntries << " colormap entries";
}
G4cout << ", has been opened." << endl;
}
G4OwnColormapXView::~G4OwnColormapXView () {
if (fViewId >= 0) {
XFree (fSize_hints);
XFree (fWM_hints);
if(fClass_hints -> res_name!=NULL) free(fClass_hints -> res_name);
if(fClass_hints -> res_class!=NULL) free(fClass_hints -> res_class);
XFree (fClass_hints);
//Close a window from here
XUnmapWindow (fpDisplay, fWindow);
XDestroyWindow (fpDisplay, fWindow);
}
if (fpDisplay) {
XFlush (fpDisplay);
XCloseDisplay (fpDisplay);
}
}
void G4OwnColormapXView::ClearView () {
XClearWindow (fpDisplay, fWindow);
}
void G4OwnColormapXView::FinishView () {
XFlush (fpDisplay);
}
#endif
@@ -0,0 +1,85 @@
// 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: G4RayMessenger.cc,v 2.4 1998/07/13 17:11:10 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// GEANT4 Ray tracing for X windows Messenger - John Allison 5th June 1997
#include "G4RayMessenger.hh"
#include "G4RayScene.hh"
#include "G4RayView.hh"
#include "G4UImanager.hh"
#include "G4UIcommand.hh"
#include "G4UIparameter.hh"
G4RayMessenger::G4RayMessenger ():
fpScene (0),
fpView (0)
{
G4UIcommand* command;
G4UIparameter* param;
///////////////////////////////////////////////// /vis~/ray/... ////
//vis \hline
//vis /vis~/ray/ &&
//vis ...menu of ray tracing commands. \\%
command = new G4UIcommand ("/vis~/ray/", this);
command -> SetGuidance ("GEANT4 Ray Tracing");
fpVisRayCommandDirectory = command;
///////////////////////////////////////////////// /vis~/ray/resolution ////
//vis \hline
//vis /vis~/ray/resolution/ & resolution &
//vis Set resolution in pixels. A resolution less than 1 causes
//vis over-sampling which improves the appearance and avoids random
//vis spots and staircase effects (aliasing). \\%
command = new G4UIcommand ("/vis~/ray/resolution", this);
command -> SetGuidance
("Set resolution in pixels. A resolution less than 1 causes"
"\nover-sampling which improves the appearance and avoids random"
"\nspots and staircase effects (aliasing)."
);
param = new G4UIparameter ("resolution", 'd', true);
param -> SetDefaultValue (-1);
command -> SetParameter (param);
fpResolutionCommand = command;
}
G4RayMessenger::~G4RayMessenger () {
delete fpResolutionCommand;
delete fpVisRayCommandDirectory;
}
void G4RayMessenger::SetNewValue (G4UIcommand* command, G4String newValues)
{
///////////////////////////////////////////////// /vis~/ray/resolution ////
if (command == fpResolutionCommand) {
G4double resolution;
const char* t = newValues;
istrstream is ((char*)t); is >> resolution;
if (resolution < 0) {
G4cout << "Resolution is currently "
<< fpView -> GetResolution ()
<< "\nSupply required resolution as argument."
<< endl;
}
else {
fpView -> SetResolution (resolution);
G4cout << "Resolution is now "
<< fpView -> GetResolution ()
<< endl;
}
}
}
G4String G4RayMessenger::GetCurrentValue (G4UIcommand* command) {
return "";
}
@@ -0,0 +1,60 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4RayPrimaryGeneratorAction.cc,v 2.2 1998/08/05 12:53:43 barrand Exp $
// GEANT4 tag $Name: geant4-00 $
//
#include "G4RayPrimaryGeneratorAction.hh"
#include "G4Event.hh"
#include "G4ParticleGun.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
#include "globals.hh"
G4RayPrimaryGeneratorAction::G4RayPrimaryGeneratorAction()
{
G4int n_particle = 1;
particleGun = new G4ParticleGun(n_particle);
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
G4String particleName;
G4ParticleDefinition* particle
= particleTable->FindParticle(particleName="geantino");
particleGun->SetParticleDefinition(particle);
particleGun->SetParticleMomentumDirection(G4ThreeVector(0.,1.,0.));
particleGun->SetParticleEnergy(100.*GeV);
particleGun->SetParticlePosition(G4ThreeVector(0.*cm,-300.*cm,0.*cm));
}
G4RayPrimaryGeneratorAction::~G4RayPrimaryGeneratorAction()
{
delete particleGun;
}
void G4RayPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
/***************************** Moved to constructor.
*************************** Change with ParticleGunMessenger.
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
G4String particleName;
G4ParticleDefinition* particle
= particleTable->FindParticle(particleName="geantino");
particleGun->SetParticleDefinition(particle);
particleGun->SetParticleMomentumDirection(G4ThreeVector(0.,1.,0.));
particleGun->SetParticleEnergy(100.*GeV);
particleGun->SetParticlePosition(G4ThreeVector(0.*cm,-300.*cm,0.*cm));
********************************/
particleGun->GeneratePrimaryVertex(anEvent);
}
G4ParticleGun* G4RayPrimaryGeneratorAction::GetParticleGun()
{
return particleGun;
}
@@ -0,0 +1,101 @@
// 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: G4RayScene.cc,v 2.3 1998/11/06 13:41:55 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Nikos Savvas 1st June 1997
// GEANT4 Ray Tracing scene.
#include "G4RayScene.hh"
G4RayScene::G4RayScene (G4VGraphicsSystem& system,
const G4String& name):
G4VScene (system, fSceneIdCount++, name)
{
fSceneCount++;
}
G4RayScene::~G4RayScene ()
{
fSceneCount--;
}
G4int G4RayScene::GetSceneCount () {
return fSceneCount;
}
void G4RayScene::AddPrimitive (const G4Polyline&) {
static G4bool warned = false;
if (!warned) {
warned = true;
G4cout << "***WARNING***" << endl;
G4cout << " void G4RayScene::AddPrimitive (const G4Polyline&) called."
<< " \nG4Ray cannot handle polylines."
<< endl;
}
}
void G4RayScene::AddPrimitive (const G4Text&) {
static G4bool warned = false;
if (!warned) {
warned = true;
G4cout << "***WARNING***" << endl;
G4cout << " void G4RayScene::AddPrimitive (const G4Text&) called."
<< " \nG4Ray cannot handle text."
<< endl;
}
}
void G4RayScene::AddPrimitive (const G4Circle&) {
static G4bool warned = false;
if (!warned) {
warned = true;
G4cout << "***WARNING***" << endl;
G4cout << " void G4RayScene::AddPrimitive (const G4Circle&) called."
<< " \nG4Ray cannot handle markers."
<< endl;
}
}
void G4RayScene::AddPrimitive (const G4Square&) {
static G4bool warned = false;
if (!warned) {
warned = true;
G4cout << "***WARNING***" << endl;
G4cout << " void G4RayScene::AddPrimitive (const G4Square&) called."
<< " \nG4Ray cannot handle markers."
<< endl;
}
}
void G4RayScene::AddPrimitive (const G4Polyhedron&) {
static G4bool warned = false;
if (!warned) {
warned = true;
G4cout << "***WARNING***" << endl;
G4cout << "void G4RayScene::AddPrimitive (const G4Polyhedron&) called."
<< " \nG4Ray cannot handle polyhedra."
<< endl;
}
}
void G4RayScene::AddPrimitive (const G4NURBS&) {
static G4bool warned = false;
if (!warned) {
warned = true;
G4cout << "***WARNING***" << endl;
G4cout << "void G4RayScene::AddPrimitive (const G4NURBS&) called."
<< " \nG4Ray cannot handle NURBS."
<< endl;
}
}
G4int G4RayScene::fSceneIdCount = 0;
G4int G4RayScene::fSceneCount = 0;
@@ -0,0 +1,109 @@
// 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: G4RaySteppingAction.cc,v 2.1 1998/07/13 17:11:12 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// 16/Apr/1997 J. Allison: For visualization/test/test19.
#include "G4RaySteppingAction.hh"
#include "G4SteppingManager.hh"
#include "G4ParticleDefinition.hh"
#include "G4VVisManager.hh"
#include "G4VisAttributes.hh"
#include "G4Colour.hh"
#include "G4Polyline.hh"
#include "G4Point3D.hh"
#include "G4Vector3D.hh"
G4RaySteppingAction::G4RaySteppingAction() : weHaveContact(false), pVisAttribs(0){}
void G4RaySteppingAction::UserSteppingAction() {
G4Step* piStep = GetSteppingManager () -> GetStep ();
// G4cout <<"G4Step* piStep: "<< (void *) piStep << endl;
G4Track* pTrack = piStep -> GetTrack();
//G4cout << "G4Track* pTrack: "<<(void *) pTrack << endl;
pVPV = pTrack -> GetNextVolume();
//G4cout << "G4VPhysicalVolume* pVPV: "<<(void *) pVPV << endl;
if (pVPV) {
weHaveContact = true;
pLV = pVPV -> GetLogicalVolume();
//G4cout <<"G4LogicalVolume* pLV: "<< (void *) pLV << endl;
pSol = pLV -> GetSolid();
//G4cout <<"G4VSolid* pSol: "<< (void *) pSol << endl;
G4Point3D point = piStep -> GetPostStepPoint () -> GetPosition ();
//G4cout << "Point: " << point << endl;
G4Vector3D translation = pVPV -> GetTranslation();
G4RotationMatrix* rotation = pVPV -> GetRotation();
if (rotation) {
point.transform(G4Transform3D(*rotation, -translation));
}
else {
point.transform(G4Translate3D(-translation));
}
//G4cout << "Point after transformation: " << point << endl;
normal = pSol -> SurfaceNormal(point);
//G4cout << "normal: " << normal << endl;
pVisAttribs = pLV -> GetVisAttributes ();
//G4cout << "Vis attributes: " << *pVisAttribs << endl;
}
else {
weHaveContact = false;
}
pTrack -> SetTrackStatus(fStopAndKill);
}
+783
View File
@@ -0,0 +1,783 @@
// 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: G4RayView.cc,v 2.9 1998/11/06 13:41:56 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Nikos Savvas 1st June 1997
// GEANT4 Ray Tracing view.
#include "G4RayView.hh"
#include "G4RayScene.hh"
#include "G4ParticleGun.hh"
#include "G4TransportationManager.hh"
#include "geomdefs.hh"
#include "G4VSolid.hh"
#include <math.h>
#ifdef GNU_GCC
template class RWTValHashDictionary <G4RayCoordinate, G4RayHitColour>;
template class RWTValHashDictionary <G4RayHitColour, G4int>;
#endif
G4RayView::G4RayView (G4RayScene& scene, const G4String& name):
G4VView (scene, -1, name),
fScene (scene),
fpWorld (0)
{
//RUN MANAGER
fG4RayRunManager = new G4RunManager;
//G4RaySteppingAction
fG4RaySteppingAction = new G4RaySteppingAction;
//Gun
fG4RayGenerator = new G4RayPrimaryGeneratorAction;
fG4RayRunManager -> SetUserAction ( fG4RayGenerator );
fG4RayRunManager -> SetUserAction ( fG4RaySteppingAction);
fG4RayGun = fG4RayGenerator -> GetParticleGun();
}
G4RayView::~G4RayView(){
delete fG4RayRunManager;
// Note: G4RunManager deletes userPrimaryGeneratorAction, what we
// have called fG4RayGenerator). And G4SteppingManager deletes
// fUserSteppingAction, what we have called fG4RaySteppingAction
}
void G4RayView::SetView () {
fpWorld = G4TransportationManager::GetTransportationManager ()
-> GetNavigatorForTracking () -> GetWorldVolume ();
// We need to know the world so we can be sure to start traceing inside.
if (!fpWorld) {
G4Exception ("G4RayView::SetView: no world established yet!");
}
// VECTORS
const G4Vector3D& viewvector = fVP.GetViewpointDirection().unit();
// view vector on the line from the target point to the eye-- view
// point direction
const G4Vector3D& upvector = fVP.GetUpVector().unit(); // the up vector of the volume
const G4Vector3D& lightDirection = fVP.GetActualLightpointDirection().unit();
// vector of incident light
// DOUBLES
G4double radius = fScene.GetSceneData ().GetExtent ().GetExtentRadius ();
//radius of the bounding sphere.
G4double cameradistance = fVP.GetCameraDistance (radius);
// from the center of the bounding sphere to the camera.
G4double johnsneardistance = fVP.GetNearDistance (cameradistance, radius);
G4double halfheight = fVP.GetFrontHalfHeight (johnsneardistance, radius);
// half the size of the front view plane (screen)
// xprime ,yprime, zprime define the screen coordinate system.
G4Vector3D zprime = viewvector.unit();
G4Vector3D xprime = (upvector.cross(viewvector)).unit();
G4Vector3D yprime = (zprime.cross(xprime)).unit();
// Make xprime and yprime have lengths equal to halfheight so that
// they can be multplied by a screen coordinate in the range -1 to
// +1.
fXprime = halfheight * xprime;
fYprime = halfheight * yprime;
// POINTS
const G4Point3D& centeroftarget = fVP.GetCurrentTargetPoint ();// the center of target
//fCenterofscreen = centeroftarget + radius * viewvector.unit();
fCamerapoint = centeroftarget + cameradistance * viewvector.unit();
fCenterofscreen = fCamerapoint - johnsneardistance * viewvector.unit();
G4cout << " The viewvector is : " << viewvector<<endl;
G4cout << " The lightDirection is : " << lightDirection << endl;
G4cout << " The cameraDistance is: " << cameradistance << endl;
G4cout << " fCamerapoint is : " << fCamerapoint << endl;
G4cout << " fCenterofscreen is : " << fCenterofscreen << endl;
G4cout << " centeroftarget is : " << centeroftarget << endl;
}
G4ViewParameters G4RayView::fImageViewParameters;
G4double G4RayView::fInitialResolution = 27.;
G4double G4RayView::fRequestedResolution = 27.;
G4double G4RayView::fCurrentResolution = 27.;
G4float G4RayView::fMaxMinColourSeparation = 0.;
G4int G4RayView::fImageWidth = 0;
G4int G4RayView::fImageHeight = 0;
G4int G4RayView::fMaxImageMapEntries = 0;
G4bool G4RayView::fImageMapRejigged = true;
G4bool G4RayView::fTriggerRescan = true;
G4int G4RayView::fWaitLimit = 200;
G4int G4RayView::fWaitCount = 200;
RWTValOrderedVector <G4RayColourCell>
G4RayView::fRayHitColourMap (256);
RWTValHashDictionary <G4RayCoordinate, G4RayHitColour>
G4RayView::fRayHits (G4RayView::RayCoordHash, 1000);
RWTValHashDictionary <G4RayHitColour, G4int>
G4RayView::fRayHitColourIndex (G4RayView::RayColourHash, 1000);
void G4RayView::InitialiseImage () {
fRayHitColourMap.clear ();
fRayHits.clear ();
fMaxMinColourSeparation = 0.;
fInitialResolution = 27;
fCurrentResolution = fInitialResolution;
fRequestedResolution = fInitialResolution;
G4cout << "Requested resolution reset to " << fRequestedResolution << endl;
fWaitLimit = 200;
G4cout << "Wait limit reset to: " << fWaitLimit
<< "\n(e.g, display refreshed every this many rays traced.)"
<< endl;
TriggerRedraw ();
}
void G4RayView::TriggerRedraw () {
fImageMapRejigged = true;
fTriggerRescan = true;
fWaitCount = fWaitLimit;
}
G4bool G4RayView::Scan (int& i, int& j, int& k,
float& red, float& green, float& blue,
int& iPixVal) {
static G4bool Done = true;
static G4bool nearlyDone;
static G4double cellSize;
static G4int requestedNoOfRays;
static G4int doneCount;
static G4int u, v;
if (Done) { // Assume called anew.
if (fRequestedResolution < 1.0) {
G4cout <<
"Over-sampling not implemented - resetting requested resolution to 1."
<< endl;
fRequestedResolution = 1.;
}
Done = false;
nearlyDone = false;
requestedNoOfRays = (int)
((((fImageWidth - 1) / fRequestedResolution) + 1) *
(((fImageHeight - 1) / fRequestedResolution) + 1));
doneCount = 1;
cellSize = fInitialResolution;
u = v = 0;
if (fCurrentResolution >= 3 * fRequestedResolution) {
G4cout << "Resizing Ray Hits Dictionaries - " << requestedNoOfRays
<< " buckets." << endl;
fRayHits.resize (requestedNoOfRays);
fRayHitColourIndex.resize (requestedNoOfRays);
G4cout << "Continuing..." << endl;
}
}
if (fTriggerRescan) {
fTriggerRescan = false;
cellSize = 3 * cellSize;
u = v = 0;
}
if (fRayHitColourMap.entries () >= fMaxImageMapEntries) {
static int count = 0;
if (count++ < 10 || count % 10 == 0) {
G4cout << "G4RayView::Scan: compacting colour map - count = "
<< count << endl;
}
CompactColour (false);
if (fRayHitColourMap.entries () >= fMaxImageMapEntries) {
G4Exception ("G4RayView::Scan: compaction failure!");
}
fImageMapRejigged = true;
}
i = u;
j = v;
k = int (cellSize);
G4double x = 2. * (G4double (i + cellSize / 2) / fImageWidth - 0.5);
G4double y = 2. * (0.5 - G4double (j + cellSize / 2) / fImageHeight);
if (x > 1.0) x = 1.0;
if (y < -1.0) y = -1.0;
G4RayCoordinate rayCoord (x, y);
G4RayHitColour rayHitColour;
if (fRayHits.findValue (rayCoord, rayHitColour)) {
iPixVal = fRayHitColourIndex [rayHitColour]; // Old pixval.
red = rayHitColour.GetRed ();
green = rayHitColour.GetGreen ();
blue = rayHitColour.GetBlue ();
//G4cout << "G4RayView::Scan: " << x << ", " << y << " already traced."
// " Pixval = " << iPixVal
// << endl;
}
else {
// Initiate a new ray.
Trace (x, y, red, green, blue);
doneCount++;
int ii;
for (ii = 0; ii < fRayHitColourMap.entries (); ii++) {
G4RayColourCell& colourCell = fRayHitColourMap [ii];
if (ColourSeparation
(red, green, blue,
colourCell.red, colourCell.green, colourCell.blue) < 0.01) {
break; // ...if there's a close-match.
}
}
iPixVal = ii; // If no close-match found, ii = no. of entries, which
// will be no. of entries - 1 after append.
if (iPixVal == fRayHitColourMap.entries ())
fRayHitColourMap.append (G4RayColourCell (red, green, blue, 1));
rayHitColour = G4RayHitColour (red, green, blue);
fRayHits.insertKeyAndValue (rayCoord, rayHitColour);
fRayHitColourIndex.insertKeyAndValue (rayHitColour, iPixVal);
}
//G4cout << "G4RayView::Scan: Draw x,y,r,g,b,i,j,k,iPixVal: "
// << x << ' ' << y << ' ' << red << ' ' << green << ' ' << blue << ' '
// << i << ' ' << j << ' ' << k << ' ' << iPixVal
// << endl;
if (!(doneCount % fWaitLimit) && !nearlyDone) {
doneCount = 1;
G4cout << "G4RayView::Scan: "
<< (int) ((100. * (fImageWidth * v + u)) /
(fImageWidth * fImageHeight))
<< "% Done at cell-size "
<< cellSize
<< endl;
}
u += int (cellSize);
if (u >= fImageWidth) {
u = 0;
v += int (cellSize);
}
if (v >= fImageHeight) {
u = v = 0;
cellSize = cellSize / 3; // Next size down.
}
if ((cellSize < fRequestedResolution
|| 3 * cellSize < 1.)
// The above line can be removed when over-sampling implemented.
&& !nearlyDone
) {
G4cout << "G4RayView::Scan: final redraw." << endl;
nearlyDone = true;
cellSize = 3 * cellSize;
u = v = 0;
TriggerRedraw ();
}
if ((cellSize < fRequestedResolution
|| 3 * cellSize < 1.)
// The above line can be removed when over-sampling implemented.
&& nearlyDone
) {
fCurrentResolution = 3 * cellSize;
G4cout << "G4RayView::Scan: requested resolution = "
<< fRequestedResolution
<< ", achieved\nresolution = "
<< fCurrentResolution << " (always a Power of 3).";
G4cout << "\nNo. of ray hits = " << fRayHits.entries ();
G4cout << "\nNo. of ray Hit colours = " << fRayHitColourIndex.entries ();
G4cout << "\nNo. of colourmap entries = " << fRayHitColourMap.entries ();
fWaitLimit = 3 * fWaitLimit;
G4cout << "\nWait limit increased to: " << fWaitLimit
<< "\n(e.g, display refreshed every this many rays traced.)";
if (fRequestedResolution < 1.) {
G4cout << "\nOver-sampling (resolution < 1.) not implemented.";
}
G4cout << "\nYou can continue as follows:"
"\n/vis~/ray/resolution " << cellSize
<< "\n/vis~/draw/current"
"\n(It may take some time - 10 Times longer than so far!!!"
"\nMoreover, it will use about another "
<< 30 * (((fImageWidth - 1) / cellSize) + 1) *
(((fImageHeight - 1) / cellSize) + 1) * 1.e-6
<< " MB of memory to Store the image.)";
G4cout << endl;
Done = true;
}
return !Done;
}
void G4RayView::CompactColour (G4bool Print) {
G4int i;
G4int j;
RWTValOrderedVector <G4RayColourCell>& cmap = fRayHitColourMap;
G4double minColourSeparation = 2.;
// i.e, bigger than possible in the colour cube.
for (i = 0; i < cmap.entries (); i++) {
G4RayColourCell& celli = fRayHitColourMap [i];
for (j = i + 1; j < cmap.entries (); j++) {
G4RayColourCell& cellj = fRayHitColourMap [j];
float colourSeparation = ColourSeparation
(celli.red, celli.green, celli.blue,
cellj.red, cellj.green, cellj.blue);
if (minColourSeparation > colourSeparation) {
minColourSeparation = colourSeparation;
}
}
}
if (fMaxMinColourSeparation < minColourSeparation) {
fMaxMinColourSeparation = minColourSeparation;
G4cout << "G4RayView::CompactColour: minColourSeparation has peaked at "
<< minColourSeparation << endl;
}
if (minColourSeparation > 0.125) {
G4cerr << "G4RayView::CompactColour: WARNING: minimum colour separation"
"\nis greater than 0.125, the separation of R/G/B 3/3/2!" << endl;
}
G4int foundi;
G4int foundij [2];
RWTValOrderedVector <G4int> foundjs;
G4int jj;
// Process all pairs with colour separation < compaction * minimum.
const float compaction = 1.5;
do {
foundi = -1;
for (i = 0; i < cmap.entries (); i++) {
G4RayColourCell& celli = fRayHitColourMap [i];
for (j = i + 1; j < cmap.entries (); j++) {
G4RayColourCell& cellj = fRayHitColourMap [j];
float colourSeparation = ColourSeparation
(celli.red, celli.green, celli.blue,
cellj.red, cellj.green, cellj.blue);
if (colourSeparation < compaction * minColourSeparation) {
if (foundi < 0) {
foundi = i;
foundjs.clear ();
foundjs.append (i); // First entry is the i value.
}
foundjs.append (j);
}
}
if (foundi >= 0) break;
}
if (foundi >= 0) {
if (Print) {
G4cout << "G4RayView::CompactColour: foundjs:";
for (jj = 0; jj < foundjs.entries (); jj++) {
G4cout << ' ' << foundjs [jj];
}
G4int iii = 0;
G4cout << "\nG4RayView::CompactColour: (colour, index) before:";
fRayHitColourIndex.applyToKeyAndValue (PrintPixVals, (void *) &iii);
}
// Change all ray hits with pix val j to pix val i.
fRayHitColourIndex.applyToKeyAndValue (ChangePixVals, (void *) &foundjs);
// Decrement pix vals of all ray hits with pix val j + 1 and and above.
for (jj = foundjs.entries (); jj-- > 1;) { // ...in reverse order so
// that decrements are applied in the correct order.
G4int jjj = foundjs [jj];
fRayHitColourIndex.applyToKeyAndValue
(DecrementPixVals, (void *) &jjj);
}
// Recalculate colour map and remove redundant entries.
G4RayColourCell& celli = fRayHitColourMap [foundi];
for (jj = foundjs.entries (); jj-- > 1;) { // ...in reverse order so
// that we can safely remove colour cells.
G4int jjj = foundjs [jj];
G4RayColourCell& cellj = fRayHitColourMap [jjj];
// Recompute colour of cell.
G4int N = (celli.nHits + cellj.nHits);
celli.red = (celli.nHits * celli.red
+ cellj.nHits * cellj.red) / N;
celli.green = (celli.nHits * celli.green
+ cellj.nHits * cellj.green) / N;
celli.blue = (celli.nHits * celli.blue
+ cellj.nHits * cellj.blue) / N;
celli.nHits = N;
// Finally, remove the redundant cells.
if (Print) G4cout << "Removing " << jjj << endl;
fRayHitColourMap.removeAt (jjj);
}
if (Print) {
G4int iii = 0;
G4cout << "\nG4RayView::CompactColour: (colour, index) after:";
fRayHitColourIndex.applyToKeyAndValue (PrintPixVals, (void *) &iii);
G4cout << endl;
}
}
} while (foundi >=0);
if (Print) {
G4cout << "G4RayView::CompactColour: map compressed to "
<< fRayHitColourMap.entries ()
<< endl;
}
}
float G4RayView::ColourSeparation (float ri, float gi, float bi,
float rj, float gj, float bj) {
float sep = abs (rj -ri);
float sepg = abs (gj - gi);
if (sep < sepg) sep = sepg;
float sepb = abs (bj - bi) / 2.;
if (sep < sepb) sep = sepb;
return sep;
}
void G4RayView::ChangePixVals (const G4RayHitColour& colour,
G4int& index, void* pfjs) {
RWTValOrderedVector <G4int>* pfoundjs = (RWTValOrderedVector <G4int>*) pfjs;
G4int i = (*pfoundjs) [0];
// Change all ray Hit colours with index j to index i.
for (int jj = 1; jj < (*pfoundjs).entries (); jj++) {
G4int j = (*pfoundjs) [jj];
if (index == j) {
//G4cout << "G4RayView::ChangePixVal: ray Hit colour index changed from "
// << index;
index = i;
//G4cout << " to " << index << endl;
}
}
}
void G4RayView::DecrementPixVals (const G4RayHitColour& colour,
G4int& index, void* pjjj) {
G4int jjj = * (G4int*) pjjj;
// Decrement indices all ray Hit colours with index jjj + 1 and above.
if (index > jjj) {
//G4cout << index << " decremented." << endl;
index--;
}
}
void G4RayView::PrintPixVals (const G4RayHitColour& colour,
G4int& index, void* pjjj) {
G4cout << ' '
//<< '(' << colour.colour << ','
<< index
//<< ')'
;
}
void G4RayView::Trace (G4double x, G4double y,
float& red, float& green, float& blue) {
// Colour
G4Colour colour; // The colour of the object
G4double Ip = 0.6 ; // incident light intensity
G4double Id = 0.9 ; // reflected light intensity
G4double Ia = 0.2; // ambient light intensity
G4double I; // total intensity
G4double intrinsicred; // intrinsic colour of the object
G4double intrinsicgreen; // given in red green
G4double intrinsicblue; // and blue
G4double outsideDistance;
G4Point3D newPoint;
G4double Dot; // Dot product of the normal vector of surface
// with the normalized vector of incident light
G4double reflectionDot; // Dot product of the normal vector of reflection
// with the normal vector of angle of viewing
G4Vector3D rayDirection; //unit vector, the ray direction.
G4Point3D rayPosition; // position of ray on the front view plane
G4Vector3D roughrayDirection; // the vector from camera to
//the point on screen
G4Vector3D reflightDirection; // vector of reflection light
G4Vector3D screenvector; // vector on the front view plane pointing from
// the center of screen to a given point on screen
const G4Vector3D& viewvector = fVP.GetViewpointDirection().unit();
// view vector on the line from the target point to the eye-- view
// point direction
const G4Vector3D& lightDirection = fVP.GetActualLightpointDirection().unit();
// vector of incident light
EInside whereisit;
screenvector = fXprime * x + fYprime * y;
rayPosition = fCenterofscreen + screenvector;
if (fVP.GetFieldHalfAngle() == 0 ) {
rayDirection = - viewvector.unit();
}
else {
roughrayDirection = rayPosition - fCamerapoint;
rayDirection = roughrayDirection.unit();
}
// Default - black.
I = 0;
// Check if rayPosition is in the world.
outsideDistance = kInfinity;
whereisit = fpWorld -> GetLogicalVolume() -> GetSolid()->Inside(rayPosition);
if (whereisit == kInside) {
outsideDistance = 0.;
}
else { // It's outside the world, so move it inside.
outsideDistance = fpWorld -> GetLogicalVolume() ->
GetSolid()-> DistanceToIn(rayPosition,rayDirection);
if ( outsideDistance != kInfinity) {
rayPosition = rayPosition + outsideDistance * rayDirection;
}
}
if (outsideDistance != kInfinity) {
fG4RayGun -> SetParticlePosition(rayPosition);
fG4RayGun -> SetParticleMomentumDirection(rayDirection);
fG4RayRunManager -> BeamOn(1);
if (fG4RaySteppingAction -> WeHaveContact ()) {
// Store these in the scene so we can use culling algorithms.
// Not figured out how to do this yet.
// Certainly we don't need to Store these in the scene now
// culling is Done in the modeling category.
// Rethink this.
//fScene.SetWorkingPhysicalVolume
//(fG4RaySteppingAction -> GetPhysicalVolume ());
//fScene.SetWorkingLogicalVolume
//(fG4RaySteppingAction -> GetLogicalVolume ());
//fScene.SetWorkingSolid (fG4RaySteppingAction -> GetSolid ());
const G4VisAttributes* pVA =
fG4RaySteppingAction -> GetVisAttributes();
pVA = GetApplicableVisAttributes (pVA);
//fScene.SetWorkingVisAttributes (pVA);
/**** if (!fScene.IsThisCulled ()) ****/ {
G4Normal3D normal = fG4RaySteppingAction -> GetSurfaceNormal ();
// Return colour of the object
colour = pVA -> GetColour();
intrinsicred = colour.GetRed();
intrinsicgreen = colour.GetGreen();
intrinsicblue = colour.GetBlue();
//G4cout << "The intrnsic red colour is: " << red << endl;
//G4cout << "The intrinsic green colour is: " << green << endl;
//G4cout << "The intrinsic blue colour is: " << blue << endl;
// Calculate Intencity.
Dot = normal.unit() * lightDirection.unit();
reflightDirection = 2.0 * Dot * normal.unit() - lightDirection.unit();
reflectionDot = viewvector.unit() * reflightDirection.unit();
if (Dot < 0) Dot = 0;
if (reflectionDot < 0) reflectionDot = 0;
I = Ia + Ip * Dot ; //+ Id * pow(reflectionDot,90);
}
}
}
/*************
else {
outsideDistance = fpWorld -> GetLogicalVolume() -> GetSolid()-> DistanceToIn(rayPosition,rayDirection);
if ( outsideDistance == kInfinity) {I=0;}
else{
newPoint = rayPosition + outsideDistance * rayDirection;
fG4RayGun -> SetParticlePosition(newPoint);
fG4RayGun -> SetParticleMomentumDirection(rayDirection);
fG4RayRunManager -> BeamOn(1);
if (fG4RaySteppingAction -> WeHaveContact ()) {
// Store these in the scene so we can use culling algorithms.
fScene.SetWorkingPhysicalVolume
(fG4RaySteppingAction -> GetPhysicalVolume ());
fScene.SetWorkingLogicalVolume
(fG4RaySteppingAction -> GetLogicalVolume ());
fScene.SetWorkingSolid (fG4RaySteppingAction -> GetSolid ());
const G4VisAttributes* pVA =
fG4RaySteppingAction -> GetVisAttributes();
pVA = GetApplicableVisAttributes (pVA);
fScene.SetWorkingVisAttributes (pVA);
if (!fScene.IsThisCulled ()) {
G4Normal3D normal = fG4RaySteppingAction -> GetSurfaceNormal ();
// Return colour of the object
colour = pVA -> GetColour();
intrinsicred = colour.GetRed();
intrinsicgreen = colour.GetGreen();
intrinsicblue = colour.GetBlue();
//G4cout << "The intrnsic red colour is: " << red << endl;
//G4cout << "The intrinsic green colour is: " << green << endl;
//G4cout << "The intrinsic blue colour is: " << blue << endl;
// Calculate Intencity.
Dot = normal.unit() * lightDirection.unit();
reflightDirection =
2.0 * Dot * normal.unit() - lightDirection.unit();
reflectionDot = viewvector.unit() * reflightDirection.unit();
if (Dot < 0) Dot = 0;
if (reflectionDot < 0) reflectionDot = 0;
I = Ia + Ip * Dot ; //+ Id * pow(reflectionDot,90);
}
}
}
}
**********************/
// G4cout << " Intensity : " << I << endl;
red = intrinsicred * I ;
green = intrinsicgreen * I ;
blue = intrinsicblue * I;
if (I > 0.) {
G4double specular = Id * pow(reflectionDot,10);
red += specular;
green += specular;
blue += specular;
}
/****************************************************************
////////////////////////////////////////////////////////
// A very testing pallette...
////////////////////////////////////////////////////////
if (x < -0.8) {
red = (y + 1.) / 2.;
green = 0;
blue = 0;
}
else if (x < -0.6) {
red = 0;
green = (y + 1.) / 2.;
blue = 0;
}
else if (x < -0.4) {
red = 0;
green = 0;
blue = (y + 1.) / 2.;
}
else if (x < -0.2) {
red = 0;
green = (y + 1.) / 2.;
blue = (y + 1.) / 2.;
}
else if (x < 0.) {
red = (y + 1.) / 2.;
green = 0;
blue = (y + 1.) / 2.;
}
else if (x < 0.2) {
red = (y + 1.) / 2.;
green = (y + 1.) / 2.;
blue = 0.;
}
else if (x < 0.4) {
red = (y + 1.) / 2.;
green = (y + 1.) / 2.;
blue = (y + 1.) / 2.;
}
else {
red = pow (sin (y), 2);
green = pow (cos (y), 2);
blue = x * x;
}
***********************************/
/**********************************
////////////////////////////////////////////////////////
// A shiny red sphere...
////////////////////////////////////////////////////////
const G4double size (0.5);
const G4Point3D centre;
const G4double ambient (0.2);
const G4Vector3D viewpointDirection (0.0, 0.0, 1.0);
const G4Vector3D lightpointDirection = G4Vector3D (1.0, 1.0, 1.0).unit ();
G4double p = sqrt (pow (x - centre.x (), 2) + pow (y - centre.y (), 2));
if (p > 0.5) {
red = green = blue = 0.;
}
else {
G4double z = sqrt (pow (size,2) - pow (p, 2));
G4Vector3D radiusVector (x, y, z);
G4double brightness = radiusVector.unit () * lightpointDirection;
if (brightness < 0.0) brightness = 0.0;
G4Vector3D reflightDirection =
2.0 * brightness * radiusVector.unit () - lightpointDirection;
G4double reflectionDot =
viewpointDirection.unit() * reflightDirection.unit();
if (reflectionDot < 0) reflectionDot = 0;
G4double specular = pow (reflectionDot, 10);
red = ambient + (1.0 - ambient) * brightness;
red += specular;
green += specular;
blue += specular;
}
**************************/
////////////////////////////////////////////////////////
// Always check...
////////////////////////////////////////////////////////
if (red < 0.) red = 0.;
if (green < 0.) green = 0.;
if (blue < 0.) blue = 0.;
if (red > 1.) red = 1.;
if (green > 1.) green = 1.;
if (blue > 1.) blue = 1.;
}
+72
View File
@@ -0,0 +1,72 @@
// 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: G4RayX.cc,v 2.2 1998/11/06 13:41:57 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Nikos Savvas 1st June 1997
// GEANT4 Ray Tracing graphics system factory.
#ifdef G4VIS_BUILD_RAYX_DRIVER
#include "G4RayX.hh"
#include "G4VisFeaturesOfRay.hh"
#include "G4RayXMessenger.hh"
#include "G4RayScene.hh"
#include "G4RayXView.hh"
G4RayX::G4RayX ():
G4VGraphicsSystem ("G4RayX",
"RayX",
G4VisFeaturesOfRayX (),
G4VGraphicsSystem::twoD) {
if (fInstances >= 1) {
G4Exception ("An attempt to instantiate a second G4RayX object.");
}
fInstances++;
// Instantiate my messenger.
fpMessenger = new G4RayXMessenger (this);
}
G4RayX::~G4RayX () {
delete fpMessenger;
fInstances--;
}
G4VScene* G4RayX::CreateScene (const G4String& name) {
G4RayScene* pRayScene = new G4RayScene (*this, name);
G4VScene* pScene = pRayScene;
G4cout << G4RayScene::GetSceneCount ()
<< ' ' << fName << " scenes extanct." << endl;
fpMessenger -> RegisterScene ((G4RayScene*) pScene);
return pScene;
}
G4VView* G4RayX::CreateView (G4VScene& scene, const G4String& name) {
G4RayView* pRayXView = new G4RayXView ((G4RayScene&) scene, name);
G4VView* pView = pRayXView;
if (pView) {
if (pView -> GetViewId () < 0) {
G4cerr << "Error flagged by negative view id in G4RayXView creation."
"\nDestroying view and returning null pointer."
<<endl;
delete pView;
pView = 0;
}
}
else {
G4cerr << "Null pointer on new G4RayXView." << endl;
}
fpMessenger -> RegisterView (pRayXView);
return pView;
}
G4int G4RayX::fInstances = 0;
#endif
@@ -0,0 +1,49 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4RayXMessenger.cc,v 2.4 1998/07/16 01:57:32 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// GEANT4 Ray tracing for X windows Messenger - John Allison 5th June 1997
#ifdef G4VIS_BUILD_RAYX_DRIVER
#include "G4RayXMessenger.hh"
#include "G4RayX.hh"
#include "G4UImanager.hh"
#include "G4UIcommand.hh"
#include "G4UIparameter.hh"
G4RayXMessenger::G4RayXMessenger (G4RayX* pRayX):
fpRayX (pRayX)
{
G4UIcommand* command;
G4UIparameter* param;
///////////////////////////////////////////////// /vis~/ray/X... ////
//vis \hline
//vis /vis~/ray/X... &&
//vis ...any X-special commands for ray tracing... \\%
//command = new G4UIcommand ("/vis~/ray/X...", this);
//command -> SetGuidance ("...any X-special commands for ray tracing...");
}
G4RayXMessenger::~G4RayXMessenger () {}
void G4RayXMessenger::SetNewValue (G4UIcommand* command, G4String newValues)
{
G4RayMessenger::SetNewValue (command, newValues);
}
G4String G4RayXMessenger::GetCurrentValue (G4UIcommand* command) {
return "";
}
#endif
@@ -0,0 +1,196 @@
// 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: G4RayXView.cc,v 2.2 1998/11/06 13:41:58 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Nikos Savvas 1st June 1997
// GEANT4 Ray Tracing view.
#ifdef G4VIS_BUILD_RAYX_DRIVER
#include "G4RayXView.hh"
#include "G4RayScene.hh"
G4RayXView::G4RayXView (G4RayScene& scene, const G4String& name):
G4RayView (scene),
G4OwnColormapXView (scene),
G4VView (scene, scene.IncrementViewCount (), name) {
if (fViewId < 0) return; // Traps possible error in base class creation.
if (fTrueColor) {
fMaxImageMapEntries = 256; // make a 256 colour map anyway.
}
if (fMapEntries != 256 ) {
G4cerr << "G4RayXView::G4RayXView: no of colormap entries is " << ncells
<< "\nWe cannot deal with this case for ray tracing yet."
<< endl;
fViewId = -1;
return;
}
/************************************
// Fill 3x3x2 colormap.
// (In future, I'll write something to evolve the colormap on the fly.
if (fMapEntries != 256 ) {
G4cerr << "G4RayXView::G4RayXView: no of colormap entries is " << ncells
<< "\nWe cannot deal with this case for ray tracing yet."
<< endl;
fViewId = -1;
return;
}
XColor* cells = new XColor [fMapEntries];
red_max = 7;
green_max = 7;
blue_max = 4;
int red_max_1 = red_max + 1;
int green_max_1 = green_max + 1;
int blue_max_1 = blue_max + 1;
float red_scale = 65535 * (float (red_max_1) / red_max);
float green_scale = 65535 * (float (green_max_1) / green_max);
float blue_scale = 65535 * (float (blue_max_1) / blue_max);
red_mult = 32;
green_mult = 4;
blue_mult = 1;
for (int iPixel = 0; iPixel < ncells; iPixel++) {
cells [iPixel].pixel = iPixel;
cells [iPixel].red = (short unsigned int)
(red_scale * ((iPixel / red_mult) % red_max_1));
cells [iPixel].green = (short unsigned int)
(green_scale * ((iPixel / green_mult) % green_max_1));
cells [iPixel].blue = (short unsigned int)
(blue_scale * ((iPixel / blue_mult) % blue_max_1));
cells [iPixel].flags = DoRed | DoGreen | DoBlue;
}
XStoreColors (fpDisplay, fColormap, cells, ncells);
************************************/
}
void G4RayXView::DrawView () {
// If view parameters have changed, start again from scratch.
// But if not, be smart, and start from private map, depending on
// the value of resolution.
SetView ();
// Decide whether to initialise image...
if (fImageViewParameters != fVP ||
fMaxImageMapEntries != fMapEntries ||
fImageWidth != fWidth ||
fImageHeight != fHeight) { // Clear and reset image stores.
G4cout
<< "G4RayXView::DrawView: image re-initialised because...\n ";
if (fImageViewParameters != fVP)
G4cout << "view parameters, ";
if (fMaxImageMapEntries != fMapEntries)
G4cout << "no. of entries in colormap, ";
if (fImageWidth != fWidth)
G4cout << "width, ";
if (fImageHeight != fHeight)
G4cout << " height, ";
G4cout << "changed." << endl;
// Reset above parameters...
fImageViewParameters = fVP;
fMaxImageMapEntries = fMapEntries;
fImageWidth = fWidth;
fImageHeight = fHeight;
// Now things that need initialising...
InitialiseImage ();
}
// Now things that need resetting for every Draw.
TriggerRedraw ();
XGCValues xgcValues;
XColor cell;
XColor* cells = new XColor [fMapEntries];
int i, j, k, iPixVal;
float red, green, blue;
// Square of side k whose upper left corner is (i, j). The above
// are set by the function Scan, inherited from G4RayView. You
// don't have to use it - you can call Trace, also inherited from
// G4RayView, directly. iPixVal is the pixel value for this colour,
// i.e., the key in fRayHitColourIndex.
while (Scan (i, j, k, red, green, blue, iPixVal)) {
if(fTrueColor) {
unsigned long int trueColorPixval =
((unsigned long int) (red * fRedMax)) << fRedShift |
((unsigned long int) (green * fGreenMax)) << fGreenShift |
((unsigned long int) (blue * fBlueMax)) << fBlueShift;
xgcValues.foreground = trueColorPixval;
XChangeGC (fpDisplay, fGC, GCForeground, &xgcValues);
}
else {
G4int nCells = fRayHitColourMap.entries ();
if (nCells > fMapEntries) {
G4Exception ("G4RayXView::DrawView: fRayHitColourMap overflow!!!");
}
if (fImageMapRejigged && ++fWaitCount > fWaitLimit) {
// Note: ++fWaitCount only executed if fImageMapRejigged is true.
fWaitCount = 0;
fImageMapRejigged = false;
fTriggerRescan = true;
//G4cout << "G4RayXView::DrawView: remaking whole colormap." << endl;
for (int iCells = 0; iCells < nCells; iCells++) {
cells [iCells].pixel = iCells;
cells [iCells].red = (short unsigned int)
(65535 * fRayHitColourMap (iCells).red);
cells [iCells].green = (short unsigned int)
(65535 * fRayHitColourMap (iCells).green);
cells [iCells].blue = (short unsigned int)
(65535 * fRayHitColourMap (iCells).blue);
cells [iCells].flags = DoRed | DoGreen | DoBlue;
}
XStoreColors (fpDisplay, fColormap, cells, nCells);
}
else {
if (iPixVal == nCells - 1) {
// Just do the last one, the latest addition.
cell.pixel = iPixVal;
cell.red = (short unsigned int)
(65535 * fRayHitColourMap (iPixVal).red);
cell.green = (short unsigned int)
(65535 * fRayHitColourMap (iPixVal).green);
cell.blue = (short unsigned int)
(65535 * fRayHitColourMap (iPixVal).blue);
cell.flags = DoRed | DoGreen | DoBlue;
XStoreColor (fpDisplay, fColormap, &cell);
}
// (Otherwise assume an old pixel value is being used,
// i.e., do nothing.)
}
XSetForeground (fpDisplay, fGC, iPixVal);
}
if (k <= 1) {
XDrawPoint (fpDisplay, fWindow, fGC, i, j);
}
else {
XFillRectangle (fpDisplay, fWindow, fGC, i, j, k, k);
}
XFlush (fpDisplay);
//for (int ii = 0; ii < 1000000; ii++); //?? 1000000 = about 0.5 secs!!
}
delete cells;
FinishView ();
}
#endif
+74
View File
@@ -0,0 +1,74 @@
# $Id: GNUmakefile,v 2.4 1998/07/07 16:25:07 allison Exp $
# -----------------------------------------------------------------------
# GNUmakefile for visualization and modeling. John Allison, 5/7/95.
# Modeling is always made. Others by environment. John Allison 4/7/98.
# -----------------------------------------------------------------------
MAKEFLAGS= --no-print-directory
name := G4visualization
ifndef G4INSTALL
G4INSTALL = ../..
endif
include $(G4INSTALL)/config/architecture.gmk
include $(G4INSTALL)/config/G4VIS_BUILD.gmk
include $(G4INSTALL)/config/interactivity.gmk
G4LIBDIR := $(G4LIB)/$(G4SYSTEM)
G4TMPDIR := $(G4TMP)/$(G4SYSTEM)/$(name)
SUBDIRS := modeling
SUBLIBS := G4modeling
ifdef G4VIS_BUILD
SUBDIRS += management
SUBLIBS += G4vis_management
endif
# For DAWN and DAWNFILE drivers
ifdef G4VIS_BUILD_DAWN_DRIVER
SUBDIRS += FukuiRenderer
SUBLIBS += G4FR
endif
ifdef G4VIS_BUILD_DAWNFILE_DRIVER
ifndef G4VIS_BUILD_DAWN_DRIVER
SUBDIRS += FukuiRenderer
SUBLIBS += G4FR
endif
endif
# End of DAWN and DAWNFILE drivers
ifdef G4VIS_BUILD_OPACS_DRIVER
SUBDIRS += OPACS
SUBLIBS += G4OPACS
endif
ifdef G4VIS_BUILD_OPENGL_DRIVER
SUBDIRS += OpenGL
SUBLIBS += G4OpenGL
endif
ifdef G4VIS_BUILD_OI_DRIVER
SUBDIRS += OpenInventor
SUBLIBS += G4OpenInventor
endif
ifdef G4VIS_BUILD_RAYX_DRIVER
SUBDIRS += G4Ray
SUBLIBS += G4Ray
endif
# For VRML and VRMLFILE drivers
ifdef G4VIS_BUILD_VRML_DRIVER
SUBDIRS += VRML
SUBLIBS += G4VRML
endif
ifdef G4VIS_BUILD_VRMLFILE_DRIVER
ifndef G4VIS_BUILD_VRML_DRIVER
SUBDIRS += VRML
SUBLIBS += G4VRML
endif
endif
# End of VRML and VRMLFILE drivers
include $(G4INSTALL)/config/globlib.gmk
+611
View File
@@ -0,0 +1,611 @@
$Id: History,v 2.55 1998/12/16 20:25:27 allison Exp $
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
Category History file
---------------------
This file should be used by G4 developers and category coordinators
to briefly summarize all major modifications introduced in the code
and keep track of all category-tags.
It DOES NOT substitute the CVS log-message one should put at every
committal in the CVS repository !
*************************************************************
* Note that modeling and test have their own History files. *
*************************************************************
----------------------------------------------------------
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
History file for visualization category
---------------------------------------
vis-00-04-04 16th December 1998 John Allison
- test/GNUmakefile for Linux-g++
- test/test19.cc - removed g4templates.hh
- OpenGL - reverted to 100%.
vis-00-04-03 9th December 1998 John Allison
- Made /vis/ commands from /vis~/. The idea is to maintain backwards
compatibility while allowing us to "deprecate" the old commands over
a period of time. Some of these /vis/ commands respond with "superceded",
i.e., superceded by new commands, but still available in /vis~/.
- OpenGL viewing volume increased by 20% to prevent corners being clipped.
- 08/12/98 : G.Barrand : OpenInventor : due to
huge load problems on various platforms, init only
the HEPVis things that are needed.
vis-00-04-02 30th November 1998 Satoshi Tanaka
- G4VRMLFILE_DEST_DIR for customising out file name - see VRML/History.
29th November 1998
- Added CPPFLAGS += -I....electromagnetic/utils/include to test/GNUmakefile.
- Added fName to G4SceneData.
vis-00-04-01 25th November 1998 John Allison.
- G4Ray/GNUmakefile update for move of files in particles.
- Added const G4VisAttributes* fpDefaultVisAttributes and access
functions to G4ModelingParameters.
- Reverted to default assignment operator and copy constructor for
G4ModelingParameters and G4ViewParameters.
- G4PhysicalVolumeModel can now handle invisible daughters.
- More new /vis/ commands - depends on intercoms-00-04-01.
- G4VScene passes DefaultVisAttributes* to ModelingParameters.
vis-00-03-07 23rd November 1998 John Allison.
- modeling/GNUmakefile update for move of files in particles (Hisaya).
- Removed semi-colon in G4BoundingSphereScene.cc.
vis-00-03-06 9th November 1998 John Allison.
- Small change to a message in G4VisManager.
- VRML refinement - see VRML/History.
- Needs greps-00-03-03.
vis-00-03-05b 9th November 1998 John Allison.
- Merged 6th November changes with vis-00-03-05a
- Bug fix in G4VisManager::IsValidView for batch running.
- Needs greps-00-03-03.
vis-00-03-05a 9th November 1998 Satoshi Tanaka
- VRML 2.0 Visualization driver is added to
management/include/MyVisManager.cc.
vis-00-03-05 9th November 1998 Satoshi Tanaka
- VRML 2.0 Visualization driver is commited:
(1) Generatin of VRML 2.0 format files to describe Geant4 simulation.
(2) Interactive displaying of physiccal-volume names and copy numbers
(3) Interactive displaying of hit positions (displayed strings are
costomizable.
(4) Wireframe drawing style of Geant4 visualization is reflected as
transparency = 0.7. This value is customizable.
If transparency is 1.0, drawing of detector geometry is skipped,
and hits can be picked easily.
6th November 1998 John Allison
- Implemented basic /vis/viewer commands.
- Added `const G4String& name' argument to G4VScene and G4VView constructors.
vis-00-03-04 30th October 1998 John Allison
- Tagged.
29th October 1998 Guy Barrand
- G4OpenGLXView.hh, G4OpenGLXmView.cc, G4OpenGLXmWindowHandlingCallbacks.cc
in order that things compile and compile without warnings on HP/aCC
14th October 1998 John Allison
- Augmented the new /vis/ commands. Still not complete but they
co-work with the old commands.
- Changed char* fName to G4String fName in G4VScene and G4VView.
Consequent changes in G4OpenGLView. Also OpenInventor? Etc.
11th October 1998 Andy Walkden
- added (not a very good) version of hidden lines removal code. This code
suffers from depth buffering artefacts. glPolygonOffset is a feature of
OpenGL version 1.1, and can help overcome depth buffer problems. The code
to utilise glPolygonOffset is committed, but commented out, as it doesn't
seem to work with the version of Mesa available on rsplus currently. My
ideal strategy is to enable depth testing, draw the model as lines, enable
filled polygon offsetting (glPolygonOffset(1.0 /*offset scale factor*/,
2/*offset bias*/); glEnable (GL_POLYGON_OFFSET_FILLED);) then draw the
model as filled polygons. The offsetting should just add `2' (in window
coordinates, I think) onto the z value of all vertices relating to filled
polygons, thus dismissing the conflict between almost identical z values
for lines and filled polygon edges.
vis-00-03-03 9th October 1998 John Allison
- G4VisManager inherits G4VStateDependent. This is used to draw
end-of-event models.
4th October 1998 Andy Walkden
- Added ability for all G4OpenGLX derived graphics systems to produce
vectored PostScript hardcopy. Facility for `automated screen dump'
(i.e. pixmap output) still kept, as some rasterization features
don't make it into the vectored PostScript output (such as haloing
effects). Facility currently available via G4OpenGLXm by clicking
`Miscellany' then `Create .eps file', to get a popup printing
window.
vis-00-03-02a 26th September 1998
- DAWNFILE driver is made platform dependent.
(It is now compilable both at both Unix and NT without necessity
of C macros like WIN32.)
vis-00-03-02 25th September 1998
- DAWNFILE driver is ported to VC++
vis-00-03-01 24th September 1998 John Allison
- Eliminated G4VPhysicalVolume* fpWorld data memebr from G4VisManager.
22th September 1998 Guy Barrand.
- Correct modeling, management, G4Ray /GNUmakefile to have
correct digits+hits includes.
19th September 1998 Guy Barrand.
- Due to a correction in globals.h restore correct code
so that OpenInventor files compile correctly on NT.
vis-00-02-06 31st August 1998 John Allison
- Added G4VModel::Validate() and in subclasses.
- Reverted to default copy constructir and assignment operator in G4SceneData.
- Implemented G4VisManager::GeometryHasChanged().
- Switched on echoing of commands and history mechanism in test19.g4m.
vis-00-02-05 27th August 1998 John Allison
- Added G4HitsModel and G4TrajectoriesModel.
- Added /vis/scene/include/hits and trajectories, and some bug fixes.
vis-00-02-04 22nd August 1998 John Allison
- Many changes in modeling - see modeling/History.
- New commands: /vis/scene/create, list, add/volume, add/ghosts.
vis-00-02-03a 20th August 1998 John Allison
- Restored some code in G4SceneData.cc
- Fixed syntax bug in G4PhysicalVolumeSearchScene.hh
vis-00-02-03 14th August 1998 John Allison
- Added G4VisManager::GeometryHasChanged() - run manager can notify change.
- Removed AddRun(Event)DurationModelToCurrentSceneData - no longer used.
- Some bug corrections in visualization/OpenGL (Guy Barrand - see
vis blackboard for details).
- Some protection added in visualization/OPACS (do.)
- Created visualization/test/OPACS (do.)
12th August 1998 John Allison
- More new commands - not fully functional yet.
11th August 1998 Guy Barrand
- G4OpenInventor : remove uneccesary includes.
vis-00-02-02b 11th August Satoshi Tanaka
- AddPrimitive() for polymarker are implemented in DAWN and VRML drivers.
vis-00-02-02a 9th August John Allison
- Small bug fix in G4VisCommandsScene.cc.
vis-00-02-02 9th August John Allison
- Changed '.' to '-' in scene/view names.
- Began introduction of new /vis/ commands.
- Consequent changes to test - see test/History.
7th August Guy Barrand.
- OPACS : use G4VView name to build widget names.
- OPACS : use new interactor parenting logic.
- OpenGL, OpenInventor, G4Ray : clean compilation warnings for OSF1/cxx, HP/aCC.
7th August John Allison/Satoshi Tanaka/Guy Barrand.
- Added G4<driver>Scene::AddPrimitive (const G4Polymarker&) to keep
compilers happy.
vis-00-02-01 6th August John Allison
- Created G4VisManagerRegisterMessengers.cc.
- Bug fix in G4VisManager: now follows change of world volume after
/vis~/clear/scene.
- OpenInventor: Correct some upper -> lower case mess (Guy Barrand)
- G4RayView: syntax bug fixes.
4th August 1998 Andy Walkden
I made some changes to OpenGL code...
The changes are (i) to tidy up some redundant hidden line
removal function calls, (ii) to put some hidden line removal
code in G4OpenGLScene::AddPrimitive(G4Polyhedron) and
(iii) to add an option to generate an encapsulated postscript
file of the current view in OpenGLXm. There is now a button
in the Miscellany pulldown of the main menubar to bring up
a shell in which you can specify a filename, colour or black
and white and request the creation of a .eps file. The
code is to be found in G4OpenGLXView, and so is not bound
to the Xm user. Also it needs fixing for some Mesa
implementations, and the HP CDE environment manages to stuff
things up when rendering to a pixmap (although CDE makes a
mess of most other things as well, so this isn't
disastrous).
vis-00-01-08 21th July 1998 John Allison
- Removed automatic refresh from /vis/camera/reset in G4VisCommandsCamera.cc.
vis-00-01-07b 21th July 1998 Satoshi Tanaka
- Revised G4FRSCENE::SendBoundingBox() so that
zooming polycy of DAWN drivers becomes consistent with
OpenGL drivers
vis-00-01-07 20th July 1998 John Allison
- Corrected bug in G4VisManager::IsViewValid to trap drawing commands
before geometry is available.
vis-00-01-06 19th July 1998 John Allison
- Default culling: culling - on, culling of invisible objects - on.
- set/drawing_style does *not* change culling flags.
- Minor bug fixes.
vis-00-01-05 15th July 1998 John Allison
- Cleaned up after name changes.
- Minor bug fixes.
vis-00-01-04 7th July 1998 Guy Barrand
- Introduced interactivity.gmk into GNUmakefiles.
vis-00-01-03 6th July 1998 John Allison
- Changes for interface restructuring.
- Simplified MyVisManager.
vis-00-01-02 5th July 1998 John Allison
- Changed visualization/GNUmakefile to use globlib.gmk.
- Updated README for geant4beta.
- Changed /vis~/draw/Ghosts to /vis~/draw/ghosts.
vis-00-01-01 4th July 1998 John Allison
- Moved G4VIS_BUILD.gmk and G4VIS_USE.gmk to geant4beta/config.
- Changed /vis/ to /vis~/.
3rd July 1998 John Allison
- Small changes to test - see test/History.
- Tidied.
- Removed GNUmakefile.G4VIS_USE and make_list.sh.
30th June 1998 - Paulo & Marc
- added the G4FlavoredParallelWorldModel.hh file to
visualization/modeling/include;
- added the /vis~/draw/Ghosts [particle name] command
in the G4VisManMessDraw.cc file;
- added
CPPFLAGS += -I$(G4BASE)/geometry/magneticfield/include and
CPPFLAGS += -I$(G4BASE)/processes/parameterisation/include
lines to GNUmakefile to compile G4VisManMessDraw.cc.
geant4beta
============================================================
geant4alpha
vis-00-06-09 26th June 1998 John Allison
- OPACS and Open Inventor - something about widget parents (GB)
- Removed /new_vis/ commands.
vis-00-06-08a 26th June 1998 Satoshi Tanaka
- Updated G4VIS_USE.gmk
- (1) Macro -DG4VIS_USE_DAWNFILE is made properly set
- (2) G4VIS_USE_DAWN_ is renamed to G4VIS_USE_DAWN_OR_DAWNFILE
- (3) G4VIS_USE_VRML_ is renamed to G4VIS_USE_VRML_OR_VRMLFILE
vis-00-06-08 22nd June 1998 John Allison
- Changed G4BASE = ../.. to G4BASE = $(shell (cd ../..; pwd))
- Changed GNUmakefile.G4VIS_BUILD to G4VIS_BUILD.gmk
vis-00-06-07 19th June 1998 John Allison
- Defined G4_SOLVE_VIS_TEMPLATES in G4VIS_USE.gmk. Needs
the head version of GNUmakefile.architecture.
- Consequential changes (improvements) to template handling in test19.cc
- Some minor improvements in modeling.
vis-00-06-06 11th June 1998 John Allison
- Fixes to test_utils - see test/History.
- Improvements in modeling - see modeling/History.
vis-00-06-05 11th June 1998 Satoshi Tanaka
- In G4VisManMessDraw.cc and G4VisManMessSet.cc , ...
// G4double unit = G4UIcommand::valueOf (unitString);
G4double unit = G4UnitDefinition::GetValueOf (unitString);
vis-00-06-04 10th June 1998 John Allison
- Created G4VIS_USE.gmk to replace GNUmakefile.G4VIS_USE.
- Changed test/GNUmakefile to use G4VIS_USE.gmk.
- Separate libraries are now default in GNUmakefile.
- Committed an interim version of README.
- Moved G4BoundingSphereScene from management to modeling.
- First attempt at defining the "scene" as lists of models.
- Removed some unnecessary checks in G4VisManMess*.
vis-00-06-03 27th May 1998 Satoshi Tanaka
- DAWNFILE driver is added. It is to generate g4.prim file
under the current directory. And make DAWN or DAVID invoke
using the g4.prim file as an input. For details, see the blackboard
document.
21st May 1998 Andy Walkden
- Added hidden line removal code to G4OpenGLView. HLR utilises OpenGL's
stencil buffer, but still the drawn lines are a little fragmented
(an effect seen often when depth buffering is used to resolve pixel
rendering disputes).
- HLR requires wireframe rendering, filled polygon rendering and then wireframe
rendering again. Hence, three visits to the kernel help to slow HLR
rendering right down.
vis-00-06-02 20th May 1998 Satoshi Tanaka
- Added G4VisFeaturesOfDAWNFILE.hh, cc
- Revised visualization/GNUmakefile, GNUmakefile.G4VIS_BUILD,
GNUmakefile.G4VIS_USE
- These are for DAWNFILE driver in preparation, which enables to
invoke DAVID directly from Geant4.
vis-00-06-01a 20th May 1998 Satoshi Tanaka
- code refinement of FukuiRenderer driver
vis-00-06-01 29th April 1998 John Allison
- Introduced non-pure virtual functions
Establish/DecommissionSpecials (G4PhysicalVolumeModel&) in
G4VGraphicsScene with implementation of the former in G4VScene.
Modified G4PhysicalVolumeModel to use it; also protected
G4PhysicalVolumeModel against non-implementation of
Establish/DecommissionSpecials.
- Template instantiations in G4RayView made exclusive to GNU_GCC
- Some minor changes under test - see test/History.
27th April 1998 Andy Walkden
- altered OpenGLView's structure a little. Now, G4OpenGLXmView is a
type of (inherits from) G4OpenGLXView.
- made code for haloing effects common to all OpenGL views.
- changed XUnmapWindow in G4OpenGLXView::~G4OpenGLXView to XDestroyWindow
(idea of Guy's)
27th April 1998 Guy Barrand
- vis/OPACS : remove Begin/EndModeling in G4GoScene.
vis-00-05-06 23rd April 1998 John Allison
- Changed test19.mac to test19.g4m and consequent change in test19.cc.
- Fixed order of linking vis-a-vis -lG4track and -lG4tracking (GB).
- Fixed inadvertent bug in test_utils/src/MyPhysicsList.cc.
- Bug fix in G4OpenGLXmConvenienceRoutines.cc (GB).
vis-00-05-05 21st April 1998 John Allison
- Added run-time command line argument: test19 [<session-type>] [<verbosity>]
- Removed #if GNU_GCC from template instantiation requests in test19.cc.
- Added fDefaultTextVisAttributes to G4ViewParameters.
- Added G4VScene::GetTextColour (changed G4FukuiRendererScene, G4GoScene and
G4OpenInventorScene.
- Changed default view parameters: culling on and invisible object culling on.
- Tidied CreateScene/View.
- Continued BaBar development.
15th April 1998 John Allison
- Added test/EucIntfce/, test/Bogus/ and test/babar_utils/ for BaBar test code.
Also a new main() in BaBarCallListTest.cc. Also a data file call_list.dat.
See babar_utils/README.
- Camera commands, except spin and orbit, no longer initiate draw.
- Text is blue for time being (visible on black or white background.)
15th April 1998 : Guy Barrand
- From discussion with John and Simone G4VToolkit
has been renamed to G4VInteractorManager.
vis-00-05-04a 11th April 1998 Satoshi Tanaka
- Code improvements in DAWN driver
- (1) View parameters are sent to DAWN only at drawing times.
- (2) Way of getting marker size are made simpler by using
- G4VScene::GetMarkerRadius () etc.
vis-00-05-04 8th April 1998 John Allison
- Small bug fix - then tag for Easter.
HEAD 6th April 1998 John Allison
- Added error printing to G4OpenGLScene::AddPrimitive (const G4Text& text).
- Added /vis~/draw/text.
- Added units to /vis~/draw/axes.
- Began the job of restructuring vis commands; so there is a new class
G4VisCommandsCameraMessengers for starters!
HEAD 4th April 1998 John Allison
- Removed automatic drawing after /vis~/set commands. Now an explicit
redraw is necessary, but it allows you to change parameters during
building a view. For example to superimpose projected hits on a
section:
/vis~/clear/view
/vis~/set/section_plane on 0 0 20 cm 0 0 1
/vis~/draw/current
/vis~/set/section_plane off
/run/beamOn
- Fixed small bug in OpenGL for section drawing.
- Made some small improvements in G4ViewParameters.
vis-00-05-03 4th April 1998 John Allison
- Re-engineered maintenance of current depth, etc. Needed new method
G4VGraphicsScene::BeginModeling (G4PhysicalVolumeModel&) in
graphics_reps. The result is much cleaner model and modeling
parameters classes. Also, the current depth, physical volume and
logical volume are immediately available as protected pointers in
G4VScene.
- Required G4VScene::Begin/EndModeling to be invoked from subclass.
- Introduced G4NullModel to hold modeling parameters. This avoids
having to create a G4VModel for each graphics primitive.
HEAD 3rd April 1998 John Allison
- Added GetMarkerDiameter/Radius to G4VScene.
- Bug fix in G4VScene::GetMarkerSize.
- Removed GetCurrentPhysicalVolume from G4PhysicalVolumeModel - now in
G4ModelingParameters (but might move again soon!).
- test/GNUmakefile now uses "$(MAKE) separate" for vis libraries.
- test19 recognises argument "1" as a verbose flag value.
HEAD April 2, 98 G.Barrand
- Modifications for Win32/NT.
- G4VIS_BUILD_[OIX, OIWIN32]_DRIVER, G4VIS_USE_[OIX, OIWIN32]
vis-00-05-02 26th March 1998 John Allison
- Added GetMarkerSize to G4VScene.
- Made ~G4VisManager virtual.
- Added current logical volume and current physical volume to working
space in modeling parameters. So it is no longer necessary to cast
to G4PhysicalVolumeModel; all such casts removed.
- Moved nested classes out of G4RayView.
HEAD March 24, 98 G.Cosmo
- Modified G4VisManMessExpert.cc to correctly use random numbers
by calling directly G4UniformRand().
HEAD March 24, 98 G.Barrand
- GNUmakefile : MAKESHLIB changed in G4MAKESHLIB
vis-00-05-01a 24 March 1998 Satoshi Tanaka
- Geometry tree can be obtained by, e.g.,
% grep PVName g4.prim > g4.tree
vis-00-05-01 23rd March 1998 John Allison
- Made RegisterGraphicsSystems pure virtual.
- Added verbose level control to printing at initialization.
- Fixed (hopefully) bug in scene deletion.
- Made AddPrimitive (const G4Text/Circle/Square) pure virtual.
(Had to add dummy void G4VRML1SCENE::AddPrimitive (const G4Text&).)
- Made AddPrimitive (const G4Polymarker&) virtual again.
- Opened some .hh files to G4VIS_USE flags.
- Removed Pre/PostAddThis from some graphics systems (not OPACS, OI).
- First implementation of G4ModelingParameters::hierarchy (DTREE).
- Added Get Global/Current Tag/Description to G4VModel.
- Introduced "working space" in G4ModelingParameters for geometry depth.
- Relocated some template instantiation requests (might give trouble on DEC).
vis-00-04-05a 16th March 1998 Satoshi Tanaka
- DAWN driver outputs physical-volume names and copy number.
vis-00-04-05 5th March 1998 John Allison
- Added G4Text/Circle/Square in G4RayScene.hh.
- Added G4Text/Circle/Square in G4BoundingSphereScene.hh.
- Made AddPrimitive (const G4Polymarker&) non-virtual in G4VScene.hh.
HEAD 5th March 1998 Andy Walkden
- Implemented G4Circle/Square.
- Added haloing to OpenGLXm "value added" options.
HEAD 5th March 1998 S.Sadilov
- visualization/GNUmakefile - using $OUT_LIB intoduced in
GNUmakefile.architecture
- visualization/management/GNUmakefile - compiling G4VisManMessSet.cc
without optimization on WinNT
vis-00-04-04a 5th March 1998 Satoshi TANAKA
- Environmental variables to customized DAWN driver is
renamed from DAWN_... to G4DAWN_...
- Default mode of DAWN driver is EPS mode, i.e.
mode in which EPS files are generated.
vis-00-04-04 4th March 1998 John Allison
- First tag with modeling under visualization.
Here's what you need to do...
cd prototype
cvs update -A -d -P modeling
cd visualization
cvs update -r vis-00-04-04 -d -P
Change the following lines in your GNUmakefile...
CPPFLAGS += -I../../visualization/modeling/include
LDFLAGS += -L../../visualization/modeling/$(G4SYSTEM)
Remove: @cd ../../modeling && $(MAKE)
vis-00-04-03 4th March 1998 John Allison
- Last tag with modeling at same level as visualization.
- Renamed near and far (VC++ keywords) in G4ViewParameters.cc.
- Removed unnecessary #include <strstream.h> or adapted for WIN32.
vis-00-04-02b 22nd February 1998 Satoshi Tanaka
- Split G4VIS_BUILD_VRML1_DRIVER into G4VIS_BUILD_VRML_DRIVER
and G4VIS_BUILD_VRMLFILE_DRIVER.
- Split G4VIS_USE_VRML1 into G4VIS_USE_VRML
and G4VIS_USE_VRMLFILE.
vis-00-04-02a 18th February 1998 John Allison
- Bug fix in G4RayView!
vis-00-04-02 18th February 1998 John Allison
- Introduced /vis~/set/section_plane.
vis-00-04-01 13th February 1998 John Allison
- Made messengers compatible with the new style.
vis-00-03-02a 3rd February 1998 John Allison
- Bug fix for 02.
- Changed GNUmakefile to use processes sub-libraries.
vis-00-03-02 2nd February 1998 John Allison
- Modernised messengers.
vis-00-03-01a 29th January 1998 John Allison
- Tagged a few improvement in OpenGL
vis-00-03-01 26th January 1998 John Allison
- Old environment variables abandoned - see visualization/README.
- G4VisManager is now instantiated *and* deleted in main().
- G4VisRegisterGraphicsSystem.icc replaced by
MyVisManager::RegisterGraphicsSystems as a way - now optional - of
a user overriding the default graphics system registration.
Januray 20 , 98 G. Barrand
- Implement object rotation in OPACS driver
Januray 19 , 98 G. Barrand
- Correct OpenInventor code so that it is ANSI-C++
and then compiles with OSF1/cxx, HP-UX/aCC.
7th January 1998 John Allison
- Restructuring to use modeling category.
December 19, 97 G. Cosmo - (alpha03)
- 1st December 1997 - John Allison.
- This is interim code for testing by the visualization
group and it will be tagged soon. You must update to the
head of graphics_reps and visualization simulatanouesly.
It coworks (I hope - it's difficult to be 100% sure about
this since I have a few changes for other categories in
the pipeline - see previous email) with:
digits+hits digi-00-02-01
events+tracks event-00-02-01
geometry HEAD
global global-00-02-01
intercoms intercoms-00-02-01
interfaces interfaces-00-02-01
particle+matter piim-00-02-01
run run-00-02-01
track track-00-02-01
tracking tracking-00-02-01
- Addition of:
visualization/GNUmakefile.transition_to_G4VIS_BUILD
visualization/GNUmakefile.transition_to_G4VIS_USE
visualization/GNUmakefile.vis_cppflags_for_G4VIS_USE
to turn the existing environment variables into the
to-be-adopted G4VIS_... variables - see visualization/test/README.
- Consequent changes to other visualization GNUmakefiles.
- New way of instantiating graphics systems:
Set the appropriate environment variables and include and
compile G4VisRegisterGraphicsSystems.icc in your main():
...
#include G4VisRegisterGraphicsSystems.icc
...
main() {
...
- Added G4VisFeaturesOfXXX files which simple return a G4String.
(Guy, Jeff, would you like to join this scheme?)
- Added commands /vis~/delete/scene and /vis~/delete/view.
- Added /vis~/show/view to test19.odb.
vis-00-02-01 to vis-00-02-05a not logged!!!
vis-00-01-02 13th July 1997 John Allison
- Consolidation of previous tag.
vis-00-01-01 8th June 1997 John Allison
- First systematic tag.
- G4Ray introduced.
+33
View File
@@ -0,0 +1,33 @@
# $Id: GNUmakefile,v 2.3 1998/07/07 17:11:11 allison Exp $
name := G4OPACS
ifndef G4INSTALL
G4INSTALL = ../../..
endif
include $(G4INSTALL)/config/architecture.gmk
include $(G4INSTALL)/config/G4VIS_BUILD.gmk
include $(G4INSTALL)/config/interactivity.gmk
CPPFLAGS += -I$(G4BASE)/visualization/management/include
CPPFLAGS += -I$(G4BASE)/visualization/modeling/include
CPPFLAGS += -I$(G4BASE)/global/management/include
CPPFLAGS += -I$(G4BASE)/global/HEPGeometry/include
CPPFLAGS += -I$(G4BASE)/geometry/solids/CSG/include
CPPFLAGS += -I$(G4BASE)/graphics_reps/include
CPPFLAGS += -I$(G4BASE)/geometry/management/include
CPPFLAGS += -I$(G4BASE)/geometry/volumes/include
CPPFLAGS += -I$(G4BASE)/interfaces/common/include
ifdef G4VIS_BUILD_OPACS_DRIVER
CPPFLAGS += -I$(COROOT)/include -I$(XXROOT)/include -I$(WOROOT)/include\
-I$(GOROOT)/include -I$(XOROOT)/include
ifeq ($(G4_OPACS_WIDGET_SET),Xm)
CPPFLAGS += -DHAS_XM $(X11FLAGS) $(XMFLAGS)
else
CPPFLAGS += -DHAS_XAW $(X11FLAGS) $(XAWFLAGS)
endif
endif
include $(G4INSTALL)/config/common.gmk
+113
View File
@@ -0,0 +1,113 @@
OPACS as a G4 driver
--------------------
The OPACS html address is :
http://www.lal.in2p3.fr/OPACS
To have G4 running with OPACS :
- Install the OPACS v3 by following
the web installation page.
For G4 take the group :
WoXoXm if you have MOTIF
WoXoXaw if you have Xaw
For example on a UNIX with MOTIF only :
UNIX> mkdir OPACS
UNIX> cd OPACS
UNIX> ftp ftp.lal.in2p3.fr
anonymous
user name
ftp> cd pub/OPACS/v3
ftp> bin
ftp> get WoXoXm.tar.Z
( ftp> get WoXoXaw.tar.Z )
ftp> quit
UNIX> uncompress WoXoXm.tar.Z
( UNIX> uncompress WoXoXaw.tar.Z )
UNIX> tar xvf WoXoXm.tar
( UNIX> tar xvf WoXoXaw.tar )
UNIX> rm WoXoXm.tar
( UNIX> rm WoXoXaw.tar )
UNIX> cd OPACS/v3
UNIX> chmod u+x conf.sh
UNIX> ./conf.sh
csh> source setup.csh
(sh> . ./setup.sh)
UNIX> make WoXo
( UNIX> gmake WoXo )
At end of installation you should
be able to build a simple Wo application
(for exa named Xxx) by doing :
csh> mkdir tmp
csh> cd tmp
with MOTIF :
csh> onew Xxx
or with Xaw :
csh> onew Xxx $WOROOT/usr/template/Xaw/
then :
csh> gmake `uname`
csh> ./Xxx.exe
The interpreted interface is described
in Xxx.odb.
See OPACS doc for more.
- Execute OPACS setup script :
csh> source <OPACS_HOME>/OPACS/v3/setup.csh
- Set environment variables :
G4UI_BUILD_WO_SESSION
G4UI_USE_WO
G4VIS_BUILD_OPACS_DRIVER
G4VIS_USE_OPACS
For example :
csh> setenv G4UI_BUILD_WO_SESSION 1
csh> setenv G4UI_USE_WO 1
csh> setenv G4VIS_BUILD_OPACS_DRIVER 1
csh> setenv G4VIS_USE_OPACS 1
Set G4_OPACS_WIDGET_SET to Xaw if you want
to use Athena widget set instead of Motif :
csh> setenv G4_OPACS_WIDGET_SET Xaw
- Compile G4 interfaces and visualization modules with
the upper variables setted.
- Build visualization/test/test19.
- example to run test 19 with Xaw G4UI and Xo vis driver :
csh> source <OPACS_HOME>/OPACS/v3/setup.csh
(or sh> . <OPACS_HOME>/v3/setup.sh)
csh> cd .../visualization/test
csh> G++-Linux/test19 Xaw
In the little window type :
continue (and click on ok)
continue
/vis~/create_view/new_graphics_system Xo
/run/beamOn 1
continue
When you have something in the Xo window
you can manipulate it with :
Ctrl+button1+move pointer
on the window. On button3 you have a popup
menu to do things, like changing "Ctrl" action,
setting ZBuffer, etc...
- example to run test19 with Wo G4UI reconstructed
with MOTIF :
csh> source <OPACS_HOME>/OPACS/v3/setup.csh
(or sh> . <OPACS_HOME>/v3/setup.sh)
csh> cd .../visualization/test
csh> HP-UX/test19 Wo
or with Xaw :
csh> source <OPACS_HOME>/OPACS/v3/setup.csh
csh> cd .../visualization/test
csh> setenv WOENVIRONMENT test19Xaw.odb
csh> G++-Linux/test19 Wo
The "Wo" interface to test19 is in test19.odb
(or test19Xaw.odb). In this file you can
find examples of buttons that triggs G4 commands.
@@ -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: G4GoScene.hh,v 2.1 1998/11/06 13:42:01 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Guy Barrand 04 November 1996
// Wo scene - creates Wo Display lists.
#ifndef G4GOSCENE_HH
#define G4GOSCENE_HH
#if defined(G4VIS_BUILD_OPACS_DRIVER) || defined(G4VIS_USE_OPACS)
//Go
#include <ONode.h>
#include <OColormap.h>
//G4
#include "globals.hh"
#include "G4VGraphicsSystem.hh"
#include "G4VScene.hh"
class G4GoScene: public G4VScene {
public:
G4GoScene (G4VGraphicsSystem& system,
const G4String& name = "");
~G4GoScene ();
void AddPrimitive (const G4Polyline&);
void AddPrimitive (const G4Text&);
void AddPrimitive (const G4Circle&);
void AddPrimitive (const G4Square&);
void AddPrimitive (const G4Polymarker&);
void AddPrimitive (const G4Polyhedron&);
void AddPrimitive (const G4NURBS&);
void AddThis (const G4Box&);
void AddThis (const G4Cons&);
void AddThis (const G4Tubs&);
void AddThis (const G4Trd&);
void AddThis (const G4Trap&);
void AddThis (const G4Sphere&);
void AddThis (const G4Para&);
void AddThis (const G4Torus&);
void AddThis (const G4VSolid&);
void BeginPrimitives (const G4Transform3D& objectTransformation);
void EndPrimitives ();
void PreAddThis (const G4Transform3D& objectTransformation,
const G4VisAttributes& visAttribs);
void PostAddThis ();
static G4int GetSceneCount ();
ONode GetRootNode ();
private:
void ClearStore ();
void RequestPrimitives (const G4VSolid& solid);
G4VGraphicsSystem& fSystem; // Graphics system for this scene.
ONode fRootGoNode; // Root ONode for this scene.
static G4int fSceneIdCount; // static counter for Wo scenes.
static G4int fSceneCount; // No. of extanct scenes.
static ONode fGoNode; // Current ONode.
static OColormap fOColormap;
void SetColour (const G4Colour&);
char* nodeName;
};
inline G4int G4GoScene::GetSceneCount () {
return fSceneCount;
}
#endif
#endif
@@ -0,0 +1,36 @@
// 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: G4Wo.hh,v 2.1 1998/11/06 13:42:01 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Guy Barrand 04 November 1996
// Wo graphics system factory.
#ifndef G4WO_HH
#define G4WO_HH
#if defined(G4VIS_BUILD_OPACS_DRIVER) || defined(G4VIS_USE_OPACS)
//G4
#include "G4VGraphicsSystem.hh"
class G4VInteractorManager;
class G4Wo: public G4VGraphicsSystem {
public:
G4Wo ();
~G4Wo ();
G4VScene* CreateScene (const G4String& name = "");
G4VView* CreateView (G4VScene&, const G4String& name = "");
static G4VInteractorManager* GetInteractorManager ();
};
#endif
#endif
@@ -0,0 +1,49 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4WoView.hh,v 2.1 1998/11/06 13:42:02 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Guy Barrand 04 November 1996
// Wo view - opens window, hard copy, etc.
#ifndef G4WOVIEW_HH
#define G4WOVIEW_HH
#if defined(G4VIS_BUILD_OPACS_DRIVER) || defined(G4VIS_USE_OPACS)
#include <X11/Intrinsic.h>
#include <OCamera.h>
#include "G4VView.hh"
#include "globals.hh"
class G4GoScene;
// Base class for various WoView classes.
class G4WoView: public G4VView {
public:
G4WoView (G4GoScene& scene, const G4String& name = "");
~G4WoView ();
void DrawView ();
void ShowView ();
OCamera GetCamera ();
private:
void ClearView ();
void FinishView ();
void SetView ();
private:
G4GoScene& fScene; // Graphics Scene for this view.
OCamera fGoCamera;
Widget fXoCamera;
Widget fShell;
};
#endif
#endif
@@ -0,0 +1,36 @@
// 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: G4Xo.hh,v 2.1 1998/11/06 13:42:04 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Guy Barrand 04 November 1996
// Wo graphics system factory.
#ifndef G4XO_HH
#define G4XO_HH
#if defined(G4VIS_BUILD_OPACS_DRIVER) || defined(G4VIS_USE_OPACS)
//G4
#include "G4VGraphicsSystem.hh"
class G4VInteractorManager;
class G4Xo: public G4VGraphicsSystem {
public:
G4Xo ();
~G4Xo ();
G4VScene* CreateScene (const G4String& name = "");
G4VView* CreateView (G4VScene&, const G4String& name = "");
static G4VInteractorManager* GetInteractorManager ();
};
#endif
#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: G4XoView.hh,v 2.1 1998/11/06 13:42:05 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Guy Barrand 04 November 1996
// Wo view - opens window, hard copy, etc.
#ifndef G4XOVIEW_HH
#define G4XOVIEW_HH
#if defined(G4VIS_BUILD_OPACS_DRIVER) || defined(G4VIS_USE_OPACS)
#include <X11/Intrinsic.h>
#include <OCamera.h>
#include "G4VView.hh"
#include "globals.hh"
class G4Xo;
class G4GoScene;
// Base class for various WoView classes.
class G4XoView: public G4VView {
public:
G4XoView (G4GoScene& scene, const G4String& name = "");
~G4XoView ();
void DrawView ();
void ShowView ();
OCamera GetCamera ();
private:
void ClearView ();
void FinishView ();
void SetView ();
private:
G4GoScene& fScene; // Graphics Scene for this view.
OCamera fGoCamera;
Widget fXoCamera;
Widget fShell;
};
#endif
#endif
+471
View File
@@ -0,0 +1,471 @@
// 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: G4GoScene.cc,v 2.3 1998/11/06 13:42:07 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Guy Barrand 04 November 1996
// Wo stored scene - creates Wo display lists.
//#define DEBUG
#ifdef G4VIS_BUILD_OPACS_DRIVER
//Co
#include <CPrinter.h>
#include <CString.h>
//Go
#include <Go.h>
//G4
#include "G4Point3D.hh"
#include "G4Normal3D.hh"
#include "G4Polyline.hh"
#include "G4Polymarker.hh"
#include "G4Polyhedron.hh"
#include "G4Circle.hh"
#include "G4Square.hh"
#include "G4Text.hh"
#include "G4NURBS.hh"
#include "G4PhysicalVolumeModel.hh"
#include "G4VPhysicalVolume.hh"
//This
#include "G4GoScene.hh"
static G4Transform3D transformation;
G4int G4GoScene::fSceneIdCount = 0;
G4int G4GoScene::fSceneCount = 0;
ONode G4GoScene::fGoNode = NULL;
OColormap G4GoScene::fOColormap = NULL;
/***************************************************************************/
G4GoScene::G4GoScene (
G4VGraphicsSystem& system,
const G4String& name
)
/***************************************************************************/
// Creator.
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
:
G4VScene (system, fSceneIdCount++, name),
fSystem (system),
fRootGoNode (NULL),
nodeName (NULL)
/*.........................................................................*/
{
#ifdef DEBUG
G4cout << "G4GoScene::G4GoScene" << endl;
#endif
fSceneCount++;
}
/***************************************************************************/
G4GoScene::~G4GoScene (
)
/***************************************************************************/
// Destructor.
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
if(ONodeIsValid(fRootGoNode)==1) ONodeDelete (fRootGoNode); //fRootGoNode could be deleted by an XoCamera popup "Erase".
fRootGoNode = NULL;
fSceneCount--;
}
/***************************************************************************/
void G4GoScene::AddPrimitive (
const G4Polyline& line
)
/***************************************************************************/
// Method for handling G4Polyline objects.
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
#ifdef DEBUG
G4cout << "G4GoScene::AddPrimitive(G4Polyline&) " << line.entries () << endl;
#endif
SetColour (GetColour(line));
int nPoints = line.entries ();
OPointList points;
points = OPointListCreate(nPoints);
for (int iPoint = 0; iPoint < nPoints; iPoint++) {
OPointListSetIthEntry (points,iPoint,
line(iPoint).x(),
line(iPoint).y(),
line(iPoint).z());
}
GoAddLinesToNode (fGoNode,points);
OPointListDelete (points);
}
/***************************************************************************/
void G4GoScene::AddPrimitive (
const G4Polymarker& line
)
/***************************************************************************/
// Method for handling G4Polymarker objects.
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
#ifdef DEBUG
G4cout << "G4GoScene::AddPrimitive(G4Polymarker&) " << line.entries () << endl;
#endif
SetColour (GetColour(line));
int nPoints = line.entries ();
OPointList points;
points = OPointListCreate(nPoints);
for (int iPoint = 0; iPoint < nPoints; iPoint++) {
OPointListSetIthEntry (points,iPoint,
line(iPoint).x(),
line(iPoint).y(),
line(iPoint).z());
}
GoAddMarkersToNode (fGoNode,points);
OPointListDelete (points);
}
/***************************************************************************/
void G4GoScene::AddPrimitive (
const G4Circle& circle
)
/***************************************************************************/
// Method for handling G4Circle objects.
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
SetColour (GetColour(circle));
G4Point3D center = circle.GetPosition();
G4double radius = circle.GetWorldSize();
#ifdef DEBUG
G4cout << "G4GoScene::AddPrimitive(G4Circle&) : center : "
<< " x : " << center.x()
<< " y : " << center.y()
<< " z : " << center.z()
<< " ,radius : " << radius << endl;
#endif
// Direction of circle ?
//GoAddCircleToNode (fGoNode,radius,center.x(),center.y(),center.z(),0.,0.,1.);
GoAddMarkerToNode (fGoNode,center.x(),center.y(),center.z());
}
/***************************************************************************/
void G4GoScene::AddPrimitive (
const G4Polyhedron& polyhedron
)
/***************************************************************************/
// Method for handling G4Polyhedron objects for drawing solids.
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
#ifdef DEBUG
G4cout << "G4GoScene::AddPrimitive(G4Polyhedron&) " << endl;
#endif
SetColour (GetColour(polyhedron));
OModeling modeling = OModelingWireFrame;
switch (GetDrawingStyle (polyhedron)) {
case (G4ViewParameters::hlhsr):
case (G4ViewParameters::hsr):
modeling = OModelingSolid;
break;
case (G4ViewParameters::hlr):
case (G4ViewParameters::wireframe):
default:
modeling = OModelingWireFrame;
break;
}
G4bool notLastFace;
G4Normal3D SurfaceNormal;
double xs[5];
double ys[5];
double zs[5];
do
{
G4bool notLastEdge;
G4Point3D vertex;
G4int edgeFlag = 1;
int iPoint;
iPoint = 0;
notLastFace = polyhedron.GetNextNormal (SurfaceNormal);
do
{
notLastEdge = polyhedron.GetNextVertex (vertex, edgeFlag);
xs[iPoint] = vertex.x();
ys[iPoint] = vertex.y();
zs[iPoint] = vertex.z();
iPoint++;
} while (notLastEdge);
if( (iPoint!=3) && (iPoint!=4) )
{
CWarnF ("G4GoScene::AddPrimitive G4Polyhedron : not a quad or a triangle : %d\n",iPoint);
}
else
{
if (modeling==OModelingWireFrame)
{
xs[iPoint] = xs[0];
ys[iPoint] = ys[0];
zs[iPoint] = zs[0];
iPoint++;
ONodeAddLines (fGoNode,OContextGetStaticInstance(),iPoint,xs,ys,zs);
}
else if (modeling==OModelingSolid)
{
ONodeAddPolygon (fGoNode,OContextGetStaticInstance(),iPoint,xs,ys,zs);
}
}
} while (notLastFace);
}
/***************************************************************************/
void G4GoScene::AddPrimitive (
const G4Text& text
)
/***************************************************************************/
// Method for handling G4Text objects.
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
SetColour (GetTextColour(text));
#ifdef DEBUG
G4cout << "G4GoScene::AddPrimitive(G4Text&) " << endl;
#endif
CWarnF ("G4GoScene::AddPrimitive G4Text : not yet implemented.\n");
}
/***************************************************************************/
void G4GoScene::AddPrimitive (
const G4Square& Square
)
/***************************************************************************/
// Method for handling G4Square objects.
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
SetColour (GetColour(Square));
#ifdef DEBUG
G4cout << "G4GoScene::AddPrimitive(G4Square&) " << endl;
#endif
CWarnF ("G4GoScene::AddPrimitive G4Square : not yet implemented.\n");
}
/***************************************************************************/
void G4GoScene::AddPrimitive (
const G4NURBS& nurb
)
/***************************************************************************/
//Method for handling G4NURBS objects for drawing solids.
//Knots and Ctrl Pnts MUST be arrays of GLfloats.
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
SetColour (GetColour(nurb));
#ifdef DEBUG
G4cout << "G4GoScene::AddPrimitive(G4NURBS&) " << endl;
#endif
CWarnF ("G4GoScene::AddPrimitive G4NURBS : not yet implemented.\n");
}
/***************************************************************************/
void G4GoScene::AddThis (
const G4Box& box
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4VScene::AddThis (box);
}
/***************************************************************************/
void G4GoScene::AddThis (
const G4Cons& cons
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4VScene::AddThis (cons);
}
/***************************************************************************/
void G4GoScene::AddThis (
const G4Tubs& tubs
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4VScene::AddThis (tubs);
}
/***************************************************************************/
void G4GoScene::AddThis (
const G4Trd& trd
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4VScene::AddThis (trd);
}
/***************************************************************************/
void G4GoScene::AddThis (
const G4Trap& trap
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4VScene::AddThis (trap);
}
/***************************************************************************/
void G4GoScene::AddThis (
const G4Sphere& sphere
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4VScene::AddThis (sphere);
}
/***************************************************************************/
void G4GoScene::AddThis (
const G4Para& para
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4VScene::AddThis (para);
}
/***************************************************************************/
void G4GoScene::AddThis (
const G4Torus& torus
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4VScene::AddThis (torus);
}
/***************************************************************************/
void G4GoScene::AddThis (
const G4VSolid& solid
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4VScene::AddThis (solid);
}
/***************************************************************************/
void G4GoScene::PreAddThis (
const G4Transform3D& objectTransformation,
const G4VisAttributes& visAttribs
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4VScene::PreAddThis (objectTransformation, visAttribs);
CStringDelete (nodeName);
nodeName = NULL;
const G4VPhysicalVolume* currentPhysicalVolume = fpCurrentPV;
if(currentPhysicalVolume==NULL) return;
nodeName = CStringCreateF (15+64,"PhysicalVolume/%lu",currentPhysicalVolume );
#ifdef DEBUG
G4cout << "G4GoScene::PreAddThis : " << nodeName << endl;
#endif
}
/***************************************************************************/
void G4GoScene::PostAddThis (
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
#ifdef DEBUG
G4cout << "G4GoScene::PostAddThis" << endl;
#endif
CStringDelete (nodeName);
nodeName = NULL;
G4VScene::PostAddThis();
}
/***************************************************************************/
void G4GoScene::BeginPrimitives (
const G4Transform3D& objectTransformation
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
#ifdef DEBUG
G4cout << "G4GoScene::BeginPrimitives" << endl;
#endif
G4VScene::BeginPrimitives (objectTransformation);
transformation = objectTransformation;
fGoNode = nodeName!=NULL ? ONodeCreate (nodeName) : ONodeMake ();
if(ONodeIsValid(fRootGoNode)==0) fRootGoNode = ONodeMake ();
ONodeAddChild (fRootGoNode,fGoNode);
}
/***************************************************************************/
void G4GoScene::EndPrimitives (
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
#ifdef DEBUG
G4cout << "G4GoScene::EndPrimitives" << endl;
#endif
G4double g4angle;
G4ThreeVector g4axis;
G4ThreeVector g4trans;
transformation.getRotation().getAngleAxis(g4angle,g4axis);
g4trans = transformation.getTranslation();
OMatrix orot = OMatrixCreate (OMatrixRotationAxis,g4angle,g4axis.x(),g4axis.y(),g4axis.z());
OMatrix otra = OMatrixCreate (OMatrixTranslation,g4trans.x(),g4trans.y(),g4trans.z());
OMatrix omatrix = OMatrixMultiply (otra,orot);
ONodeSetMatrix (fGoNode,omatrix);
OMatrixDelete (omatrix);
OMatrixDelete (orot);
OMatrixDelete (otra);
fGoNode = NULL;
G4VScene::EndPrimitives ();
}
/***************************************************************************/
void G4GoScene::ClearStore (
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
#ifdef DEBUG
G4cout << "G4GoScene::ClearStore" << endl;
#endif
if(ONodeIsValid(fRootGoNode)==0) fRootGoNode = NULL;
ONodeDestroyChildren (fRootGoNode);
}
/***************************************************************************/
void G4GoScene::RequestPrimitives (
const G4VSolid& solid
)
/***************************************************************************/
// Stop-gap solution for display List re-use.
// A proper implementation would use geometry hierarchy.
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
#ifdef DEBUG
G4cout << "G4GoScene::RequestPrimitives" << endl;
#endif
G4VScene::RequestPrimitives (solid);
}
/***************************************************************************/
ONode G4GoScene::GetRootNode (
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
#ifdef DEBUG
G4cout << "G4GoScene::RequestPrimitives" << endl;
#endif
if(ONodeIsValid(fRootGoNode)==0) fRootGoNode = NULL;
return fRootGoNode;
}
/***************************************************************************/
void G4GoScene::SetColour (
const G4Colour& a_colour
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
if(fOColormap==NULL) fOColormap = OColormapGetIdentifier("ocolormap_X");
int index = OColormapGetRGB_Index(fOColormap,a_colour.GetRed (), a_colour.GetGreen (), a_colour.GetBlue ());
#ifdef DEBUG
G4cout << "G4GoScene::SetColour : red : " << a_colour.GetRed () <<
" green : " << a_colour.GetGreen () <<
" blue : " << a_colour.GetBlue () <<
" index : " << index << endl;
#endif
OContextSetColorIndex (OContextGetStaticInstance(),index);
}
#endif
+78
View File
@@ -0,0 +1,78 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4Wo.cc,v 2.1 1998/11/06 13:42:08 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Guy Barrand 04 November 1996
// Wo graphics system factory.
#ifdef G4VIS_BUILD_OPACS_DRIVER
//Co
#include <CPrinter.h>
#include <Wo.h>
//G4
#include "G4Xt.hh"
#include "G4WoView.hh"
#include "G4GoScene.hh"
//This
#include "G4Wo.hh"
static G4VInteractorManager* interactorManager = NULL;
/***************************************************************************/
G4Wo::G4Wo (
)
:G4VGraphicsSystem ("Wo",G4VGraphicsSystem::threeD)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
/*.........................................................................*/
{
interactorManager = G4Xt::getInstance ();
}
/***************************************************************************/
G4Wo::~G4Wo (
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
}
/***************************************************************************/
G4VInteractorManager* G4Wo::GetInteractorManager (
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
return interactorManager;
}
/***************************************************************************/
G4VScene* G4Wo::CreateScene (
const G4String& name
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4GoScene* pScene = new G4GoScene (*this, name);
return pScene;
}
/***************************************************************************/
G4VView* G4Wo::CreateView (
G4VScene& scene,
const G4String& name
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4GoScene* pScene = (G4GoScene*)&scene;
G4VView* pView = new G4WoView (*pScene, name);
return pView;
}
#endif
+201
View File
@@ -0,0 +1,201 @@
// 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: G4WoView.cc,v 2.8 1998/11/09 15:51:38 barrand Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Guy Barrand 04 November 1996
#ifdef G4VIS_BUILD_OPACS_DRIVER
//#define DEBUG
/*Co*/
#include <CPrinter.h>
#include <CString.h>
/*Xx*/
#include <XWidget.h>
/*Go*/
#include <OCamera.h>
/*Wo*/
#include <OWidget.h>
#include <Wo.h>
//G4
#include "G4VInteractorManager.hh"
#include "G4Wo.hh"
#include "G4GoScene.hh"
//This
#include "G4WoView.hh"
/***************************************************************************/
G4WoView::G4WoView (
G4GoScene& scene,
const G4String& name
)
:G4VView (scene, scene.IncrementViewCount(), name)
,fScene (scene)
,fGoCamera (NULL)
,fXoCamera (NULL)
,fShell (NULL)
/***************************************************************************/
// Constructor.
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
#ifdef DEBUG
G4cout << "G4WoView::G4WoView" << endl;
#endif
if(WoIsInitialized()==0) {
CWarn ("G4WoView : Wo is not initialized !\n");
return;
}
char* defName = CStringDuplicate((char*)fName.data());
CStringReplacePart (&defName,"-","_");
fGoCamera = OCameraGetIdentifier (defName);
if(fGoCamera!=NULL) {
return; //OCamera could have been created
//by loading an odb file at Wo startup.
}
G4VInteractorManager* interactorManager = G4Wo::GetInteractorManager();
Widget parent = (Widget)interactorManager->GetParentInteractor ();
char* wname = NULL;
if(parent==NULL) { //Create a shell widget.
wname = CStringCreateF (6+strlen(defName),"shell_%s",defName);
#ifdef HAS_XM
fShell = OWidgetCreate (wname,XWidgetGetTop(),"XmFormDialog",False);
#else
fShell = OWidgetCreate (wname,XWidgetGetTop(),"TopLevelShell",False);
#endif
CStringDelete (wname);
parent = fShell;
wname = CStringDuplicate (defName);
} else {
char* str = interactorManager->GetCreationString ();
if(str==NULL) {
wname = CStringDuplicate (defName);
} else {
wname = CStringDuplicate (str);
}
}
fXoCamera = OWidgetCreate (wname,parent,"XoCamera",False);
if(fShell!=NULL) {
#ifdef HAS_XM
OWidgetSetResourceFromString (fShell,"dialogTitle",wname,False);
OWidgetSetResourceFromString (fXoCamera,"topAttachment","attach_form",False);
OWidgetSetResourceFromString (fXoCamera,"leftAttachment","attach_form",False);
OWidgetSetResourceFromString (fXoCamera,"rightAttachment","attach_form",False);
OWidgetSetResourceFromString (fXoCamera,"bottomAttachment","attach_form",False);
#else
OWidgetSetResourceFromString (fShell,"title",wname,False);
#endif
XWidgetMap (fShell);
}
fGoCamera = OCameraGetIdentifier (wname);
if(fGoCamera==NULL) {
CWarnF ("Can't find/create OCamera %s\n",wname);
}
CStringDelete (wname);
CStringDelete (defName);
interactorManager->SetCreatedInteractor (fXoCamera);
}
/***************************************************************************/
G4WoView::~G4WoView (
)
/***************************************************************************/
// Destructor.
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
if(fShell!=NULL) {
OWidgetDelete (fShell,False);
} else if(fXoCamera!=NULL) {
OWidgetDelete (fXoCamera,False);
}
}
/***************************************************************************/
void G4WoView::ClearView (
)
/***************************************************************************/
{
}
/***************************************************************************/
void G4WoView::SetView (
)
/***************************************************************************/
// Calculates view representation based on extent of object being
// viewed and (initial) direction of camera. (Note: it can change
// later due to user interaction via visualization system's GUI.)
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
const G4Point3D target = fVP.GetCurrentTargetPoint ();
G4double radius = fScene.GetSceneData().GetExtent().GetExtentRadius();
if(radius<=0.) radius = 1. * m;
const G4double cameraDistance = fVP.GetCameraDistance (radius);
const G4Point3D& pCamera =
target + cameraDistance * fVP.GetViewpointDirection().unit();
#ifdef DEBUG
G4cout << "G4WoView::SetView : target.x " << target.x() << " target.y " << target.y() << " target.z " << target.z() << endl;
G4cout << "G4WoView::SetView : dir.x " << fVP.GetViewpointDirection().unit().x() <<
" dir.y " << fVP.GetViewpointDirection().unit().y() <<
" dir.z " << fVP.GetViewpointDirection().unit().z() << endl;
G4cout << "G4WoView::SetView : cameraDistance " << cameraDistance << endl;
G4cout << "G4WoView::SetView : pCamera.x " << pCamera.x() << " pCamera.y " << pCamera.y() << " pCamera.z " << pCamera.z() << endl;
G4cout << "G4WoView::SetView : pCamera.x " << pCamera.x() << " pCamera.y " << pCamera.y() << " pCamera.z " << pCamera.z() << endl;
#endif
OCameraSetCenter (fGoCamera,target.x() ,target.y() ,target.z());
OCameraSetDefaultVRP (fGoCamera,pCamera.x(),pCamera.y(),pCamera.z());
OCameraSetDefaultUpVector (fGoCamera,0.,1.,0.);
OCameraSetField (fGoCamera,-radius,radius);
}
/***************************************************************************/
void G4WoView::DrawView (
)
/***************************************************************************/
{
NeedKernelVisit ();
ProcessView ();
ShowView ();
}
/***************************************************************************/
void G4WoView::ShowView (
)
/***************************************************************************/
{
OCameraViewNode (fGoCamera,fScene.GetRootNode());
}
/***************************************************************************/
OCamera G4WoView::GetCamera (
)
/***************************************************************************/
{
return fGoCamera;
}
/***************************************************************************/
void G4WoView::FinishView (
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
}
#endif
+88
View File
@@ -0,0 +1,88 @@
// 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: G4Xo.cc,v 2.2 1998/11/06 13:42:10 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Guy Barrand 04 November 1996
// Wo graphics system factory.
#ifdef G4VIS_BUILD_OPACS_DRIVER
//#define DEBUG
#include <stddef.h>
//Co
#include <CPrinter.h>
//Xx
#include <XWidget.h>
//G4
#include "G4Xt.hh"
#include "G4XoView.hh"
#include "G4GoScene.hh"
//This
#include "G4Xo.hh"
static G4VInteractorManager* interactorManager = NULL;
/***************************************************************************/
G4Xo::G4Xo (
)
:G4VGraphicsSystem ("Xo",G4VGraphicsSystem::threeD)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
/*.........................................................................*/
{
interactorManager = G4Xt::getInstance ();
Widget top = (Widget)interactorManager->GetMainInteractor ();
if(top==NULL) {
CWarn ("G4Xo : Unable to init Xt.\n");
return;
}
XWidgetSetTop (top);
XDisplayPutFileInResourceDatabase (XtDisplay(top),"G4Xo.xrm");
}
/***************************************************************************/
G4Xo::~G4Xo (
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
}
/***************************************************************************/
G4VInteractorManager* G4Xo::GetInteractorManager (
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
return interactorManager;
}
/***************************************************************************/
G4VScene* G4Xo::CreateScene (
const G4String& name
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4GoScene* pScene = new G4GoScene (*this, name);
return pScene;
}
/***************************************************************************/
G4VView* G4Xo::CreateView (
G4VScene& scene,
const G4String& name
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4GoScene* pScene = (G4GoScene*)&scene;
G4VView* pView = new G4XoView (*pScene, name);
return pView;
}
#endif
+263
View File
@@ -0,0 +1,263 @@
// 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: G4XoView.cc,v 2.7 1998/11/06 13:42:11 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Guy Barrand 04 November 1996
#ifdef G4VIS_BUILD_OPACS_DRIVER
//#define DEBUG
//X11
#include <X11/Intrinsic.h>
#include <X11/Shell.h>
/*Co*/
#include <CPrinter.h>
#include <CString.h>
#include <CList.h>
/*Xx*/
#include <XWidget.h>
/*Go*/
#include <OCamera.h>
/*Xo*/
#include <XoCamera.h>
//G4
#include "G4GoScene.hh"
#include "G4Xo.hh"
#include "G4VInteractorManager.hh"
//This
#include "G4XoView.hh"
static Bool WaitForNotify (Display*,XEvent*,char*);
static void ActivateCallback (Widget,XtPointer,XtPointer);
static void CollectCallback (Widget,XtPointer,XtPointer);
/***************************************************************************/
G4XoView::G4XoView (
G4GoScene& scene,
const G4String& name
)
:G4VView (scene, scene.IncrementViewCount(), name)
,fScene (scene)
,fGoCamera (NULL)
,fXoCamera (NULL)
,fShell (NULL)
/***************************************************************************/
// Constructor.
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
#ifdef DEBUG
G4cout << "G4XoView::G4XoView" << endl;
#endif
G4VInteractorManager* interactorManager = G4Xo::GetInteractorManager();
Widget top = (Widget)interactorManager->GetMainInteractor ();
if(top==NULL) {
CWarn ("Xt is not initialized !\n");
return;
}
char* defName = CStringDuplicate((char*)fName.data());
CStringReplacePart (&defName,"-","_");
Arg args[1];
char* wname = NULL;
Widget parent = (Widget)interactorManager->GetParentInteractor ();
if(parent==NULL) {
// Create a shell widget.
// Add WMClose does not works on ApplicationShell, then use a TopLevelShell.
char* cname;
wname = CStringCreateF (6+strlen(defName),"shell_%s",defName);
cname = CStringCreateF (6+strlen(defName),"Shell_%s",defName);
fShell = XtAppCreateShell (wname,cname,topLevelShellWidgetClass,XtDisplay(top),args,0);
CStringDelete (wname);
CStringDelete (cname);
interactorManager->AddShell (fShell);
parent = fShell;
wname = CStringDuplicate(defName);
} else {
char* str = interactorManager->GetCreationString ();
if(str==NULL) {
wname = CStringDuplicate (defName);
} else {
wname = CStringDuplicate (str);
}
}
fXoCamera = XtCreateManagedWidget (wname,xoCameraWidgetClass ,parent, args, 0);
fGoCamera = (OCamera) XoCameraGetCamera (fXoCamera);
XoCameraAddPopupEntry (fXoCamera,"Escape",ActivateCallback,NULL);
XtAddCallback (fXoCamera,XoNcollectCallback,CollectCallback,NULL);
if(fShell!=NULL) {
XtRealizeWidget (fShell);
XtMapWidget (fShell);
XEvent event;
XIfEvent (XtDisplay(fShell), &event, WaitForNotify, (char*)XtWindow(fShell));
}
if(fGoCamera==NULL) {
CWarnF ("Can't create OCamera %s\n",wname);
fXoCamera = NULL;
fGoCamera = NULL;
}
// g++ wants the cast !!!
interactorManager->AddSecondaryLoopPreAction ((G4SecondaryLoopAction)XoCameraEnablePopup);
interactorManager->AddSecondaryLoopPostAction ((G4SecondaryLoopAction)XoCameraDisablePopup);
interactorManager->SetCreatedInteractor (fXoCamera);
CStringDelete (wname);
CStringDelete (defName);
}
/***************************************************************************/
G4XoView::~G4XoView (
)
/***************************************************************************/
// Destructor.
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
if(fShell!=NULL) {
G4Xo::GetInteractorManager()->RemoveShell (fShell);
XtDestroyWidget (fShell);
} else if(fXoCamera!=NULL) {
XtDestroyWidget (fXoCamera);
}
fXoCamera = NULL;
fGoCamera = NULL;
}
/***************************************************************************/
void G4XoView::ClearView (
)
/***************************************************************************/
{
}
/***************************************************************************/
void G4XoView::SetView (
)
/***************************************************************************/
// Calculates view representation based on extent of object being
// viewed and (initial) direction of camera. (Note: it can change
// later due to user interaction via visualization system's GUI.)
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
const G4Point3D target = fVP.GetCurrentTargetPoint ();
G4double radius = fScene.GetSceneData().GetExtent().GetExtentRadius();
if(radius<=0.) radius = 1. * m;
const G4double cameraDistance = fVP.GetCameraDistance (radius);
const G4Point3D& pCamera =
target + cameraDistance * fVP.GetViewpointDirection().unit();
#ifdef DEBUG
G4cout << "G4XoView::SetView : target.x " << target.x() << " target.y " << target.y() << " target.z " << target.z() << endl;
G4cout << "G4XoView::SetView : dir.x " << fVP.GetViewpointDirection().unit().x() <<
" dir.y " << fVP.GetViewpointDirection().unit().y() <<
" dir.z " << fVP.GetViewpointDirection().unit().z() << endl;
G4cout << "G4XoView::SetView : cameraDistance " << cameraDistance << endl;
G4cout << "G4XoView::SetView : pCamera.x " << pCamera.x() << " pCamera.y " << pCamera.y() << " pCamera.z " << pCamera.z() << endl;
#endif
OCameraSetCenter (fGoCamera,target.x() ,target.y() ,target.z());
OCameraSetDefaultVRP (fGoCamera,pCamera.x(),pCamera.y(),pCamera.z());
OCameraSetDefaultUpVector (fGoCamera,0.,1.,0.);
OCameraSetField (fGoCamera,-radius,radius);
}
/***************************************************************************/
OCamera G4XoView::GetCamera (
)
/***************************************************************************/
{
return fGoCamera;
}
/***************************************************************************/
void G4XoView::DrawView (
)
/***************************************************************************/
{
NeedKernelVisit ();
ProcessView ();
FinishView ();
}
/***************************************************************************/
void G4XoView::FinishView (
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
}
/***************************************************************************/
void G4XoView::ShowView (
)
/***************************************************************************/
{
OCameraViewNode (fGoCamera,fScene.GetRootNode());
G4Xo::GetInteractorManager() -> SecondaryLoop();
}
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
Bool WaitForNotify (
Display* d
,XEvent* e
,char* arg
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
/*.........................................................................*/
d = NULL;
return (e->type == MapNotify) && (e->xmap.window == (Window)arg);
}
/***************************************************************************/
void ActivateCallback (
Widget This
,XtPointer a_tag
,XtPointer a_data
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
G4Xo::GetInteractorManager() -> RequireExitSecondaryLoop (XO_EXIT_CODE);
This = NULL;
a_tag = NULL;
a_data = NULL;
}
/***************************************************************************/
void CollectCallback (
Widget This
,XtPointer a_tag
,XtPointer a_data
)
/***************************************************************************/
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
{
OCamera camera;
ONode* nodes;
int noden,count;
/*.........................................................................*/
// collectCallback = osh> getCameraNodes `thisCamera` | collect ONode where highlight eq 1 | get - name | dump -
camera = (OCamera)XoCameraGetCamera (This);
nodes = OCameraCollect (camera,OCollectHighlighted);
noden = CListGetSize ((CList)nodes);
for(count=0;count<noden;count++)
{
char* name = ONodeGetName(nodes[count]);
CInfoF("%s\n",name==NULL ? "(nil)" : name);
}
CListDelete ((CList)nodes);
This = NULL;
a_tag = NULL;
a_data = NULL;
}
#endif
+37
View File
@@ -0,0 +1,37 @@
# $Id: GNUmakefile,v 2.3 1998/07/07 17:11:13 allison Exp $
name := G4OpenGL
ifndef G4INSTALL
G4INSTALL = ../../..
endif
include $(G4INSTALL)/config/architecture.gmk
include $(G4INSTALL)/config/G4VIS_BUILD.gmk
include $(G4INSTALL)/config/interactivity.gmk
CPPFLAGS += -I$(G4BASE)/visualization/management/include
CPPFLAGS += -I$(G4BASE)/visualization/modeling/include
CPPFLAGS += -I$(G4BASE)/global/management/include
CPPFLAGS += -I$(G4BASE)/global/HEPGeometry/include
CPPFLAGS += -I$(G4BASE)/geometry/solids/CSG/include
CPPFLAGS += -I$(G4BASE)/graphics_reps/include
CPPFLAGS += -I$(G4BASE)/geometry/management/include
CPPFLAGS += -I$(G4BASE)/geometry/volumes/include
CPPFLAGS += -I$(G4BASE)/intercoms/include
CPPFLAGS += -I$(G4BASE)/interfaces/common/include
ifdef G4VIS_BUILD_OPENGL_DRIVER
CPPFLAGS += $(OGLFLAGS)
endif
ifdef G4VIS_BUILD_OPENGLXAW_DRIVER
CPPFLAGS += $(XAWFLAGS)
endif
ifdef G4VIS_BUILD_OPENGLXM_DRIVER
CPPFLAGS += $(XMFLAGS)
endif
ifdef G4VIS_BUILD_OPENGLX_DRIVER
CPPFLAGS += $(X11FLAGS)
endif
include $(G4INSTALL)/config/common.gmk
@@ -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: G4OpenGLImmediateScene.hh,v 2.2 1998/11/06 13:42:13 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Andrew Walkden 10th February 1997
// G4OpenGLImmediateScene - no Display lists.
#ifdef G4VIS_BUILD_OPENGL_DRIVER
#ifndef G4OPENGLIMMEDIATESCENE_HH
#define G4OPENGLIMMEDIATESCENE_HH
#include "G4VScene.hh"
#include "G4OpenGLView.hh"
#include "G4OpenGLImmediateView.hh"
#include "globals.hh"
#include "G4RotationMatrix.hh"
#include "G4OpenGLScene.hh"
class G4OpenGLImmediate;
class G4OpenGLImmediateScene: public G4OpenGLScene {
public:
G4OpenGLImmediateScene (G4VGraphicsSystem& system, const G4String& name);
~G4OpenGLImmediateScene ();
void BeginPrimitives (const G4Transform3D& objectTransformation);
void EndPrimitives ();
void BeginModeling ();
void EndModeling ();
static G4int GetSceneCount ();
private:
static G4int fSceneIdCount; // static counter for OpenGLImmediate scenes.
static G4int fSceneCount; // No. of extanct scenes.
};
#endif
#endif
@@ -0,0 +1,44 @@
// 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: G4OpenGLImmediateView.hh,v 2.0 1998/07/02 16:44:02 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Andrew Walkden 7th February 1997
// Class G4OpenGLImmediateView : Encapsulates the `immediateness' of
// an OpenGL view, for inheritance by
// derived (X, Xm...) classes.
#ifdef G4VIS_BUILD_OPENGL_DRIVER
#ifndef G4OPENGLIMMEDIATEVIEW_HH
#define G4OPENGLIMMEDIATEVIEW_HH
#include "G4VView.hh"
#include "G4OpenGLView.hh"
#include "G4OpenGLScene.hh"
#include "G4OpenGLImmediateScene.hh"
#include "G4OpenGLTransform3D.hh"
#include "globals.hh"
#include <rw/tvordvec.h>
class G4OpenGLScene;
class G4OpenGLImmediateScene;
class G4OpenGLImmediateView: virtual public G4OpenGLView {
public:
G4OpenGLImmediateView (G4OpenGLImmediateScene& scene);
private:
G4OpenGLImmediateScene& fScene; // Graphics Scene for this view.
};
#endif
#endif
@@ -0,0 +1,30 @@
// 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: G4OpenGLImmediateWin32.hh,v 2.0 1998/07/02 16:44:03 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// OpenGLImmediateWin32 graphics system factory.
#if defined (G4VIS_BUILD_OPENGLWIN32_DRIVER) || defined (G4VIS_USE_OPENGLWIN32)
#ifndef G4OPENGLIMMEDIATEWIN32_HH
#define G4OPENGLIMMEDIATEWIN32_HH
#include "G4VGraphicsSystem.hh"
class G4OpenGLImmediateWin32: public G4VGraphicsSystem {
public:
G4OpenGLImmediateWin32 ();
G4VScene* CreateScene ();
G4VView* CreateView (G4VScene&);
};
#endif
#endif
@@ -0,0 +1,39 @@
// 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: G4OpenGLImmediateWin32View.hh,v 2.0 1998/07/02 16:44:05 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Class G4OpenGLImmediateWin32View : a class derived from G4OpenGLWin32View and
// G4OpenGLImmediateView.
#ifdef G4VIS_BUILD_OPENGLWIN32_DRIVER
#ifndef G4OpenGLIMMEDIATEWIN32VIEW_HH
#define G4OpenGLIMMEDIATEWIN32VIEW_HH
#include "G4VView.hh"
#include "G4OpenGLImmediateView.hh"
#include "G4OpenGLWin32View.hh"
#include "globals.hh"
#include <rw/tvordvec.h>
class G4OpenGLImmediateScene;
class G4OpenGLImmediateWin32View:
public G4OpenGLWin32View, public G4OpenGLImmediateView{
public:
G4OpenGLImmediateWin32View (G4OpenGLImmediateScene& scene);
void DrawView ();
};
#endif
#endif
@@ -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: G4OpenGLImmediateX.hh,v 2.1 1998/11/06 13:42:14 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Andrew Walkden 10th February 1997
// OpenGL graphics system factory.
#if defined (G4VIS_BUILD_OPENGLX_DRIVER) || defined (G4VIS_USE_OPENGLX)
#ifndef G4OPENGLIMMEDIATEX_HH
#define G4OPENGLIMMEDIATEX_HH
#include "G4VGraphicsSystem.hh"
class G4OpenGLImmediateX: public G4VGraphicsSystem {
public:
G4OpenGLImmediateX ();
G4VScene* CreateScene (const G4String& name = "");
G4VView* CreateView (G4VScene&, const G4String& name = "");
};
#endif
#endif
@@ -0,0 +1,41 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4OpenGLImmediateXView.hh,v 2.1 1998/11/06 13:42:15 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Andrew Walkden 7th February 1997
// Class G4OpenGLImmediateXView : a class derived from G4OpenGLXView and
// G4OpenGLImmediateView.
#ifdef G4VIS_BUILD_OPENGLX_DRIVER
#ifndef G4OpenGLIMMEDIATEXVIEW_HH
#define G4OpenGLIMMEDIATEXVIEW_HH
#include "G4VView.hh"
#include "G4OpenGLImmediateView.hh"
#include "G4OpenGLXView.hh"
#include "globals.hh"
#include <rw/tvordvec.h>
class G4OpenGLImmediateScene;
class G4OpenGLImmediateXView:
public G4OpenGLXView, public G4OpenGLImmediateView{
public:
G4OpenGLImmediateXView (G4OpenGLImmediateScene& scene,
const G4String& name = "");
void DrawView ();
};
#endif
#endif
@@ -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: G4OpenGLImmediateXm.hh,v 2.1 1998/11/06 13:42:16 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Andrew Walkden 10th February 1997
// OpenGL graphics system factory.
#if defined (G4VIS_BUILD_OPENGLXM_DRIVER) || defined (G4VIS_USE_OPENGLXM)
#ifndef G4OPENGLIMMEDIATEXM_HH
#define G4OPENGLIMMEDIATEXM_HH
#include "G4VGraphicsSystem.hh"
class G4OpenGLImmediateXm: public G4VGraphicsSystem {
public:
G4OpenGLImmediateXm ();
G4VScene* CreateScene (const G4String& name = "");
G4VView* CreateView (G4VScene&, const G4String& name = "");
};
#endif
#endif
@@ -0,0 +1,42 @@
// 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: G4OpenGLImmediateXmView.hh,v 2.1 1998/11/06 13:42:17 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Andrew Walkden 10th February 1997
// G4OpenGLXmView : Class derived from G4OpenGLXView, to provide
// (Motif) widget OpenGL functionality for GEANT4.
#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
#ifndef G4OPENGLIMMEDIATEXMVIEW_HH
#define G4OPENGLIMMEDIATEXMVIEW_HH
#include "G4VView.hh"
#include "G4OpenGLImmediateView.hh"
#include "G4OpenGLXmView.hh"
#include "globals.hh"
#include <rw/tvordvec.h>
class G4OpenGLImmediateScene;
class G4OpenGLImmediateXmView:
public G4OpenGLXmView, public G4OpenGLImmediateView{
public:
G4OpenGLImmediateXmView (G4OpenGLImmediateScene& scene,
const G4String& name = "");
void DrawView ();
};
#endif
#endif
@@ -0,0 +1,69 @@
// 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: G4OpenGLScene.hh,v 2.3 1998/11/06 13:42:18 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Andrew Walkden 27th March 1996
// OpenGL scene - base for immediate mode and stored mode classes to
// inherit from.
#ifdef G4VIS_BUILD_OPENGL_DRIVER
#ifndef G4OPENGLSCENE_HH
#define G4OPENGLSCENE_HH
#include <rw/tvhdict.h>
#include "G4VScene.hh"
#include "G4OpenGLView.hh"
#include "globals.hh"
#include "G4RotationMatrix.hh"
#include <GL/gl.h>
#include <GL/glx.h>
#include <GL/glu.h>
// Base class for various OpenGLScene classes.
class G4OpenGLScene: public G4VScene {
public:
void AddPrimitive (const G4Polyline&);
void AddPrimitive (const G4Text&);
void AddPrimitive (const G4Circle&);
void AddPrimitive (const G4Square&);
void AddPrimitive (const G4Polyhedron&);
void AddPrimitive (const G4NURBS&);
void AddPrimitive (const G4Polymarker&);
void AddThis (const G4Box&);
void AddThis (const G4Cons&);
void AddThis (const G4Tubs&);
void AddThis (const G4Trd&);
void AddThis (const G4Trap&);
void AddThis (const G4Sphere&);
void AddThis (const G4Para&);
void AddThis (const G4Torus&);
void AddThis (const G4VSolid&);
protected:
G4OpenGLScene (G4VGraphicsSystem& system,
G4int id,
const G4String& name = "");
~G4OpenGLScene ();
G4bool initialize_hlr;
private:
GLdouble clear_colour[4];
};
#include "G4OpenGLScene.icc"
#endif
#endif
@@ -0,0 +1,53 @@
// 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: G4OpenGLScene.icc,v 2.1 1998/08/07 12:46:14 barrand Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Andrew Walkden 20th January 1998
inline void G4OpenGLScene::AddThis (const G4Box& box) {
G4VScene::AddThis (box);
}
inline void G4OpenGLScene::AddThis (const G4Cons& cons) {
G4VScene::AddThis (cons);
}
inline void G4OpenGLScene::AddThis (const G4Tubs& tubs) {
G4VScene::AddThis (tubs);
}
inline void G4OpenGLScene::AddThis (const G4Trd& trd) {
G4VScene::AddThis (trd);
}
inline void G4OpenGLScene::AddThis (const G4Trap& trap) {
G4VScene::AddThis (trap);
}
inline void G4OpenGLScene::AddThis (const G4Sphere& sphere) {
G4VScene::AddThis (sphere);
}
inline void G4OpenGLScene::AddThis (const G4Para& para) {
G4VScene::AddThis (para);
}
inline void G4OpenGLScene::AddThis (const G4Torus& torus) {
G4VScene::AddThis (torus);
}
inline void G4OpenGLScene::AddThis (const G4VSolid& vsolid) {
G4VScene::AddThis (vsolid);
}
inline void G4OpenGLScene::AddPrimitive (const G4Polymarker& polymarker) {
G4VScene::AddPrimitive (polymarker);
}
@@ -0,0 +1,71 @@
// 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: G4OpenGLStoredScene.hh,v 2.2 1998/11/06 13:42:19 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Andrew Walkden 10th February 1997
// G4OpenGLStoredScene - creates OpenGL Display lists.
#ifdef G4VIS_BUILD_OPENGL_DRIVER
#ifndef G4OPENGLSTOREDSCENE_HH
#define G4OPENGLSTOREDSCENE_HH
#include "G4VScene.hh"
#include "G4OpenGLView.hh"
#include "G4OpenGLStoredView.hh"
#include "globals.hh"
#include "G4RotationMatrix.hh"
#include "G4OpenGLScene.hh"
class G4OpenGLStored;
class G4OpenGLStoredScene: public G4OpenGLScene {
public:
typedef unsigned long G4VSolidPointer;
G4OpenGLStoredScene (G4VGraphicsSystem& system, const G4String& name = "");
~G4OpenGLStoredScene ();
void BeginPrimitives (const G4Transform3D& objectTransformation);
void EndPrimitives ();
void BeginModeling ();
void EndModeling ();
static G4int GetSceneCount ();
G4bool fMemoryForDisplayLists; // avoid memory overflow
private:
friend class G4OpenGLStoredView;
// ..allows access to P/TODLs.
void ClearStore ();
void RequestPrimitives (const G4VSolid& solid);
static G4int fSceneIdCount; // static counter for OpenGLStored scenes.
static G4int fSceneCount; // No. of extanct scenes.
G4int fDisplayListId; // Workspace.
// PODL = Persistent Object Display List.
GLint fTopPODL; // List which calls the other PODLs.
RWTValOrderedVector<G4int> fPODLList;
RWTValOrderedVector<G4Transform3D> fPODLTransformList;
// TODL = Transient Object Display List.
RWTValOrderedVector<G4int> fTODLList;
RWTValOrderedVector<G4Transform3D> fTODLTransformList;
// Stop-gap solution of structure re-use.
// A proper implementation would use geometry hierarchy.
RWTValHashDictionary<G4VSolidPointer, G4int> fSolidDictionary;
};
inline G4int G4OpenGLStoredScene::GetSceneCount () {
return fSceneCount;
}
#endif
#endif
@@ -0,0 +1,45 @@
// 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: G4OpenGLStoredView.hh,v 2.0 1998/07/02 16:44:28 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Andrew Walkden 7th February 1997
// Class G4OpenGLStoredView : Encapsulates the `storedness' of
// an OpenGL view, for inheritance by
// derived (X, Xm...) classes.
#ifdef G4VIS_BUILD_OPENGL_DRIVER
#ifndef G4OPENGLSTOREDVIEW_HH
#define G4OPENGLSTOREDVIEW_HH
#include "G4VView.hh"
#include "G4OpenGLView.hh"
#include "G4OpenGLScene.hh"
#include "G4OpenGLStoredScene.hh"
#include "G4OpenGLTransform3D.hh"
#include "globals.hh"
#include <rw/tvordvec.h>
class G4OpenGLStoredScene;
class G4OpenGLStoredView: virtual public G4OpenGLView {
public:
G4OpenGLStoredView (G4OpenGLStoredScene& scene);
protected:
void KernelVisitDecision ();
void DrawDisplayLists ();
G4OpenGLStoredScene& fScene; // Graphics Scene for this view.
};
#endif
#endif
@@ -0,0 +1,30 @@
// 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: G4OpenGLStoredWin32.hh,v 2.0 1998/07/02 16:44:31 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// OpenGLStoredWin32 graphics system factory.
#if defined (G4VIS_BUILD_OPENGLWIN32_DRIVER) || defined (G4VIS_USE_OPENGLWIN32)
#ifndef G4OPENGLSTOREDWIN32_HH
#define G4OPENGLSTOREDWIN32_HH
#include "G4VGraphicsSystem.hh"
class G4OpenGLStoredWin32: public G4VGraphicsSystem {
public:
G4OpenGLStoredWin32 ();
G4VScene* CreateScene ();
G4VView* CreateView (G4VScene&);
};
#endif
#endif
@@ -0,0 +1,37 @@
// 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: G4OpenGLStoredWin32View.hh,v 2.0 1998/07/02 16:44:32 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Class G4OpenGLStoredWin32View : a class derived from G4OpenGLWin32View and
// G4OpenGLStoredView.
#ifdef G4VIS_BUILD_OPENGLWIN32_DRIVER
#ifndef G4OPENGLSTOREDWIN32VIEW_HH
#define G4OPENGLSTOREDWIN32VIEW_HH
#include "G4VView.hh"
#include "G4OpenGLStoredView.hh"
#include "G4OpenGLWin32View.hh"
class G4OpenGLStoredScene;
class G4OpenGLStoredWin32View:
public G4OpenGLWin32View, public G4OpenGLStoredView{
public:
G4OpenGLStoredWin32View (G4OpenGLStoredScene& scene);
void DrawView ();
};
#endif
#endif
@@ -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: G4OpenGLStoredX.hh,v 2.1 1998/11/06 13:42:20 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Andrew Walkden 10th February 1997
// OpenGL graphics system factory.
#if defined (G4VIS_BUILD_OPENGLX_DRIVER) || defined (G4VIS_USE_OPENGLX)
#ifndef G4OPENGLSTOREDX_HH
#define G4OPENGLSTOREDX_HH
#include "G4VGraphicsSystem.hh"
class G4OpenGLStoredX: public G4VGraphicsSystem {
public:
G4OpenGLStoredX ();
G4VScene* CreateScene (const G4String& name = "");
G4VView* CreateView (G4VScene&, const G4String& name = "");
};
#endif
#endif
@@ -0,0 +1,38 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4OpenGLStoredXView.hh,v 2.1 1998/11/06 13:42:21 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Andrew Walkden 7th February 1997
// Class G4OpenGLStoredXView : a class derived from G4OpenGLXView and
// G4OpenGLStoredView.
#ifdef G4VIS_BUILD_OPENGLX_DRIVER
#ifndef G4OPENGLSTOREDXVIEW_HH
#define G4OPENGLSTOREDXVIEW_HH
#include "G4VView.hh"
#include "G4OpenGLStoredView.hh"
#include "G4OpenGLXView.hh"
class G4OpenGLStoredScene;
class G4OpenGLStoredXView:
public G4OpenGLXView, public G4OpenGLStoredView{
public:
G4OpenGLStoredXView (G4OpenGLStoredScene& scene, const G4String& name = "");
void DrawView ();
};
#endif
#endif
@@ -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: G4OpenGLStoredXm.hh,v 2.1 1998/11/06 13:42:21 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Andrew Walkden 10th February 1997
// OpenGL graphics system factory.
#if defined (G4VIS_BUILD_OPENGLXM_DRIVER) || defined (G4VIS_USE_OPENGLXM)
#ifndef G4OPENGLSTOREDXM_HH
#define G4OPENGLSTOREDXM_HH
#include "G4VGraphicsSystem.hh"
class G4OpenGLStoredXm: public G4VGraphicsSystem {
public:
G4OpenGLStoredXm ();
G4VScene* CreateScene (const G4String& name = "");
G4VView* CreateView (G4VScene&, const G4String& name = "");
};
#endif
#endif
@@ -0,0 +1,38 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4OpenGLStoredXmView.hh,v 2.1 1998/11/06 13:42:22 allison Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Andrew Walkden 10th February 1997
// Class G4OpenGLStoredXmView : a class derived from G4OpenGLXmView
// and G4OpenGLStoredView.
#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
#ifndef G4OpenGLSTOREDXMVIEW_HH
#define G4OpenGLSTOREDXMVIEW_HH
#include "G4VView.hh"
#include "G4OpenGLStoredView.hh"
#include "G4OpenGLXmView.hh"
class G4OpenGLStoredScene;
class G4OpenGLStoredXmView:
public G4OpenGLXmView, public G4OpenGLStoredView{
public:
G4OpenGLStoredXmView (G4OpenGLStoredScene& scene, const G4String& name = "");
void DrawView ();
};
#endif
#endif
@@ -0,0 +1,33 @@
// 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: G4OpenGLTransform3D.hh,v 2.0 1998/07/02 16:44:42 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Andrew Walkden 24th October 1996
// G4OpenGLTransform3D provides OpenGL style transformation matrix
// from G4Transform3D.
#ifdef G4VIS_BUILD_OPENGL_DRIVER
#ifndef G4OPENGLTRANSFORM3D_HH
#define G4OPENGLTRANSFORM3D_HH
#include "G4Transform3D.hh"
class G4OpenGLTransform3D : public G4Transform3D {
public:
G4OpenGLTransform3D (const G4Transform3D &t);
const GLdouble* GetGLMatrix ();
private:
GLdouble m[16];
};
#endif
#endif
@@ -0,0 +1,60 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4OpenGLView.hh,v 2.0 1998/07/02 16:44:46 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Andrew Walkden 27th March 1996
// OpenGL view - opens window, hard copy, etc.
#ifdef G4VIS_BUILD_OPENGL_DRIVER
#ifndef G4OPENGLVIEW_HH
#define G4OPENGLVIEW_HH
#include "G4VView.hh"
#include "globals.hh"
#include <rw/tvordvec.h>
class G4OpenGLScene;
// Base class for various OpenGLView classes.
class G4OpenGLView: virtual public G4VView {
public:
void ClearView ();
protected:
G4OpenGLView (G4OpenGLScene& scene);
void SetView ();
void HaloingFirstPass ();
void HaloingSecondPass ();
void HLRFirstPass ();
void HLRSecondPass ();
void HLRThirdPass ();
void InitializeGLView ();
G4bool white_background, //the OpenGL clear colour
doublebuffer, //are we using a double buffered visual?
transparency_enabled, //is alpha blending enabled?
antialiasing_enabled, //is antialiasing enabled?
haloing_enabled; //is haloing enabled for wireframe?
static int snglBuf_RGBA[10];
static int dblBuf_RGBA[11];
G4OpenGLScene& fScene; // Graphics Scene for this view.
private:
// G4OpenGLScene& fScene; // Graphics Scene for this view.
};
class G4OpenGLImmediateScene;
class G4OpenGLStoredScene;
#endif
#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: G4OpenGLWin32View.hh,v 2.0 1998/07/02 16:44:47 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// G4OpenGLWin32View : Class to provide WindowsNT specific
// functionality for OpenGL in GEANT4
#ifdef G4VIS_BUILD_OPENGLWIN32_DRIVER
#ifndef G4OPENGLWIN32VIEW_HH
#define G4OPENGLWIN32VIEW_HH
#include "G4VView.hh"
#include "G4OpenGLScene.hh"
#include "globals.hh"
#include <rw/tvordvec.h>
//Win32 includes?
#include <GL/gl.h>
#include <GL/glx.h>
#include <GL/glu.h>
class G4OpenGLScene;
class G4OpenGLWin32View: virtual public G4OpenGLView {
public:
G4OpenGLWin32View (G4OpenGLScene& scene);
~G4OpenGLWin32View ();
void FinishView ();
protected:
void GetWin32Connection ();
void CreateGLWin32Context ();
virtual void CreateMainWindow ();
G4int WinSize_x, WinSize_y;
};
#endif
#endif
@@ -0,0 +1,145 @@
// 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: G4OpenGLXView.hh,v 2.5 1998/10/29 09:37:23 barrand Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Andrew Walkden 7th February 1997
// G4OpenGLXView : Class to provide XWindows specific
// functionality for OpenGL in GEANT4
#ifdef G4VIS_BUILD_OPENGLX_DRIVER
#ifndef G4OPENGLXVIEW_HH
#define G4OPENGLXVIEW_HH
#include "G4VView.hh"
#include "G4OpenGLScene.hh"
#include "globals.hh"
#include <rw/tvordvec.h>
#include <X11/Xlib.h>
#include <X11/Intrinsic.h>
#include <X11/Xmu/StdCmap.h>
#include <GL/gl.h>
#include <GL/glx.h>
#include <GL/glu.h>
class G4OpenGLScene;
class G4OpenGLXView: virtual public G4OpenGLView {
public:
G4OpenGLXView (G4OpenGLScene& scene);
~G4OpenGLXView ();
void FinishView ();
void print();
protected:
void GetXConnection ();
void CreateGLXContext (XVisualInfo* vi);
virtual void CreateMainWindow ();
char print_string[50];
G4bool print_colour,
vectored_ps;
//////////////////////////////Vectored PostScript production functions//////////////////////////////
void printBuffer(GLint, GLfloat*);
GLfloat* spewPrimitiveEPS (FILE*, GLfloat*);
void spewSortedFeedback (FILE*, GLint, GLfloat*);
void spewWireframeEPS (FILE*, GLint, GLfloat*, char*);
void print3DcolorVertex(GLint, GLint*, GLfloat*);
G4float pointSize;
//////////////////////////////Pixmap (screen dump) production functions//////////////////////////////
GLubyte* grabPixels (int inColor,
unsigned int width,
unsigned int height);
int generateEPS (char* filnam,
int inColour,
unsigned int width,
unsigned int height);
GLXContext create_GL_print_context (XVisualInfo*& pvi, G4bool& db);
XWindowAttributes xwa;
Display *dpy;
XVisualInfo *vi_immediate,
*vi_stored,
*vi;
Colormap cmap;
XSetWindowAttributes swa;
GLXDrawable win;
GLXContext cx;
XEvent event;
G4int *attributeList,
errorBase,
eventBase,
major,
minor,
x_origin,
y_origin;
XSizeHints *norm_hints;
XWMHints *wm_hints;
XClassHint *class_hints;
Pixmap icon_pixmap;
XSizeHints *size_hints;
G4int WinSize_x,
WinSize_y;
Atom Xatom;
XTextProperty windowName,
iconName;
char charViewName [100];
};
static const char* gouraudtriangleEPS[] =
{
"/bd{bind def}bind def /triangle { aload pop setrgbcolor aload pop 5 3",
"roll 4 2 roll 3 2 roll exch moveto lineto lineto closepath fill } bd",
"/computediff1 { 2 copy sub abs threshold ge {pop pop pop true} { exch 2",
"index sub abs threshold ge { pop pop true} { sub abs threshold ge } ifelse",
"} ifelse } bd /computediff3 { 3 copy 0 get 3 1 roll 0 get 3 1 roll 0 get",
"computediff1 {true} { 3 copy 1 get 3 1 roll 1 get 3 1 roll 1 get",
"computediff1 {true} { 3 copy 2 get 3 1 roll 2 get 3 1 roll 2 get",
"computediff1 } ifelse } ifelse } bd /middlecolor { aload pop 4 -1 roll",
"aload pop 4 -1 roll add 2 div 5 1 roll 3 -1 roll add 2 div 3 1 roll add 2",
"div 3 1 roll exch 3 array astore } bd /gouraudtriangle { computediff3 { 4",
"-1 roll aload 7 1 roll 6 -1 roll pop 3 -1 roll pop add 2 div 3 1 roll add",
"2 div exch 3 -1 roll aload 7 1 roll exch pop 4 -1 roll pop add 2 div 3 1",
"roll add 2 div exch 3 -1 roll aload 7 1 roll pop 3 -1 roll pop add 2 div 3",
"1 roll add 2 div exch 7 3 roll 10 -3 roll dup 3 index middlecolor 4 1 roll",
"2 copy middlecolor 4 1 roll 3 copy pop middlecolor 4 1 roll 13 -1 roll",
"aload pop 17 index 6 index 15 index 19 index 6 index 17 index 6 array",
"astore 10 index 10 index 14 index gouraudtriangle 17 index 5 index 17",
"index 19 index 5 index 19 index 6 array astore 10 index 9 index 13 index",
"gouraudtriangle 13 index 16 index 5 index 15 index 18 index 5 index 6",
"array astore 12 index 12 index 9 index gouraudtriangle 17 index 16 index",
"15 index 19 index 18 index 17 index 6 array astore 10 index 12 index 14",
"index gouraudtriangle 18 {pop} repeat } { aload pop 5 3 roll aload pop 7 3",
"roll aload pop 9 3 roll 4 index 6 index 4 index add add 3 div 10 1 roll 7",
"index 5 index 3 index add add 3 div 10 1 roll 6 index 4 index 2 index add",
"add 3 div 10 1 roll 9 {pop} repeat 3 array astore triangle } ifelse } bd",
NULL
};
typedef struct _Feedback3Dcolor {
GLfloat x;
GLfloat y;
GLfloat z;
GLfloat red;
GLfloat green;
GLfloat blue;
GLfloat alpha;
} Feedback3Dcolor;
#endif
#endif
@@ -0,0 +1,53 @@
// 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: G4OpenGLXmBox.hh,v 2.0 1998/07/02 16:44:53 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
//Box container class
#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
#ifndef G4OPENGLXMBOX_HH
#define G4OPENGLXMBOX_HH
#include "G4OpenGLXmVWidgetContainer.hh"
#include "globals.hh"
#include <Xm/Frame.h>
#include <Xm/RowColumn.h>
class G4OpenGLXmVWidgetComponent;
class G4OpenGLXmVWidgetShell;
class G4OpenGLXmBox : public G4OpenGLXmVWidgetContainer
{
public:
G4OpenGLXmBox (char* = NULL,
G4bool = False); //constructor
~G4OpenGLXmBox (); //destructor
void AddChild (G4OpenGLXmVWidgetComponent*);
void AddYourselfTo (G4OpenGLXmVWidgetShell*);
Widget* GetPointerToParent ();
Widget* GetPointerToWidget ();
char* GetName ();
void SetName (char*);
protected:
char* name;
Widget* parent;
Widget box_row_col;
G4bool radio;
};
#endif
#endif
@@ -0,0 +1,155 @@
// 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: G4OpenGLXmConvenienceRoutines.hh,v 2.1 1998/07/12 03:09:31 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
#ifndef G4OPENGLXMCONVENIENCEROUTINES_HH
#define G4OPENGLXMCONVENIENCEROUTINES_HH
#include "G4OpenGLXmView.hh"
// Methods contained in G4OpenGLXmConvenienceRoutines:
//
// 1) Add_four_arrow_buttons
// 2) Add_radio_box
// 3) Add_set_field
// 4) Add_slider_box
// 5) get_float_value_callback
//
// Description of methods in G4OpenGLXmConvenienceRoutines:
//
// 1) Add_four_arrow_buttons (G4OpenGLXmView* pView,
// XtCallbackProc* arrow_callbacks,
// Widget* parent_widget)
//
// Adds a form widget containing four arrows (up, down, left, right)
// to the row column parent_widget which is passed in the arguments
// List. The XtCallbackProc* is an array containing four callback
// proceedures to be registered with the up, down, left and right arrow
// widgets respectively.
//
// 2) Add_radio_box (char* label_string,
// Widget* parent_widget,
// XtCallbackProc radio_box_callback,
// G4int num_buttons,
// G4int default_button,
// char* radio_box_name,
// char** button_names,
// G4OpenGLXmView* pView);
//
// Adds a row column widget containing num_buttons toggle buttons, to the
// row column parent_widget passed in the arguments List. label_string is
// the title that gets written above the radio buttons, and radio_box_name
// is used by the compiler, to give the radio_box a name to refer to, e.g.
// for resource setting, or error information. default_button is the button
// which appears `clicked' when the radio_box first appears. The first char*
// object in the button_names array, gets written next to the first button,
// the second next to the second, etc. radio_box_callback is the
// XtCallbackProc callback proceedure, which is registered with all of the
// buttons. XmNuserData is set to the index (0, 1,.., (num_buttons -1)) of
// the calling button so that radio_box_callback can tell which button was
// clicked, and what to do as a consequence.
//
// 3) Add_set_field (char* widget,
// char* widget_text,
// Widget* row_col_box,
// Widget* wid,
// G4float* val,
// G4OpenGLXmView* pView);
//
// Adds a text field widget to the row_col_box supplied in the arguments
// List. widget goes towards giving the widgets created within Add_set_field
// names for reference (e.g. to set resources) and widget_text gets printed
// above the text field box. val is the variable into which a number typed
// into the text field widget, will get placed. Add_set_field uses the
// get_float_value also in this file.
//
// 4) Add_slider_box (char* label_string,
// G4int num_sliders,
// char** slider_names,
// G4OpenGLXmView* pView,
// G4float* min_array,
// G4float* max_array,
// G4float* value_array,
// G4bool* show,
// short* decimals,
// unsigned char* orientation,
// unsigned char* direction,
// XtCallbackProc* slider_box_callbacks,
// Widget* parent_widget);
//
// Adds a row column widget containing num_sliders scale widgets, to the
// row column widget specified by parent_widget. Each of the arrays,
// slider_names, min_array, max_array, value_array, show, decimals,
// orientation, direction and slider_box_callbacks contains num_sliders
// elements, and govern the properties of each scale widget placed within
// the slider box individually. The relevance of most of the arrays is self
// explanatory.
// - value_array contains the initial value for each scale widget.
// - show determines whether or not the current numerical value represented
// by the position of the slider bar on the scale widget is displayed.
// - decimals indicates the Power of ten, by which to divide the current
// scale widget value, before displaying it (if show is set) above the
// slider bar. Scale widgets can only have integer values, but the use
// of decimals and show can give the appearance of the scale widget having
// a floating point value.
// - The XtCallbackProc specified in slider_box_callbacks is registered for
// both XmNvalueChanged and XmNdrag events generated by the scale widget.
//
// 5) get_float_value_callback (Widget w,
// XtPointer clientData,
// XtPointer callData);
//
// This XtCallbackProc reads a character string from a text field widget,
// and converts it to a floating point number.
void Add_four_arrow_buttons (G4OpenGLXmView* pView,
XtCallbackProc* arrow_callbacks,
Widget* parent_widget);
void Add_radio_box (char* label_string,
Widget* parent_widget,
XtCallbackProc radio_box_callback,
G4int num_buttons,
G4int default_button,
char* radio_box_name,
char** button_names,
G4OpenGLXmView* pView);
void Add_set_field (char* widget,
char* widget_text,
Widget* row_col_box,
Widget* wid,
G4float* val,
G4OpenGLXmView* pView);
void Add_slider_box (char* label_string,
G4int num_sliders,
char** slider_names,
G4OpenGLXmView* pView,
G4float* min_array,
G4float* max_array,
G4float* value_array,
G4bool* show,
short* decimals,
unsigned char* orientation,
unsigned char* direction,
XtCallbackProc* slider_box_callbacks,
Widget* parent_widget);
void get_float_value_callback (Widget w,
XtPointer clientData,
XtPointer callData);
#endif
#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: G4OpenGLXmFourArrowButtons.hh,v 2.0 1998/07/02 16:44:58 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
//Four arrow buttons class. Inherits from G4OpenGLXmVWidgetComponent
#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
#ifndef G4OPENGLXMFOURARROWBUTTONS_HH
#define G4OPENGLXMFOURARROWBUTTONS_HH
#include "G4OpenGLXmVWidgetComponent.hh"
class G4OpenGLXmFourArrowButtons : public G4OpenGLXmVWidgetComponent
{
public:
G4OpenGLXmFourArrowButtons (XtCallbackRec** = NULL); // array of 4 callbacks
//constructor
~G4OpenGLXmFourArrowButtons (); //destructor
void SetName (char*);
char* GetName ();
void AddYourselfTo (G4OpenGLXmVWidgetContainer*);
Widget* GetPointerToParent ();
Widget* GetPointerToWidget ();
private:
XtCallbackRec** callback;
Widget arrow_form;
Widget arrow;
Widget* parent;
};
#endif
#endif
@@ -0,0 +1,46 @@
// 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: G4OpenGLXmFramedBox.hh,v 2.0 1998/07/02 16:45:01 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
//Framed box container class
//Inherits from G4OpenGLXmBox
#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
#ifndef G4OPENGLXMFRAMEDBOX_HH
#define G4OPENGLXMFRAMEDBOX_HH
#include "G4OpenGLXmVWidgetContainer.hh"
#include "G4OpenGLXmBox.hh"
#include "globals.hh"
#include <Xm/Frame.h>
#include <Xm/RowColumn.h>
class G4OpenGLXmVWidgetComponent;
class G4OpenGLXmVWidgetShell;
class G4OpenGLXmFramedBox : public G4OpenGLXmBox
{
public:
G4OpenGLXmFramedBox (char* = NULL,
G4bool = False); //constructor
~G4OpenGLXmFramedBox (); //destructor
void AddChild (G4OpenGLXmVWidgetComponent*);
void AddYourselfTo (G4OpenGLXmVWidgetShell*);
private:
Widget frame;
};
#endif
#endif
@@ -0,0 +1,26 @@
// 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: G4OpenGLXmMainMenubarCallbacks.hh,v 2.0 1998/07/02 16:45:03 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
#ifndef G4OPENGLXMMAINMENUBARCALLBACKS_HH
#define G4OPENGLXMMAINMENUBARCALLBACKS_HH
#include "G4OpenGLXmView.hh"
void misc_callback (Widget w, XtPointer clientData, XtPointer callData);
void actions_callback (Widget w, XtPointer clientData, XtPointer callData);
void update_panels_callback (Widget w, XtPointer clientData, XtPointer callData);
#endif
#endif
@@ -0,0 +1,44 @@
// 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: G4OpenGLXmPanningCallbacks.hh,v 2.0 1998/07/02 16:45:05 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
#ifndef G4OPENGLXMPANNINGCALLBACKS_HH
#define G4OPENGLXMPANNINGCALLBACKS_HH
#include "G4OpenGLXmView.hh"
void zoom_callback (Widget w,
XtPointer clientData,
XtPointer callData);
void dolly_callback (Widget w,
XtPointer clientData,
XtPointer callData);
void pan_left_right_callback (Widget w,
XtPointer clientData,
XtPointer callData);
void pan_up_down_callback (Widget w,
XtPointer clientData,
XtPointer callData);
void left_right_pan_callback (XtPointer clientData,
XtIntervalId timer_id);
void up_down_pan_callback (XtPointer clientData,
XtIntervalId timer_id);
#endif
#endif
@@ -0,0 +1,46 @@
// 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: G4OpenGLXmPushButton.hh,v 2.0 1998/07/02 16:45:08 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
//Push button class. Inherits from G4OpenGLXmVWidgetComponent
#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
#ifndef G4OPENGLXMPUSHBUTTON_HH
#define G4OPENGLXMPUSHBUTTON_HH
#include "G4OpenGLXmVWidgetComponent.hh"
class G4OpenGLXmPushButton : public G4OpenGLXmVWidgetComponent
{
public:
G4OpenGLXmPushButton (char* = NULL,
XtCallbackRec* = NULL); //constructor
~G4OpenGLXmPushButton (); //destructor
void SetName (char*);
char* GetName ();
void AddYourselfTo (G4OpenGLXmVWidgetContainer*);
Widget* GetPointerToParent ();
Widget* GetPointerToWidget ();
private:
char* name;
XtCallbackRec* callback;
Widget button;
Widget* parent;
};
#endif
#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: G4OpenGLXmRadioButton.hh,v 2.0 1998/07/02 16:45:10 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
//Radio button class. Inherits from G4OpenGLXmVWidgetComponent
#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
#ifndef G4OPENGLXMRADIOBUTTON_HH
#define G4OPENGLXMRADIOBUTTON_HH
#include "G4OpenGLXmVWidgetComponent.hh"
class G4OpenGLXmRadioButton : public G4OpenGLXmVWidgetComponent
{
public:
G4OpenGLXmRadioButton (char*,
XtCallbackRec*,
G4bool,
G4int); //constructor
~G4OpenGLXmRadioButton (); //destructor
void SetName (char*);
char* GetName ();
void AddYourselfTo (G4OpenGLXmVWidgetContainer*);
Widget* GetPointerToParent ();
Widget* GetPointerToWidget ();
private:
char* name;
XtCallbackRec* callback;
Widget button;
Widget* parent;
G4bool default_button;
G4int number;
};
#endif
#endif
@@ -0,0 +1,30 @@
// 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: G4OpenGLXmResources.hh,v 2.1 1998/10/04 11:32:49 ajw Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Default resources file for GEANT4 OpenGL Motif windows.
#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
#ifndef G4OPENGLXMRESOURCES_HH
#define G4OPENGLXMRESOURCES_HH
static String fallbackResources[] = {
"*glxarea*width: 500", "*glxarea*height: 500",
"*frame*x: 10", "*frame*y: 10",
"*frame*topOffset: 10", "*frame*bottomOffset: 10",
"*frame*rightOffset: 10", "*frame*leftOffset: 10",
"*frame*shadowType: SHADOW_IN", "*useColorObj: False",
NULL
};
#endif
#endif
@@ -0,0 +1,44 @@
// 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: G4OpenGLXmRotationCallbacks.hh,v 2.0 1998/07/02 16:45:16 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
#ifndef G4OPENGLXMROTATIONCALLBACKS_HH
#define G4OPENGLXMROTATIONCALLBACKS_HH
#include "G4OpenGLXmView.hh"
void theta_rotation_callback (Widget w,
XtPointer clientData,
XtPointer callData);
void rotate_in_theta (XtPointer clientData,
XtIntervalId timer_id);
void phi_rotation_callback (Widget w,
XtPointer clientData,
XtPointer callData);
void rotate_in_phi (XtPointer clientData,
XtIntervalId timer_id);
void set_rot_sens_callback (Widget w,
XtPointer clientData,
XtPointer callData);
void set_rot_subject_callback (Widget w,
XtPointer clientData,
XtPointer callData);
#endif
#endif
@@ -0,0 +1,41 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4OpenGLXmSeparator.hh,v 2.0 1998/07/02 16:45:17 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
//Separator class. Inherits from G4OpenGLXmVWidgetComponent
#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
#ifndef G4OPENGLXMSEPARATOR_HH
#define G4OPENGLXMSEPARATOR_HH
#include "G4OpenGLXmVWidgetComponent.hh"
class G4OpenGLXmSeparator : public G4OpenGLXmVWidgetComponent
{
public:
G4OpenGLXmSeparator (unsigned char = XmSINGLE_LINE); //constructor
~G4OpenGLXmSeparator (); //destructor
void AddYourselfTo (G4OpenGLXmVWidgetContainer*);
Widget* GetPointerToParent ();
Widget* GetPointerToWidget ();
private:
unsigned char line_type;
Widget line;
Widget* parent;
};
#endif
#endif
@@ -0,0 +1,77 @@
// 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: G4OpenGLXmSliderBar.hh,v 2.0 1998/07/02 16:45:20 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
//Slider bar class. Inherits from G4OpenGLXmVWidgetComponent
#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
#ifndef G4OPENGLXMSLIDERBAR_HH
#define G4OPENGLXMSLIDERBAR_HH
#include "G4OpenGLXmVWidgetComponent.hh"
class G4OpenGLXmSliderBar : public G4OpenGLXmVWidgetComponent
{
public:
G4OpenGLXmSliderBar (char* = NULL, // name of slider bar
XtCallbackRec* = NULL, // callbacks for slider bar
G4bool = False, // show current value if True
short = 0, // decimal places for show value
G4double = 0., // initial value
G4double = 0., // max value
G4double = 0., // min value
unsigned char = XmHORIZONTAL,
unsigned char = XmMAX_ON_RIGHT);
//constructor
~G4OpenGLXmSliderBar (); //destructor
void SetName (char*);
void SetShow (G4bool);
void SetDecimalPlaces (short);
void SetInitialValue (G4double);
void SetMaxValue (G4double);
void SetMinValue (G4double);
void SetOrientation (unsigned char);
void SetDirection (unsigned char);
char* GetName ();
G4bool GetShow ();
short GetDecimalPlaces ();
G4double GetInitialValue ();
G4double GetMaxValue ();
G4double GetMinValue ();
unsigned char GetOrientation ();
unsigned char GetDirection ();
void AddYourselfTo (G4OpenGLXmVWidgetContainer*);
Widget* GetPointerToParent ();
Widget* GetPointerToWidget ();
private:
char* name;
XtCallbackRec* callback;
Widget sliderbar;
Widget* parent;
G4bool show;
short decimal_places;
G4int initial_value;
G4int max_value;
G4int min_value;
unsigned char orientation;
unsigned char direction;
};
#endif
#endif
@@ -0,0 +1,38 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4OpenGLXmStyleCallbacks.hh,v 2.0 1998/07/02 16:45:22 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
#ifndef G4OPENGLXMSTYLECALLBACKS_HH
#define G4OPENGLXMSTYLECALLBACKS_HH
#include "G4OpenGLXmView.hh"
void drawing_style_callback (Widget w,
XtPointer clientData,
XtPointer callData);
void rep_style_callback (Widget w,
XtPointer clientData,
XtPointer callData);
void background_color_callback (Widget w,
XtPointer clientData,
XtPointer callData);
void projection_callback (Widget w,
XtPointer clientData,
XtPointer callData);
#endif
#endif
@@ -0,0 +1,54 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4OpenGLXmTextField.hh,v 2.2 1998/08/07 12:46:30 barrand Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
//Text field class. Inherits from G4OpenGLXmVWidgetComponent
#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
#ifndef G4OPENGLXMTEXTFIELD_HH
#define G4OPENGLXMTEXTFIELD_HH
#include "G4OpenGLXmVWidgetComponent.hh"
//#include "G4OpenGLXmConvenienceRoutines.hh"
class G4OpenGLXmTextField : public G4OpenGLXmVWidgetComponent
{
public:
G4OpenGLXmTextField (char*,G4double*); //constructor
G4OpenGLXmTextField (char*,char*); //constructor
~G4OpenGLXmTextField (); //destructor
void SetName (char*);
char* GetName ();
void SetValue (G4double);
void SetValue (char*);
char* GetValue ();
void AddYourselfTo (G4OpenGLXmVWidgetContainer*);
Widget* GetPointerToParent ();
Widget* GetPointerToWidget ();
private:
char* name;
void* value;
G4bool text;
char* initial;
Widget text_label;
Widget text_field;
Widget* parent;
};
#endif
#endif
@@ -0,0 +1,45 @@
// 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: G4OpenGLXmTopLevelShell.hh,v 2.0 1998/07/02 16:45:28 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
//Top level shell class
#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
#ifndef G4OPENGLXMTOPLEVELSHELL_HH
#define G4OPENGLXMTOPLEVELSHELL_HH
#include "G4OpenGLXmVWidgetShell.hh"
class G4OpenGLXmVWidgetContainer;
class G4OpenGLXmTopLevelShell : public G4OpenGLXmVWidgetShell
{
public:
G4OpenGLXmTopLevelShell(G4OpenGLXmView*, char*); //constructor
~G4OpenGLXmTopLevelShell(); //destructor
void AddChild (G4OpenGLXmVWidgetContainer*);
void Realize ();
Widget* GetPointerToWidget ();
char* GetName ();
private:
char* name;
Widget toplevel;
Widget top_box;
Widget frame;
};
#endif
#endif
@@ -0,0 +1,41 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4OpenGLXmVWidgetComponent.hh,v 2.0 1998/07/02 16:45:31 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
//Base class for all Motif component widgets
#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
#ifndef G4OPENGLXMVWIDGETCOMPONENT_HH
#define G4OPENGLXMVWIDGETCOMPONENT_HH
#include "G4OpenGLXmVWidgetObject.hh"
class G4OpenGLXmVWidgetContainer;
class G4OpenGLXmVWidgetComponent : public G4OpenGLXmVWidgetObject
{
public:
G4OpenGLXmVWidgetComponent(); //constructor
~G4OpenGLXmVWidgetComponent(); //destructor
virtual void AddYourselfTo (G4OpenGLXmVWidgetContainer*) = 0;
virtual Widget* GetPointerToParent () = 0;
virtual Widget* GetPointerToWidget () = 0;
private:
};
#endif
#endif
@@ -0,0 +1,43 @@
// 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: G4OpenGLXmVWidgetContainer.hh,v 2.0 1998/07/02 16:45:34 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
//Base class for all Motif container widgets
#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
#ifndef G4OPENGLXMVWIDGETCONTAINER_HH
#define G4OPENGLXMVWIDGETCONTAINER_HH
#include "G4OpenGLXmVWidgetObject.hh"
class G4OpenGLXmVWidgetShell;
class G4OpenGLXmVWidgetComponent;
class G4OpenGLXmVWidgetContainer : public G4OpenGLXmVWidgetObject
{
public:
G4OpenGLXmVWidgetContainer(); //constructor
~G4OpenGLXmVWidgetContainer(); //destructor
virtual void AddChild (G4OpenGLXmVWidgetComponent*) = 0;
virtual void AddYourselfTo (G4OpenGLXmVWidgetShell*) = 0;
virtual Widget* GetPointerToParent () = 0;
virtual Widget* GetPointerToWidget () = 0;
private:
};
#endif
#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: G4OpenGLXmVWidgetObject.hh,v 2.0 1998/07/02 16:45:35 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
//Virtual base class for all Motif widgets.
#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
#ifndef G4OPENGLXMVWIDGETOBJECT_HH
#define G4OPENGLXMVWIDGETOBJECT_HH
#include "globals.hh"
#include <Xm/Xm.h>
#include "X11/Intrinsic.h"
#include <X11/Xlib.h>
#include "G4OpenGLXmView.hh"
class G4OpenGLXmVWidgetObject {
public:
G4OpenGLXmVWidgetObject (); //constructor
~G4OpenGLXmVWidgetObject (); //destructor
G4OpenGLXmView* GetView (); //access to the pView
void ProcesspView ();
protected:
G4OpenGLXmView* pView;
Colormap cmap;
Pixel borcol;
Pixel bgnd;
unsigned int depth;
Visual* visual;
Widget top;
};
#endif
#endif

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