Enumerations | |
enum | TimesValidity { InvalidTimes, ValidTimes } |
Functions | |
void | GetPoints (const G4VTrajectory &traj, G4Polyline &trajectoryLine, G4Polymarker &auxiliaryPoints, G4Polymarker &stepPoints) |
void | DrawLineAndPoints (const G4VTrajectory &traj, const G4VisTrajContext &, const G4int &i_mode) |
void | DrawLineAndPoints (const G4VTrajectory &traj, const G4VisTrajContext &) |
TimesValidity | GetPointsAndTimes (const G4VTrajectory &traj, const G4VisTrajContext &context, G4Polyline &trajectoryLine, G4Polymarker &auxiliaryPoints, G4Polymarker &stepPoints, std::vector< G4double > &trajectoryLineTimes, std::vector< G4double > &auxiliaryPointTimes, std::vector< G4double > &stepPointTimes) |
void G4TrajectoryDrawerUtils::GetPoints | ( | const G4VTrajectory & | traj, | |
G4Polyline & | trajectoryLine, | |||
G4Polymarker & | auxiliaryPoints, | |||
G4Polymarker & | stepPoints | |||
) |
void G4TrajectoryDrawerUtils::DrawLineAndPoints | ( | const G4VTrajectory & | traj, | |
const G4VisTrajContext & | , | |||
const G4int & | i_mode | |||
) |
Definition at line 313 of file G4TrajectoryDrawerUtils.cc.
References G4Exception(), G4VisTrajContext::GetDrawAuxPts(), G4VisTrajContext::GetDrawLine(), G4VisTrajContext::GetDrawStepPts(), GetPointsAndTimes(), G4VisTrajContext::GetTimeSliceInterval(), JustWarning, G4VisTrajContext::SetAuxPtsSize(), G4VisTrajContext::SetDrawAuxPts(), G4VisTrajContext::SetDrawLine(), G4VisTrajContext::SetDrawStepPts(), G4VisTrajContext::SetStepPtsSize(), and ValidTimes.
Referenced by G4TrajectoryGenericDrawer::Draw(), G4TrajectoryDrawByParticleID::Draw(), G4TrajectoryDrawByOriginVolume::Draw(), G4TrajectoryDrawByCharge::Draw(), and G4TrajectoryDrawByAttribute::Draw().
00314 { 00315 static G4bool warnedAboutIMode = false; 00316 G4ExceptionDescription ed; 00317 ed << "WARNING: DEPRECATED use of i_mode (i_mode: " << i_mode 00318 << "). Feature will be removed at a future major release."; 00319 if (!warnedAboutIMode) { 00320 G4Exception 00321 ("G4TrajectoryDrawerUtils::DrawLineAndPoints(traj, context, i_mode)", 00322 "modeling0125", JustWarning, ed); 00323 warnedAboutIMode = true; 00324 } 00325 00326 // Extra copy while i_mode is still around 00327 G4VisTrajContext myContext(context); 00328 00329 if (i_mode != 0) { 00330 const G4double markerSize = std::abs(i_mode)/1000; 00331 G4bool lineRequired (i_mode >= 0); 00332 G4bool markersRequired (markerSize > 0.); 00333 00334 myContext.SetDrawLine(lineRequired); 00335 myContext.SetDrawAuxPts(markersRequired); 00336 myContext.SetDrawStepPts(markersRequired); 00337 00338 myContext.SetAuxPtsSize(markerSize); 00339 myContext.SetStepPtsSize(markerSize); 00340 } 00341 00342 // Return if don't need to do anything 00343 if (!myContext.GetDrawLine() && !myContext.GetDrawAuxPts() && !myContext.GetDrawStepPts()) return; 00344 00345 // Get points and times (times are returned only if time-slicing 00346 // is requested). 00347 G4Polyline trajectoryLine; 00348 G4Polymarker stepPoints; 00349 G4Polymarker auxiliaryPoints; 00350 std::vector<G4double> trajectoryLineTimes; 00351 std::vector<G4double> stepPointTimes; 00352 std::vector<G4double> auxiliaryPointTimes; 00353 00354 TimesValidity validity = GetPointsAndTimes 00355 (traj, context, 00356 trajectoryLine, auxiliaryPoints, stepPoints, 00357 trajectoryLineTimes, auxiliaryPointTimes, stepPointTimes); 00358 00359 if (validity == ValidTimes) { 00360 00361 SliceLine(context.GetTimeSliceInterval(), 00362 trajectoryLine, trajectoryLineTimes); 00363 00364 DrawWithTime(context, 00365 trajectoryLine, auxiliaryPoints, stepPoints, 00366 trajectoryLineTimes, auxiliaryPointTimes, stepPointTimes); 00367 00368 } else { 00369 00370 DrawWithoutTime(context, trajectoryLine, auxiliaryPoints, stepPoints); 00371 00372 } 00373 }
void G4TrajectoryDrawerUtils::DrawLineAndPoints | ( | const G4VTrajectory & | traj, | |
const G4VisTrajContext & | ||||
) |
Definition at line 375 of file G4TrajectoryDrawerUtils.cc.
References G4VisTrajContext::GetDrawAuxPts(), G4VisTrajContext::GetDrawLine(), G4VisTrajContext::GetDrawStepPts(), GetPointsAndTimes(), G4VisTrajContext::GetTimeSliceInterval(), and ValidTimes.
00376 { 00377 // Return if don't need to do anything 00378 if (!context.GetDrawLine() && !context.GetDrawAuxPts() && !context.GetDrawStepPts()) return; 00379 00380 // Get points and times (times are returned only if time-slicing 00381 // is requested). 00382 G4Polyline trajectoryLine; 00383 G4Polymarker stepPoints; 00384 G4Polymarker auxiliaryPoints; 00385 std::vector<G4double> trajectoryLineTimes; 00386 std::vector<G4double> stepPointTimes; 00387 std::vector<G4double> auxiliaryPointTimes; 00388 00389 TimesValidity validity = GetPointsAndTimes 00390 (traj, context, 00391 trajectoryLine, auxiliaryPoints, stepPoints, 00392 trajectoryLineTimes, auxiliaryPointTimes, stepPointTimes); 00393 00394 if (validity == ValidTimes) { 00395 00396 SliceLine(context.GetTimeSliceInterval(), 00397 trajectoryLine, trajectoryLineTimes); 00398 00399 DrawWithTime(context, 00400 trajectoryLine, auxiliaryPoints, stepPoints, 00401 trajectoryLineTimes, auxiliaryPointTimes, stepPointTimes); 00402 00403 } else { 00404 00405 DrawWithoutTime(context, trajectoryLine, auxiliaryPoints, stepPoints); 00406 00407 } 00408 }
TimesValidity G4TrajectoryDrawerUtils::GetPointsAndTimes | ( | const G4VTrajectory & | traj, | |
const G4VisTrajContext & | context, | |||
G4Polyline & | trajectoryLine, | |||
G4Polymarker & | auxiliaryPoints, | |||
G4Polymarker & | stepPoints, | |||
std::vector< G4double > & | trajectoryLineTimes, | |||
std::vector< G4double > & | auxiliaryPointTimes, | |||
std::vector< G4double > & | stepPointTimes | |||
) |
Definition at line 47 of file G4TrajectoryDrawerUtils.cc.
References G4UIcommand::ConvertToDimensionedDouble(), G4cout, G4endl, G4VTrajectory::GetPoint(), G4VTrajectory::GetPointEntries(), G4VisTrajContext::GetTimeSliceInterval(), InvalidTimes, and ValidTimes.
Referenced by DrawLineAndPoints().
00055 { 00056 TimesValidity validity = InvalidTimes; 00057 if (context.GetTimeSliceInterval()) validity = ValidTimes; 00058 00059 // Memory for last trajectory point position for auxiliary point 00060 // time interpolation algorithm. There are no auxiliary points 00061 // for the first trajectory point, so its initial value is 00062 // immaterial. 00063 G4ThreeVector lastTrajectoryPointPosition; 00064 00065 // Keep positions. Don't store unless first or different. 00066 std::vector<G4ThreeVector> positions; 00067 00068 for (G4int iPoint=0; iPoint<traj.GetPointEntries(); iPoint++) { 00069 00070 G4VTrajectoryPoint* aTrajectoryPoint = traj.GetPoint(iPoint); 00071 const G4ThreeVector& trajectoryPointPosition = 00072 aTrajectoryPoint->GetPosition(); 00073 00074 // Only store if first or if different 00075 if (positions.size() == 0 || 00076 trajectoryPointPosition != positions[positions.size()-1]) { 00077 00078 // Pre- and Post-Point times from the trajectory point... 00079 G4double trajectoryPointPreTime = -std::numeric_limits<double>::max(); 00080 G4double trajectoryPointPostTime = std::numeric_limits<double>::max(); 00081 00082 if (context.GetTimeSliceInterval() && validity == ValidTimes) { 00083 00084 std::vector<G4AttValue>* trajectoryPointAttValues = 00085 aTrajectoryPoint->CreateAttValues(); 00086 if (!trajectoryPointAttValues) { 00087 static G4bool warnedNoAttValues = false; 00088 if (!warnedNoAttValues) { 00089 G4cout << 00090 "*************************************************************************" 00091 "\n* WARNING: G4TrajectoryDrawerUtils::GetPointsAndTimes: no att values." 00092 "\n*************************************************************************" 00093 << G4endl; 00094 warnedNoAttValues = true; 00095 } 00096 validity = InvalidTimes; 00097 } else { 00098 G4bool foundPreTime = false, foundPostTime = false; 00099 for (std::vector<G4AttValue>::iterator i = 00100 trajectoryPointAttValues->begin(); 00101 i != trajectoryPointAttValues->end(); ++i) { 00102 if (i->GetName() == "PreT") { 00103 trajectoryPointPreTime = 00104 G4UIcommand::ConvertToDimensionedDouble(i->GetValue()); 00105 foundPreTime = true; 00106 } 00107 if (i->GetName() == "PostT") { 00108 trajectoryPointPostTime = 00109 G4UIcommand::ConvertToDimensionedDouble(i->GetValue()); 00110 foundPostTime = true; 00111 } 00112 } 00113 if (!foundPreTime || !foundPostTime) { 00114 static G4bool warnedTimesNotFound = false; 00115 if (!warnedTimesNotFound) { 00116 G4cout << 00117 "*************************************************************************" 00118 "\n* WARNING: G4TrajectoryDrawerUtils::GetPointsAndTimes: times not found." 00119 "\n*************************************************************************" 00120 << G4endl; 00121 warnedTimesNotFound = true; 00122 } 00123 validity = InvalidTimes; 00124 } 00125 } 00126 } 00127 00128 const std::vector<G4ThreeVector>* auxiliaries 00129 = aTrajectoryPoint->GetAuxiliaryPoints(); 00130 if (0 != auxiliaries) { 00131 for (size_t iAux=0; iAux<auxiliaries->size(); ++iAux) { 00132 const G4ThreeVector& auxPointPosition = (*auxiliaries)[iAux]; 00133 if (positions.size() == 0 || 00134 auxPointPosition != positions[positions.size()-1]) { 00135 // Only store if first or if different 00136 positions.push_back(trajectoryPointPosition); 00137 trajectoryLine.push_back(auxPointPosition); 00138 auxiliaryPoints.push_back(auxPointPosition); 00139 if (validity == ValidTimes) { 00140 // Interpolate time for auxiliary points... 00141 G4double s1 = 00142 (auxPointPosition - lastTrajectoryPointPosition).mag(); 00143 G4double s2 = 00144 (trajectoryPointPosition - auxPointPosition).mag(); 00145 G4double t = trajectoryPointPreTime + 00146 (trajectoryPointPostTime - trajectoryPointPreTime) * 00147 (s1 / (s1 + s2)); 00148 trajectoryLineTimes.push_back(t); 00149 auxiliaryPointTimes.push_back(t); 00150 } 00151 } 00152 } 00153 } 00154 00155 positions.push_back(trajectoryPointPosition); 00156 trajectoryLine.push_back(trajectoryPointPosition); 00157 stepPoints.push_back(trajectoryPointPosition); 00158 if (validity == ValidTimes) { 00159 trajectoryLineTimes.push_back(trajectoryPointPostTime); 00160 stepPointTimes.push_back(trajectoryPointPostTime); 00161 } 00162 lastTrajectoryPointPosition = trajectoryPointPosition; 00163 } 00164 } 00165 return validity; 00166 }