51 std::vector<G4double>& trajectoryLineTimes,
52 std::vector<G4double>& auxiliaryPointTimes,
53 std::vector<G4double>& stepPointTimes)
65 std::vector<G4ThreeVector> positions;
74 if (positions.size() == 0 ||
75 trajectoryPointPosition != positions[positions.size()-1]) {
78 G4double trajectoryPointPreTime = -std::numeric_limits<double>::max();
79 G4double trajectoryPointPostTime = std::numeric_limits<double>::max();
83 std::vector<G4AttValue>* trajectoryPointAttValues =
85 if (!trajectoryPointAttValues) {
86 static G4bool warnedNoAttValues =
false;
87 if (!warnedNoAttValues) {
89 "*************************************************************************"
90 "\n* WARNING: G4TrajectoryDrawerUtils::GetPointsAndTimes: no att values."
91 "\n*************************************************************************"
93 warnedNoAttValues =
true;
97 G4bool foundPreTime =
false, foundPostTime =
false;
98 for (std::vector<G4AttValue>::iterator i =
99 trajectoryPointAttValues->begin();
100 i != trajectoryPointAttValues->end(); ++i) {
101 if (i->GetName() ==
"PreT") {
102 trajectoryPointPreTime =
106 if (i->GetName() ==
"PostT") {
107 trajectoryPointPostTime =
109 foundPostTime =
true;
112 if (!foundPreTime || !foundPostTime) {
113 static G4bool warnedTimesNotFound =
false;
114 if (!warnedTimesNotFound) {
116 "*************************************************************************"
117 "\n* WARNING: G4TrajectoryDrawerUtils::GetPointsAndTimes: times not found."
118 "\n You need to specify \"/vis/scene/add/trajectories rich\""
119 "\n*************************************************************************"
121 warnedTimesNotFound =
true;
126 delete trajectoryPointAttValues;
129 const std::vector<G4ThreeVector>* auxiliaries
131 if (0 != auxiliaries) {
132 for (
size_t iAux=0; iAux<auxiliaries->size(); ++iAux) {
133 const G4ThreeVector& auxPointPosition = (*auxiliaries)[iAux];
134 if (positions.size() == 0 ||
135 auxPointPosition != positions[positions.size()-1]) {
137 positions.push_back(trajectoryPointPosition);
138 trajectoryLine.push_back(auxPointPosition);
139 auxiliaryPoints.push_back(auxPointPosition);
143 (auxPointPosition - lastTrajectoryPointPosition).mag();
145 (trajectoryPointPosition - auxPointPosition).mag();
146 G4double t = trajectoryPointPreTime +
147 (trajectoryPointPostTime - trajectoryPointPreTime) *
149 trajectoryLineTimes.push_back(t);
150 auxiliaryPointTimes.push_back(t);
156 positions.push_back(trajectoryPointPosition);
157 trajectoryLine.push_back(trajectoryPointPosition);
158 stepPoints.push_back(trajectoryPointPosition);
160 trajectoryLineTimes.push_back(trajectoryPointPostTime);
161 stepPointTimes.push_back(trajectoryPointPostTime);
163 lastTrajectoryPointPosition = trajectoryPointPosition;
169 static void SliceLine(
G4double timeIncrement,
171 std::vector<G4double>& trajectoryLineTimes)
176 std::vector<G4double> newTrajectoryLineTimes;
178 newTrajectoryLine.push_back(trajectoryLine[0]);
179 newTrajectoryLineTimes.push_back(trajectoryLineTimes[0]);
180 size_t lineSize = trajectoryLine.size();
182 for (
size_t i = 1; i < trajectoryLine.size(); ++i) {
183 G4double deltaT = trajectoryLineTimes[i] - trajectoryLineTimes[i - 1];
186 std::max(timeIncrement, deltaT / 100.);
188 (
int(trajectoryLineTimes[i - 1]/practicalTimeIncrement) + 1) *
189 practicalTimeIncrement;
190 t <= trajectoryLineTimes[i];
191 t += practicalTimeIncrement) {
193 (trajectoryLine[i] - trajectoryLine[i - 1]) *
194 ((t - trajectoryLineTimes[i - 1]) / deltaT);
195 newTrajectoryLine.push_back(pos);
196 newTrajectoryLineTimes.push_back(t);
199 newTrajectoryLine.push_back(trajectoryLine[i]);
200 newTrajectoryLineTimes.push_back(trajectoryLineTimes[i]);
204 trajectoryLine = newTrajectoryLine;
205 trajectoryLineTimes = newTrajectoryLineTimes;
216 if (0 == pVVisManager)
return;
220 trajectoryLineAttribs.SetLineWidth(myContext.
GetLineWidth());
223 pVVisManager->
Draw(trajectoryLine);
227 && (auxiliaryPoints.size() > 0)) {
235 pVVisManager->
Draw(auxiliaryPoints);
239 && (stepPoints.size() > 0)) {
247 pVVisManager->
Draw(stepPoints);
255 std::vector<G4double>& trajectoryLineTimes,
256 std::vector<G4double>& auxiliaryPointTimes,
257 std::vector<G4double>& stepPointTimes)
262 if (0 == pVVisManager)
return;
266 trajectoryLineAttribs.SetLineWidth(myContext.
GetLineWidth());
268 for (
size_t i = 1; i < trajectoryLine.size(); ++i ) {
270 slice.push_back(trajectoryLine[i -1]);
271 slice.push_back(trajectoryLine[i]);
272 trajectoryLineAttribs.SetStartTime(trajectoryLineTimes[i - 1]);
273 trajectoryLineAttribs.SetEndTime(trajectoryLineTimes[i]);
275 pVVisManager->
Draw(slice);
280 && (auxiliaryPoints.size() > 0)) {
283 for (
size_t i = 0; i < auxiliaryPoints.size(); ++i ) {
285 point.push_back(auxiliaryPoints[i]);
289 auxiliaryPointsAttribs.SetStartTime(auxiliaryPointTimes[i]);
290 auxiliaryPointsAttribs.SetEndTime(auxiliaryPointTimes[i]);
292 pVVisManager->
Draw(point);
297 && (stepPoints.size() > 0)) {
300 for (
size_t i = 0; i < stepPoints.size(); ++i ) {
302 point.push_back(stepPoints[i]);
306 stepPointsAttribs.SetStartTime(stepPointTimes[i]);
307 stepPointsAttribs.SetEndTime(stepPointTimes[i]);
309 pVVisManager->
Draw(point);
324 std::vector<G4double> trajectoryLineTimes;
325 std::vector<G4double> stepPointTimes;
326 std::vector<G4double> auxiliaryPointTimes;
330 trajectoryLine, auxiliaryPoints, stepPoints,
331 trajectoryLineTimes, auxiliaryPointTimes, stepPointTimes);
336 trajectoryLine, trajectoryLineTimes);
338 DrawWithTime(context,
339 trajectoryLine, auxiliaryPoints, stepPoints,
340 trajectoryLineTimes, auxiliaryPointTimes, stepPointTimes);
344 DrawWithoutTime(context, trajectoryLine, auxiliaryPoints, stepPoints);
G4GLOB_DLL 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 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 &)