53 std::vector<G4double>& trajectoryLineTimes,
54 std::vector<G4double>& auxiliaryPointTimes,
55 std::vector<G4double>& stepPointTimes)
67 std::vector<G4ThreeVector> positions;
76 if (positions.size() == 0 ||
77 trajectoryPointPosition != positions[positions.size()-1]) {
80 G4double trajectoryPointPreTime = -std::numeric_limits<double>::max();
81 G4double trajectoryPointPostTime = std::numeric_limits<double>::max();
85 std::vector<G4AttValue>* trajectoryPointAttValues =
87 if (!trajectoryPointAttValues) {
88 static G4bool warnedNoAttValues =
false;
89 if (!warnedNoAttValues) {
91 "*************************************************************************"
92 "\n* WARNING: G4TrajectoryDrawerUtils::GetPointsAndTimes: no att values."
93 "\n*************************************************************************"
95 warnedNoAttValues =
true;
99 G4bool foundPreTime =
false, foundPostTime =
false;
100 for (std::vector<G4AttValue>::iterator i =
101 trajectoryPointAttValues->begin();
102 i != trajectoryPointAttValues->end(); ++i) {
103 if (i->GetName() ==
"PreT") {
104 trajectoryPointPreTime =
108 if (i->GetName() ==
"PostT") {
109 trajectoryPointPostTime =
111 foundPostTime =
true;
114 if (!foundPreTime || !foundPostTime) {
115 static G4bool warnedTimesNotFound =
false;
116 if (!warnedTimesNotFound) {
118 "*************************************************************************"
119 "\n* WARNING: G4TrajectoryDrawerUtils::GetPointsAndTimes: times not found."
120 "\n You need to specify \"/vis/scene/add/trajectories rich\""
121 "\n*************************************************************************"
123 warnedTimesNotFound =
true;
128 delete trajectoryPointAttValues;
131 const std::vector<G4ThreeVector>* auxiliaries
133 if (0 != auxiliaries) {
134 for (
size_t iAux=0; iAux<auxiliaries->size(); ++iAux) {
135 const G4ThreeVector& auxPointPosition = (*auxiliaries)[iAux];
136 if (positions.size() == 0 ||
137 auxPointPosition != positions[positions.size()-1]) {
139 positions.push_back(trajectoryPointPosition);
140 trajectoryLine.push_back(auxPointPosition);
141 auxiliaryPoints.push_back(auxPointPosition);
145 (auxPointPosition - lastTrajectoryPointPosition).mag();
147 (trajectoryPointPosition - auxPointPosition).mag();
148 G4double t = trajectoryPointPreTime +
149 (trajectoryPointPostTime - trajectoryPointPreTime) *
151 trajectoryLineTimes.push_back(t);
152 auxiliaryPointTimes.push_back(t);
158 positions.push_back(trajectoryPointPosition);
159 trajectoryLine.push_back(trajectoryPointPosition);
160 stepPoints.push_back(trajectoryPointPosition);
162 trajectoryLineTimes.push_back(trajectoryPointPostTime);
163 stepPointTimes.push_back(trajectoryPointPostTime);
165 lastTrajectoryPointPosition = trajectoryPointPosition;
171 static void SliceLine(
G4double timeIncrement,
173 std::vector<G4double>& trajectoryLineTimes)
178 std::vector<G4double> newTrajectoryLineTimes;
180 newTrajectoryLine.push_back(trajectoryLine[0]);
181 newTrajectoryLineTimes.push_back(trajectoryLineTimes[0]);
182 size_t lineSize = trajectoryLine.size();
184 for (
size_t i = 1; i < trajectoryLine.size(); ++i) {
185 G4double deltaT = trajectoryLineTimes[i] - trajectoryLineTimes[i - 1];
188 std::max(timeIncrement, deltaT / 100.);
190 (
int(trajectoryLineTimes[i - 1]/practicalTimeIncrement) + 1) *
191 practicalTimeIncrement;
192 t <= trajectoryLineTimes[i];
193 t += practicalTimeIncrement) {
195 (trajectoryLine[i] - trajectoryLine[i - 1]) *
196 ((t - trajectoryLineTimes[i - 1]) / deltaT);
197 newTrajectoryLine.push_back(pos);
198 newTrajectoryLineTimes.push_back(t);
201 newTrajectoryLine.push_back(trajectoryLine[i]);
202 newTrajectoryLineTimes.push_back(trajectoryLineTimes[i]);
206 trajectoryLine = newTrajectoryLine;
207 trajectoryLineTimes = newTrajectoryLineTimes;
218 if (0 == pVVisManager)
return;
222 trajectoryLineAttribs.SetLineWidth(myContext.
GetLineWidth());
225 pVVisManager->
Draw(trajectoryLine);
229 && (auxiliaryPoints.size() > 0)) {
237 pVVisManager->
Draw(auxiliaryPoints);
241 && (stepPoints.size() > 0)) {
249 pVVisManager->
Draw(stepPoints);
257 std::vector<G4double>& trajectoryLineTimes,
258 std::vector<G4double>& auxiliaryPointTimes,
259 std::vector<G4double>& stepPointTimes)
264 if (0 == pVVisManager)
return;
268 trajectoryLineAttribs.SetLineWidth(myContext.
GetLineWidth());
270 for (
size_t i = 1; i < trajectoryLine.size(); ++i ) {
272 slice.push_back(trajectoryLine[i -1]);
273 slice.push_back(trajectoryLine[i]);
274 trajectoryLineAttribs.SetStartTime(trajectoryLineTimes[i - 1]);
275 trajectoryLineAttribs.SetEndTime(trajectoryLineTimes[i]);
277 pVVisManager->
Draw(slice);
282 && (auxiliaryPoints.size() > 0)) {
285 for (
size_t i = 0; i < auxiliaryPoints.size(); ++i ) {
287 point.push_back(auxiliaryPoints[i]);
291 auxiliaryPointsAttribs.SetStartTime(auxiliaryPointTimes[i]);
292 auxiliaryPointsAttribs.SetEndTime(auxiliaryPointTimes[i]);
294 pVVisManager->
Draw(point);
299 && (stepPoints.size() > 0)) {
302 for (
size_t i = 0; i < stepPoints.size(); ++i ) {
304 point.push_back(stepPoints[i]);
308 stepPointsAttribs.SetStartTime(stepPointTimes[i]);
309 stepPointsAttribs.SetEndTime(stepPointTimes[i]);
311 pVVisManager->
Draw(point);
326 std::vector<G4double> trajectoryLineTimes;
327 std::vector<G4double> stepPointTimes;
328 std::vector<G4double> auxiliaryPointTimes;
332 trajectoryLine, auxiliaryPoints, stepPoints,
333 trajectoryLineTimes, auxiliaryPointTimes, stepPointTimes);
338 trajectoryLine, trajectoryLineTimes);
340 DrawWithTime(context,
341 trajectoryLine, auxiliaryPoints, stepPoints,
342 trajectoryLineTimes, auxiliaryPointTimes, stepPointTimes);
346 DrawWithoutTime(context, trajectoryLine, auxiliaryPoints, stepPoints);
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 G4int GetPointEntries() const =0
static G4VVisManager * GetConcreteInstance()
virtual void Draw(const G4Circle &, const G4Transform3D &objectTransformation=G4Transform3D())=0
G4bool GetDrawAuxPts() const
G4Colour GetStepPtsColour() const
G4double GetLineWidth() const
G4double GetStepPtsSize() const
G4bool GetLineVisible() const
G4double GetTimeSliceInterval() const
G4bool GetDrawLine() const
G4VMarker::SizeType GetStepPtsSizeType() const
G4Polymarker::MarkerType GetAuxPtsType() const
G4double GetAuxPtsSize() const
G4VMarker::SizeType GetAuxPtsSizeType() const
G4Colour GetAuxPtsColour() const
G4VMarker::FillStyle GetStepPtsFillStyle() const
G4VMarker::FillStyle GetAuxPtsFillStyle() const
G4bool GetAuxPtsVisible() const
G4bool GetStepPtsVisible() const
G4Colour GetLineColour() const
G4Polymarker::MarkerType GetStepPtsType() const
G4bool GetDrawStepPts() const
void SetVisAttributes(const G4VisAttributes *)
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 &)