12.07.2015 Views

Geant4 User's Guide for Application Developers - Geant4 - CERN

Geant4 User's Guide for Application Developers - Geant4 - CERN

Geant4 User's Guide for Application Developers - Geant4 - CERN

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

VisualizationExample 8.2. The <strong>for</strong>m of the main() function.//----- C++ source codes: Instantiation and initialization of G4VisManager.....// Your Visualization Manager#include "G4VisExecutive.hh".....// Instantiation and initialization of the Visualization Manager#ifdef G4VIS_USEG4VisManager* visManager = new G4VisExecutive;visManager -> initialize ();#endif.....#ifdef G4VIS_USEdelete visManager;#endif//----- end of C++Alternatively, you can implement an empty RegisterGraphicsSystems() function, and register visualizationdrivers you want directly in your main() function. See Example 8.3.Example 8.3. An alternative style <strong>for</strong> the main() function.//----- C++ source codes: How to register a visualization driver directly// in main() function.....G4VisManager* visManager = new G4VisExecutive;visManager -> RegisterGraphicsSystem (new MyGraphicsSystem);.....delete visManager//----- end of C++Do not <strong>for</strong>get to delete the instantiated Visualization Manager by yourself. Note that a graphics system <strong>for</strong> <strong>Geant4</strong>Visualization may run as a different process. In that case, the destructor of G4VisManager might have to terminatethe graphics system and/or close the connection.We recommend that the instantiation, initialization, and deletion of the Visualization Manager be protected by C-pre-processor commands, as in the novice examples. The C-pre-processor macro G4VIS_USE is automaticallydefined unless the environment variable G4VIS_NONE is set. This assumes that you are compiling your <strong>Geant4</strong>executable with the standard version of GNUmakefile found in the config directory.Example 8.4 shows an example of the main() function available <strong>for</strong> <strong>Geant4</strong> Visualization.220

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!