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

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

update to CVS

File size: 5.3 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.31 2009/09/29 21:35:56 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#ifdef G4UI_USE
51#include "G4UIExecutive.hh"
52#endif
53
54#include "G4RunManager.hh"
55
56#ifdef G4VIS_USE
57#include "G4VisExecutive.hh"
58// G4VisExecutive is a G4VisManager that implements graphics system
59// registration in the user domain.
60#include "G4XXX.hh"
61#include "G4XXXFile.hh"
62#include "G4XXXStored.hh"
63#ifdef G4VIS_USE_XXXSG
64#include "G4XXXSG.hh"
65#endif
66#endif
67
68
69#ifdef G4UI_USE_WIN32
70#include <windows.h>
71int WINAPI WinMain (
72HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpszCmdLine,int nCmdShow) {
73#else
74int main (int argc, char** argv) {
75#endif
76
77  G4String verbosityString("warnings");
78#ifndef G4UI_USE_WIN32
79  if ((argc >= 3)) verbosityString = argv[2];
80#endif
81
82#ifdef G4UI_USE
83  // Choose (G)UI.
84  G4UIExecutive* UIexecutive = new G4UIExecutive(argc, argv);
85  G4UImanager::GetUIpointer()->SetSession(UIexecutive->GetSession());  //So that Pause works..
86#endif
87
88  // Run manager
89  G4cout << "RunManager is constructing...." << G4endl;
90  G4RunManager * runManager = new G4RunManager;
91
92  // User initialization classes
93  runManager -> SetUserInitialization (new test19DetectorConstruction);
94  //runManager -> SetUserInitialization (new SharedSolidDetectorConstruction);
95  runManager -> SetUserInitialization (new MyPhysicsList);
96
97  // UserAction classes.
98  runManager -> SetUserAction (new MyRunAction);
99  runManager -> SetUserAction (new MyPrimaryGeneratorAction);
100  runManager -> SetUserAction (new MyEventAction);
101  runManager -> SetUserAction (new MySteppingAction);
102
103  //Initialize G4 kernel
104  //runManager->Initialize();  // Do this with /run/initialize so that
105                               // you can, optionally, choose detector
106                               // (/test19det/detector N) first.
107
108#ifdef G4VIS_USE
109  // Instantiate and initialise Visualization Manager.
110  G4VisManager* visManager = new G4VisExecutive;
111  visManager -> SetVerboseLevel (verbosityString);
112  visManager -> RegisterGraphicsSystem(new G4XXX);
113  visManager -> RegisterGraphicsSystem(new G4XXXFile);
114  visManager -> RegisterGraphicsSystem(new G4XXXStored);
115#ifdef G4VIS_USE_XXXSG
116  visManager -> RegisterGraphicsSystem(new G4XXXSG);
117#endif
118  visManager -> Initialize ();
119#endif
120
121  G4UImanager* UI = G4UImanager::GetUIpointer ();
122#ifdef G4UI_USE_WIN32
123  G4cout << "Reading win32.g4m file...." << G4endl;
124  UI -> ApplyCommand ("/control/execute win32.g4m");
125#else
126  G4cout << "Reading test19.g4m file...." << G4endl;
127  UI -> ApplyCommand ("/control/execute test19.g4m");
128#endif
129
130  G4cout << 
131    "Choose a detector with /test19det/detector (or let default be"
132    " constructed)."
133       << G4endl;
134
135#ifdef G4UI_USE
136  // Start an interactive session.
137  UIexecutive -> SessionStart();
138#endif
139
140#ifdef G4VIS_USE
141  G4cout << "vis_test19: Deleting vis manager..." << G4endl;
142  delete visManager;
143  G4cout << "vis_test19: Vis manager deleted." << G4endl;
144#endif
145  G4cout << "vis_test19: Deleting run manager..." << G4endl;
146  delete runManager;
147  G4cout << "vis_test19: Run manager deleted." << G4endl;
148  G4cout << "vis_test19: Deleting session..." << G4endl;
149#ifdef G4UI_USE
150  delete UIexecutive;
151  G4cout << "vis_test19: Session deleted." << G4endl;
152#endif
153
154  return 0;
155}
Note: See TracBrowser for help on using the repository browser.