Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/visualization/modeling/src/G4TrajectoryDrawerUtils.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /visualization/modeling/src/G4TrajectoryDrawerUtils.cc (Version 11.3.0) and /visualization/modeling/src/G4TrajectoryDrawerUtils.cc (Version 9.5.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
                                                   >>  26 // $Id: G4TrajectoryDrawerUtils.cc,v 1.16 2010-12-11 16:40:16 allison Exp $
                                                   >>  27 // GEANT4 tag $Name: not supported by cvs2svn $
 26 //                                                 28 //
 27 // Jane Tinslay, John Allison, Joseph Perl Nov     29 // Jane Tinslay, John Allison, Joseph Perl November 2005
 28 //                                                 30 //
 29 #include "G4TrajectoryDrawerUtils.hh"              31 #include "G4TrajectoryDrawerUtils.hh"
 30 #include "G4Colour.hh"                             32 #include "G4Colour.hh"
 31 #include "G4Polyline.hh"                           33 #include "G4Polyline.hh"
 32 #include "G4Polymarker.hh"                         34 #include "G4Polymarker.hh"
 33 #include "G4VTrajectory.hh"                        35 #include "G4VTrajectory.hh"
 34 #include "G4VTrajectoryPoint.hh"                   36 #include "G4VTrajectoryPoint.hh"
 35 #include "G4VisAttributes.hh"                      37 #include "G4VisAttributes.hh"
 36 #include "G4VisTrajContext.hh"                     38 #include "G4VisTrajContext.hh"
 37 #include "G4VVisManager.hh"                        39 #include "G4VVisManager.hh"
 38 #include "G4UIcommand.hh"                          40 #include "G4UIcommand.hh"
 39 #include "G4AttValue.hh"                           41 #include "G4AttValue.hh"
 40                                                    42 
 41 #include <utility>                             << 
 42                                                << 
 43 #define G4warn G4cout                          << 
 44                                                << 
 45 namespace G4TrajectoryDrawerUtils {                43 namespace G4TrajectoryDrawerUtils {
 46                                                    44 
 47   enum TimesValidity {InvalidTimes, ValidTimes     45   enum TimesValidity {InvalidTimes, ValidTimes};
 48                                                    46 
 49   TimesValidity GetPointsAndTimes                  47   TimesValidity GetPointsAndTimes
 50   (const G4VTrajectory& traj,                      48   (const G4VTrajectory& traj,
 51    const G4VisTrajContext& context,                49    const G4VisTrajContext& context,
 52    G4Polyline& trajectoryLine,                     50    G4Polyline& trajectoryLine,
 53    G4Polymarker& auxiliaryPoints,                  51    G4Polymarker& auxiliaryPoints,
 54    G4Polymarker& stepPoints,                       52    G4Polymarker& stepPoints,
 55    std::vector<G4double>& trajectoryLineTimes,     53    std::vector<G4double>& trajectoryLineTimes,
 56    std::vector<G4double>& auxiliaryPointTimes,     54    std::vector<G4double>& auxiliaryPointTimes,
 57    std::vector<G4double>& stepPointTimes)          55    std::vector<G4double>& stepPointTimes)
 58   {                                                56   {
 59     TimesValidity validity = InvalidTimes;         57     TimesValidity validity = InvalidTimes;
 60     if (context.GetTimeSliceInterval()) validi     58     if (context.GetTimeSliceInterval()) validity = ValidTimes;
 61                                                    59 
 62     // Memory for last trajectory point positi     60     // Memory for last trajectory point position for auxiliary point
 63     // time interpolation algorithm.  There ar     61     // time interpolation algorithm.  There are no auxiliary points
 64     // for the first trajectory point, so its      62     // for the first trajectory point, so its initial value is
 65     // immaterial.                                 63     // immaterial.
 66     G4ThreeVector lastTrajectoryPointPosition;     64     G4ThreeVector lastTrajectoryPointPosition;
 67                                                    65 
 68     // Keep positions.  Don't store unless fir     66     // Keep positions.  Don't store unless first or different.
 69     std::vector<G4ThreeVector> positions;          67     std::vector<G4ThreeVector> positions;
 70                                                    68 
 71     for (G4int iPoint=0; iPoint<traj.GetPointE <<  69     for (G4int i=0; i<traj.GetPointEntries(); i++) {
 72                                                    70 
 73       G4VTrajectoryPoint* aTrajectoryPoint = t <<  71       G4VTrajectoryPoint* aTrajectoryPoint = traj.GetPoint(i);
 74       const G4ThreeVector& trajectoryPointPosi     72       const G4ThreeVector& trajectoryPointPosition =
 75   aTrajectoryPoint->GetPosition();                 73   aTrajectoryPoint->GetPosition();
 76                                                    74 
 77       // Only store if first or if different       75       // Only store if first or if different
 78       if (positions.size() == 0 ||                 76       if (positions.size() == 0 ||
 79     trajectoryPointPosition != positions[posit     77     trajectoryPointPosition != positions[positions.size()-1]) {
 80                                                    78 
 81   // Pre- and Post-Point times from the trajec     79   // Pre- and Post-Point times from the trajectory point...
 82   G4double trajectoryPointPreTime = -std::nume     80   G4double trajectoryPointPreTime = -std::numeric_limits<double>::max();
 83   G4double trajectoryPointPostTime = std::nume     81   G4double trajectoryPointPostTime = std::numeric_limits<double>::max();
 84                                                    82 
 85   if (context.GetTimeSliceInterval() && validi     83   if (context.GetTimeSliceInterval() && validity == ValidTimes) {
 86                                                    84 
 87     std::vector<G4AttValue>* trajectoryPointAt     85     std::vector<G4AttValue>* trajectoryPointAttValues =
 88       aTrajectoryPoint->CreateAttValues();         86       aTrajectoryPoint->CreateAttValues();
 89     if (!trajectoryPointAttValues) {               87     if (!trajectoryPointAttValues) {
 90       static G4bool warnedNoAttValues = false;     88       static G4bool warnedNoAttValues = false;
 91       if (!warnedNoAttValues) {                    89       if (!warnedNoAttValues) {
 92         G4warn <<                              <<  90         G4cout <<
 93   "*******************************************     91   "*************************************************************************"
 94   "\n*  WARNING: G4TrajectoryDrawerUtils::GetP     92   "\n*  WARNING: G4TrajectoryDrawerUtils::GetPointsAndTimes: no att values."
 95   "\n*****************************************     93   "\n*************************************************************************"
 96          << G4endl;                                94          << G4endl;
 97         warnedNoAttValues = true;                  95         warnedNoAttValues = true;
 98       }                                            96       }
 99       validity = InvalidTimes;                     97       validity = InvalidTimes;
100     } else {                                       98     } else {
101       G4bool foundPreTime = false, foundPostTi     99       G4bool foundPreTime = false, foundPostTime = false;
102       for (std::vector<G4AttValue>::iterator i    100       for (std::vector<G4AttValue>::iterator i =
103        trajectoryPointAttValues->begin();         101        trajectoryPointAttValues->begin();
104      i != trajectoryPointAttValues->end(); ++i    102      i != trajectoryPointAttValues->end(); ++i) {
105         if (i->GetName() == "PreT") {             103         if (i->GetName() == "PreT") {
106     trajectoryPointPreTime =                      104     trajectoryPointPreTime =
107       G4UIcommand::ConvertToDimensionedDouble(    105       G4UIcommand::ConvertToDimensionedDouble(i->GetValue());
108     foundPreTime = true;                          106     foundPreTime = true;
109         }                                         107         }
110         if (i->GetName() == "PostT") {            108         if (i->GetName() == "PostT") {
111     trajectoryPointPostTime =                     109     trajectoryPointPostTime =
112       G4UIcommand::ConvertToDimensionedDouble(    110       G4UIcommand::ConvertToDimensionedDouble(i->GetValue());
113     foundPostTime = true;                         111     foundPostTime = true;
114         }                                         112         }
115       }                                           113       }
116       if (!foundPreTime || !foundPostTime) {      114       if (!foundPreTime || !foundPostTime) {
117         static G4bool warnedTimesNotFound = fa    115         static G4bool warnedTimesNotFound = false;
118         if (!warnedTimesNotFound) {               116         if (!warnedTimesNotFound) {
119     G4warn <<                                  << 117     G4cout <<
120   "*******************************************    118   "*************************************************************************"
121   "\n*  WARNING: G4TrajectoryDrawerUtils::GetP    119   "\n*  WARNING: G4TrajectoryDrawerUtils::GetPointsAndTimes: times not found."
122   "\n You need to specify \"/vis/scene/add/tra << 
123   "\n*****************************************    120   "\n*************************************************************************"
124            << G4endl;                             121            << G4endl;
125     warnedTimesNotFound = true;                   122     warnedTimesNotFound = true;
126         }                                         123         }
127         validity = InvalidTimes;                  124         validity = InvalidTimes;
128       }                                           125       }
129     }                                             126     }
130           delete trajectoryPointAttValues;  // << 
131   }                                               127   }
132                                                   128 
133   const std::vector<G4ThreeVector>* auxiliarie    129   const std::vector<G4ThreeVector>* auxiliaries
134     = aTrajectoryPoint->GetAuxiliaryPoints();     130     = aTrajectoryPoint->GetAuxiliaryPoints();
135   if (0 != auxiliaries) {                         131   if (0 != auxiliaries) {
136     for (size_t iAux=0; iAux<auxiliaries->size    132     for (size_t iAux=0; iAux<auxiliaries->size(); ++iAux) {
137       const G4ThreeVector& auxPointPosition =     133       const G4ThreeVector& auxPointPosition = (*auxiliaries)[iAux];
138       if (positions.size() == 0 ||                134       if (positions.size() == 0 ||
139     auxPointPosition != positions[positions.si    135     auxPointPosition != positions[positions.size()-1]) {
140         // Only store if first or if different    136         // Only store if first or if different
141         positions.push_back(trajectoryPointPos    137         positions.push_back(trajectoryPointPosition);
142         trajectoryLine.push_back(auxPointPosit    138         trajectoryLine.push_back(auxPointPosition);
143         auxiliaryPoints.push_back(auxPointPosi    139         auxiliaryPoints.push_back(auxPointPosition);
144         if (validity == ValidTimes) {             140         if (validity == ValidTimes) {
145     // Interpolate time for auxiliary points..    141     // Interpolate time for auxiliary points...
                                                   >> 142     const G4ThreeVector& auxPointPosition = (*auxiliaries)[iAux];
146     G4double s1 =                                 143     G4double s1 =
147       (auxPointPosition - lastTrajectoryPointP    144       (auxPointPosition - lastTrajectoryPointPosition).mag();
148     G4double s2 =                                 145     G4double s2 =
149       (trajectoryPointPosition - auxPointPosit    146       (trajectoryPointPosition - auxPointPosition).mag();
150     G4double t = trajectoryPointPreTime +         147     G4double t = trajectoryPointPreTime +
151       (trajectoryPointPostTime - trajectoryPoi    148       (trajectoryPointPostTime - trajectoryPointPreTime) *
152       (s1 / (s1 + s2));                           149       (s1 / (s1 + s2));
153     trajectoryLineTimes.push_back(t);             150     trajectoryLineTimes.push_back(t);
154     auxiliaryPointTimes.push_back(t);             151     auxiliaryPointTimes.push_back(t);
155         }                                         152         }
156       }                                           153       }
157     }                                             154     }
158   }                                               155   }
159                                                   156 
160   positions.push_back(trajectoryPointPosition)    157   positions.push_back(trajectoryPointPosition);
161   trajectoryLine.push_back(trajectoryPointPosi    158   trajectoryLine.push_back(trajectoryPointPosition);
162   stepPoints.push_back(trajectoryPointPosition    159   stepPoints.push_back(trajectoryPointPosition);
163   if (validity == ValidTimes) {                   160   if (validity == ValidTimes) {
164     trajectoryLineTimes.push_back(trajectoryPo    161     trajectoryLineTimes.push_back(trajectoryPointPostTime);
165     stepPointTimes.push_back(trajectoryPointPo    162     stepPointTimes.push_back(trajectoryPointPostTime);
166   }                                               163   }
167         lastTrajectoryPointPosition = trajecto    164         lastTrajectoryPointPosition = trajectoryPointPosition;
168       }                                           165       }
169     }                                             166     }
170     return validity;                              167     return validity;    
171   }                                               168   }
172                                                   169 
173   static void SliceLine(G4double timeIncrement    170   static void SliceLine(G4double timeIncrement,
174       G4Polyline& trajectoryLine,                 171       G4Polyline& trajectoryLine,
175       std::vector<G4double>& trajectoryLineTim    172       std::vector<G4double>& trajectoryLineTimes)
176   {                                               173   {
177     // Assumes valid arguments from GetPoints     174     // Assumes valid arguments from GetPoints and GetTimes.
178                                                   175 
179     G4Polyline newTrajectoryLine;                 176     G4Polyline newTrajectoryLine;
180     std::vector<G4double> newTrajectoryLineTim    177     std::vector<G4double> newTrajectoryLineTimes;
181                                                   178 
182     newTrajectoryLine.push_back(trajectoryLine    179     newTrajectoryLine.push_back(trajectoryLine[0]);
183     newTrajectoryLineTimes.push_back(trajector    180     newTrajectoryLineTimes.push_back(trajectoryLineTimes[0]);
184     size_t lineSize = trajectoryLine.size();      181     size_t lineSize = trajectoryLine.size();
185     if (lineSize > 1) {                           182     if (lineSize > 1) {
186       for (size_t i = 1; i < trajectoryLine.si    183       for (size_t i = 1; i < trajectoryLine.size(); ++i) {
187   G4double deltaT = trajectoryLineTimes[i] - t    184   G4double deltaT = trajectoryLineTimes[i] - trajectoryLineTimes[i - 1];
188   if (deltaT > 0.) {                              185   if (deltaT > 0.) {
189     G4double practicalTimeIncrement =             186     G4double practicalTimeIncrement = 
190       std::max(timeIncrement, deltaT / 100.);     187       std::max(timeIncrement, deltaT / 100.);
191     for (G4double t =                             188     for (G4double t =
192      (int(trajectoryLineTimes[i - 1]/practical    189      (int(trajectoryLineTimes[i - 1]/practicalTimeIncrement) + 1) *
193      practicalTimeIncrement;                      190      practicalTimeIncrement;
194          t <= trajectoryLineTimes[i];             191          t <= trajectoryLineTimes[i];
195          t += practicalTimeIncrement) {           192          t += practicalTimeIncrement) {
196       G4ThreeVector pos = trajectoryLine[i - 1    193       G4ThreeVector pos = trajectoryLine[i - 1] +
197         (trajectoryLine[i] - trajectoryLine[i     194         (trajectoryLine[i] - trajectoryLine[i - 1]) *
198         ((t - trajectoryLineTimes[i - 1]) / de    195         ((t - trajectoryLineTimes[i - 1]) / deltaT);
199       newTrajectoryLine.push_back(pos);           196       newTrajectoryLine.push_back(pos);
200       newTrajectoryLineTimes.push_back(t);        197       newTrajectoryLineTimes.push_back(t);
201     }                                             198     }
202   }                                               199   }
203   newTrajectoryLine.push_back(trajectoryLine[i    200   newTrajectoryLine.push_back(trajectoryLine[i]);
204   newTrajectoryLineTimes.push_back(trajectoryL    201   newTrajectoryLineTimes.push_back(trajectoryLineTimes[i]);
205       }                                           202       }
206     }                                             203     }
207                                                   204 
208     trajectoryLine = std::move(newTrajectoryLi << 205     trajectoryLine = newTrajectoryLine;
209     trajectoryLineTimes = std::move(newTraject << 206     trajectoryLineTimes = newTrajectoryLineTimes;
210   }                                               207   }
211                                                   208 
212   static void DrawWithoutTime(const G4VisTrajC    209   static void DrawWithoutTime(const G4VisTrajContext& myContext,
213             G4Polyline& trajectoryLine,           210             G4Polyline& trajectoryLine,
214             G4Polymarker& auxiliaryPoints,        211             G4Polymarker& auxiliaryPoints,
215             G4Polymarker& stepPoints)             212             G4Polymarker& stepPoints)
216   {                                               213   {
217     // Draw without time slice information        214     // Draw without time slice information
218                                                   215 
219     G4VVisManager* pVVisManager = G4VVisManage    216     G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
220     if (0 == pVVisManager) return;                217     if (0 == pVVisManager) return;
221                                                   218     
222     if (myContext.GetDrawLine() && myContext.G << 219     if (myContext.GetDrawLine()) {
223       G4VisAttributes trajectoryLineAttribs(my    220       G4VisAttributes trajectoryLineAttribs(myContext.GetLineColour());
224       trajectoryLineAttribs.SetLineWidth(myCon << 221       trajectoryLineAttribs.SetVisibility(myContext.GetLineVisible());
225       trajectoryLine.SetVisAttributes(&traject    222       trajectoryLine.SetVisAttributes(&trajectoryLineAttribs);
226                                                   223 
227       pVVisManager->Draw(trajectoryLine);         224       pVVisManager->Draw(trajectoryLine);
228     }                                             225     }
229                                                   226   
230     if (myContext.GetDrawAuxPts() && myContext << 227     if (myContext.GetDrawAuxPts() && (auxiliaryPoints.size() > 0)) {
231         && (auxiliaryPoints.size() > 0)) {     << 
232       auxiliaryPoints.SetMarkerType(myContext.    228       auxiliaryPoints.SetMarkerType(myContext.GetAuxPtsType());
233       auxiliaryPoints.SetSize(myContext.GetAux    229       auxiliaryPoints.SetSize(myContext.GetAuxPtsSizeType(), myContext.GetAuxPtsSize());
234       auxiliaryPoints.SetFillStyle(myContext.G    230       auxiliaryPoints.SetFillStyle(myContext.GetAuxPtsFillStyle());
235                                                   231 
236       G4VisAttributes auxiliaryPointsAttribs(m    232       G4VisAttributes auxiliaryPointsAttribs(myContext.GetAuxPtsColour());  
                                                   >> 233       auxiliaryPointsAttribs.SetVisibility(myContext.GetAuxPtsVisible());
237       auxiliaryPoints.SetVisAttributes(&auxili    234       auxiliaryPoints.SetVisAttributes(&auxiliaryPointsAttribs);
238                                                   235 
239       pVVisManager->Draw(auxiliaryPoints);        236       pVVisManager->Draw(auxiliaryPoints);
240     }                                             237     }
241                                                   238   
242     if (myContext.GetDrawStepPts() && myContex << 239     if (myContext.GetDrawStepPts() && (stepPoints.size() > 0)) {
243         && (stepPoints.size() > 0)) {          << 
244       stepPoints.SetMarkerType(myContext.GetSt    240       stepPoints.SetMarkerType(myContext.GetStepPtsType());
245       stepPoints.SetSize(myContext.GetStepPtsS    241       stepPoints.SetSize(myContext.GetStepPtsSizeType(), myContext.GetStepPtsSize());
246       stepPoints.SetFillStyle(myContext.GetSte    242       stepPoints.SetFillStyle(myContext.GetStepPtsFillStyle());
247                                                   243 
248       G4VisAttributes stepPointsAttribs(myCont    244       G4VisAttributes stepPointsAttribs(myContext.GetStepPtsColour()); 
                                                   >> 245       stepPointsAttribs.SetVisibility(myContext.GetStepPtsVisible());
249       stepPoints.SetVisAttributes(&stepPointsA    246       stepPoints.SetVisAttributes(&stepPointsAttribs);
250                                                   247 
251       pVVisManager->Draw(stepPoints);             248       pVVisManager->Draw(stepPoints);
252     }                                             249     }
253   }                                               250   }
254                                                   251 
255   static void DrawWithTime(const G4VisTrajCont    252   static void DrawWithTime(const G4VisTrajContext& myContext,
256          G4Polyline& trajectoryLine,              253          G4Polyline& trajectoryLine,
257          G4Polymarker& auxiliaryPoints,           254          G4Polymarker& auxiliaryPoints,
258          G4Polymarker& stepPoints,                255          G4Polymarker& stepPoints,
259          std::vector<G4double>& trajectoryLine    256          std::vector<G4double>& trajectoryLineTimes,
260          std::vector<G4double>& auxiliaryPoint    257          std::vector<G4double>& auxiliaryPointTimes,
261          std::vector<G4double>& stepPointTimes    258          std::vector<G4double>& stepPointTimes)
262   {                                               259   {
263     // Draw with time slice information           260     // Draw with time slice information
264                                                   261 
265     G4VVisManager* pVVisManager = G4VVisManage    262     G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
266     if (0 == pVVisManager) return;                263     if (0 == pVVisManager) return;
267                                                   264 
268     if (myContext.GetDrawLine() && myContext.G << 265     if (myContext.GetDrawLine()) {
269       G4VisAttributes trajectoryLineAttribs(my    266       G4VisAttributes trajectoryLineAttribs(myContext.GetLineColour());
270       trajectoryLineAttribs.SetLineWidth(myCon << 267       trajectoryLineAttribs.SetVisibility(myContext.GetLineVisible());
271                                                   268 
272       for (size_t i = 1; i < trajectoryLine.si    269       for (size_t i = 1; i < trajectoryLine.size(); ++i ) {
273   G4Polyline slice;                               270   G4Polyline slice;
274   slice.push_back(trajectoryLine[i -1]);          271   slice.push_back(trajectoryLine[i -1]);
275   slice.push_back(trajectoryLine[i]);             272   slice.push_back(trajectoryLine[i]);
276   trajectoryLineAttribs.SetStartTime(trajector    273   trajectoryLineAttribs.SetStartTime(trajectoryLineTimes[i - 1]);
277   trajectoryLineAttribs.SetEndTime(trajectoryL    274   trajectoryLineAttribs.SetEndTime(trajectoryLineTimes[i]);
278   slice.SetVisAttributes(&trajectoryLineAttrib    275   slice.SetVisAttributes(&trajectoryLineAttribs);
279   pVVisManager->Draw(slice);                      276   pVVisManager->Draw(slice);
280       }                                           277       }
281     }                                             278     }
282                                                   279 
283     if (myContext.GetDrawAuxPts() && myContext << 280     if (myContext.GetDrawAuxPts() && (auxiliaryPoints.size() > 0)) {
284         && (auxiliaryPoints.size() > 0)) {     << 
285       G4VisAttributes auxiliaryPointsAttribs(m    281       G4VisAttributes auxiliaryPointsAttribs(myContext.GetAuxPtsColour());  
                                                   >> 282       auxiliaryPointsAttribs.SetVisibility(myContext.GetAuxPtsVisible());
286                                                   283 
287       for (size_t i = 0; i < auxiliaryPoints.s    284       for (size_t i = 0; i < auxiliaryPoints.size(); ++i ) {
288   G4Polymarker point;                             285   G4Polymarker point;
289   point.push_back(auxiliaryPoints[i]);            286   point.push_back(auxiliaryPoints[i]);
290   point.SetMarkerType(myContext.GetAuxPtsType(    287   point.SetMarkerType(myContext.GetAuxPtsType());
291   point.SetSize(myContext.GetAuxPtsSizeType(),    288   point.SetSize(myContext.GetAuxPtsSizeType(), myContext.GetAuxPtsSize());
292   point.SetFillStyle(myContext.GetAuxPtsFillSt    289   point.SetFillStyle(myContext.GetAuxPtsFillStyle());
293   auxiliaryPointsAttribs.SetStartTime(auxiliar    290   auxiliaryPointsAttribs.SetStartTime(auxiliaryPointTimes[i]);
294   auxiliaryPointsAttribs.SetEndTime(auxiliaryP    291   auxiliaryPointsAttribs.SetEndTime(auxiliaryPointTimes[i]);
295   point.SetVisAttributes(&auxiliaryPointsAttri    292   point.SetVisAttributes(&auxiliaryPointsAttribs);
296   pVVisManager->Draw(point);                      293   pVVisManager->Draw(point);
297       }                                           294       }
298     }                                             295     }
299                                                   296 
300     if (myContext.GetDrawStepPts() && myContex << 297     if (myContext.GetDrawStepPts() && (stepPoints.size() > 0)) {
301         && (stepPoints.size() > 0)) {          << 
302       G4VisAttributes stepPointsAttribs(myCont    298       G4VisAttributes stepPointsAttribs(myContext.GetStepPtsColour()); 
                                                   >> 299       stepPointsAttribs.SetVisibility(myContext.GetStepPtsVisible());
303                                                   300 
304       for (size_t i = 0; i < stepPoints.size()    301       for (size_t i = 0; i < stepPoints.size(); ++i ) {
305   G4Polymarker point;                             302   G4Polymarker point;
306   point.push_back(stepPoints[i]);                 303   point.push_back(stepPoints[i]);
307   point.SetMarkerType(myContext.GetStepPtsType    304   point.SetMarkerType(myContext.GetStepPtsType());
308   point.SetSize(myContext.GetStepPtsSizeType()    305   point.SetSize(myContext.GetStepPtsSizeType(), myContext.GetStepPtsSize());
309   point.SetFillStyle(myContext.GetStepPtsFillS    306   point.SetFillStyle(myContext.GetStepPtsFillStyle());
310   stepPointsAttribs.SetStartTime(stepPointTime    307   stepPointsAttribs.SetStartTime(stepPointTimes[i]);
311   stepPointsAttribs.SetEndTime(stepPointTimes[    308   stepPointsAttribs.SetEndTime(stepPointTimes[i]);
312   point.SetVisAttributes(&stepPointsAttribs);     309   point.SetVisAttributes(&stepPointsAttribs);
313   pVVisManager->Draw(point);                      310   pVVisManager->Draw(point);
314       }                                           311       }
                                                   >> 312     }
                                                   >> 313   }
                                                   >> 314 
                                                   >> 315   void DrawLineAndPoints(const G4VTrajectory& traj, const G4VisTrajContext& context, const G4int& i_mode) 
                                                   >> 316   {
                                                   >> 317     static G4bool warnedAboutIMode = false;
                                                   >> 318     G4ExceptionDescription ed;
                                                   >> 319     ed << "WARNING: DEPRECATED use of i_mode (i_mode: " << i_mode
                                                   >> 320   << ").  Feature will be removed at a future major release.";
                                                   >> 321     if (!warnedAboutIMode) {
                                                   >> 322       G4Exception
                                                   >> 323   ("G4TrajectoryDrawerUtils::DrawLineAndPoints(traj, context, i_mode)",
                                                   >> 324    "modeling0125", JustWarning, ed);
                                                   >> 325       warnedAboutIMode = true;
                                                   >> 326     }
                                                   >> 327 
                                                   >> 328     // Extra copy while i_mode is still around
                                                   >> 329     G4VisTrajContext myContext(context);
                                                   >> 330     
                                                   >> 331     if (i_mode != 0) {
                                                   >> 332       const G4double markerSize = std::abs(i_mode)/1000;
                                                   >> 333       G4bool lineRequired (i_mode >= 0);
                                                   >> 334       G4bool markersRequired (markerSize > 0.);        
                                                   >> 335       
                                                   >> 336       myContext.SetDrawLine(lineRequired);
                                                   >> 337       myContext.SetDrawAuxPts(markersRequired);
                                                   >> 338       myContext.SetDrawStepPts(markersRequired);
                                                   >> 339 
                                                   >> 340       myContext.SetAuxPtsSize(markerSize);
                                                   >> 341       myContext.SetStepPtsSize(markerSize);
                                                   >> 342     }
                                                   >> 343 
                                                   >> 344     // Return if don't need to do anything
                                                   >> 345     if (!myContext.GetDrawLine() && !myContext.GetDrawAuxPts() && !myContext.GetDrawStepPts()) return;
                                                   >> 346     
                                                   >> 347     // Get points and times (times are returned only if time-slicing
                                                   >> 348     // is requested).
                                                   >> 349     G4Polyline trajectoryLine;
                                                   >> 350     G4Polymarker stepPoints;
                                                   >> 351     G4Polymarker auxiliaryPoints;
                                                   >> 352     std::vector<G4double> trajectoryLineTimes;
                                                   >> 353     std::vector<G4double> stepPointTimes;
                                                   >> 354     std::vector<G4double> auxiliaryPointTimes;
                                                   >> 355 
                                                   >> 356     TimesValidity validity = GetPointsAndTimes
                                                   >> 357       (traj, context,
                                                   >> 358        trajectoryLine, auxiliaryPoints, stepPoints,
                                                   >> 359        trajectoryLineTimes, auxiliaryPointTimes, stepPointTimes);
                                                   >> 360     
                                                   >> 361     if (validity == ValidTimes) {
                                                   >> 362 
                                                   >> 363       SliceLine(context.GetTimeSliceInterval(),
                                                   >> 364                 trajectoryLine, trajectoryLineTimes);
                                                   >> 365 
                                                   >> 366       DrawWithTime(context,
                                                   >> 367                    trajectoryLine, auxiliaryPoints, stepPoints,
                                                   >> 368                    trajectoryLineTimes, auxiliaryPointTimes, stepPointTimes);
                                                   >> 369 
                                                   >> 370     } else {
                                                   >> 371 
                                                   >> 372       DrawWithoutTime(context, trajectoryLine, auxiliaryPoints, stepPoints);
                                                   >> 373 
315     }                                             374     }
316   }                                               375   }
317                                                   376 
318   void DrawLineAndPoints(const G4VTrajectory&     377   void DrawLineAndPoints(const G4VTrajectory& traj, const G4VisTrajContext& context) 
319   {                                               378   {
320     // Return if don't need to do anything        379     // Return if don't need to do anything
321     if (!context.GetDrawLine() && !context.Get    380     if (!context.GetDrawLine() && !context.GetDrawAuxPts() && !context.GetDrawStepPts()) return;
322                                                   381     
323     // Get points and times (times are returne    382     // Get points and times (times are returned only if time-slicing
324     // is requested).                             383     // is requested).
325     G4Polyline trajectoryLine;                    384     G4Polyline trajectoryLine;
326     G4Polymarker stepPoints;                      385     G4Polymarker stepPoints;
327     G4Polymarker auxiliaryPoints;                 386     G4Polymarker auxiliaryPoints;
328     std::vector<G4double> trajectoryLineTimes;    387     std::vector<G4double> trajectoryLineTimes;
329     std::vector<G4double> stepPointTimes;         388     std::vector<G4double> stepPointTimes;
330     std::vector<G4double> auxiliaryPointTimes;    389     std::vector<G4double> auxiliaryPointTimes;
331                                                   390 
332     TimesValidity validity = GetPointsAndTimes    391     TimesValidity validity = GetPointsAndTimes
333       (traj, context,                             392       (traj, context,
334        trajectoryLine, auxiliaryPoints, stepPo    393        trajectoryLine, auxiliaryPoints, stepPoints,
335        trajectoryLineTimes, auxiliaryPointTime    394        trajectoryLineTimes, auxiliaryPointTimes, stepPointTimes);
336                                                   395     
337     if (validity == ValidTimes) {                 396     if (validity == ValidTimes) {
338                                                   397 
339       SliceLine(context.GetTimeSliceInterval()    398       SliceLine(context.GetTimeSliceInterval(),
340     trajectoryLine, trajectoryLineTimes);         399     trajectoryLine, trajectoryLineTimes);
341                                                   400 
342       DrawWithTime(context,                       401       DrawWithTime(context,
343        trajectoryLine, auxiliaryPoints, stepPo    402        trajectoryLine, auxiliaryPoints, stepPoints,
344        trajectoryLineTimes, auxiliaryPointTime    403        trajectoryLineTimes, auxiliaryPointTimes, stepPointTimes);
345                                                   404 
346     } else {                                      405     } else {
347                                                   406 
348       DrawWithoutTime(context, trajectoryLine,    407       DrawWithoutTime(context, trajectoryLine, auxiliaryPoints, stepPoints);
349                                                   408 
350     }                                             409     }
351   }                                               410   }
352 }                                                 411 }
353                                                   412