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