00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include "G4TrajectoriesModel.hh"
00034
00035 #include "G4ModelingParameters.hh"
00036 #include "G4VGraphicsScene.hh"
00037 #include "G4Event.hh"
00038 #include "G4AttDefStore.hh"
00039 #include "G4AttValue.hh"
00040 #include "G4AttDef.hh"
00041 #include "G4AttCheck.hh"
00042 #include "G4UIcommand.hh"
00043
00044 G4TrajectoriesModel::G4TrajectoriesModel ():
00045 fDrawingModeSet(false),
00046 fDrawingMode(0),
00047 fpCurrentTrajectory(0)
00048 {
00049 fType = "G4TrajectoriesModel";
00050 fGlobalTag = "G4TrajectoriesModel for all trajectories.";
00051 fGlobalDescription = fGlobalTag;
00052 }
00053
00054 G4TrajectoriesModel::G4TrajectoriesModel (G4int drawingMode):
00055 fDrawingModeSet(true),
00056 fDrawingMode(drawingMode),
00057 fpCurrentTrajectory(0) {
00058 fGlobalTag = "G4TrajectoriesModel for all trajectories.";
00059 fGlobalDescription = fGlobalTag;
00060 }
00061
00062 G4TrajectoriesModel::~G4TrajectoriesModel () {}
00063
00064 void G4TrajectoriesModelDebugG4AttValues(const G4VTrajectory*);
00065
00066 #include "G4VVisManager.hh"
00067 void G4TrajectoriesModel::DescribeYourselfTo (G4VGraphicsScene& sceneHandler)
00068 {
00069 const G4Event* event = fpMP->GetEvent();
00070 if (!event) return;
00071
00072 G4TrajectoryContainer* TC = event -> GetTrajectoryContainer ();
00073 if (!TC) return;
00074
00075 G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
00076 if (!pVVisManager) return;
00077
00078 fEventID = event->GetEventID();
00079
00080 pVVisManager->BeginDraw();
00081
00082
00083
00084
00085 for (G4int iT = 0; iT < TC->entries(); iT++) {
00086 fpCurrentTrajectory = (*TC) [iT];
00087
00088
00089
00090
00091 if (fpCurrentTrajectory)
00092 sceneHandler.AddCompound (*fpCurrentTrajectory);
00093 }
00094 pVVisManager->EndDraw();
00095 }
00096
00097 G4bool G4TrajectoriesModel::IsDrawingModeSet() const
00098 {
00099 return fDrawingModeSet;
00100 }
00101
00102 G4int G4TrajectoriesModel::GetDrawingMode() const
00103 {
00104 if (fDrawingModeSet) return fDrawingMode;
00105 else {
00106 G4Exception
00107 ("G4TrajectoriesModel::GetDrawingMode",
00108 "modeling0010",
00109 FatalException,
00110 "Illegal attempt to obtain i_mode."
00111 "\n i_mode is an old trajectories parameter that is DEPRECATED"
00112 "\n and will be removed at the next major release."
00113 );
00114 return 0;
00115 }
00116 }
00117
00118 void G4TrajectoriesModel::SetDrawingMode(G4int drawingMode)
00119 {
00120 if (fDrawingModeSet) fDrawingMode = drawingMode;
00121 else {
00122 G4Exception
00123 ("G4TrajectoriesModel::SetDrawingMode",
00124 "modeling0011",
00125 FatalException,
00126 "Illegal attempt to set i_mode."
00127 "\n i_mode is an old trajectories parameter that is DEPRECATED"
00128 "\n and will be removed at the next major release."
00129 );
00130 }
00131 }
00132
00133 const std::map<G4String,G4AttDef>* G4TrajectoriesModel::GetAttDefs() const
00134 {
00135 G4bool isNew;
00136 std::map<G4String,G4AttDef>* store
00137 = G4AttDefStore::GetInstance("G4TrajectoriesModel", isNew);
00138 if (isNew) {
00139 (*store)["EventID"] =
00140 G4AttDef("EventID","Event ID","Physics","","G4int");
00141 }
00142 return store;
00143 }
00144
00145 std::vector<G4AttValue>* G4TrajectoriesModel::CreateCurrentAttValues() const
00146 {
00147 std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
00148 values->push_back
00149 (G4AttValue("EventID",G4UIcommand::ConvertToString(fEventID),""));
00150 return values;
00151 }
00152
00153
00154
00155 #include "G4VTrajectoryPoint.hh"
00156
00157 void G4TrajectoriesModelDebugG4AttValues(const G4VTrajectory* pTraj)
00158 {
00159
00160 {
00161 std::vector<G4AttValue>* attValues = pTraj->CreateAttValues();
00162 if (attValues) {
00163 G4AttCheck attCheck(attValues, pTraj->GetAttDefs());
00164 G4cout << "\nProvided G4Atts:\n" << attCheck;
00165 if (attCheck.Check()) G4cout << "Error" << G4endl;
00166 else {
00167 std::vector<G4AttValue> standardValues;
00168 std::map<G4String,G4AttDef> standardDefinitions;
00169 attCheck.Standard(&standardValues, &standardDefinitions);
00170 G4cout << "\nStandard G4Atts:\n"
00171 << G4AttCheck(&standardValues, &standardDefinitions);
00172 }
00173 delete attValues;
00174 }
00175 }
00176
00177 for (G4int i = 0; i < pTraj->GetPointEntries(); i++) {
00178 G4VTrajectoryPoint* aPoint = pTraj->GetPoint(i);
00179 std::vector<G4AttValue>* attValues = aPoint->CreateAttValues();
00180 if (attValues) {
00181 G4AttCheck attCheck(attValues, aPoint->GetAttDefs());
00182 G4cout << "\nProvided G4Atts:\n" << attCheck;
00183 if (attCheck.Check()) G4cout << "Error" << G4endl;
00184 else {
00185 std::vector<G4AttValue> standardValues;
00186 std::map<G4String,G4AttDef> standardDefinitions;
00187 attCheck.Standard(&standardValues, &standardDefinitions);
00188 G4cout << "\nStandard G4Atts:\n"
00189 << G4AttCheck(&standardValues, &standardDefinitions);
00190 }
00191 delete attValues;
00192 }
00193 }
00194 }