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

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

changes to have Qt on test19

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#if defined(G4UI_USE_GAG)
52  #include "G4UIGAG.hh"
53#elif defined(G4UI_USE_TCSH)
54  #include "G4UItcsh.hh"
55#elif defined(G4UI_USE_WO)
56  #include "G4UIWo.hh"
57#elif defined(G4UI_USE_XM)
58  #include "G4UIXm.hh"
59#elif defined(G4UI_USE_XAW)
60  #include "G4UIXaw.hh"
61#elif defined(G4UI_USE_WIN32)
62  #include "G4UIWin32.hh"
63#elif defined(G4UI_USE_QT)
64  #include "G4UIQt.hh"
65#endif
66
67#include "G4RunManager.hh"
68
69#ifdef G4VIS_USE
70#include "G4VisExecutive.hh"
71// G4VisExecutive is a G4VisManager that implements graphics system
72// registration in the user domain.
73#include "G4XXX.hh"
74#include "G4XXXFile.hh"
75#include "G4XXXStored.hh"
76#ifdef G4VIS_USE_XXXSG
77#include "G4XXXSG.hh"
78#endif
79#endif
80
81
82#ifdef G4UI_USE_WIN32
83#include <windows.h>
84int WINAPI WinMain (
85HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpszCmdLine,int nCmdShow) {
86#else
87int main (int argc, char** argv) {
88#endif
89
90  G4String verbosityString("warnings");
91#ifndef G4UI_USE_WIN32
92  if ((argc >= 3)) verbosityString = argv[2];
93#endif
94
95  // Choose (G)UI.
96  G4UIsession* session;
97#ifdef G4UI_USE_WIN32
98  session = new G4UIWin32 (hInstance,hPrevInstance,lpszCmdLine,nCmdShow);
99#else
100  if (argc >= 2) {
101  #if defined(G4UI_USE_TCSH)
102    if (strcmp (argv[1], "tcsh")==0)     session =
103      new G4UIterminal(new G4UItcsh);
104  #elif defined(G4UI_USE_WO)
105    if (strcmp (argv[1], "Wo")==0)  session = new G4UIWo (argc, argv);
106  #elif defined(G4UI_USE_XM)
107    if (strcmp (argv[1], "Xm")==0)  session = new G4UIXm (argc, argv);
108  #elif defined(G4UI_USE_XAW)
109    if (strcmp (argv[1], "Xaw")==0) session = new G4UIXaw (argc, argv);
110  #elif defined(G4UI_USE_GAG)
111    if (strcmp (argv[1], "gag")==0) session = new G4UIGAG ;
112  #elif defined(G4UI_USE_QT)
113    if (strcmp (argv[1], "Qt")==0) session = new G4UIQt(argc, argv) ;
114  #else
115    session = new G4UIterminal();
116  #endif
117    else
118      session = new G4UIterminal();
119  }
120  else                                   
121  {
122    G4cerr << "You should define a UI in order to interact with test" << G4endl;
123    return 0;
124  }
125#endif
126  G4UImanager::GetUIpointer()->SetSession(session);  //So that Pause works..
127
128  // Run manager
129  G4cout << "RunManager is constructing...." << G4endl;
130  G4RunManager * runManager = new G4RunManager;
131
132  // User initialization classes
133  runManager -> SetUserInitialization (new test19DetectorConstruction);
134  //runManager -> SetUserInitialization (new SharedSolidDetectorConstruction);
135  runManager -> SetUserInitialization (new MyPhysicsList);
136
137  // UserAction classes.
138  runManager -> SetUserAction (new MyRunAction);
139  runManager -> SetUserAction (new MyPrimaryGeneratorAction);
140  runManager -> SetUserAction (new MyEventAction);
141  runManager -> SetUserAction (new MySteppingAction);
142
143  //Initialize G4 kernel
144  //runManager->Initialize();  // Do this with /run/initialize so that
145                               // you can, optionally, choose detector
146                               // (/test19det/detector N) first.
147
148#ifdef G4VIS_USE
149  // Instantiate and initialise Visualization Manager.
150  G4VisManager* visManager = new G4VisExecutive;
151  visManager -> SetVerboseLevel (verbosityString);
152  visManager -> RegisterGraphicsSystem(new G4XXX);
153  visManager -> RegisterGraphicsSystem(new G4XXXFile);
154  visManager -> RegisterGraphicsSystem(new G4XXXStored);
155#ifdef G4VIS_USE_XXXSG
156  visManager -> RegisterGraphicsSystem(new G4XXXSG);
157#endif
158  visManager -> Initialize ();
159#endif
160
161  G4UImanager* UI = G4UImanager::GetUIpointer ();
162
163#ifdef G4UI_USE_WIN32
164  G4cout << "Reading win32.g4m file...." << G4endl;
165  UI -> ApplyCommand ("/control/execute win32.g4m");
166#else
167  G4cout << "Reading test19.g4m file...." << G4endl;
168  UI -> ApplyCommand ("/control/execute test19.g4m");
169#endif
170
171  G4cout << 
172    "Choose a detector with /test19det/detector (or let default be"
173    " constructed)."
174       << G4endl;
175
176  // Start an interactive session.
177  session -> SessionStart();
178
179#ifdef G4VIS_USE
180  G4cout << "vis_test19: Deleting vis manager..." << G4endl;
181  delete visManager;
182  G4cout << "vis_test19: Vis manager deleted." << G4endl;
183#endif
184  G4cout << "vis_test19: Deleting run manager..." << G4endl;
185  delete runManager;
186  G4cout << "vis_test19: Run manager deleted." << G4endl;
187  G4cout << "vis_test19: Deleting session..." << G4endl;
188  delete session;
189  G4cout << "vis_test19: Session deleted." << G4endl;
190
191  return 0;
192}
Note: See TracBrowser for help on using the repository browser.