33 #ifdef G4VIS_BUILD_DAWN_DRIVER
53 const int FR_DEFAULT_CONNECTION_TIME = 5 ;
54 const char FR_ENV_CONNECTION_TIME [] =
"G4DAWN_CONNECTION_TIME";
55 const char FR_ENV_DAWN_GUI_ALWAYS [] =
"G4DAWN_GUI_ALWAYS";
58 G4FukuiRenderer::G4FukuiRenderer ():
64 fIPMode( G4FukuiRenderer::IP_UNIX ),
65 flag_use_gui (
false) ,
69 if( ( std::getenv( FR_ENV_DAWN_GUI_ALWAYS ) != NULL ) && \
70 ( strcmp( std::getenv( FR_ENV_DAWN_GUI_ALWAYS ),
"0" ) ) )
78 G4FukuiRenderer::~G4FukuiRenderer ()
80 if( flag_connected ) {
85 fPrimDest.DisConnect();
95 if(!flag_connected) {
delete p ; p = NULL ; }
103 if(!flag_connected)
return NULL;
105 new G4FukuiRendererViewer ((G4FukuiRendererSceneHandler&) scene, name);
110 void G4FukuiRenderer::UseInetDomainAuto()
114 #if defined DEBUG_FR_SYSTEM
116 G4cout <<
"***** Unix Inet Domain (AUTO mode)" <<
G4endl;
118 fIPMode = G4FukuiRenderer::IP_UNIX ;
120 if( ( pid = fork() ) == 0 ) {
121 if ( execlp (
"dawn",
"dawn",
"-G" , (
char *)0 ) < 0 )
128 int connection_time = FR_DEFAULT_CONNECTION_TIME ;
129 if( std::getenv( FR_ENV_CONNECTION_TIME ) != NULL ) {
130 int sscanf_status = \
131 sscanf( std::getenv( FR_ENV_CONNECTION_TIME ),
"%d", &connection_time) ;
132 if ( sscanf_status == EOF ) {
133 connection_time = FR_DEFAULT_CONNECTION_TIME ;
139 sleep(connection_time);
145 if(!flag_connected) {
151 G4cout <<
"***** GEANT4 is connected to FukuiRenderer DAWN ";
161 G4FukuiRenderer::UseInetDomain()
163 #if defined DEBUG_FR_SYSTEM
167 fIPMode = G4FukuiRenderer::IP_INET ;
171 if(!flag_connected) {
177 G4cout <<
"GEANT4 is connected to FukuiRenderer DAWN via socket" ;
185 G4FukuiRenderer::ConnectPort(
int max_port_incr )
188 int connect_trial = 0 ;
190 if ( ++connect_trial > max_port_incr ) {
191 this->flag_connected = 0 ;
194 G4cout <<
" Maybe, you have not invoked DAWN yet," <<
G4endl;
195 G4cout <<
" or too many DAWN's are already running" <<
G4endl;
198 fPrimDest.IncrementPortNumber( (- FR_MAX_PORT_INCR) );
200 }
else if ( fPrimDest.ConnectINET() ) {
202 this->flag_connected = 1 ;
204 G4cout <<
"***** GEANT4 is connected to port " ;
205 G4cout << fPrimDest.GetPortNumber() ;
211 this->flag_connected = 0 ;
212 fPrimDest.IncrementPortNumber();
214 G4cout <<
"***** GEANT4 incremented targeting port to " ;
225 void G4FukuiRenderer::UseBSDUnixDomainAuto()
229 #if defined DEBUG_FR_SYSTEM
233 fIPMode = G4FukuiRenderer::IP_UNIX ;
235 if( ( pid = fork() ) == 0 ) {
236 if ( execlp (
"dawn",
"dawn",
"-g" , (
char *)0 ) < 0 )
244 int connection_time = FR_DEFAULT_CONNECTION_TIME ;
245 if( std::getenv( FR_ENV_CONNECTION_TIME ) != NULL ) {
246 int sscanf_status = \
247 sscanf( std::getenv( FR_ENV_CONNECTION_TIME ),
"%d", &connection_time) ;
248 if ( sscanf_status == EOF ) { connection_time = FR_DEFAULT_CONNECTION_TIME ;}
250 sleep(connection_time);
253 this->flag_connected = fPrimDest.ConnectUnix();
256 if(!flag_connected) {
261 G4cout <<
"*** GEANT4 is connected to FukuiRenderer DAWN ";
271 #endif // G4VIS_BUILD_DAWN_DRIVER