| [834] | 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: testshapes.cc,v 1.4 2006/06/29 21:33:32 gunter Exp $
|
|---|
| [1347] | 28 | // GEANT4 tag $Name: geant4-09-04-ref-00 $
|
|---|
| [834] | 29 | //
|
|---|
| 30 | //
|
|---|
| 31 | // John Allison Jan 1996
|
|---|
| 32 |
|
|---|
| 33 | #include "BuildShapes.hh"
|
|---|
| 34 |
|
|---|
| 35 | #include "G4VisManager.hh"
|
|---|
| 36 |
|
|---|
| 37 | #include "G4UImanager.hh"
|
|---|
| 38 | #include "G4UIterminal.hh"
|
|---|
| 39 | #include "G4UIWo.hh"
|
|---|
| 40 |
|
|---|
| 41 | #include "G4Initializer.hh"
|
|---|
| 42 | #include "G4RunManager.hh"
|
|---|
| 43 | #include "G4GeometryManager.hh"
|
|---|
| 44 |
|
|---|
| 45 | // Solve templates.
|
|---|
| 46 | // Code in g4templates.hh controlled by the macro G4_SOLVE_TEMPLATES
|
|---|
| 47 | #include "g4templates.hh"
|
|---|
| 48 |
|
|---|
| 49 | main (int argc,char** argv) {
|
|---|
| 50 |
|
|---|
| 51 | // Set up User Interface.
|
|---|
| 52 | G4UImanager* UI = G4UImanager::GetUIpointer ();
|
|---|
| 53 |
|
|---|
| 54 | // Choose (G)UI.
|
|---|
| 55 | #ifdef Wo
|
|---|
| 56 | if(argc==2)
|
|---|
| 57 | {
|
|---|
| 58 | G4UIterminal* interactor = new G4UIterminal;
|
|---|
| 59 | UI -> SetSession (interactor);
|
|---|
| 60 | }
|
|---|
| 61 | else
|
|---|
| 62 | {
|
|---|
| 63 | G4UIWo* interactor = new G4UIWo (argc,argv);
|
|---|
| 64 | UI -> SetSession (interactor);
|
|---|
| 65 | }
|
|---|
| 66 | #else
|
|---|
| 67 | G4UIterminal* interactor = new G4UIterminal;
|
|---|
| 68 | UI -> SetSession (interactor);
|
|---|
| 69 | #endif
|
|---|
| 70 |
|
|---|
| 71 | G4VPhysicalVolume* pBox = BuildBox (); // 0
|
|---|
| 72 | G4VPhysicalVolume* pCylinder = BuildCylinder(); // 1
|
|---|
| 73 | G4VPhysicalVolume* pTubs = BuildTubs(); // 2
|
|---|
| 74 | G4VPhysicalVolume* pCons = BuildCons(); // 3
|
|---|
| 75 | G4VPhysicalVolume* pTrd = BuildTrd (); // 4
|
|---|
| 76 | G4VPhysicalVolume* pTrap = BuildTrap(); // 5
|
|---|
| 77 | G4VPhysicalVolume* pSphereFull = BuildSphereFull(); // 6
|
|---|
| 78 | G4VPhysicalVolume* pSphereSeg = BuildSphereSeg (); // 7
|
|---|
| 79 | G4VPhysicalVolume* pPara = BuildPara(); // 8
|
|---|
| 80 | G4VPhysicalVolume* pPCon = BuildPCon(); // 9
|
|---|
| 81 | G4VPhysicalVolume* pPGon = BuildPGon(); // 10
|
|---|
| 82 | G4VPhysicalVolume* pforcedWireframeBox = BuildForcedWireframeBox(); // 11
|
|---|
| 83 |
|
|---|
| 84 | G4VPhysicalVolume* pGeometries [20];
|
|---|
| 85 | pGeometries [0] = pBox;
|
|---|
| 86 | pGeometries [1] = pCylinder;
|
|---|
| 87 | pGeometries [2] = pTubs;
|
|---|
| 88 | pGeometries [3] = pCons;
|
|---|
| 89 | pGeometries [4] = pTrd;
|
|---|
| 90 | pGeometries [5] = pTrap;
|
|---|
| 91 | pGeometries [6] = pSphereFull ;
|
|---|
| 92 | pGeometries [7] = pSphereSeg ;
|
|---|
| 93 | pGeometries [8] = pPara ;
|
|---|
| 94 | pGeometries [9] = pPCon ;
|
|---|
| 95 | pGeometries [10] = pPGon ;
|
|---|
| 96 | pGeometries [11] = pforcedWireframeBox ;
|
|---|
| 97 |
|
|---|
| 98 | if (!pGeometries [0]) { return 0 ; }
|
|---|
| 99 |
|
|---|
| 100 | // Initializer, etc.
|
|---|
| 101 | G4Initializer * initializer = new G4Initializer;
|
|---|
| 102 | testshapesDetectorConstruction* pDetectorConstruction
|
|---|
| 103 | = new testshapesDetectorConstruction;
|
|---|
| 104 | pDetectorConstruction -> SetDetector (pGeometries [0]);
|
|---|
| 105 | initializer -> SetUserInitialization (pDetectorConstruction);
|
|---|
| 106 | initializer -> Initialize();
|
|---|
| 107 |
|
|---|
| 108 | // Instantiate Vis Manager.
|
|---|
| 109 | G4VisManager* pVMan = G4VisManager::GetInstance ();
|
|---|
| 110 |
|
|---|
| 111 | // Tie streams together so output is flushed before any input.
|
|---|
| 112 | G4cin.tie (&G4cout);
|
|---|
| 113 | // Main loop.
|
|---|
| 114 | G4int iGeom;
|
|---|
| 115 | do {
|
|---|
| 116 | // Choose a shape.
|
|---|
| 117 | do {
|
|---|
| 118 | G4cout << "Choose a shape ( < 0 to quit ):\n"
|
|---|
| 119 | << "0) Box\n"
|
|---|
| 120 | << "1) Cylinder\n"
|
|---|
| 121 | << "2) Tubs\n"
|
|---|
| 122 | << "3) Cons\n"
|
|---|
| 123 | << "4) Trd\n"
|
|---|
| 124 | << "5) Trap\n"
|
|---|
| 125 | << "6) Sphere (full)\n"
|
|---|
| 126 | << "7) Sphere (segment)\n"
|
|---|
| 127 | << "8) Pararellepiped\n"
|
|---|
| 128 | << "9) PCon (Not implemented yet)\n"
|
|---|
| 129 | << "10) PGon (Not implemented yet)\n"
|
|---|
| 130 | << "11) Forced wireframe box\n"
|
|---|
| 131 | << G4endl;
|
|---|
| 132 | G4cout << "Enter choice (< 0 to exit): ";
|
|---|
| 133 | G4cin >> iGeom; // (Protect against invalid input!!!!!!!!!!!!!!!!!!!)
|
|---|
| 134 | while (G4cin.get () != '\n'); // Get newline character after G4cin >> iGS;
|
|---|
| 135 |
|
|---|
| 136 | } while (iGeom > 11);
|
|---|
| 137 |
|
|---|
| 138 | if (iGeom >= 0) {
|
|---|
| 139 |
|
|---|
| 140 | if (pGeometries [iGeom]) {
|
|---|
| 141 |
|
|---|
| 142 | pDetectorConstruction -> SetDetector (pGeometries [iGeom]);
|
|---|
| 143 | initializer -> Initialize();
|
|---|
| 144 |
|
|---|
| 145 | pVMan -> AddToCurrentSceneData (pGeometries [iGeom]);
|
|---|
| 146 |
|
|---|
| 147 | // These lines temporarily removed from G4RunManager, so they're here..
|
|---|
| 148 | G4cout << "Start closing geometry." << G4endl;
|
|---|
| 149 | G4GeometryManager::GetInstance()->CloseGeometry();
|
|---|
| 150 | G4cout << "Geometry closed. Start event processing." << G4endl;
|
|---|
| 151 |
|
|---|
| 152 | // Enter UI command interpreter.
|
|---|
| 153 | UI -> Interact ("G4Vis> ");
|
|---|
| 154 | }
|
|---|
| 155 | else {
|
|---|
| 156 | G4cout << "Null geometry pointer."
|
|---|
| 157 | "\nMaybe you selected a not-implemented shape!"
|
|---|
| 158 | << G4endl;
|
|---|
| 159 | }
|
|---|
| 160 | }
|
|---|
| 161 | } while ( iGeom >= 0 );
|
|---|
| 162 |
|
|---|
| 163 | // Ensure VisManager destructor is called.
|
|---|
| 164 | delete G4VisManager::GetInstance ();
|
|---|
| 165 |
|
|---|
| 166 | return 0;
|
|---|
| 167 | }
|
|---|