source: trunk/source/visualization/test/test19.cc @ 1025

Last change on this file since 1025 was 1025, checked in by garnier, 15 years ago

modif pour compil

File size: 6.5 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26//
27// $Id: test19.cc,v 1.29 2007/01/05 16:00:48 allison Exp $
28// GEANT4 tag $Name:  $
29//
30//
31
32// Usage: test19 [<session>] [<verbosity>]
33// Without verbosity, verbosity=warnings.
34// Without session, session=new G4UIterminal(), or if G4UI_USE_TCSH is set
35//                  session=new G4UIterminal(new G4UItcsh),
36
37#include <stdio.h>
38#include <ctype.h>
39#include <stdlib.h>
40
41#include "globals.hh"
42//#include "SharedSolidDetectorConstruction.hh"
43#include "test19DetectorConstruction.hh"
44#include "MyPhysicsList.hh"
45#include "MyRunAction.hh"
46#include "MyPrimaryGeneratorAction.hh"
47#include "MyEventAction.hh"
48#include "MySteppingAction.hh"
49
50#include "G4UIterminal.hh"
51#ifdef G4UI_USE_TCSH
52#include "G4UItcsh.hh"
53#endif
54#include "G4UIGAG.hh"
55#ifdef G4UI_USE_WO
56  #include "G4UIWo.hh"
57#endif
58#ifdef G4UI_USE_XM
59  #include "G4UIXm.hh"
60#endif
61#ifdef G4UI_USE_XAW
62  #include "G4UIXaw.hh"
63#endif
64#ifdef G4UI_USE_WIN32
65  #include "G4UIWin32.hh"
66#endif
67#ifdef G4UI_USE_QT
68  #include "G4UIQt.hh"
69#endif
70
71#include "G4RunManager.hh"
72
73#ifdef G4VIS_USE
74#include "G4VisExecutive.hh"
75// G4VisExecutive is a G4VisManager that implements graphics system
76// registration in the user domain.
77#include "G4XXX.hh"
78#include "G4XXXFile.hh"
79#include "G4XXXStored.hh"
80#ifdef G4VIS_USE_XXXSG
81#include "G4XXXSG.hh"
82#endif
83#endif
84
85
86#ifdef G4UI_USE_WIN32
87#include <windows.h>
88int WINAPI WinMain (
89HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpszCmdLine,int nCmdShow) {
90#else
91int main (int argc, char** argv) {
92#endif
93
94  G4String verbosityString("warnings");
95#ifndef G4UI_USE_WIN32
96  if ((argc >= 3)) verbosityString = argv[2];
97#endif
98
99  // Choose (G)UI.
100  G4UIsession* session;
101#ifdef G4UI_USE_WIN32
102  session = new G4UIWin32 (hInstance,hPrevInstance,lpszCmdLine,nCmdShow);
103#else
104  if (argc >= 2) {
105#ifdef G4UI_USE_TCSH
106    if (strcmp (argv[1], "tcsh")==0)     session =
107                                           new G4UIterminal(new G4UItcsh);
108    else
109#endif
110#ifdef G4UI_USE_WO
111    if (strcmp (argv[1], "Wo")==0)  session = new G4UIWo (argc, argv);
112    else
113#endif
114#ifdef G4UI_USE_XM
115    if (strcmp (argv[1], "Xm")==0)  session = new G4UIXm (argc, argv);
116    else
117#endif
118#ifdef G4UI_USE_XAW
119    if (strcmp (argv[1], "Xaw")==0) session = new G4UIXaw (argc, argv);
120    else
121#endif
122#ifdef G4UI_USE_GAG
123    if (strcmp (argv[1], "gag")==0) session = new G4UIGAG ;
124    else
125#endif
126#ifdef G4UI_USE_QT
127      if (strcmp (argv[1], "Qt")==0) session = new G4UIQt(argc, argv) ;
128    else
129#endif
130                                    session =
131                                           new G4UIterminal();
132  }
133  else                                   
134#ifdef G4UI_USE_TCSH
135                                    session =  new G4UIterminal(new G4UItcsh);
136#else
137  {
138    G4cerr << "You should define a UI in order to interact with test" << G4endl;
139    return 0;
140  }
141#endif
142#endif
143  G4UImanager::GetUIpointer()->SetSession(session);  //So that Pause works..
144
145  // Run manager
146  G4cout << "RunManager is constructing...." << G4endl;
147  G4RunManager * runManager = new G4RunManager;
148
149  // User initialization classes
150  runManager -> SetUserInitialization (new test19DetectorConstruction);
151  //runManager -> SetUserInitialization (new SharedSolidDetectorConstruction);
152  runManager -> SetUserInitialization (new MyPhysicsList);
153
154  // UserAction classes.
155  runManager -> SetUserAction (new MyRunAction);
156  runManager -> SetUserAction (new MyPrimaryGeneratorAction);
157  runManager -> SetUserAction (new MyEventAction);
158  runManager -> SetUserAction (new MySteppingAction);
159
160  //Initialize G4 kernel
161  //runManager->Initialize();  // Do this with /run/initialize so that
162                               // you can, optionally, choose detector
163                               // (/test19det/detector N) first.
164
165#ifdef G4VIS_USE
166  // Instantiate and initialise Visualization Manager.
167  G4VisManager* visManager = new G4VisExecutive;
168  visManager -> SetVerboseLevel (verbosityString);
169  visManager -> RegisterGraphicsSystem(new G4XXX);
170  visManager -> RegisterGraphicsSystem(new G4XXXFile);
171  visManager -> RegisterGraphicsSystem(new G4XXXStored);
172#ifdef G4VIS_USE_XXXSG
173  visManager -> RegisterGraphicsSystem(new G4XXXSG);
174#endif
175  visManager -> Initialize ();
176#endif
177
178  G4UImanager* UI = G4UImanager::GetUIpointer ();
179
180#ifdef G4UI_USE_WIN32
181  G4cout << "Reading win32.g4m file...." << G4endl;
182  UI -> ApplyCommand ("/control/execute win32.g4m");
183#else
184  G4cout << "Reading test19.g4m file...." << G4endl;
185  UI -> ApplyCommand ("/control/execute test19.g4m");
186#endif
187
188  G4cout << 
189    "Choose a detector with /test19det/detector (or let default be"
190    " constructed)."
191       << G4endl;
192
193  // Start an interactive session.
194  session -> SessionStart();
195
196#ifdef G4VIS_USE
197  G4cout << "vis_test19: Deleting vis manager..." << G4endl;
198  delete visManager;
199  G4cout << "vis_test19: Vis manager deleted." << G4endl;
200#endif
201  G4cout << "vis_test19: Deleting run manager..." << G4endl;
202  delete runManager;
203  G4cout << "vis_test19: Run manager deleted." << G4endl;
204  G4cout << "vis_test19: Deleting session..." << G4endl;
205  delete session;
206  G4cout << "vis_test19: Session deleted." << G4endl;
207
208  return 0;
209}
Note: See TracBrowser for help on using the repository browser.