Geant4  10.00.p01
G4TrajectoriesModel.cc
Go to the documentation of this file.
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 68043 2013-03-13 14:27:49Z gcosmo $
28 //
29 //
30 // John Allison 26th August 1998.
31 // Model which knows how to draw GEANT4 trajectories.
32 
33 #include "G4TrajectoriesModel.hh"
34 
35 #include "G4ModelingParameters.hh"
36 #include "G4VGraphicsScene.hh"
37 #include "G4Event.hh"
38 #include "G4AttDefStore.hh"
39 #include "G4AttValue.hh"
40 #include "G4AttDef.hh"
41 #include "G4AttCheck.hh"
42 #include "G4UIcommand.hh"
43 
45  fpCurrentTrajectory(0),
46  fEventID(0)
47 {
48  fType = "G4TrajectoriesModel";
49  fGlobalTag = "G4TrajectoriesModel for all trajectories.";
51 }
52 
54 
56 
57 #include "G4VVisManager.hh"
59 {
60  const G4Event* event = fpMP->GetEvent();
61  if (!event) return;
62 
63  G4TrajectoryContainer* TC = event -> GetTrajectoryContainer ();
64  if (!TC) return;
65 
67  if (!pVVisManager) return;
68 
69  fEventID = event->GetEventID();
70 
71  pVVisManager->BeginDraw();
72  // The use of Begin/EndDraw (optional methods to improve drawing
73  // speed) assumes all trajectories are drawn with the same
74  // transformation. If not, a fatal exception with be raised in
75  // G4VisManager::DrawT.
76  for (G4int iT = 0; iT < TC->entries(); iT++) {
77  fpCurrentTrajectory = (*TC) [iT];
78  // Debug trajectory:
79  // fpCurrentTrajectory->ShowTrajectory(); G4cout << G4endl;
80  // Debug G4AttValues:
81  // G4TrajectoriesModelDebugG4AttValues(fpCurrentTrajectory);
83  sceneHandler.AddCompound (*fpCurrentTrajectory);
84  }
85  pVVisManager->EndDraw();
86 }
87 
88 const std::map<G4String,G4AttDef>* G4TrajectoriesModel::GetAttDefs() const
89 {
90  G4bool isNew;
91  std::map<G4String,G4AttDef>* store
92  = G4AttDefStore::GetInstance("G4TrajectoriesModel", isNew);
93  if (isNew) {
94  (*store)["EventID"] =
95  G4AttDef("EventID","Event ID","Physics","","G4int");
96  }
97  return store;
98 }
99 
100 std::vector<G4AttValue>* G4TrajectoriesModel::CreateCurrentAttValues() const
101 {
102  std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
103  values->push_back
105  return values;
106 }
107 
108 // Debug material...
109 
110 #include "G4VTrajectoryPoint.hh"
111 
113 {
114  // Trajectory attributes
115  { // Scope bracket - allows re-use of names without compiler warnings.
116  std::vector<G4AttValue>* attValues = pTraj->CreateAttValues();
117  if (attValues) {
118  G4AttCheck attCheck(attValues, pTraj->GetAttDefs());
119  G4cout << "\nProvided G4Atts:\n" << attCheck;
120  if (attCheck.Check()) G4cout << "Error" << G4endl;
121  else {
122  std::vector<G4AttValue> standardValues;
123  std::map<G4String,G4AttDef> standardDefinitions;
124  attCheck.Standard(&standardValues, &standardDefinitions);
125  G4cout << "\nStandard G4Atts:\n"
126  << G4AttCheck(&standardValues, &standardDefinitions);
127  }
128  delete attValues;
129  }
130  }
131  // Trajectory point attributes
132  for (G4int i = 0; i < pTraj->GetPointEntries(); i++) {
133  G4VTrajectoryPoint* aPoint = pTraj->GetPoint(i);
134  std::vector<G4AttValue>* attValues = aPoint->CreateAttValues();
135  if (attValues) {
136  G4AttCheck attCheck(attValues, aPoint->GetAttDefs());
137  G4cout << "\nProvided G4Atts:\n" << attCheck;
138  if (attCheck.Check()) G4cout << "Error" << G4endl;
139  else {
140  std::vector<G4AttValue> standardValues;
141  std::map<G4String,G4AttDef> standardDefinitions;
142  attCheck.Standard(&standardValues, &standardDefinitions);
143  G4cout << "\nStandard G4Atts:\n"
144  << G4AttCheck(&standardValues, &standardDefinitions);
145  }
146  delete attValues;
147  }
148  }
149 }
G4String fType
Definition: G4VModel.hh:108
static G4VVisManager * GetConcreteInstance()
std::vector< G4AttValue > * CreateCurrentAttValues() const
virtual G4VTrajectoryPoint * GetPoint(G4int i) const =0
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:357
int G4int
Definition: G4Types.hh:78
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
G4String fGlobalTag
Definition: G4VModel.hh:109
virtual std::vector< G4AttValue > * CreateAttValues() const
virtual int GetPointEntries() const =0
G4GLOB_DLL std::ostream G4cout
const G4Event * GetEvent() const
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
bool G4bool
Definition: G4Types.hh:79
virtual void EndDraw()=0
const G4ModelingParameters * fpMP
Definition: G4VModel.hh:113
virtual void BeginDraw(const G4Transform3D &objectTransformation=G4Transform3D())=0
G4String fGlobalDescription
Definition: G4VModel.hh:110
virtual void DescribeYourselfTo(G4VGraphicsScene &)
virtual void AddCompound(const G4VTrajectory &)=0
void G4TrajectoriesModelDebugG4AttValues(const G4VTrajectory *)
virtual std::vector< G4AttValue > * CreateAttValues() const
const G4VTrajectory * fpCurrentTrajectory
const std::map< G4String, G4AttDef > * GetAttDefs() const
#define G4endl
Definition: G4ios.hh:61
std::map< G4String, G4AttDef > * GetInstance(const G4String &storeKey, G4bool &isNew)