52 std::vector<G4double>& trajectoryLineTimes,
53 std::vector<G4double>& auxiliaryPointTimes,
54 std::vector<G4double>& stepPointTimes)
66 std::vector<G4ThreeVector> positions;
75 if (positions.size() == 0 ||
76 trajectoryPointPosition != positions[positions.size()-1]) {
79 G4double trajectoryPointPreTime = -std::numeric_limits<double>::max();
80 G4double trajectoryPointPostTime = std::numeric_limits<double>::max();
84 std::vector<G4AttValue>* trajectoryPointAttValues =
86 if (!trajectoryPointAttValues) {
87 static G4bool warnedNoAttValues =
false;
88 if (!warnedNoAttValues) {
90 "*************************************************************************"
91 "\n* WARNING: G4TrajectoryDrawerUtils::GetPointsAndTimes: no att values."
92 "\n*************************************************************************"
94 warnedNoAttValues =
true;
98 G4bool foundPreTime =
false, foundPostTime =
false;
99 for (std::vector<G4AttValue>::iterator i =
100 trajectoryPointAttValues->begin();
101 i != trajectoryPointAttValues->end(); ++i) {
102 if (i->GetName() ==
"PreT") {
103 trajectoryPointPreTime =
107 if (i->GetName() ==
"PostT") {
108 trajectoryPointPostTime =
110 foundPostTime =
true;
113 if (!foundPreTime || !foundPostTime) {
114 static G4bool warnedTimesNotFound =
false;
115 if (!warnedTimesNotFound) {
117 "*************************************************************************"
118 "\n* WARNING: G4TrajectoryDrawerUtils::GetPointsAndTimes: times not found."
119 "\n*************************************************************************"
121 warnedTimesNotFound =
true;
128 const std::vector<G4ThreeVector>* auxiliaries
130 if (0 != auxiliaries) {
131 for (
size_t iAux=0; iAux<auxiliaries->size(); ++iAux) {
132 const G4ThreeVector& auxPointPosition = (*auxiliaries)[iAux];
133 if (positions.size() == 0 ||
134 auxPointPosition != positions[positions.size()-1]) {
136 positions.push_back(trajectoryPointPosition);
137 trajectoryLine.push_back(auxPointPosition);
138 auxiliaryPoints.push_back(auxPointPosition);
142 (auxPointPosition - lastTrajectoryPointPosition).mag();
144 (trajectoryPointPosition - auxPointPosition).mag();
145 G4double t = trajectoryPointPreTime +
146 (trajectoryPointPostTime - trajectoryPointPreTime) *
148 trajectoryLineTimes.push_back(t);
149 auxiliaryPointTimes.push_back(t);
155 positions.push_back(trajectoryPointPosition);
156 trajectoryLine.push_back(trajectoryPointPosition);
157 stepPoints.push_back(trajectoryPointPosition);
159 trajectoryLineTimes.push_back(trajectoryPointPostTime);
160 stepPointTimes.push_back(trajectoryPointPostTime);
162 lastTrajectoryPointPosition = trajectoryPointPosition;
168 static void SliceLine(
G4double timeIncrement,
170 std::vector<G4double>& trajectoryLineTimes)
175 std::vector<G4double> newTrajectoryLineTimes;
177 newTrajectoryLine.push_back(trajectoryLine[0]);
178 newTrajectoryLineTimes.push_back(trajectoryLineTimes[0]);
179 size_t lineSize = trajectoryLine.size();
181 for (
size_t i = 1; i < trajectoryLine.size(); ++i) {
182 G4double deltaT = trajectoryLineTimes[i] - trajectoryLineTimes[i - 1];
185 std::max(timeIncrement, deltaT / 100.);
187 (
int(trajectoryLineTimes[i - 1]/practicalTimeIncrement) + 1) *
188 practicalTimeIncrement;
189 t <= trajectoryLineTimes[i];
190 t += practicalTimeIncrement) {
192 (trajectoryLine[i] - trajectoryLine[i - 1]) *
193 ((t - trajectoryLineTimes[i - 1]) / deltaT);
194 newTrajectoryLine.push_back(pos);
195 newTrajectoryLineTimes.push_back(t);
198 newTrajectoryLine.push_back(trajectoryLine[i]);
199 newTrajectoryLineTimes.push_back(trajectoryLineTimes[i]);
203 trajectoryLine = newTrajectoryLine;
204 trajectoryLineTimes = newTrajectoryLineTimes;
215 if (0 == pVVisManager)
return;
222 pVVisManager->
Draw(trajectoryLine);
225 if (myContext.
GetDrawAuxPts() && (auxiliaryPoints.size() > 0)) {
234 pVVisManager->
Draw(auxiliaryPoints);
246 pVVisManager->
Draw(stepPoints);
254 std::vector<G4double>& trajectoryLineTimes,
255 std::vector<G4double>& auxiliaryPointTimes,
256 std::vector<G4double>& stepPointTimes)
261 if (0 == pVVisManager)
return;
267 for (
size_t i = 1; i < trajectoryLine.size(); ++i ) {
269 slice.push_back(trajectoryLine[i -1]);
270 slice.push_back(trajectoryLine[i]);
271 trajectoryLineAttribs.SetStartTime(trajectoryLineTimes[i - 1]);
272 trajectoryLineAttribs.SetEndTime(trajectoryLineTimes[i]);
274 pVVisManager->
Draw(slice);
278 if (myContext.
GetDrawAuxPts() && (auxiliaryPoints.size() > 0)) {
282 for (
size_t i = 0; i < auxiliaryPoints.size(); ++i ) {
284 point.push_back(auxiliaryPoints[i]);
288 auxiliaryPointsAttribs.SetStartTime(auxiliaryPointTimes[i]);
289 auxiliaryPointsAttribs.SetEndTime(auxiliaryPointTimes[i]);
291 pVVisManager->
Draw(point);
299 for (
size_t i = 0; i < stepPoints.size(); ++i ) {
301 point.push_back(stepPoints[i]);
305 stepPointsAttribs.SetStartTime(stepPointTimes[i]);
306 stepPointsAttribs.SetEndTime(stepPointTimes[i]);
308 pVVisManager->
Draw(point);
315 static G4bool warnedAboutIMode =
false;
317 ed <<
"WARNING: DEPRECATED use of i_mode (i_mode: " << i_mode
318 <<
"). Feature will be removed at a future major release.";
319 if (!warnedAboutIMode) {
321 (
"G4TrajectoryDrawerUtils::DrawLineAndPoints(traj, context, i_mode)",
323 warnedAboutIMode =
true;
330 const G4double markerSize = std::abs(i_mode)/1000;
331 G4bool lineRequired (i_mode >= 0);
332 G4bool markersRequired (markerSize > 0.);
350 std::vector<G4double> trajectoryLineTimes;
351 std::vector<G4double> stepPointTimes;
352 std::vector<G4double> auxiliaryPointTimes;
356 trajectoryLine, auxiliaryPoints, stepPoints,
357 trajectoryLineTimes, auxiliaryPointTimes, stepPointTimes);
362 trajectoryLine, trajectoryLineTimes);
364 DrawWithTime(context,
365 trajectoryLine, auxiliaryPoints, stepPoints,
366 trajectoryLineTimes, auxiliaryPointTimes, stepPointTimes);
370 DrawWithoutTime(context, trajectoryLine, auxiliaryPoints, stepPoints);
385 std::vector<G4double> trajectoryLineTimes;
386 std::vector<G4double> stepPointTimes;
387 std::vector<G4double> auxiliaryPointTimes;
391 trajectoryLine, auxiliaryPoints, stepPoints,
392 trajectoryLineTimes, auxiliaryPointTimes, stepPointTimes);
397 trajectoryLine, trajectoryLineTimes);
399 DrawWithTime(context,
400 trajectoryLine, auxiliaryPoints, stepPoints,
401 trajectoryLineTimes, auxiliaryPointTimes, stepPointTimes);
405 DrawWithoutTime(context, trajectoryLine, auxiliaryPoints, stepPoints);
G4DLLIMPORT std::ostream G4cout
void SetMarkerType(MarkerType)
static G4double ConvertToDimensionedDouble(const char *st)
void SetSize(SizeType, G4double)
void SetFillStyle(FillStyle)
virtual std::vector< G4AttValue > * CreateAttValues() const
virtual const std::vector< G4ThreeVector > * GetAuxiliaryPoints() const
virtual const G4ThreeVector GetPosition() const =0
virtual G4VTrajectoryPoint * GetPoint(G4int i) const =0
virtual int GetPointEntries() const =0
static G4VVisManager * GetConcreteInstance()
virtual void Draw(const G4Circle &, const G4Transform3D &objectTransformation=G4Transform3D())=0
void SetStepPtsSize(const G4double &size)
G4bool GetDrawAuxPts() const
G4Colour GetStepPtsColour() const
G4double GetStepPtsSize() const
G4bool GetLineVisible() const
void SetDrawAuxPts(const G4bool &draw)
G4double GetTimeSliceInterval() const
void SetDrawLine(const G4bool &draw)
G4bool GetDrawLine() const
G4VMarker::SizeType GetStepPtsSizeType() const
G4Polymarker::MarkerType GetAuxPtsType() const
void SetDrawStepPts(const G4bool &draw)
G4double GetAuxPtsSize() const
G4VMarker::SizeType GetAuxPtsSizeType() const
G4Colour GetAuxPtsColour() const
G4VMarker::FillStyle GetStepPtsFillStyle() const
void SetAuxPtsSize(const G4double &size)
G4VMarker::FillStyle GetAuxPtsFillStyle() const
G4bool GetAuxPtsVisible() const
G4bool GetStepPtsVisible() const
G4Colour GetLineColour() const
G4Polymarker::MarkerType GetStepPtsType() const
G4bool GetDrawStepPts() const
void SetVisAttributes(const G4VisAttributes *)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
std::ostringstream G4ExceptionDescription
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 DrawLineAndPoints(const G4VTrajectory &traj, const G4VisTrajContext &, const G4int &i_mode)