00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef WIN32
00033
00034
00035
00036 #ifdef G4VIS_BUILD_VRML_DRIVER
00037
00038
00039
00040
00041
00042 #include <unistd.h>
00043 #include <fstream>
00044 #include <cmath>
00045
00046 #include "globals.hh"
00047 #include "G4VisManager.hh"
00048
00049 #include "G4VPhysicalVolume.hh"
00050 #include "G4LogicalVolume.hh"
00051 #include "G4Point3D.hh"
00052 #include "G4VModel.hh"
00053 #include "G4Scene.hh"
00054 #include "G4VisAttributes.hh"
00055 #include "G4Polyhedron.hh"
00056 #include "G4Box.hh"
00057 #include "G4Cons.hh"
00058 #include "G4Polyline.hh"
00059 #include "G4Trd.hh"
00060 #include "G4Tubs.hh"
00061 #include "G4Text.hh"
00062 #include "G4Circle.hh"
00063 #include "G4Square.hh"
00064
00065 #include "G4VRML2SceneHandler.hh"
00066 #include "G4VRML2Viewer.hh"
00067 #include "G4VRML2.hh"
00068
00069
00070
00071 G4VRML2SceneHandler::G4VRML2SceneHandler(G4VRML2& system, const G4String& name) :
00072 G4VSceneHandler(system, fSceneIdCount++, name),
00073 fSystem(system),
00074 fPVPickable ( false ),
00075 fDest()
00076 {
00077
00078
00079 if( getenv( "G4VRML_PV_PICKABLE" ) != NULL ) {
00080
00081 int is_pickable ;
00082 sscanf( getenv("G4VRML_PV_PICKABLE"), "%d", &is_pickable ) ;
00083
00084 if ( is_pickable ) { SetPVPickability ( true ) ; }
00085 }
00086
00087
00088 SetPVTransparency ();
00089
00090 }
00091
00092
00093 G4VRML2SceneHandler::~G4VRML2SceneHandler()
00094 {
00095 #if defined DEBUG_FR_SCENE
00096 if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
00097 G4cout << "***** ~G4VRML2SceneHandler" << G4endl;
00098 #endif
00099 }
00100
00101
00102
00103 #define G4VRML2SCENEHANDLER G4VRML2SceneHandler
00104 #define IS_CONNECTED fDest.isConnected()
00105 #include "G4VRML2SceneHandlerFunc.icc"
00106 #undef IS_CONNECTED
00107 #undef G4VRML2SCENEHANDLER
00108
00109
00110 void G4VRML2SceneHandler::connectPort(G4int max_trial)
00111 {
00112 G4int trial = 0 ;
00113 int port = fSystem.getPort();
00114 for (trial = 0; !fDest.isConnected()&& trial < max_trial; trial++, port++ ) {
00115 if (fDest.connect( (const char * )fSystem.getHostName(), port)) {
00116
00117 if (G4VisManager::GetVerbosity() >= G4VisManager::errors) {
00118 G4cout << "*** GEANT4 is connected to port ";
00119 G4cout << fDest.getPort();
00120 G4cout << " of server " << fSystem.getHostName() << G4endl;
00121 }
00122 break;
00123 } else {
00124
00125 if (G4VisManager::GetVerbosity() >= G4VisManager::errors) {
00126 G4cout << "*** GEANT4 incremented targeting port to ";
00127 G4cout << port << G4endl;
00128 }
00129 }
00130
00131 sleep (1);
00132
00133 }
00134
00135 if (!fDest.isConnected()) {
00136 if (G4VisManager::GetVerbosity() >= G4VisManager::errors) {
00137 G4cout << "*** INET Connection failed. " << G4endl;
00138 G4cout << " Maybe, you have not invoked viewer g4vrmlview yet, " << G4endl;
00139 G4cout << " or too many viewers are already running in the " << G4endl;
00140 G4cout << " server host(" << fSystem.getHostName() << "). " << G4endl;
00141 }
00142 }
00143 }
00144
00145 void G4VRML2SceneHandler::closePort()
00146 {
00147 fDest.close();
00148 if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
00149 G4cout << "*** INET Connection closed. " << G4endl;
00150 }
00151
00152
00153 G4int G4VRML2SceneHandler::fSceneIdCount = 0;
00154
00155 #endif
00156 #endif //WIN32