Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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$
28//
29//
30// John Allison 26th August 1998.
31// Model which knows how to draw GEANT4 trajectories.
32
34
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 fDrawingModeSet(false),
46 fDrawingMode(0),
47 fpCurrentTrajectory(0)
48{
49 fType = "G4TrajectoriesModel";
50 fGlobalTag = "G4TrajectoriesModel for all trajectories.";
52}
53
55 fDrawingModeSet(true),
56 fDrawingMode(drawingMode),
57 fpCurrentTrajectory(0) {
58 fGlobalTag = "G4TrajectoriesModel for all trajectories.";
60}
61
63
65
66#include "G4VVisManager.hh"
68{
69 const G4Event* event = fpMP->GetEvent();
70 if (!event) return;
71
72 G4TrajectoryContainer* TC = event -> GetTrajectoryContainer ();
73 if (!TC) return;
74
76 if (!pVVisManager) return;
77
78 fEventID = event->GetEventID();
79
80 pVVisManager->BeginDraw();
81 // The use of Begin/EndDraw (optional methods to improve drawing
82 // speed) assumes all trajectories are drawn with the same
83 // transformation. If not, a fatal exception with be raised in
84 // G4VisManager::DrawT.
85 for (G4int iT = 0; iT < TC->entries(); iT++) {
86 fpCurrentTrajectory = (*TC) [iT];
87 // Debug trajectory:
88 // fpCurrentTrajectory->ShowTrajectory(); G4cout << G4endl;
89 // Debug G4AttValues:
90 // G4TrajectoriesModelDebugG4AttValues(fpCurrentTrajectory);
91 if (fpCurrentTrajectory)
92 sceneHandler.AddCompound (*fpCurrentTrajectory);
93 }
94 pVVisManager->EndDraw();
95}
96
98{
99 return fDrawingModeSet;
100}
101
103{
104 if (fDrawingModeSet) return fDrawingMode;
105 else {
107 ("G4TrajectoriesModel::GetDrawingMode",
108 "modeling0010",
110 "Illegal attempt to obtain i_mode."
111 "\n i_mode is an old trajectories parameter that is DEPRECATED"
112 "\n and will be removed at the next major release."
113 );
114 return 0;
115 }
116}
117
119{
120 if (fDrawingModeSet) fDrawingMode = drawingMode;
121 else {
123 ("G4TrajectoriesModel::SetDrawingMode",
124 "modeling0011",
126 "Illegal attempt to set i_mode."
127 "\n i_mode is an old trajectories parameter that is DEPRECATED"
128 "\n and will be removed at the next major release."
129 );
130 }
131}
132
133const std::map<G4String,G4AttDef>* G4TrajectoriesModel::GetAttDefs() const
134{
135 G4bool isNew;
136 std::map<G4String,G4AttDef>* store
137 = G4AttDefStore::GetInstance("G4TrajectoriesModel", isNew);
138 if (isNew) {
139 (*store)["EventID"] =
140 G4AttDef("EventID","Event ID","Physics","","G4int");
141 }
142 return store;
143}
144
145std::vector<G4AttValue>* G4TrajectoriesModel::CreateCurrentAttValues() const
146{
147 std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
148 values->push_back
149 (G4AttValue("EventID",G4UIcommand::ConvertToString(fEventID),""));
150 return values;
151}
152
153// Debug material...
154
155#include "G4VTrajectoryPoint.hh"
156
158{
159 // Trajectory attributes
160 { // Scope bracket - allows re-use of names without compiler warnings.
161 std::vector<G4AttValue>* attValues = pTraj->CreateAttValues();
162 if (attValues) {
163 G4AttCheck attCheck(attValues, pTraj->GetAttDefs());
164 G4cout << "\nProvided G4Atts:\n" << attCheck;
165 if (attCheck.Check()) G4cout << "Error" << G4endl;
166 else {
167 std::vector<G4AttValue> standardValues;
168 std::map<G4String,G4AttDef> standardDefinitions;
169 attCheck.Standard(&standardValues, &standardDefinitions);
170 G4cout << "\nStandard G4Atts:\n"
171 << G4AttCheck(&standardValues, &standardDefinitions);
172 }
173 delete attValues;
174 }
175 }
176 // Trajectory point attributes
177 for (G4int i = 0; i < pTraj->GetPointEntries(); i++) {
178 G4VTrajectoryPoint* aPoint = pTraj->GetPoint(i);
179 std::vector<G4AttValue>* attValues = aPoint->CreateAttValues();
180 if (attValues) {
181 G4AttCheck attCheck(attValues, aPoint->GetAttDefs());
182 G4cout << "\nProvided G4Atts:\n" << attCheck;
183 if (attCheck.Check()) G4cout << "Error" << G4endl;
184 else {
185 std::vector<G4AttValue> standardValues;
186 std::map<G4String,G4AttDef> standardDefinitions;
187 attCheck.Standard(&standardValues, &standardDefinitions);
188 G4cout << "\nStandard G4Atts:\n"
189 << G4AttCheck(&standardValues, &standardDefinitions);
190 }
191 delete attValues;
192 }
193 }
194}
@ FatalException
void G4TrajectoriesModelDebugG4AttValues(const G4VTrajectory *)
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
G4bool Check(const G4String &leader="") const
Definition: G4AttCheck.cc:110
G4bool Standard(std::vector< G4AttValue > *standardValues, std::map< G4String, G4AttDef > *standardDefinitions) const
Definition: G4AttCheck.cc:336
const G4Event * GetEvent() const
virtual void DescribeYourselfTo(G4VGraphicsScene &)
G4bool IsDrawingModeSet() const
std::vector< G4AttValue > * CreateCurrentAttValues() const
void SetDrawingMode(G4int drawingMode)
const std::map< G4String, G4AttDef > * GetAttDefs() const
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:349
virtual void AddCompound(const G4VTrajectory &)=0
G4String fGlobalDescription
Definition: G4VModel.hh:110
G4String fType
Definition: G4VModel.hh:108
const G4ModelingParameters * fpMP
Definition: G4VModel.hh:113
G4String fGlobalTag
Definition: G4VModel.hh:109
virtual std::vector< G4AttValue > * CreateAttValues() const
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
virtual G4VTrajectoryPoint * GetPoint(G4int i) const =0
virtual int GetPointEntries() const =0
virtual std::vector< G4AttValue > * CreateAttValues() const
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
virtual void EndDraw()=0
static G4VVisManager * GetConcreteInstance()
virtual void BeginDraw(const G4Transform3D &objectTransformation=G4Transform3D())=0
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
std::map< G4String, G4AttDef > * GetInstance(G4String storeKey, G4bool &isNew)