| 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: G4TrajectoriesModel.cc,v 1.25 2010/05/11 11:21:52 allison Exp $
|
|---|
| 28 | // GEANT4 tag $Name: geant4-09-04-beta-01 $
|
|---|
| 29 | //
|
|---|
| 30 | //
|
|---|
| 31 | // John Allison 26th August 1998.
|
|---|
| 32 | // Model which knows how to draw GEANT4 trajectories.
|
|---|
| 33 |
|
|---|
| 34 | #include "G4TrajectoriesModel.hh"
|
|---|
| 35 |
|
|---|
| 36 | #include "G4ModelingParameters.hh"
|
|---|
| 37 | #include "G4VGraphicsScene.hh"
|
|---|
| 38 | #include "G4Event.hh"
|
|---|
| 39 | #include "G4AttValue.hh"
|
|---|
| 40 | #include "G4AttDef.hh"
|
|---|
| 41 | #include "G4AttCheck.hh"
|
|---|
| 42 |
|
|---|
| 43 | G4TrajectoriesModel::G4TrajectoriesModel ():
|
|---|
| 44 | fDrawingModeSet(false),
|
|---|
| 45 | fDrawingMode(0),
|
|---|
| 46 | fpCurrentTrajectory(0)
|
|---|
| 47 | {
|
|---|
| 48 | fGlobalTag = "G4TrajectoriesModel for all trajectories.";
|
|---|
| 49 | fGlobalDescription = fGlobalTag;
|
|---|
| 50 | }
|
|---|
| 51 |
|
|---|
| 52 | G4TrajectoriesModel::G4TrajectoriesModel (G4int drawingMode):
|
|---|
| 53 | fDrawingModeSet(true),
|
|---|
| 54 | fDrawingMode(drawingMode),
|
|---|
| 55 | fpCurrentTrajectory(0) {
|
|---|
| 56 | fGlobalTag = "G4TrajectoriesModel for all trajectories.";
|
|---|
| 57 | fGlobalDescription = fGlobalTag;
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 | G4TrajectoriesModel::~G4TrajectoriesModel () {}
|
|---|
| 61 |
|
|---|
| 62 | void G4TrajectoriesModelDebugG4AttValues(const G4VTrajectory*);
|
|---|
| 63 |
|
|---|
| 64 | void G4TrajectoriesModel::DescribeYourselfTo (G4VGraphicsScene& sceneHandler) {
|
|---|
| 65 | const G4Event* event = fpMP->GetEvent();
|
|---|
| 66 | if (event) {
|
|---|
| 67 | G4TrajectoryContainer* TC = event -> GetTrajectoryContainer ();
|
|---|
| 68 | if (TC) {
|
|---|
| 69 | for (G4int iT = 0; iT < TC->entries(); iT++) {
|
|---|
| 70 | fpCurrentTrajectory = (*TC) [iT];
|
|---|
| 71 | // Debug trajectory:
|
|---|
| 72 | // fpCurrentTrajectory->ShowTrajectory(); G4cout << G4endl;
|
|---|
| 73 | // Debug G4AttValues:
|
|---|
| 74 | // G4TrajectoriesModelDebugG4AttValues(fpCurrentTrajectory);
|
|---|
| 75 | if (fpCurrentTrajectory)
|
|---|
| 76 | sceneHandler.AddCompound (*fpCurrentTrajectory);
|
|---|
| 77 | }
|
|---|
| 78 | }
|
|---|
| 79 | }
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 | G4bool G4TrajectoriesModel::IsDrawingModeSet() const
|
|---|
| 83 | {
|
|---|
| 84 | return fDrawingModeSet;
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | G4int G4TrajectoriesModel::GetDrawingMode() const
|
|---|
| 88 | {
|
|---|
| 89 | if (fDrawingModeSet) return fDrawingMode;
|
|---|
| 90 | else {
|
|---|
| 91 | G4Exception
|
|---|
| 92 | ("G4TrajectoriesModel::GetDrawingMode",
|
|---|
| 93 | "",
|
|---|
| 94 | FatalException,
|
|---|
| 95 | "Illegal attempt to obtain i_mode."
|
|---|
| 96 | "\n i_mode is an old trajectories parameter that is DEPRECATED"
|
|---|
| 97 | "\n and will be removed at the next major release."
|
|---|
| 98 | );
|
|---|
| 99 | return 0;
|
|---|
| 100 | }
|
|---|
| 101 | }
|
|---|
| 102 |
|
|---|
| 103 | void G4TrajectoriesModel::SetDrawingMode(G4int drawingMode)
|
|---|
| 104 | {
|
|---|
| 105 | if (fDrawingModeSet) fDrawingMode = drawingMode;
|
|---|
| 106 | else {
|
|---|
| 107 | G4Exception
|
|---|
| 108 | ("G4TrajectoriesModel::SetDrawingMode",
|
|---|
| 109 | "",
|
|---|
| 110 | FatalException,
|
|---|
| 111 | "Illegal attempt to set i_mode."
|
|---|
| 112 | "\n i_mode is an old trajectories parameter that is DEPRECATED"
|
|---|
| 113 | "\n and will be removed at the next major release."
|
|---|
| 114 | );
|
|---|
| 115 | }
|
|---|
| 116 | }
|
|---|
| 117 |
|
|---|
| 118 | // Debug material...
|
|---|
| 119 |
|
|---|
| 120 | #include "G4VTrajectoryPoint.hh"
|
|---|
| 121 |
|
|---|
| 122 | void G4TrajectoriesModelDebugG4AttValues(const G4VTrajectory* pTraj)
|
|---|
| 123 | {
|
|---|
| 124 | std::vector<G4AttValue>* attValues = pTraj->CreateAttValues();
|
|---|
| 125 | if (attValues) {
|
|---|
| 126 | G4AttCheck attCheck(attValues, pTraj->GetAttDefs());
|
|---|
| 127 | G4cout << "\nProvided G4Atts:\n" << attCheck;
|
|---|
| 128 | if (attCheck.Check()) G4cout << "Error" << G4endl;
|
|---|
| 129 | else {
|
|---|
| 130 | std::vector<G4AttValue> standardValues;
|
|---|
| 131 | std::map<G4String,G4AttDef> standardDefinitions;
|
|---|
| 132 | attCheck.Standard(&standardValues, &standardDefinitions);
|
|---|
| 133 | G4cout << "\nStandard G4Atts:\n"
|
|---|
| 134 | << G4AttCheck(&standardValues, &standardDefinitions);
|
|---|
| 135 | }
|
|---|
| 136 | delete attValues;
|
|---|
| 137 | }
|
|---|
| 138 | for (G4int i = 0; i < pTraj->GetPointEntries(); i++) {
|
|---|
| 139 | G4VTrajectoryPoint* aPoint = pTraj->GetPoint(i);
|
|---|
| 140 | std::vector<G4AttValue>* attValues = aPoint->CreateAttValues();
|
|---|
| 141 | if (attValues) {
|
|---|
| 142 | G4AttCheck attCheck(attValues, aPoint->GetAttDefs());
|
|---|
| 143 | G4cout << "\nProvided G4Atts:\n" << attCheck;
|
|---|
| 144 | if (attCheck.Check()) G4cout << "Error" << G4endl;
|
|---|
| 145 | else {
|
|---|
| 146 | std::vector<G4AttValue> standardValues;
|
|---|
| 147 | std::map<G4String,G4AttDef> standardDefinitions;
|
|---|
| 148 | attCheck.Standard(&standardValues, &standardDefinitions);
|
|---|
| 149 | G4cout << "\nStandard G4Atts:\n"
|
|---|
| 150 | << G4AttCheck(&standardValues, &standardDefinitions);
|
|---|
| 151 | }
|
|---|
| 152 | delete attValues;
|
|---|
| 153 | }
|
|---|
| 154 | }
|
|---|
| 155 | }
|
|---|