G4VRML2FileSceneHandler Class Reference

#include <G4VRML2FileSceneHandler.hh>

Inheritance diagram for G4VRML2FileSceneHandler:

G4VSceneHandler G4VGraphicsScene

Public Member Functions

 G4VRML2FileSceneHandler (G4VRML2File &system, const G4String &name="")
virtual ~G4VRML2FileSceneHandler ()
void AddSolid (const G4Box &)
void AddSolid (const G4Cons &)
void AddSolid (const G4Tubs &)
void AddSolid (const G4Trd &)
void AddSolid (const G4Trap &)
void AddSolid (const G4Sphere &)
void AddSolid (const G4Para &)
void AddSolid (const G4Torus &)
void AddSolid (const G4Polycone &polycone)
void AddSolid (const G4Polyhedra &polyhedra)
void AddSolid (const G4VSolid &)
void AddCompound (const G4VTrajectory &traj)
void AddCompound (const G4VHit &hit)
void AddCompound (const G4VDigi &digi)
void AddCompound (const G4THitsMap< G4double > &hits)
void BeginPrimitives (const G4Transform3D &objectTransformation)
void EndPrimitives ()
void AddPrimitive (const G4Polyline &)
void AddPrimitive (const G4Polyhedron &)
void AddPrimitive (const G4NURBS &)
void AddPrimitive (const G4Text &)
void AddPrimitive (const G4Circle &)
void AddPrimitive (const G4Square &)
void AddPrimitive (const G4Polymarker &polymarker)
void AddPrimitive (const G4Scale &scale)
void ClearTransientStore ()
void BeginModeling ()
void EndModeling ()
void VRMLBeginModeling ()
void VRMLEndModeling ()
void connectPort ()
void closePort ()

Data Fields

std::ofstream fDest

Friends

class G4VRML2FileViewer

Detailed Description

Definition at line 45 of file G4VRML2FileSceneHandler.hh.


Constructor & Destructor Documentation

G4VRML2FileSceneHandler::G4VRML2FileSceneHandler ( G4VRML2File system,
const G4String name = "" 
)

Definition at line 73 of file G4VRML2FileSceneHandler.cc.

References DEFAULT_MAX_WRL_FILE_NUM, and VRMLFILE_DEST_DIR.

00073                                                                                           :
00074         G4VSceneHandler(system, fSceneIdCount++, name),
00075         fSystem(system),
00076         fFlagDestOpen( false ),
00077         fPVPickable  ( false ),
00078         fDest()
00079 {
00080         // output file name
00081         strcpy(fVRMLFileName, "");
00082 
00083         // destination directory
00084         if ( getenv( VRMLFILE_DEST_DIR ) == NULL ) {
00085                 strcpy( fVRMLFileDestDir, "" );
00086         } else {
00087                 strcpy( fVRMLFileDestDir, getenv( VRMLFILE_DEST_DIR ) );
00088         }
00089 
00090 
00091         // maximum number of g4.prim files in the dest directory
00092         fMaxFileNum = DEFAULT_MAX_WRL_FILE_NUM ; // initialization
00093         if ( getenv( "G4VRMLFILE_MAX_FILE_NUM" ) != NULL ) {    
00094                 
00095                 sscanf( getenv("G4VRMLFILE_MAX_FILE_NUM"), "%d", &fMaxFileNum ) ;
00096 
00097         } else {
00098                 fMaxFileNum = DEFAULT_MAX_WRL_FILE_NUM ;
00099         }
00100         if( fMaxFileNum < 1 ) { fMaxFileNum = 1; }
00101 
00102 
00103         // PV name pickability  
00104         if( getenv( "G4VRML_PV_PICKABLE" ) != NULL ) {
00105 
00106                 int is_pickable ;
00107                 sscanf( getenv("G4VRML_PV_PICKABLE"), "%d", &is_pickable ) ;
00108 
00109                 if ( is_pickable ) { SetPVPickability ( true ) ; }
00110         } 
00111 
00112         // PV Transparency
00113         SetPVTransparency ();
00114 
00115 }

G4VRML2FileSceneHandler::~G4VRML2FileSceneHandler (  )  [virtual]

Definition at line 118 of file G4VRML2FileSceneHandler.cc.

References G4VisManager::errors, G4cout, G4endl, G4VisManager::GetVerbosity(), and VRMLEndModeling().

00119 {
00120 #if defined DEBUG_FR_SCENE
00121   if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
00122         G4cout << "***** ~G4VRML2FileSceneHandler" << G4endl;
00123 #endif 
00124         VRMLEndModeling();
00125 }


Member Function Documentation

void G4VRML2FileSceneHandler::AddCompound ( const G4THitsMap< G4double > &  hits  )  [inline, virtual]

Reimplemented from G4VSceneHandler.

Definition at line 77 of file G4VRML2FileSceneHandler.hh.

References G4VSceneHandler::AddCompound().

00077                                                               {
00078           G4VSceneHandler::AddCompound(hits);
00079         }

void G4VRML2FileSceneHandler::AddCompound ( const G4VDigi digi  )  [inline, virtual]

Reimplemented from G4VSceneHandler.

Definition at line 74 of file G4VRML2FileSceneHandler.hh.

References G4VSceneHandler::AddCompound().

00074                                                 {
00075           G4VSceneHandler::AddCompound(digi);
00076         }

void G4VRML2FileSceneHandler::AddCompound ( const G4VHit hit  )  [inline, virtual]

Reimplemented from G4VSceneHandler.

Definition at line 71 of file G4VRML2FileSceneHandler.hh.

References G4VSceneHandler::AddCompound().

00071                                               {
00072           G4VSceneHandler::AddCompound(hit);
00073         }

void G4VRML2FileSceneHandler::AddCompound ( const G4VTrajectory traj  )  [inline, virtual]

Reimplemented from G4VSceneHandler.

Definition at line 68 of file G4VRML2FileSceneHandler.hh.

References G4VSceneHandler::AddCompound().

00068                                                       {
00069           G4VSceneHandler::AddCompound(traj);
00070         }

void G4VRML2FileSceneHandler::AddPrimitive ( const G4Scale scale  )  [inline, virtual]

Reimplemented from G4VSceneHandler.

Definition at line 92 of file G4VRML2FileSceneHandler.hh.

References G4VSceneHandler::AddPrimitive().

00093                 { G4VSceneHandler::AddPrimitive (scale); }

void G4VRML2FileSceneHandler::AddPrimitive ( const G4Polymarker polymarker  )  [inline, virtual]

Reimplemented from G4VSceneHandler.

Definition at line 90 of file G4VRML2FileSceneHandler.hh.

References G4VSceneHandler::AddPrimitive().

00091                 { G4VSceneHandler::AddPrimitive (polymarker); }

void G4VRML2FileSceneHandler::AddPrimitive ( const G4Square  )  [virtual]

Implements G4VSceneHandler.

void G4VRML2FileSceneHandler::AddPrimitive ( const G4Circle  )  [virtual]

Implements G4VSceneHandler.

void G4VRML2FileSceneHandler::AddPrimitive ( const G4Text  )  [virtual]

Implements G4VSceneHandler.

void G4VRML2FileSceneHandler::AddPrimitive ( const G4NURBS  )  [virtual]

Implements G4VSceneHandler.

void G4VRML2FileSceneHandler::AddPrimitive ( const G4Polyhedron  )  [virtual]

Implements G4VSceneHandler.

void G4VRML2FileSceneHandler::AddPrimitive ( const G4Polyline  )  [virtual]

Implements G4VSceneHandler.

void G4VRML2FileSceneHandler::AddSolid ( const G4VSolid  )  [virtual]

Reimplemented from G4VSceneHandler.

void G4VRML2FileSceneHandler::AddSolid ( const G4Polyhedra polyhedra  )  [inline, virtual]

Reimplemented from G4VSceneHandler.

Definition at line 64 of file G4VRML2FileSceneHandler.hh.

References G4VSceneHandler::AddSolid().

00064                                                       {
00065           G4VSceneHandler::AddSolid (polyhedra);
00066         }

void G4VRML2FileSceneHandler::AddSolid ( const G4Polycone polycone  )  [inline, virtual]

Reimplemented from G4VSceneHandler.

Definition at line 61 of file G4VRML2FileSceneHandler.hh.

References G4VSceneHandler::AddSolid().

00061                                                      {
00062           G4VSceneHandler::AddSolid (polycone);
00063         }

void G4VRML2FileSceneHandler::AddSolid ( const G4Torus  )  [virtual]

Reimplemented from G4VSceneHandler.

void G4VRML2FileSceneHandler::AddSolid ( const G4Para  )  [virtual]

Reimplemented from G4VSceneHandler.

void G4VRML2FileSceneHandler::AddSolid ( const G4Sphere  )  [virtual]

Reimplemented from G4VSceneHandler.

void G4VRML2FileSceneHandler::AddSolid ( const G4Trap  )  [virtual]

Reimplemented from G4VSceneHandler.

void G4VRML2FileSceneHandler::AddSolid ( const G4Trd  )  [virtual]

Reimplemented from G4VSceneHandler.

void G4VRML2FileSceneHandler::AddSolid ( const G4Tubs  )  [virtual]

Reimplemented from G4VSceneHandler.

void G4VRML2FileSceneHandler::AddSolid ( const G4Cons  )  [virtual]

Reimplemented from G4VSceneHandler.

void G4VRML2FileSceneHandler::AddSolid ( const G4Box  )  [virtual]

Reimplemented from G4VSceneHandler.

void G4VRML2FileSceneHandler::BeginModeling (  )  [virtual]

Reimplemented from G4VSceneHandler.

void G4VRML2FileSceneHandler::BeginPrimitives ( const G4Transform3D objectTransformation  )  [virtual]

Reimplemented from G4VSceneHandler.

void G4VRML2FileSceneHandler::ClearTransientStore (  )  [virtual]

Reimplemented from G4VSceneHandler.

void G4VRML2FileSceneHandler::closePort (  ) 

Definition at line 196 of file G4VRML2FileSceneHandler.cc.

References ENV_VRML_VIEWER, G4VisManager::errors, fDest, G4cout, G4endl, G4VisManager::GetVerbosity(), and NO_VRML_VIEWER.

00197 {
00198         char command[256] ;
00199         char viewer [256] ; 
00200         strcpy( viewer, NO_VRML_VIEWER ); // initialization
00201         if( getenv( ENV_VRML_VIEWER ) ) {
00202                 strcpy( viewer, getenv( ENV_VRML_VIEWER ) ) ;
00203         }
00204 
00205         // close VRML file      
00206         fDest.close();  fFlagDestOpen = false ;
00207         if (G4VisManager::GetVerbosity() >= G4VisManager::errors)
00208               G4cout << "*** VRML 2.0 File  " << fVRMLFileName << "  is generated." << G4endl;
00209 
00210         
00211         // Invoke viewer 
00212 
00213         if ( !strcmp(viewer, NO_VRML_VIEWER )) {
00214           if (G4VisManager::GetVerbosity() >= G4VisManager::errors) {
00215                 G4cout << "MESSAGE from VRML2FILE driver:"     << G4endl;
00216                 G4cout << "    Set an environmental variable  " ;
00217                 G4cout <<      ENV_VRML_VIEWER << G4endl;
00218                 G4cout << "    if you want to visualize the generated VRML file" << G4endl; 
00219                 G4cout << "    automatically.  For example, " << G4endl;
00220                 G4cout << "    setenv  " << ENV_VRML_VIEWER << "  vrwave " << G4endl;
00221           }
00222         } else {
00223                 sprintf( command, "%s %s", viewer, fVRMLFileName  );   
00224                 (void) system( command );
00225         }
00226 }

void G4VRML2FileSceneHandler::connectPort (  ) 

Definition at line 135 of file G4VRML2FileSceneHandler.cc.

References DEFAULT_WRL_FILE_NAME, G4VisManager::errors, fDest, G4cout, G4endl, G4VisManager::GetVerbosity(), and WRL_FILE_HEADER.

00136 {
00137         // g4_00.wrl, g4_01.wrl, ..., g4_MAX_FILE_INDEX.wrl
00138         const int MAX_FILE_INDEX = fMaxFileNum - 1 ;
00139 
00140         // dest directory (null if no environmental variables is set)
00141         strcpy ( fVRMLFileName, fVRMLFileDestDir) ; 
00142 
00143         // create full path name (default)
00144         strcat ( fVRMLFileName, DEFAULT_WRL_FILE_NAME );
00145 
00146         // Determine VRML file name
00147         for( int i = 0 ; i < fMaxFileNum ; i++) { 
00148 
00149                 // Message in the final execution
00150                 if( i == MAX_FILE_INDEX ) 
00151                 {
00152                   if (G4VisManager::GetVerbosity() >= G4VisManager::errors) {
00153                     G4cout << "==========================================="   << G4endl; 
00154                     G4cout << "WARNING MESSAGE from VRML2FILE driver:     "   << G4endl;
00155                     G4cout << "  This file name is the final one in the   "   << G4endl;
00156                     G4cout << "  automatic updation of the output file name." << G4endl; 
00157                     G4cout << "  You may overwrite existing files, i.e.   "   << G4endl; 
00158                     G4cout << "  g4_XX.wrl.                               "   << G4endl;
00159                     G4cout << "==========================================="   << G4endl; 
00160                   }
00161                 }
00162 
00163                 // re-determine file name as G4VRMLFILE_DEST_DIR/g4_XX.wrl 
00164                 if( i >=  0 && i <= 9 ) { 
00165                         sprintf( fVRMLFileName, "%s%s%s%d.wrl" , fVRMLFileDestDir,  WRL_FILE_HEADER, "0", i );
00166                 } else {
00167                         sprintf( fVRMLFileName, "%s%s%d.wrl"   , fVRMLFileDestDir,  WRL_FILE_HEADER, i );
00168                 }
00169 
00170                 // check validity of the file name
00171                 std::ifstream  fin ; 
00172                 fin.open(fVRMLFileName) ;
00173                 if(!fin) { 
00174                         // new file     
00175                         fin.close();  
00176                         break; 
00177                 } else { 
00178                         // already exists (try next) 
00179                         fin.close(); 
00180                 } 
00181 
00182         } // for 
00183 
00184         // open a VRML 2.0 file with determined file name
00185         if (G4VisManager::GetVerbosity() >= G4VisManager::errors) {
00186           G4cout << "==========================================="  << G4endl; 
00187           G4cout << "Output VRML 2.0 file: " <<    fVRMLFileName << G4endl; 
00188           G4cout << "Maximum number of files in the destination directory: " << fMaxFileNum << G4endl; 
00189           G4cout << "  (Customizable with the environment variable: G4VRMLFILE_MAX_FILE_NUM) " << G4endl;
00190           G4cout << "===========================================" << G4endl; 
00191         }
00192         fDest.open(fVRMLFileName) ;  fFlagDestOpen =  true ;
00193 }

void G4VRML2FileSceneHandler::EndModeling (  )  [virtual]

Reimplemented from G4VSceneHandler.

void G4VRML2FileSceneHandler::EndPrimitives (  )  [virtual]

Reimplemented from G4VSceneHandler.

void G4VRML2FileSceneHandler::VRMLBeginModeling (  ) 

Referenced by G4VRML2FileViewer::DrawView().

void G4VRML2FileSceneHandler::VRMLEndModeling (  ) 

Referenced by G4VRML2FileViewer::ShowView(), and ~G4VRML2FileSceneHandler().


Friends And Related Function Documentation

friend class G4VRML2FileViewer [friend]

Definition at line 47 of file G4VRML2FileSceneHandler.hh.


Field Documentation

std::ofstream G4VRML2FileSceneHandler::fDest

Definition at line 145 of file G4VRML2FileSceneHandler.hh.

Referenced by G4VRML2FileViewer::ClearView(), closePort(), and connectPort().


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:53:54 2013 for Geant4 by  doxygen 1.4.7