19 #include <G4PVPlacement.hh>
20 #include <G4RunManager.hh>
21 #include <G4UImanager.hh>
22 #include <G4UIsession.hh>
23 #include <Randomize.hh>
25 #ifdef G4VIS_USE_OPENGLX
26 #include <G4OpenGLImmediateX.hh>
27 #include <G4OpenGLStoredX.hh>
30 #include <G4VisManager.hh>
31 #include <G4VisExecutive.hh>
32 #include <G4UIExecutive.hh>
33 #include <G4VUserPhysicsList.hh>
34 #include <G4ParticleTypes.hh>
45 class EmptyPhysicsList:
public G4VUserPhysicsList {
47 EmptyPhysicsList() { }
48 ~EmptyPhysicsList() { }
50 void ConstructParticle() { G4Geantino::GeantinoDefinition(); }
51 void ConstructProcess() { AddTransportation(); }
52 void SetCuts() { SetCutsWithDefault(); }
56 static const char* get_arg(
int argc,
char** argv,
int which) {
57 if ( which>0 && which < argc )
return argv[which];
58 throw runtime_error(
"Invalid argument sequence");
62 string gdml = argv[1];
63 string setup = argv[2];
64 const char* args[] = {
"cmd"};
65 for(
int i=1; i<argc;++i) {
66 if ( argv[i][0]==
'-' ) {
68 if ( ::strncmp(n.c_str(),
"gdml",4) == 0 )
69 gdml = get_arg(argc,argv,++i);
70 else if ( ::strncmp(n.c_str(),
"guisetup",3) == 0 )
71 setup = get_arg(argc,argv,++i);
74 if ( gdml.empty() || setup.empty() ) {
75 cout <<
" usage: g4gdmlDisplay -gdml <file-name> -guisetup <g4 macro>" << endl;
79 G4RunManager * run =
new G4RunManager;
81 run->SetUserInitialization(
new EmptyPhysicsList());
87 G4VisManager* vis =
new G4VisExecutive;
91 G4UImanager* uiman = G4UImanager::GetUIpointer();
92 G4UIExecutive* ui =
new G4UIExecutive(1,(
char**)args);
93 uiman->ApplyCommand(
"/control/execute "+setup);
103 int main(
int argc,
char** argv) {
108 cout <<
"Got uncaught exception: " << e.what() << endl;
111 cout <<
"Got UNKNOWN uncaught exception." << endl;