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 // 26 // >> 27 // $Id: G4ViewParameters.cc 101035 2016-11-04 08:48:17Z gcosmo $ 27 // 28 // 28 // 29 // 29 // John Allison 19th July 1996 30 // John Allison 19th July 1996 30 // View parameters and options. 31 // View parameters and options. 31 32 >> 33 #include <sstream> >> 34 32 #include "G4ViewParameters.hh" 35 #include "G4ViewParameters.hh" 33 36 34 #include "G4VisManager.hh" 37 #include "G4VisManager.hh" 35 #include "G4VPhysicalVolume.hh" 38 #include "G4VPhysicalVolume.hh" 36 #include "G4UnitsTable.hh" 39 #include "G4UnitsTable.hh" 37 #include "G4SystemOfUnits.hh" 40 #include "G4SystemOfUnits.hh" 38 #include "G4Polyhedron.hh" << 41 #include "G4ios.hh" 39 << 40 #include <sstream> << 41 #include <cmath> << 42 << 43 #define G4warn G4cout << 44 42 45 G4ViewParameters::G4ViewParameters (): 43 G4ViewParameters::G4ViewParameters (): 46 fDrawingStyle (wireframe), 44 fDrawingStyle (wireframe), 47 fNumberOfCloudPoints(10000), << 48 fAuxEdgeVisible (false), 45 fAuxEdgeVisible (false), 49 fCulling (true), 46 fCulling (true), 50 fCullInvisible (true), 47 fCullInvisible (true), 51 fDensityCulling (false), 48 fDensityCulling (false), 52 fVisibleDensity (0.01 * g / cm3), 49 fVisibleDensity (0.01 * g / cm3), 53 fCullCovered (false), 50 fCullCovered (false), 54 fCBDAlgorithmNumber (0), << 55 fSection (false), 51 fSection (false), 56 fSectionPlane (), 52 fSectionPlane (), 57 fCutawayMode (cutawayUnion), 53 fCutawayMode (cutawayUnion), 58 fCutawayPlanes (), 54 fCutawayPlanes (), 59 fExplodeFactor (1.), 55 fExplodeFactor (1.), 60 fNoOfSides (), << 56 fNoOfSides (72), 61 fViewpointDirection (G4Vector3D (0., 0., 1.) 57 fViewpointDirection (G4Vector3D (0., 0., 1.)), // On z-axis. 62 fUpVector (G4Vector3D (0., 1., 0.)), 58 fUpVector (G4Vector3D (0., 1., 0.)), // y-axis up. 63 fFieldHalfAngle (0.), 59 fFieldHalfAngle (0.), // Orthogonal projection. 64 fZoomFactor (1.), 60 fZoomFactor (1.), 65 fScaleFactor (G4Vector3D (1., 1., 1.)), 61 fScaleFactor (G4Vector3D (1., 1., 1.)), 66 fCurrentTargetPoint (), 62 fCurrentTargetPoint (), 67 fDolly (0.), 63 fDolly (0.), 68 fLightsMoveWithCamera (false), 64 fLightsMoveWithCamera (false), 69 fRelativeLightpointDirection (G4Vector3D (1. 65 fRelativeLightpointDirection (G4Vector3D (1., 1., 1.)), 70 fActualLightpointDirection (G4Vector3D (1., 66 fActualLightpointDirection (G4Vector3D (1., 1., 1.)), 71 fDefaultVisAttributes (), 67 fDefaultVisAttributes (), 72 fDefaultTextVisAttributes (G4Colour (0., 0., 68 fDefaultTextVisAttributes (G4Colour (0., 0., 1.)), 73 fDefaultMarker (), 69 fDefaultMarker (), 74 fGlobalMarkerScale (1.), 70 fGlobalMarkerScale (1.), 75 fGlobalLineWidthScale (1.), 71 fGlobalLineWidthScale (1.), 76 fMarkerNotHidden (true), 72 fMarkerNotHidden (true), 77 fWindowSizeHintX (600), 73 fWindowSizeHintX (600), 78 fWindowSizeHintY (600), 74 fWindowSizeHintY (600), 79 fWindowLocationHintX(0), 75 fWindowLocationHintX(0), 80 fWindowLocationHintY(0), 76 fWindowLocationHintY(0), 81 fWindowLocationHintXNegative(true), 77 fWindowLocationHintXNegative(true), 82 fWindowLocationHintYNegative(false), 78 fWindowLocationHintYNegative(false), 83 fGeometryMask(0), 79 fGeometryMask(0), 84 fAutoRefresh (false), 80 fAutoRefresh (false), 85 fBackgroundColour (G4Colour(0.,0.,0.)), 81 fBackgroundColour (G4Colour(0.,0.,0.)), // Black 86 fPicking (false), 82 fPicking (false), 87 fRotationStyle (constrainUpDirection), << 83 fRotationStyle (constrainUpDirection) 88 fStartTime(-G4VisAttributes::fVeryLongTime), << 89 fEndTime(G4VisAttributes::fVeryLongTime), << 90 fFadeFactor(0.), << 91 fDisplayHeadTime(false), << 92 fDisplayHeadTimeX(-0.9), << 93 fDisplayHeadTimeY(-0.9), << 94 fDisplayHeadTimeSize(24.), << 95 fDisplayHeadTimeRed(0.), << 96 fDisplayHeadTimeGreen(1.), << 97 fDisplayHeadTimeBlue(1.), << 98 fDisplayLightFront(false), << 99 fDisplayLightFrontX(0.), << 100 fDisplayLightFrontY(0.), << 101 fDisplayLightFrontZ(0.), << 102 fDisplayLightFrontT(0.), << 103 fDisplayLightFrontRed(0.), << 104 fDisplayLightFrontGreen(1.), << 105 fDisplayLightFrontBlue(0.), << 106 fSpecialMeshRendering(false), << 107 fSpecialMeshRenderingOption(meshAsDefault) << 108 { 84 { 109 // Pick up default no of sides from G4Polyhe << 110 // Note that this parameter is variously cal << 111 // No of sides << 112 // NumberOfRotationSteps << 113 // Line segments per circle << 114 // It refers to the approximation of a circl << 115 // stated number of sides. << 116 fNoOfSides = G4Polyhedron::GetNumberOfRotati << 117 << 118 fDefaultMarker.SetScreenSize (5.); 85 fDefaultMarker.SetScreenSize (5.); 119 // Markers are 5 pixels "overall" size, i.e. 86 // Markers are 5 pixels "overall" size, i.e., diameter. 120 } 87 } 121 88 122 G4ViewParameters::~G4ViewParameters () {} 89 G4ViewParameters::~G4ViewParameters () {} 123 90 124 void G4ViewParameters::MultiplyScaleFactor 91 void G4ViewParameters::MultiplyScaleFactor 125 (const G4Vector3D& scaleFactorMultiplier) { 92 (const G4Vector3D& scaleFactorMultiplier) { 126 fScaleFactor.setX(fScaleFactor.x() * scaleFa 93 fScaleFactor.setX(fScaleFactor.x() * scaleFactorMultiplier.x()); 127 fScaleFactor.setY(fScaleFactor.y() * scaleFa 94 fScaleFactor.setY(fScaleFactor.y() * scaleFactorMultiplier.y()); 128 fScaleFactor.setZ(fScaleFactor.z() * scaleFa 95 fScaleFactor.setZ(fScaleFactor.z() * scaleFactorMultiplier.z()); 129 } 96 } 130 97 131 G4Vector3D& G4ViewParameters::GetActualLightpo 98 G4Vector3D& G4ViewParameters::GetActualLightpointDirection () { 132 SetViewAndLights (fViewpointDirection); 99 SetViewAndLights (fViewpointDirection); 133 return fActualLightpointDirection; 100 return fActualLightpointDirection; 134 } 101 } 135 102 136 // Useful quantities - begin snippet. 103 // Useful quantities - begin snippet. 137 // Here Follow functions to evaluate the above 104 // Here Follow functions to evaluate the above algorithms as a 138 // function of the radius of the Bounding Sphe 105 // function of the radius of the Bounding Sphere of the object being 139 // viewed. Call them in the order given - for 106 // viewed. Call them in the order given - for efficiency, later 140 // functions depend on the results of earlier 107 // functions depend on the results of earlier ones (Store the 141 // results of earlier functions in your own te 108 // results of earlier functions in your own temporary variables - 142 // see, for example, G4OpenGLView::SetView (). 109 // see, for example, G4OpenGLView::SetView ().) 143 110 144 G4double G4ViewParameters::GetCameraDistance ( 111 G4double G4ViewParameters::GetCameraDistance (G4double radius) const { 145 G4double cameraDistance; 112 G4double cameraDistance; 146 if (fFieldHalfAngle == 0.) { 113 if (fFieldHalfAngle == 0.) { 147 cameraDistance = radius; 114 cameraDistance = radius; 148 } 115 } 149 else { 116 else { 150 cameraDistance = radius / std::sin (fField 117 cameraDistance = radius / std::sin (fFieldHalfAngle) - fDolly; 151 } 118 } 152 return cameraDistance; 119 return cameraDistance; 153 } 120 } 154 121 155 G4double G4ViewParameters::GetNearDistance (G4 122 G4double G4ViewParameters::GetNearDistance (G4double cameraDistance, 156 G4double radius) const { 123 G4double radius) const { 157 const G4double small = 1.e-6 * radius; 124 const G4double small = 1.e-6 * radius; 158 G4double nearDistance = cameraDistance - rad 125 G4double nearDistance = cameraDistance - radius; 159 if (nearDistance < small) nearDistance = sma 126 if (nearDistance < small) nearDistance = small; 160 return nearDistance; 127 return nearDistance; 161 } 128 } 162 129 163 G4double G4ViewParameters::GetFarDistance (G4d 130 G4double G4ViewParameters::GetFarDistance (G4double cameraDistance, 164 G4double nearDistance, 131 G4double nearDistance, 165 G4double radius) const { 132 G4double radius) const { 166 G4double farDistance = cameraDistance + radi 133 G4double farDistance = cameraDistance + radius; 167 if (farDistance < nearDistance) farDistance 134 if (farDistance < nearDistance) farDistance = nearDistance; 168 return farDistance; 135 return farDistance; 169 } 136 } 170 137 171 G4double G4ViewParameters::GetFrontHalfHeight 138 G4double G4ViewParameters::GetFrontHalfHeight (G4double nearDistance, 172 G4double radius) const { 139 G4double radius) const { 173 G4double frontHalfHeight; 140 G4double frontHalfHeight; 174 if (fFieldHalfAngle == 0.) { 141 if (fFieldHalfAngle == 0.) { 175 frontHalfHeight = radius / fZoomFactor; 142 frontHalfHeight = radius / fZoomFactor; 176 } 143 } 177 else { 144 else { 178 frontHalfHeight = nearDistance * std::tan 145 frontHalfHeight = nearDistance * std::tan (fFieldHalfAngle) / fZoomFactor; 179 } 146 } 180 return frontHalfHeight; 147 return frontHalfHeight; 181 } 148 } 182 // Useful quantities - end snippet. 149 // Useful quantities - end snippet. 183 150 184 void G4ViewParameters::AddCutawayPlane (const 151 void G4ViewParameters::AddCutawayPlane (const G4Plane3D& cutawayPlane) { 185 if (fCutawayPlanes.size () < 3 ) { 152 if (fCutawayPlanes.size () < 3 ) { 186 fCutawayPlanes.push_back (cutawayPlane); 153 fCutawayPlanes.push_back (cutawayPlane); 187 } 154 } 188 else { 155 else { 189 G4warn << << 156 G4cerr << 190 "ERROR: G4ViewParameters::AddCutawayPlan 157 "ERROR: G4ViewParameters::AddCutawayPlane:" 191 "\n A maximum of 3 cutaway planes suppo 158 "\n A maximum of 3 cutaway planes supported." << G4endl; 192 } 159 } 193 } 160 } 194 161 195 void G4ViewParameters::ChangeCutawayPlane 162 void G4ViewParameters::ChangeCutawayPlane 196 (size_t index, const G4Plane3D& cutawayPlane) 163 (size_t index, const G4Plane3D& cutawayPlane) { 197 if (index >= fCutawayPlanes.size()) { 164 if (index >= fCutawayPlanes.size()) { 198 G4warn << << 165 G4cerr << 199 "ERROR: G4ViewParameters::ChangeCutawayP 166 "ERROR: G4ViewParameters::ChangeCutawayPlane:" 200 "\n Plane " << index << " does not exis 167 "\n Plane " << index << " does not exist." << G4endl; 201 } else { 168 } else { 202 fCutawayPlanes[index] = cutawayPlane; 169 fCutawayPlanes[index] = cutawayPlane; 203 } 170 } 204 } 171 } 205 172 206 void G4ViewParameters::SetVisibleDensity (G4do 173 void G4ViewParameters::SetVisibleDensity (G4double visibleDensity) { 207 const G4double reasonableMaximum = 10.0 * g 174 const G4double reasonableMaximum = 10.0 * g / cm3; 208 if (visibleDensity < 0) { 175 if (visibleDensity < 0) { 209 G4warn << "G4ViewParameters::SetVisibleDen << 176 G4cout << "G4ViewParameters::SetVisibleDensity: attempt to set negative " 210 "density - ignored." << G4endl; 177 "density - ignored." << G4endl; 211 } 178 } 212 else { 179 else { 213 if (visibleDensity > reasonableMaximum) { 180 if (visibleDensity > reasonableMaximum) { 214 G4warn << "G4ViewParameters::SetVisibleD << 181 G4cout << "G4ViewParameters::SetVisibleDensity: density > " 215 << G4BestUnit (reasonableMaximum, "Volu 182 << G4BestUnit (reasonableMaximum, "Volumic Mass") 216 << " - did you mean this?" 183 << " - did you mean this?" 217 << G4endl; 184 << G4endl; 218 } 185 } 219 fVisibleDensity = visibleDensity; 186 fVisibleDensity = visibleDensity; 220 } 187 } 221 } 188 } 222 189 223 G4int G4ViewParameters::SetNoOfSides (G4int nS 190 G4int G4ViewParameters::SetNoOfSides (G4int nSides) { 224 const G4int nSidesMin = fDefaultVisAttribute 191 const G4int nSidesMin = fDefaultVisAttributes.GetMinLineSegmentsPerCircle(); 225 if (nSides < nSidesMin) { 192 if (nSides < nSidesMin) { 226 nSides = nSidesMin; 193 nSides = nSidesMin; 227 G4warn << "G4ViewParameters::SetNoOfSides: << 194 G4cout << "G4ViewParameters::SetNoOfSides: attempt to set the" 228 "\nnumber of sides per circle < " << nSide << 195 "\nnumber of sides per circle < " << nSidesMin 229 << "; forced to " << nSides << G4endl; << 196 << "; forced to " << nSides << G4endl; 230 } 197 } 231 fNoOfSides = nSides; 198 fNoOfSides = nSides; 232 return fNoOfSides; 199 return fNoOfSides; 233 } 200 } 234 201 235 G4int G4ViewParameters::SetNumberOfCloudPoints << 236 const G4int nPointsMin = 100; << 237 if (nPoints < nPointsMin) { << 238 nPoints = nPointsMin; << 239 G4warn << "G4ViewParameters::SetNumberOfCl << 240 "\nnumber of points per cloud set to minim << 241 << G4endl; << 242 } << 243 fNumberOfCloudPoints = nPoints; << 244 return fNumberOfCloudPoints; << 245 } << 246 << 247 void G4ViewParameters::SetViewAndLights 202 void G4ViewParameters::SetViewAndLights 248 (const G4Vector3D& viewpointDirection) { 203 (const G4Vector3D& viewpointDirection) { 249 204 250 fViewpointDirection = viewpointDirection; 205 fViewpointDirection = viewpointDirection; 251 206 252 // If the requested viewpoint direction is p 207 // If the requested viewpoint direction is parallel to the up 253 // vector, the orientation of the view is un 208 // vector, the orientation of the view is undefined... 254 if (fViewpointDirection.unit() * fUpVector.u 209 if (fViewpointDirection.unit() * fUpVector.unit() > .9999) { 255 static G4bool firstTime = true; 210 static G4bool firstTime = true; 256 if (firstTime) { 211 if (firstTime) { 257 firstTime = false; 212 firstTime = false; 258 G4warn << << 213 G4cout << 259 "WARNING: Viewpoint direction is very cl 214 "WARNING: Viewpoint direction is very close to the up vector direction." 260 "\n Change the up vector or \"/vis/view << 215 "\n Consider setting the up vector to obtain definable behaviour." 261 << G4endl; 216 << G4endl; 262 } 217 } 263 } 218 } 264 219 265 // Move the lights too if requested... 220 // Move the lights too if requested... 266 if (fLightsMoveWithCamera) { 221 if (fLightsMoveWithCamera) { 267 G4Vector3D zprime = fViewpointDirection.un 222 G4Vector3D zprime = fViewpointDirection.unit (); 268 G4Vector3D xprime = (fUpVector.cross (zpri 223 G4Vector3D xprime = (fUpVector.cross (zprime)).unit (); 269 G4Vector3D yprime = zprime.cross (xprime); 224 G4Vector3D yprime = zprime.cross (xprime); 270 fActualLightpointDirection = 225 fActualLightpointDirection = 271 fRelativeLightpointDirection.x () * xpri 226 fRelativeLightpointDirection.x () * xprime + 272 fRelativeLightpointDirection.y () * ypri 227 fRelativeLightpointDirection.y () * yprime + 273 fRelativeLightpointDirection.x () * zpri 228 fRelativeLightpointDirection.x () * zprime; 274 } else { 229 } else { 275 fActualLightpointDirection = fRelativeLigh 230 fActualLightpointDirection = fRelativeLightpointDirection; 276 } 231 } 277 } 232 } 278 233 279 void G4ViewParameters::SetLightpointDirection 234 void G4ViewParameters::SetLightpointDirection 280 (const G4Vector3D& lightpointDirection) { 235 (const G4Vector3D& lightpointDirection) { 281 fRelativeLightpointDirection = lightpointDir 236 fRelativeLightpointDirection = lightpointDirection; 282 SetViewAndLights (fViewpointDirection); 237 SetViewAndLights (fViewpointDirection); 283 } 238 } 284 239 285 void G4ViewParameters::SetPan (G4double right, 240 void G4ViewParameters::SetPan (G4double right, G4double up) { 286 G4Vector3D unitRight = (fUpVector.cross (fVi 241 G4Vector3D unitRight = (fUpVector.cross (fViewpointDirection)).unit(); 287 G4Vector3D unitUp = (fViewpointDirection. 242 G4Vector3D unitUp = (fViewpointDirection.cross (unitRight)).unit(); 288 fCurrentTargetPoint = right * unitRight + u 243 fCurrentTargetPoint = right * unitRight + up * unitUp; 289 } 244 } 290 245 291 void G4ViewParameters::IncrementPan (G4double 246 void G4ViewParameters::IncrementPan (G4double right, G4double up) { 292 IncrementPan (right,up, 0); 247 IncrementPan (right,up, 0); 293 } 248 } 294 249 295 void G4ViewParameters::IncrementPan (G4double 250 void G4ViewParameters::IncrementPan (G4double right, G4double up, G4double distance) { 296 G4Vector3D unitRight = (fUpVector.cross (fVi 251 G4Vector3D unitRight = (fUpVector.cross (fViewpointDirection)).unit(); 297 G4Vector3D unitUp = (fViewpointDirection. 252 G4Vector3D unitUp = (fViewpointDirection.cross (unitRight)).unit(); 298 fCurrentTargetPoint += right * unitRight + u 253 fCurrentTargetPoint += right * unitRight + up * unitUp + distance * fViewpointDirection; 299 } 254 } 300 255 301 void G4ViewParameters::AddVisAttributesModifie 256 void G4ViewParameters::AddVisAttributesModifier 302 (const G4ModelingParameters::VisAttributesModi 257 (const G4ModelingParameters::VisAttributesModifier& vam) { 303 // If target exists with same signifier just 258 // If target exists with same signifier just change vis attributes. 304 G4bool duplicateTarget = false; 259 G4bool duplicateTarget = false; 305 auto i = fVisAttributesModifiers.begin(); 260 auto i = fVisAttributesModifiers.begin(); 306 for (; i < fVisAttributesModifiers.end(); ++ 261 for (; i < fVisAttributesModifiers.end(); ++i) { 307 if (vam.GetPVNameCopyNoPath() == (*i).GetP 262 if (vam.GetPVNameCopyNoPath() == (*i).GetPVNameCopyNoPath() && 308 vam.GetVisAttributesSignifier() == (*i 263 vam.GetVisAttributesSignifier() == (*i).GetVisAttributesSignifier()) { 309 duplicateTarget = true; 264 duplicateTarget = true; 310 break; 265 break; 311 } 266 } 312 } 267 } 313 if (duplicateTarget) (*i).SetVisAttributes(v 268 if (duplicateTarget) (*i).SetVisAttributes(vam.GetVisAttributes()); 314 else fVisAttributesModifiers.push_back(vam); 269 else fVisAttributesModifiers.push_back(vam); 315 } 270 } 316 271 317 G4String G4ViewParameters::CameraAndLightingCo 272 G4String G4ViewParameters::CameraAndLightingCommands 318 (const G4Point3D standardTargetPoint) const 273 (const G4Point3D standardTargetPoint) const 319 { 274 { 320 std::ostringstream oss; 275 std::ostringstream oss; 321 276 322 oss << "#\n# Camera and lights commands"; 277 oss << "#\n# Camera and lights commands"; 323 278 324 oss << "\n/vis/viewer/set/viewpointVector " 279 oss << "\n/vis/viewer/set/viewpointVector " 325 << fViewpointDirection.x() 280 << fViewpointDirection.x() 326 << ' ' << fViewpointDirection.y() 281 << ' ' << fViewpointDirection.y() 327 << ' ' << fViewpointDirection.z(); 282 << ' ' << fViewpointDirection.z(); 328 283 329 oss << "\n/vis/viewer/set/upVector " 284 oss << "\n/vis/viewer/set/upVector " 330 << fUpVector.x() 285 << fUpVector.x() 331 << ' ' << fUpVector.y() 286 << ' ' << fUpVector.y() 332 << ' ' << fUpVector.z(); 287 << ' ' << fUpVector.z(); 333 288 334 oss << "\n/vis/viewer/set/projection "; 289 oss << "\n/vis/viewer/set/projection "; 335 if (fFieldHalfAngle == 0.) { 290 if (fFieldHalfAngle == 0.) { 336 oss 291 oss 337 << "orthogonal"; 292 << "orthogonal"; 338 } else { 293 } else { 339 oss 294 oss 340 << "perspective " 295 << "perspective " 341 << fFieldHalfAngle/deg 296 << fFieldHalfAngle/deg 342 << " deg"; 297 << " deg"; 343 } 298 } 344 299 345 oss << "\n/vis/viewer/zoomTo " 300 oss << "\n/vis/viewer/zoomTo " 346 << fZoomFactor; 301 << fZoomFactor; 347 302 348 oss << "\n/vis/viewer/scaleTo " 303 oss << "\n/vis/viewer/scaleTo " 349 << fScaleFactor.x() 304 << fScaleFactor.x() 350 << ' ' << fScaleFactor.y() 305 << ' ' << fScaleFactor.y() 351 << ' ' << fScaleFactor.z(); 306 << ' ' << fScaleFactor.z(); 352 307 353 oss << "\n/vis/viewer/set/targetPoint " 308 oss << "\n/vis/viewer/set/targetPoint " 354 << G4BestUnit(standardTargetPoint+fCurrentTa 309 << G4BestUnit(standardTargetPoint+fCurrentTargetPoint,"Length") 355 << "\n# Note that if you have not set a targ 310 << "\n# Note that if you have not set a target point, the vis system sets" 356 << "\n# a target point based on the scene - 311 << "\n# a target point based on the scene - plus any panning and dollying -" 357 << "\n# so don't be alarmed by strange coord 312 << "\n# so don't be alarmed by strange coordinates here."; 358 313 359 oss << "\n/vis/viewer/dollyTo " 314 oss << "\n/vis/viewer/dollyTo " 360 << G4BestUnit(fDolly,"Length"); 315 << G4BestUnit(fDolly,"Length"); 361 316 362 oss << "\n/vis/viewer/set/lightsMove "; 317 oss << "\n/vis/viewer/set/lightsMove "; 363 if (fLightsMoveWithCamera) { 318 if (fLightsMoveWithCamera) { 364 oss << "camera"; 319 oss << "camera"; 365 } else { 320 } else { 366 oss << "object"; 321 oss << "object"; 367 } 322 } 368 323 369 oss << "\n/vis/viewer/set/lightsVector " 324 oss << "\n/vis/viewer/set/lightsVector " 370 << fRelativeLightpointDirection.x() 325 << fRelativeLightpointDirection.x() 371 << ' ' << fRelativeLightpointDirection.y() 326 << ' ' << fRelativeLightpointDirection.y() 372 << ' ' << fRelativeLightpointDirection.z(); 327 << ' ' << fRelativeLightpointDirection.z(); 373 328 374 oss << "\n/vis/viewer/set/rotationStyle "; 329 oss << "\n/vis/viewer/set/rotationStyle "; 375 if (fRotationStyle == constrainUpDirection) 330 if (fRotationStyle == constrainUpDirection) { 376 oss << "constrainUpDirection"; 331 oss << "constrainUpDirection"; 377 } else { 332 } else { 378 oss << "freeRotation"; 333 oss << "freeRotation"; 379 } 334 } 380 335 381 G4Colour c = fBackgroundColour; 336 G4Colour c = fBackgroundColour; 382 oss << "\n/vis/viewer/set/background " 337 oss << "\n/vis/viewer/set/background " 383 << c.GetRed() 338 << c.GetRed() 384 << ' ' << c.GetGreen() 339 << ' ' << c.GetGreen() 385 << ' ' << c.GetBlue() 340 << ' ' << c.GetBlue() 386 << ' ' << c.GetAlpha(); 341 << ' ' << c.GetAlpha(); 387 342 388 c = fDefaultVisAttributes.GetColour(); 343 c = fDefaultVisAttributes.GetColour(); 389 oss << "\n/vis/viewer/set/defaultColour " 344 oss << "\n/vis/viewer/set/defaultColour " 390 << c.GetRed() 345 << c.GetRed() 391 << ' ' << c.GetGreen() 346 << ' ' << c.GetGreen() 392 << ' ' << c.GetBlue() 347 << ' ' << c.GetBlue() 393 << ' ' << c.GetAlpha(); 348 << ' ' << c.GetAlpha(); 394 349 395 c = fDefaultTextVisAttributes.GetColour(); 350 c = fDefaultTextVisAttributes.GetColour(); 396 oss << "\n/vis/viewer/set/defaultTextColour 351 oss << "\n/vis/viewer/set/defaultTextColour " 397 << c.GetRed() 352 << c.GetRed() 398 << ' ' << c.GetGreen() 353 << ' ' << c.GetGreen() 399 << ' ' << c.GetBlue() 354 << ' ' << c.GetBlue() 400 << ' ' << c.GetAlpha(); 355 << ' ' << c.GetAlpha(); 401 356 402 oss << std::endl; 357 oss << std::endl; 403 358 404 return oss.str(); 359 return oss.str(); 405 } 360 } 406 361 407 G4String G4ViewParameters::DrawingStyleCommand 362 G4String G4ViewParameters::DrawingStyleCommands() const 408 { 363 { 409 std::ostringstream oss; 364 std::ostringstream oss; 410 365 411 oss << "#\n# Drawing style commands"; 366 oss << "#\n# Drawing style commands"; 412 367 413 oss << "\n/vis/viewer/set/style "; 368 oss << "\n/vis/viewer/set/style "; 414 switch (fDrawingStyle) { << 369 if (fDrawingStyle == wireframe || fDrawingStyle == hlr) { 415 case wireframe: << 370 oss << "wireframe"; 416 case hlr: << 371 } else { 417 oss << "wireframe"; << 372 oss << "surface"; 418 break; << 419 case hsr: << 420 case hlhsr: << 421 oss << "surface"; << 422 break; << 423 case cloud: << 424 oss << "cloud"; << 425 break; << 426 } 373 } 427 << 374 428 oss << "\n/vis/viewer/set/hiddenEdge "; 375 oss << "\n/vis/viewer/set/hiddenEdge "; 429 if (fDrawingStyle == hlr || fDrawingStyle == 376 if (fDrawingStyle == hlr || fDrawingStyle == hlhsr) { 430 oss << "true"; 377 oss << "true"; 431 } else { 378 } else { 432 oss << "false"; 379 oss << "false"; 433 } 380 } 434 381 435 oss << "\n/vis/viewer/set/auxiliaryEdge "; 382 oss << "\n/vis/viewer/set/auxiliaryEdge "; 436 if (fAuxEdgeVisible) { 383 if (fAuxEdgeVisible) { 437 oss << "true"; 384 oss << "true"; 438 } else { 385 } else { 439 oss << "false"; 386 oss << "false"; 440 } 387 } 441 388 442 oss << "\n/vis/viewer/set/hiddenMarker "; 389 oss << "\n/vis/viewer/set/hiddenMarker "; 443 if (fMarkerNotHidden) { 390 if (fMarkerNotHidden) { 444 oss << "false"; 391 oss << "false"; 445 } else { 392 } else { 446 oss << "true"; 393 oss << "true"; 447 } 394 } 448 395 449 oss << "\n/vis/viewer/set/globalLineWidthSca 396 oss << "\n/vis/viewer/set/globalLineWidthScale " 450 << fGlobalLineWidthScale; 397 << fGlobalLineWidthScale; 451 398 452 oss << "\n/vis/viewer/set/globalMarkerScale 399 oss << "\n/vis/viewer/set/globalMarkerScale " 453 << fGlobalMarkerScale; 400 << fGlobalMarkerScale; 454 << 401 455 oss << "\n/vis/viewer/set/numberOfCloudPoint << 456 << fNumberOfCloudPoints; << 457 << 458 oss << "\n/vis/viewer/set/specialMeshRenderi << 459 if (fSpecialMeshRendering) { << 460 oss << "true"; << 461 } else { << 462 oss << "false"; << 463 } << 464 << 465 oss << "\n/vis/viewer/set/specialMeshRenderi << 466 << fSpecialMeshRenderingOption; << 467 << 468 oss << "\n/vis/viewer/set/specialMeshVolumes << 469 for (const auto& volume : fSpecialMeshVolume << 470 oss << ' ' << volume.GetName() << ' ' << v << 471 } << 472 << 473 oss << std::endl; 402 oss << std::endl; 474 403 475 return oss.str(); 404 return oss.str(); 476 } 405 } 477 406 478 G4String G4ViewParameters::SceneModifyingComma 407 G4String G4ViewParameters::SceneModifyingCommands() const 479 { 408 { 480 std::ostringstream oss; 409 std::ostringstream oss; 481 410 482 oss << "#\n# Scene-modifying commands"; 411 oss << "#\n# Scene-modifying commands"; 483 412 484 oss << "\n/vis/viewer/set/culling global "; 413 oss << "\n/vis/viewer/set/culling global "; 485 if (fCulling) { 414 if (fCulling) { 486 oss << "true"; 415 oss << "true"; 487 } else { 416 } else { 488 oss << "false"; 417 oss << "false"; 489 } 418 } 490 419 491 oss << "\n/vis/viewer/set/culling invisible 420 oss << "\n/vis/viewer/set/culling invisible "; 492 if (fCullInvisible) { 421 if (fCullInvisible) { 493 oss << "true"; 422 oss << "true"; 494 } else { 423 } else { 495 oss << "false"; 424 oss << "false"; 496 } 425 } 497 426 498 oss << "\n/vis/viewer/set/culling density "; 427 oss << "\n/vis/viewer/set/culling density "; 499 if (fDensityCulling) { 428 if (fDensityCulling) { 500 oss << "true " << fVisibleDensity/(g/cm3) 429 oss << "true " << fVisibleDensity/(g/cm3) << " g/cm3"; 501 } else { 430 } else { 502 oss << "false"; 431 oss << "false"; 503 } 432 } 504 433 505 oss << "\n/vis/viewer/set/culling coveredDau 434 oss << "\n/vis/viewer/set/culling coveredDaughters "; 506 if (fCullCovered) { 435 if (fCullCovered) { 507 oss << "true"; 436 oss << "true"; 508 } else { 437 } else { 509 oss << "false"; 438 oss << "false"; 510 } 439 } 511 << 440 512 oss << "\n/vis/viewer/colourByDensity " << 513 << fCBDAlgorithmNumber << " g/cm3"; << 514 for (auto p: fCBDParameters) { << 515 oss << ' ' << p/(g/cm3); << 516 } << 517 << 518 oss << "\n/vis/viewer/set/sectionPlane "; 441 oss << "\n/vis/viewer/set/sectionPlane "; 519 if (fSection) { 442 if (fSection) { 520 oss << "on " 443 oss << "on " 521 << G4BestUnit(fSectionPlane.point(),"Lengt 444 << G4BestUnit(fSectionPlane.point(),"Length") 522 << fSectionPlane.normal().x() 445 << fSectionPlane.normal().x() 523 << ' ' << fSectionPlane.normal().y() 446 << ' ' << fSectionPlane.normal().y() 524 << ' ' << fSectionPlane.normal().z(); 447 << ' ' << fSectionPlane.normal().z(); 525 } else { 448 } else { 526 oss << "off"; 449 oss << "off"; 527 } 450 } 528 451 529 oss << "\n/vis/viewer/set/cutawayMode "; 452 oss << "\n/vis/viewer/set/cutawayMode "; 530 if (fCutawayMode == cutawayUnion) { 453 if (fCutawayMode == cutawayUnion) { 531 oss << "union"; 454 oss << "union"; 532 } else { 455 } else { 533 oss << "intersection"; 456 oss << "intersection"; 534 } 457 } 535 458 536 oss << "\n/vis/viewer/clearCutawayPlanes"; 459 oss << "\n/vis/viewer/clearCutawayPlanes"; 537 if (fCutawayPlanes.size()) { 460 if (fCutawayPlanes.size()) { 538 for (size_t i = 0; i < fCutawayPlanes.size 461 for (size_t i = 0; i < fCutawayPlanes.size(); i++) { 539 oss << "\n/vis/viewer/addCutawayPlane " 462 oss << "\n/vis/viewer/addCutawayPlane " 540 << G4BestUnit(fCutawayPlanes[i].point(), 463 << G4BestUnit(fCutawayPlanes[i].point(),"Length") 541 << fCutawayPlanes[i].normal().x() 464 << fCutawayPlanes[i].normal().x() 542 << ' ' << fCutawayPlanes[i].normal().y() 465 << ' ' << fCutawayPlanes[i].normal().y() 543 << ' ' << fCutawayPlanes[i].normal().z() 466 << ' ' << fCutawayPlanes[i].normal().z(); 544 } 467 } 545 } else { 468 } else { 546 oss << "\n# No cutaway planes defined."; 469 oss << "\n# No cutaway planes defined."; 547 } 470 } 548 471 549 oss << "\n/vis/viewer/set/explodeFactor " 472 oss << "\n/vis/viewer/set/explodeFactor " 550 << fExplodeFactor 473 << fExplodeFactor 551 << ' ' << G4BestUnit(fExplodeCentre,"Length" 474 << ' ' << G4BestUnit(fExplodeCentre,"Length"); 552 475 553 oss << "\n/vis/viewer/set/lineSegmentsPerCir 476 oss << "\n/vis/viewer/set/lineSegmentsPerCircle " 554 << fNoOfSides; 477 << fNoOfSides; 555 478 556 oss << std::endl; 479 oss << std::endl; 557 480 558 return oss.str(); 481 return oss.str(); 559 } 482 } 560 483 561 G4String G4ViewParameters::TouchableCommands() 484 G4String G4ViewParameters::TouchableCommands() const 562 { 485 { 563 std::ostringstream oss; 486 std::ostringstream oss; 564 487 565 oss << "#\n# Touchable commands"; << 488 oss 566 << 489 << "#\n# Touchable commands" >> 490 << "\n/vis/viewer/clearVisAttributesModifiers"; >> 491 567 const std::vector<G4ModelingParameters::VisA 492 const std::vector<G4ModelingParameters::VisAttributesModifier>& vams = 568 fVisAttributesModifiers; 493 fVisAttributesModifiers; 569 494 570 if (vams.empty()) { 495 if (vams.empty()) { 571 oss << 496 oss << "\n# None"; 572 << "\n# None" << 573 << "\n/vis/viewer/clearVisAttributesModifi << 574 oss << std::endl; 497 oss << std::endl; 575 return oss.str(); 498 return oss.str(); 576 } 499 } 577 << 500 578 oss << 579 << "\n/vis/viewer/clearVisAttributesModifier << 580 << 581 G4ModelingParameters::PVNameCopyNoPath lastP 501 G4ModelingParameters::PVNameCopyNoPath lastPath; 582 std::vector<G4ModelingParameters::VisAttribu 502 std::vector<G4ModelingParameters::VisAttributesModifier>::const_iterator 583 iModifier; 503 iModifier; 584 for (iModifier = vams.begin(); 504 for (iModifier = vams.begin(); 585 iModifier != vams.end(); 505 iModifier != vams.end(); 586 ++iModifier) { 506 ++iModifier) { 587 const G4ModelingParameters::PVNameCopyNoPa 507 const G4ModelingParameters::PVNameCopyNoPath& vamPath = 588 iModifier->GetPVNameCopyNoPath(); 508 iModifier->GetPVNameCopyNoPath(); 589 if (vamPath != lastPath) { 509 if (vamPath != lastPath) { 590 lastPath = vamPath; 510 lastPath = vamPath; 591 oss << "\n/vis/set/touchable"; 511 oss << "\n/vis/set/touchable"; 592 G4ModelingParameters::PVNameCopyNoPathCo 512 G4ModelingParameters::PVNameCopyNoPathConstIterator iVAM; 593 for (iVAM = vamPath.begin(); 513 for (iVAM = vamPath.begin(); 594 iVAM != vamPath.end(); 514 iVAM != vamPath.end(); 595 ++iVAM) { 515 ++iVAM) { 596 oss << ' ' << iVAM->GetName() << ' ' < 516 oss << ' ' << iVAM->GetName() << ' ' << iVAM->GetCopyNo(); 597 } 517 } 598 } 518 } 599 const G4VisAttributes& vamVisAtts = iModif 519 const G4VisAttributes& vamVisAtts = iModifier->GetVisAttributes(); 600 const G4Colour& c = vamVisAtts.GetColour() 520 const G4Colour& c = vamVisAtts.GetColour(); 601 switch (iModifier->GetVisAttributesSignifi 521 switch (iModifier->GetVisAttributesSignifier()) { 602 case G4ModelingParameters::VASVisibility 522 case G4ModelingParameters::VASVisibility: 603 oss << "\n/vis/touchable/set/visibilit 523 oss << "\n/vis/touchable/set/visibility "; 604 if (vamVisAtts.IsVisible()) { 524 if (vamVisAtts.IsVisible()) { 605 oss << "true"; 525 oss << "true"; 606 } else { 526 } else { 607 oss << "false"; 527 oss << "false"; 608 } 528 } 609 break; 529 break; 610 case G4ModelingParameters::VASDaughtersI 530 case G4ModelingParameters::VASDaughtersInvisible: 611 oss << "\n/vis/touchable/set/daughters 531 oss << "\n/vis/touchable/set/daughtersInvisible "; 612 if (vamVisAtts.IsDaughtersInvisible()) 532 if (vamVisAtts.IsDaughtersInvisible()) { 613 oss << "true"; 533 oss << "true"; 614 } else { 534 } else { 615 oss << "false"; 535 oss << "false"; 616 } 536 } 617 break; 537 break; 618 case G4ModelingParameters::VASColour: 538 case G4ModelingParameters::VASColour: 619 oss << "\n/vis/touchable/set/colour " 539 oss << "\n/vis/touchable/set/colour " 620 << c.GetRed() 540 << c.GetRed() 621 << ' ' << c.GetGreen() 541 << ' ' << c.GetGreen() 622 << ' ' << c.GetBlue() 542 << ' ' << c.GetBlue() 623 << ' ' << c.GetAlpha(); 543 << ' ' << c.GetAlpha(); 624 break; 544 break; 625 case G4ModelingParameters::VASLineStyle: 545 case G4ModelingParameters::VASLineStyle: 626 oss << "\n/vis/touchable/set/lineStyle 546 oss << "\n/vis/touchable/set/lineStyle "; 627 switch (vamVisAtts.GetLineStyle()) { 547 switch (vamVisAtts.GetLineStyle()) { 628 case G4VisAttributes::unbroken: 548 case G4VisAttributes::unbroken: 629 oss << "unbroken"; 549 oss << "unbroken"; 630 break; 550 break; 631 case G4VisAttributes::dashed: 551 case G4VisAttributes::dashed: 632 oss << "dashed"; 552 oss << "dashed"; 633 break; 553 break; 634 case G4VisAttributes::dotted: 554 case G4VisAttributes::dotted: 635 oss << "dotted"; 555 oss << "dotted"; 636 } 556 } 637 break; 557 break; 638 case G4ModelingParameters::VASLineWidth: 558 case G4ModelingParameters::VASLineWidth: 639 oss << "\n/vis/touchable/set/lineWidth 559 oss << "\n/vis/touchable/set/lineWidth " 640 << vamVisAtts.GetLineWidth(); 560 << vamVisAtts.GetLineWidth(); 641 break; 561 break; 642 case G4ModelingParameters::VASForceWiref 562 case G4ModelingParameters::VASForceWireframe: 643 if (vamVisAtts.IsForceDrawingStyle()) 563 if (vamVisAtts.IsForceDrawingStyle()) { 644 if (vamVisAtts.GetForcedDrawingStyle 564 if (vamVisAtts.GetForcedDrawingStyle() == G4VisAttributes::wireframe) { 645 oss << "\n/vis/touchable/set/force 565 oss << "\n/vis/touchable/set/forceWireframe "; 646 if (vamVisAtts.IsForceDrawingStyle 566 if (vamVisAtts.IsForceDrawingStyle()) { 647 oss << "true"; 567 oss << "true"; 648 } else { 568 } else { 649 oss << "false"; 569 oss << "false"; 650 } 570 } 651 } 571 } 652 } 572 } 653 break; 573 break; 654 case G4ModelingParameters::VASForceSolid 574 case G4ModelingParameters::VASForceSolid: 655 if (vamVisAtts.IsForceDrawingStyle()) 575 if (vamVisAtts.IsForceDrawingStyle()) { 656 if (vamVisAtts.GetForcedDrawingStyle 576 if (vamVisAtts.GetForcedDrawingStyle() == G4VisAttributes::solid) { 657 oss << "\n/vis/touchable/set/force 577 oss << "\n/vis/touchable/set/forceSolid "; 658 if (vamVisAtts.IsForceDrawingStyle 578 if (vamVisAtts.IsForceDrawingStyle()) { 659 oss << "true"; 579 oss << "true"; 660 } else { 580 } else { 661 oss << "false"; 581 oss << "false"; 662 } 582 } 663 } 583 } 664 } 584 } 665 break; 585 break; 666 case G4ModelingParameters::VASForceCloud << 667 if (vamVisAtts.IsForceDrawingStyle()) << 668 if (vamVisAtts.GetForcedDrawingStyle << 669 oss << "\n/vis/touchable/set/force << 670 if (vamVisAtts.IsForceDrawingStyle << 671 oss << "true"; << 672 } else { << 673 oss << "false"; << 674 } << 675 } << 676 } << 677 break; << 678 case G4ModelingParameters::VASForceAuxEd 586 case G4ModelingParameters::VASForceAuxEdgeVisible: 679 if (vamVisAtts.IsForceAuxEdgeVisible() 587 if (vamVisAtts.IsForceAuxEdgeVisible()) { 680 oss << "\n/vis/touchable/set/forceAu 588 oss << "\n/vis/touchable/set/forceAuxEdgeVisible "; 681 if (vamVisAtts.IsForcedAuxEdgeVisibl 589 if (vamVisAtts.IsForcedAuxEdgeVisible()) { 682 oss << "true"; 590 oss << "true"; 683 } else { 591 } else { 684 oss << "false"; 592 oss << "false"; 685 } 593 } 686 } 594 } 687 break; 595 break; 688 case G4ModelingParameters::VASForceLineS 596 case G4ModelingParameters::VASForceLineSegmentsPerCircle: 689 oss << "\n/vis/touchable/set/lineSegme << 597 if (vamVisAtts.GetForcedLineSegmentsPerCircle() > 0) { 690 << vamVisAtts.GetForcedLineSegmentsPer << 598 oss << "\n/vis/touchable/set/lineSegmentsPerCircle " 691 break; << 599 << vamVisAtts.GetForcedLineSegmentsPerCircle(); 692 case G4ModelingParameters::VASForceNumbe << 600 } 693 oss << "\n/vis/touchable/set/numberOfC << 694 << vamVisAtts.GetForcedNumberOfCloudPo << 695 break; 601 break; 696 } 602 } 697 } 603 } 698 604 699 oss << std::endl; 605 oss << std::endl; 700 606 701 return oss.str(); 607 return oss.str(); 702 } 608 } 703 609 704 G4String G4ViewParameters::TimeWindowCommands( << 705 { << 706 std::ostringstream oss; << 707 << 708 oss << "#\n# Time window commands"; << 709 << 710 oss << 711 << "\n/vis/viewer/set/timeWindow/startTime " << 712 << fStartTime/ns << " ns "; << 713 << 714 oss << 715 << "\n/vis/viewer/set/timeWindow/endTime " << 716 << fEndTime/ns << " ns "; << 717 << 718 oss << "\n/vis/viewer/set/timeWindow/fadeFac << 719 << fFadeFactor; << 720 << 721 oss << 722 << "\n/vis/viewer/set/timeWindow/displayHead << 723 if (!fDisplayHeadTime) { << 724 oss << "false"; << 725 } else { << 726 oss << 727 << "true" << 728 << ' ' << fDisplayHeadTimeX << 729 << ' ' << fDisplayHeadTimeY << 730 << ' ' << fDisplayHeadTimeSize << 731 << ' ' << fDisplayHeadTimeRed << 732 << ' ' << fDisplayHeadTimeGreen << 733 << ' ' << fDisplayHeadTimeBlue; << 734 } << 735 << 736 oss << 737 << "\n/vis/viewer/set/timeWindow/displayLigh << 738 if (!fDisplayLightFront) { << 739 oss << "false"; << 740 } else { << 741 oss << 742 << "true" << 743 << ' ' << fDisplayLightFrontX/mm << 744 << ' ' << fDisplayLightFrontY/mm << 745 << ' ' << fDisplayLightFrontZ/mm << 746 << " mm" << 747 << ' ' << fDisplayLightFrontT/ns << 748 << " ns" << 749 << ' ' << fDisplayLightFrontRed << 750 << ' ' << fDisplayLightFrontGreen << 751 << ' ' << fDisplayLightFrontBlue; << 752 } << 753 << 754 oss << std::endl; << 755 << 756 return oss.str(); << 757 } << 758 << 759 void G4ViewParameters::PrintDifferences (const 610 void G4ViewParameters::PrintDifferences (const G4ViewParameters& v) const { 760 611 761 // Put performance-sensitive parameters firs 612 // Put performance-sensitive parameters first. 762 if ( 613 if ( 763 // This first to optimise spin, etc. 614 // This first to optimise spin, etc. 764 (fViewpointDirection != v.fViewpointDi 615 (fViewpointDirection != v.fViewpointDirection) || 765 616 766 // No particular order from here on. 617 // No particular order from here on. 767 (fDrawingStyle != v.fDrawingStyl 618 (fDrawingStyle != v.fDrawingStyle) || 768 (fNumberOfCloudPoints != v.fNumberOfClo << 769 (fAuxEdgeVisible != v.fAuxEdgeVisi 619 (fAuxEdgeVisible != v.fAuxEdgeVisible) || 770 (fCulling != v.fCulling) 620 (fCulling != v.fCulling) || 771 (fCullInvisible != v.fCullInvisib 621 (fCullInvisible != v.fCullInvisible) || 772 (fDensityCulling != v.fDensityCull 622 (fDensityCulling != v.fDensityCulling) || 773 (fVisibleDensity != v.fVisibleDens 623 (fVisibleDensity != v.fVisibleDensity) || 774 (fCullCovered != v.fCullCovered 624 (fCullCovered != v.fCullCovered) || 775 (fCBDAlgorithmNumber != v.fCBDAlgorith << 776 (fSection != v.fSection) 625 (fSection != v.fSection) || 777 (fNoOfSides != v.fNoOfSides) 626 (fNoOfSides != v.fNoOfSides) || 778 (fUpVector != v.fUpVector) 627 (fUpVector != v.fUpVector) || 779 (fFieldHalfAngle != v.fFieldHalfAn 628 (fFieldHalfAngle != v.fFieldHalfAngle) || 780 (fZoomFactor != v.fZoomFactor) 629 (fZoomFactor != v.fZoomFactor) || 781 (fScaleFactor != v.fScaleFactor 630 (fScaleFactor != v.fScaleFactor) || 782 (fCurrentTargetPoint != v.fCurrentTarg 631 (fCurrentTargetPoint != v.fCurrentTargetPoint) || 783 (fDolly != v.fDolly) 632 (fDolly != v.fDolly) || 784 (fRelativeLightpointDirection != v.fRela 633 (fRelativeLightpointDirection != v.fRelativeLightpointDirection) || 785 (fLightsMoveWithCamera != v.fLightsMoveW 634 (fLightsMoveWithCamera != v.fLightsMoveWithCamera) || 786 (fDefaultVisAttributes != v.fDefaultVisA 635 (fDefaultVisAttributes != v.fDefaultVisAttributes) || 787 (fDefaultTextVisAttributes != v.fDefault 636 (fDefaultTextVisAttributes != v.fDefaultTextVisAttributes) || 788 (fDefaultMarker != v.fDefaultMark 637 (fDefaultMarker != v.fDefaultMarker) || 789 (fGlobalMarkerScale != v.fGlobalMarke 638 (fGlobalMarkerScale != v.fGlobalMarkerScale) || 790 (fGlobalLineWidthScale != v.fGlobalLineW 639 (fGlobalLineWidthScale != v.fGlobalLineWidthScale) || 791 (fMarkerNotHidden != v.fMarkerNotHi 640 (fMarkerNotHidden != v.fMarkerNotHidden) || 792 (fWindowSizeHintX != v.fWindowSizeH 641 (fWindowSizeHintX != v.fWindowSizeHintX) || 793 (fWindowSizeHintY != v.fWindowSizeH 642 (fWindowSizeHintY != v.fWindowSizeHintY) || 794 (fXGeometryString != v.fXGeometrySt 643 (fXGeometryString != v.fXGeometryString) || 795 (fGeometryMask != v.fGeometryMas 644 (fGeometryMask != v.fGeometryMask) || 796 (fAutoRefresh != v.fAutoRefresh 645 (fAutoRefresh != v.fAutoRefresh) || 797 (fBackgroundColour != v.fBackgroundC 646 (fBackgroundColour != v.fBackgroundColour) || 798 (fPicking != v.fPicking) 647 (fPicking != v.fPicking) || 799 (fRotationStyle != v.fRotationSty 648 (fRotationStyle != v.fRotationStyle) 800 ) 649 ) 801 G4cout << "Difference in 1st batch." << G4 650 G4cout << "Difference in 1st batch." << G4endl; 802 651 803 if (fCBDAlgorithmNumber > 0) { << 804 if (fCBDParameters.size() != v.fCBDParamet << 805 G4cout << "Difference in number of colou << 806 } else if (fCBDParameters != v.fCBDParamet << 807 G4cout << "Difference in values of colou << 808 } << 809 } << 810 << 811 if (fSection) { 652 if (fSection) { 812 if (!(fSectionPlane == v.fSectionPlane)) 653 if (!(fSectionPlane == v.fSectionPlane)) 813 G4cout << "Difference in section planes 654 G4cout << "Difference in section planes batch." << G4endl; 814 } 655 } 815 656 816 if (IsCutaway()) { 657 if (IsCutaway()) { 817 if (fCutawayPlanes.size () != v.fCutawayPl 658 if (fCutawayPlanes.size () != v.fCutawayPlanes.size ()) { 818 G4cout << "Difference in no of cutaway p 659 G4cout << "Difference in no of cutaway planes." << G4endl; 819 } 660 } 820 else { 661 else { 821 for (size_t i = 0; i < fCutawayPlanes.si 662 for (size_t i = 0; i < fCutawayPlanes.size (); i++) { 822 if (!(fCutawayPlanes[i] == v.fCutawayPlanes[ 663 if (!(fCutawayPlanes[i] == v.fCutawayPlanes[i])) 823 G4cout << "Difference in cutaway plane no. 664 G4cout << "Difference in cutaway plane no. " << i << G4endl; 824 } 665 } 825 } 666 } 826 } 667 } 827 668 828 if (IsExplode()) { 669 if (IsExplode()) { 829 if (fExplodeFactor != v.fExplodeFactor) 670 if (fExplodeFactor != v.fExplodeFactor) 830 G4cout << "Difference in explode factor. 671 G4cout << "Difference in explode factor." << G4endl; 831 if (fExplodeCentre != v.fExplodeCentre) 672 if (fExplodeCentre != v.fExplodeCentre) 832 G4cout << "Difference in explode centre. 673 G4cout << "Difference in explode centre." << G4endl; 833 } 674 } 834 675 835 if (fVisAttributesModifiers != v.fVisAttribu 676 if (fVisAttributesModifiers != v.fVisAttributesModifiers) { 836 G4cout << "Difference in vis attributes mo 677 G4cout << "Difference in vis attributes modifiers." << G4endl; 837 } 678 } 838 << 839 if (fStartTime != v.fStartTime || << 840 fEndTime != v.fEndTime) { << 841 G4cout << "Difference in time window." << << 842 } << 843 << 844 if (fFadeFactor != v.fFadeFactor) { << 845 G4cout << "Difference in time window fade << 846 } << 847 << 848 if (fDisplayHeadTime != v.fDisplayHeadTime) << 849 G4cout << "Difference in display head time << 850 } else { << 851 if (fDisplayHeadTimeX != v.fDisplayHea << 852 fDisplayHeadTimeY != v.fDisplayHea << 853 fDisplayHeadTimeSize != v.fDisplayHea << 854 fDisplayHeadTimeRed != v.fDisplayHea << 855 fDisplayHeadTimeGreen != v.fDisplayHea << 856 fDisplayHeadTimeBlue != v.fDisplayHea << 857 G4cout << "Difference in display head ti << 858 } << 859 } << 860 << 861 if (fDisplayLightFront != v.fDisplayLightFro << 862 G4cout << "Difference in display light fro << 863 } else { << 864 if (fDisplayLightFrontX != v.fDisplayL << 865 fDisplayLightFrontY != v.fDisplayL << 866 fDisplayLightFrontZ != v.fDisplayL << 867 fDisplayLightFrontT != v.fDisplayL << 868 fDisplayLightFrontRed != v.fDisplayL << 869 fDisplayLightFrontGreen != v.fDisplayL << 870 fDisplayLightFrontBlue != v.fDisplayL << 871 G4cout << "Difference in display light f << 872 } << 873 } << 874 } 679 } 875 680 876 std::ostream& operator << << 681 std::ostream& operator << (std::ostream& os, 877 (std::ostream& os, G4ViewParameters::DrawingS << 682 const G4ViewParameters::DrawingStyle& style) { 878 { << 879 switch (style) { 683 switch (style) { 880 case G4ViewParameters::wireframe: << 684 case G4ViewParameters::wireframe: 881 os << "wireframe"; break; << 685 os << "wireframe"; break; 882 case G4ViewParameters::hlr: << 686 case G4ViewParameters::hlr: 883 os << "hlr - hidden lines removed"; brea << 687 os << "hlr - hidden lines removed"; break; 884 case G4ViewParameters::hsr: << 688 case G4ViewParameters::hsr: 885 os << "hsr - hidden surfaces removed"; b << 689 os << "hsr - hidden surfaces removed"; break; 886 case G4ViewParameters::hlhsr: << 690 case G4ViewParameters::hlhsr: 887 os << "hlhsr - hidden line, hidden surfa << 691 os << "hlhsr - hidden line, hidden surface removed"; break; 888 case G4ViewParameters::cloud: << 692 default: os << "unrecognised"; break; 889 os << "cloud - draw volume as a cloud of << 890 default: os << "unrecognised"; break; << 891 } << 892 return os; << 893 } << 894 << 895 std::ostream& operator << << 896 (std::ostream& os, G4ViewParameters::SMROption << 897 { << 898 switch (option) { << 899 case G4ViewParameters::meshAsDefault: << 900 os << "default"; break; << 901 case G4ViewParameters::meshAsDots: << 902 os << "dots"; break; << 903 case G4ViewParameters::meshAsSurfaces: << 904 os << "surfaces"; break; << 905 } 693 } 906 return os; 694 return os; 907 } 695 } 908 696 909 std::ostream& operator << (std::ostream& os, c 697 std::ostream& operator << (std::ostream& os, const G4ViewParameters& v) { 910 os << "View parameters and options:"; 698 os << "View parameters and options:"; 911 699 912 os << "\n Drawing style: " << v.fDrawingSty << 700 os << "\n Drawing style: "; 913 << 701 switch (v.fDrawingStyle) { 914 os << "\n Number of cloud points: " << v.fN << 702 case G4ViewParameters::wireframe: >> 703 os << "edges, wireframe"; break; >> 704 case G4ViewParameters::hlr: >> 705 os << "edges, hidden line removal"; break; >> 706 case G4ViewParameters::hsr: >> 707 os << "surfaces, hidden surface removal"; break; >> 708 case G4ViewParameters::hlhsr: >> 709 os << "surfaces and edges, hidden line and surface removal"; break; >> 710 default: os << "unrecognised"; break; >> 711 } 915 712 916 os << "\n Auxiliary edges: "; 713 os << "\n Auxiliary edges: "; 917 if (!v.fAuxEdgeVisible) os << "in"; 714 if (!v.fAuxEdgeVisible) os << "in"; 918 os << "visible"; 715 os << "visible"; 919 716 920 os << "\n Culling: "; 717 os << "\n Culling: "; 921 if (v.fCulling) os << "on"; 718 if (v.fCulling) os << "on"; 922 else os << "off"; 719 else os << "off"; 923 720 924 os << "\n Culling invisible objects: "; 721 os << "\n Culling invisible objects: "; 925 if (v.fCullInvisible) os << "on"; 722 if (v.fCullInvisible) os << "on"; 926 else os << "off"; 723 else os << "off"; 927 724 928 os << "\n Density culling: "; 725 os << "\n Density culling: "; 929 if (v.fDensityCulling) { 726 if (v.fDensityCulling) { 930 os << "on - invisible if density less than 727 os << "on - invisible if density less than " 931 << v.fVisibleDensity / (1. * g / cm3) < 728 << v.fVisibleDensity / (1. * g / cm3) << " g cm^-3"; 932 } 729 } 933 else os << "off"; 730 else os << "off"; 934 731 935 os << "\n Culling daughters covered by opaq 732 os << "\n Culling daughters covered by opaque mothers: "; 936 if (v.fCullCovered) os << "on"; 733 if (v.fCullCovered) os << "on"; 937 else os << "off"; 734 else os << "off"; 938 735 939 os << "\n Colour by density: "; << 940 if (v.fCBDAlgorithmNumber <= 0) { << 941 os << "inactive"; << 942 } else { << 943 os << "Algorithm " << v.fCBDAlgorithmNumbe << 944 for (auto p: v.fCBDParameters) { << 945 os << ' ' << G4BestUnit(p,"Volumic Mass" << 946 } << 947 } << 948 << 949 os << "\n Section flag: "; 736 os << "\n Section flag: "; 950 if (v.fSection) os << "true, section/cut pla 737 if (v.fSection) os << "true, section/cut plane: " << v.fSectionPlane; 951 else os << "false"; 738 else os << "false"; 952 739 953 if (v.IsCutaway()) { 740 if (v.IsCutaway()) { 954 os << "\n Cutaway planes: "; 741 os << "\n Cutaway planes: "; 955 for (size_t i = 0; i < v.fCutawayPlanes.si 742 for (size_t i = 0; i < v.fCutawayPlanes.size (); i++) { 956 os << ' ' << v.fCutawayPlanes[i]; 743 os << ' ' << v.fCutawayPlanes[i]; 957 } 744 } 958 } 745 } 959 else { 746 else { 960 os << "\n No cutaway planes"; 747 os << "\n No cutaway planes"; 961 } 748 } 962 749 963 os << "\n Explode factor: " << v.fExplodeFa 750 os << "\n Explode factor: " << v.fExplodeFactor 964 << " about centre: " << v.fExplodeCentre; 751 << " about centre: " << v.fExplodeCentre; 965 752 966 os << "\n No. of sides used in circle polyg 753 os << "\n No. of sides used in circle polygon approximation: " 967 << v.fNoOfSides; 754 << v.fNoOfSides; 968 755 969 os << "\n Viewpoint direction: " << v.fVie 756 os << "\n Viewpoint direction: " << v.fViewpointDirection; 970 757 971 os << "\n Up vector: " << v.fUpV 758 os << "\n Up vector: " << v.fUpVector; 972 759 973 os << "\n Field half angle: " << v.fFie 760 os << "\n Field half angle: " << v.fFieldHalfAngle; 974 761 975 os << "\n Zoom factor: " << v.fZoo 762 os << "\n Zoom factor: " << v.fZoomFactor; 976 763 977 os << "\n Scale factor: " << v.fSca 764 os << "\n Scale factor: " << v.fScaleFactor; 978 765 979 os << "\n Current target point: " << v.fCur 766 os << "\n Current target point: " << v.fCurrentTargetPoint; 980 767 981 os << "\n Dolly distance: " << v.fDol 768 os << "\n Dolly distance: " << v.fDolly; 982 769 983 os << "\n Light "; 770 os << "\n Light "; 984 if (v.fLightsMoveWithCamera) os << "moves"; 771 if (v.fLightsMoveWithCamera) os << "moves"; 985 else os << "does not 772 else os << "does not move"; 986 os << " with camera"; 773 os << " with camera"; 987 774 988 os << "\n Relative lightpoint direction: " 775 os << "\n Relative lightpoint direction: " 989 << v.fRelativeLightpointDirection; 776 << v.fRelativeLightpointDirection; 990 777 991 os << "\n Actual lightpoint direction: " 778 os << "\n Actual lightpoint direction: " 992 << v.fActualLightpointDirection; 779 << v.fActualLightpointDirection; 993 780 994 os << "\n Derived parameters for standard v 781 os << "\n Derived parameters for standard view of object of unit radius:"; 995 G4ViewParameters tempVP = v; 782 G4ViewParameters tempVP = v; 996 tempVP.fDolly = 0.; 783 tempVP.fDolly = 0.; 997 tempVP.fZoomFactor = 1.; 784 tempVP.fZoomFactor = 1.; 998 const G4double radius = 1.; 785 const G4double radius = 1.; 999 const G4double cameraDistance = tempVP.GetCa 786 const G4double cameraDistance = tempVP.GetCameraDistance (radius); 1000 const G4double nearDistance = 787 const G4double nearDistance = 1001 tempVP.GetNearDistance (cameraDistance, r 788 tempVP.GetNearDistance (cameraDistance, radius); 1002 const G4double farDistance = 789 const G4double farDistance = 1003 tempVP.GetFarDistance (cameraDistance, n 790 tempVP.GetFarDistance (cameraDistance, nearDistance, radius); 1004 const G4double right = tempVP.GetFrontHalf 791 const G4double right = tempVP.GetFrontHalfHeight (nearDistance, radius); 1005 os << "\n Camera distance: " << camera 792 os << "\n Camera distance: " << cameraDistance; 1006 os << "\n Near distance: " << nearDi 793 os << "\n Near distance: " << nearDistance; 1007 os << "\n Far distance: " << farDis 794 os << "\n Far distance: " << farDistance; 1008 os << "\n Front half height: " << right; 795 os << "\n Front half height: " << right; 1009 796 1010 os << "\n Default VisAttributes:\n " << v 797 os << "\n Default VisAttributes:\n " << v.fDefaultVisAttributes; 1011 798 1012 os << "\n Default TextVisAttributes:\n " 799 os << "\n Default TextVisAttributes:\n " << v.fDefaultTextVisAttributes; 1013 800 1014 os << "\n Default marker:\n " << v.fDef << 801 os << "\n Default marker: " << v.fDefaultMarker; 1015 802 1016 os << "\n Global marker scale: " << v.fGlo 803 os << "\n Global marker scale: " << v.fGlobalMarkerScale; 1017 804 1018 os << "\n Global lineWidth scale: " << v.f 805 os << "\n Global lineWidth scale: " << v.fGlobalLineWidthScale; 1019 806 1020 os << "\n Marker "; 807 os << "\n Marker "; 1021 if (v.fMarkerNotHidden) os << "not "; 808 if (v.fMarkerNotHidden) os << "not "; 1022 os << "hidden by surfaces."; 809 os << "hidden by surfaces."; 1023 810 1024 os << "\n Window size hint: " 811 os << "\n Window size hint: " 1025 << v.fWindowSizeHintX << 'x'<< v.fWindow 812 << v.fWindowSizeHintX << 'x'<< v.fWindowSizeHintX; 1026 813 1027 os << "\n X geometry string: " << v.fXGeom 814 os << "\n X geometry string: " << v.fXGeometryString; 1028 os << "\n X geometry mask: " 815 os << "\n X geometry mask: " 1029 << std::showbase << std::hex << v.fGeome 816 << std::showbase << std::hex << v.fGeometryMask 1030 << std::noshowbase << std::dec; 817 << std::noshowbase << std::dec; 1031 818 1032 os << "\n Auto refresh: "; 819 os << "\n Auto refresh: "; 1033 if (v.fAutoRefresh) os << "true"; 820 if (v.fAutoRefresh) os << "true"; 1034 else os << "false"; 821 else os << "false"; 1035 822 1036 os << "\n Background colour: " << v.fBackg 823 os << "\n Background colour: " << v.fBackgroundColour; 1037 824 1038 os << "\n Picking requested: "; 825 os << "\n Picking requested: "; 1039 if (v.fPicking) os << "true"; 826 if (v.fPicking) os << "true"; 1040 else os << "false"; 827 else os << "false"; 1041 828 1042 os << "\n Rotation style: "; 829 os << "\n Rotation style: "; 1043 switch (v.fRotationStyle) { 830 switch (v.fRotationStyle) { 1044 case G4ViewParameters::constrainUpDirection 831 case G4ViewParameters::constrainUpDirection: 1045 os << "constrainUpDirection (conventional 832 os << "constrainUpDirection (conventional HEP view)"; break; 1046 case G4ViewParameters::freeRotation: 833 case G4ViewParameters::freeRotation: 1047 os << "freeRotation (Google-like rotation 834 os << "freeRotation (Google-like rotation, using mouse-grab)"; break; 1048 default: os << "unrecognised"; break; 835 default: os << "unrecognised"; break; 1049 } 836 } 1050 837 1051 os << "\nVis attributes modifiers: "; << 838 os << "\n Vis attributes modifiers: "; 1052 const std::vector<G4ModelingParameters::Vis 839 const std::vector<G4ModelingParameters::VisAttributesModifier>& vams = 1053 v.fVisAttributesModifiers; 840 v.fVisAttributesModifiers; 1054 if (vams.empty()) { 841 if (vams.empty()) { 1055 os << "None"; 842 os << "None"; 1056 } else { 843 } else { 1057 os << vams; 844 os << vams; 1058 } 845 } 1059 846 1060 os << "\nTime window parameters:" << 1061 << "\n Start time: " << v.fStartTime/ns < << 1062 << "\n End time: " << v.fEndTime/ns << << 1063 << "\n Fade factor: " << v.fFadeFactor; << 1064 if (!v.fDisplayHeadTime) { << 1065 os << "\n Head time display not requeste << 1066 } else { << 1067 os << 1068 << "\n Head time position: " << 1069 << v.fDisplayHeadTimeX << ' ' << v.fDispl << 1070 << "\n Head time size: " << v.fDispl << 1071 << "\n Head time colour: " << v.fDispl << 1072 << ' ' << v.fDisplayHeadTimeGreen << ' ' << 1073 } << 1074 if (!v.fDisplayLightFront) { << 1075 os << "\n Light front display not reques << 1076 } else { << 1077 os << 1078 << "\n Light front position: " << 1079 << v.fDisplayLightFrontX/mm << ' ' << v.f << 1080 << ' ' << v.fDisplayLightFrontZ/mm << " m << 1081 << "\n Light front time: " << v.fDis << 1082 << "\n Light front colour: " << v.fDis << 1083 << ' ' << v.fDisplayLightFrontGreen << ' << 1084 } << 1085 << 1086 os << "\nSpecial Mesh Rendering"; << 1087 if (v.fSpecialMeshRendering) { << 1088 os << " requested with option \"" << v.fS << 1089 os << "\" for "; << 1090 if (v.fSpecialMeshVolumes.empty()) { << 1091 os << "any mesh"; << 1092 } else { << 1093 os << "selected meshes"; << 1094 for (const auto& vol: v.fSpecialMeshVol << 1095 os << "\n " << vol.GetName() << ':' << v << 1096 } << 1097 } << 1098 } else os << ": off"; << 1099 return os; 847 return os; 1100 } 848 } 1101 849 1102 G4bool G4ViewParameters::operator != (const G 850 G4bool G4ViewParameters::operator != (const G4ViewParameters& v) const { 1103 851 1104 // Put performance-sensitive parameters fir 852 // Put performance-sensitive parameters first. 1105 if ( 853 if ( 1106 // This first to optimise spin, etc. 854 // This first to optimise spin, etc. 1107 (fViewpointDirection != v.fViewpointD 855 (fViewpointDirection != v.fViewpointDirection) || 1108 856 1109 // No particular order from here on. 857 // No particular order from here on. 1110 (fDrawingStyle != v.fDrawingSty 858 (fDrawingStyle != v.fDrawingStyle) || 1111 (fNumberOfCloudPoints != v.fNumberOfCl << 1112 (fAuxEdgeVisible != v.fAuxEdgeVis 859 (fAuxEdgeVisible != v.fAuxEdgeVisible) || 1113 (fCulling != v.fCulling) 860 (fCulling != v.fCulling) || 1114 (fCullInvisible != v.fCullInvisi 861 (fCullInvisible != v.fCullInvisible) || 1115 (fDensityCulling != v.fDensityCul 862 (fDensityCulling != v.fDensityCulling) || 1116 (fCullCovered != v.fCullCovere 863 (fCullCovered != v.fCullCovered) || 1117 (fCBDAlgorithmNumber != v.fCBDAlgorit << 1118 (fSection != v.fSection) 864 (fSection != v.fSection) || 1119 (IsCutaway() != v.IsCutaway() 865 (IsCutaway() != v.IsCutaway()) || 1120 (IsExplode() != v.IsExplode() 866 (IsExplode() != v.IsExplode()) || 1121 (fNoOfSides != v.fNoOfSides) 867 (fNoOfSides != v.fNoOfSides) || 1122 (fUpVector != v.fUpVector) 868 (fUpVector != v.fUpVector) || 1123 (fFieldHalfAngle != v.fFieldHalfA 869 (fFieldHalfAngle != v.fFieldHalfAngle) || 1124 (fZoomFactor != v.fZoomFactor 870 (fZoomFactor != v.fZoomFactor) || 1125 (fScaleFactor != v.fScaleFacto 871 (fScaleFactor != v.fScaleFactor) || 1126 (fCurrentTargetPoint != v.fCurrentTar 872 (fCurrentTargetPoint != v.fCurrentTargetPoint) || 1127 (fDolly != v.fDolly) 873 (fDolly != v.fDolly) || 1128 (fRelativeLightpointDirection != v.fRel 874 (fRelativeLightpointDirection != v.fRelativeLightpointDirection) || 1129 (fLightsMoveWithCamera != v.fLightsMove 875 (fLightsMoveWithCamera != v.fLightsMoveWithCamera) || 1130 (fDefaultVisAttributes != v.fDefaultVis 876 (fDefaultVisAttributes != v.fDefaultVisAttributes) || 1131 (fDefaultTextVisAttributes != v.fDefaul 877 (fDefaultTextVisAttributes != v.fDefaultTextVisAttributes) || 1132 (fDefaultMarker != v.fDefaultMar 878 (fDefaultMarker != v.fDefaultMarker) || 1133 (fGlobalMarkerScale != v.fGlobalMark 879 (fGlobalMarkerScale != v.fGlobalMarkerScale) || 1134 (fGlobalLineWidthScale != v.fGlobalLine 880 (fGlobalLineWidthScale != v.fGlobalLineWidthScale) || 1135 (fMarkerNotHidden != v.fMarkerNotH 881 (fMarkerNotHidden != v.fMarkerNotHidden) || 1136 (fWindowSizeHintX != v.fWindowSize 882 (fWindowSizeHintX != v.fWindowSizeHintX) || 1137 (fWindowSizeHintY != v.fWindowSize 883 (fWindowSizeHintY != v.fWindowSizeHintY) || 1138 (fXGeometryString != v.fXGeometryS 884 (fXGeometryString != v.fXGeometryString) || 1139 (fGeometryMask != v.fGeometryMa 885 (fGeometryMask != v.fGeometryMask) || 1140 (fAutoRefresh != v.fAutoRefres 886 (fAutoRefresh != v.fAutoRefresh) || 1141 (fBackgroundColour != v.fBackground 887 (fBackgroundColour != v.fBackgroundColour) || 1142 (fPicking != v.fPicking) 888 (fPicking != v.fPicking) || 1143 (fRotationStyle != v.fRotationSt << 889 (fRotationStyle != v.fRotationStyle) 1144 (fSpecialMeshRendering != v.fSpecialMes << 1145 (fSpecialMeshRenderingOption != v.fSpec << 1146 ) 890 ) 1147 return true; 891 return true; 1148 892 1149 if (fDensityCulling && 893 if (fDensityCulling && 1150 (fVisibleDensity != v.fVisibleDensity)) 894 (fVisibleDensity != v.fVisibleDensity)) return true; 1151 895 1152 if (fCBDAlgorithmNumber > 0) { << 1153 if (fCBDParameters.size() != v.fCBDParame << 1154 else if (fCBDParameters != v.fCBDParamete << 1155 } << 1156 << 1157 if (fSection && 896 if (fSection && 1158 (!(fSectionPlane == v.fSectionPlane))) 897 (!(fSectionPlane == v.fSectionPlane))) return true; 1159 898 1160 if (IsCutaway()) { 899 if (IsCutaway()) { 1161 if (fCutawayPlanes.size () != v.fCutawayP 900 if (fCutawayPlanes.size () != v.fCutawayPlanes.size ()) 1162 return true; 901 return true; 1163 else { 902 else { 1164 for (size_t i = 0; i < fCutawayPlanes.s 903 for (size_t i = 0; i < fCutawayPlanes.size (); i++) { 1165 if (!(fCutawayPlanes[i] == v.fCutawayPlanes 904 if (!(fCutawayPlanes[i] == v.fCutawayPlanes[i])) return true; 1166 } 905 } 1167 } 906 } 1168 } 907 } 1169 908 1170 if (IsExplode() && 909 if (IsExplode() && 1171 ((fExplodeFactor != v.fExplodeFactor) | 910 ((fExplodeFactor != v.fExplodeFactor) || 1172 (fExplodeCentre != v.fExplodeCentre))) 911 (fExplodeCentre != v.fExplodeCentre))) return true; 1173 912 1174 if (fVisAttributesModifiers != v.fVisAttrib 913 if (fVisAttributesModifiers != v.fVisAttributesModifiers) return true; 1175 914 1176 if (fStartTime != v.fStartTime || << 1177 fEndTime != v.fEndTime || << 1178 fFadeFactor != v.fFadeFactor) return tr << 1179 << 1180 if (fDisplayHeadTime != v.fDisplayHeadTime) << 1181 if (fDisplayHeadTime) { << 1182 if (fDisplayHeadTimeX != v.fDisplayHe << 1183 fDisplayHeadTimeY != v.fDisplayHe << 1184 fDisplayHeadTimeSize != v.fDisplayHe << 1185 fDisplayHeadTimeRed != v.fDisplayHe << 1186 fDisplayHeadTimeGreen != v.fDisplayHe << 1187 fDisplayHeadTimeBlue != v.fDisplayHe << 1188 return true; << 1189 } << 1190 } << 1191 << 1192 if (fDisplayLightFront != v.fDisplayLightFr << 1193 if (fDisplayLightFront) { << 1194 if (fDisplayLightFrontX != v.fDisplay << 1195 fDisplayLightFrontY != v.fDisplay << 1196 fDisplayLightFrontZ != v.fDisplay << 1197 fDisplayLightFrontT != v.fDisplay << 1198 fDisplayLightFrontRed != v.fDisplay << 1199 fDisplayLightFrontGreen != v.fDisplay << 1200 fDisplayLightFrontBlue != v.fDisplay << 1201 return true; << 1202 } << 1203 } << 1204 << 1205 if (fSpecialMeshRendering) { << 1206 if (fSpecialMeshVolumes != v.fSpecialMesh << 1207 return true;; << 1208 } << 1209 << 1210 return false; 915 return false; 1211 } 916 } 1212 917 1213 void G4ViewParameters::SetXGeometryString (co << 918 void G4ViewParameters::SetXGeometryString (const G4String& geomStringArg) 1214 { 919 { >> 920 G4int x = 0, y = 0; >> 921 unsigned int w = 0, h = 0; >> 922 G4String geomString = geomStringArg; >> 923 // Parse windowSizeHintString for backwards compatibility... 1215 const G4String delimiters("xX+-"); 924 const G4String delimiters("xX+-"); 1216 G4String::size_type i = geomString.find_fir 925 G4String::size_type i = geomString.find_first_of(delimiters); 1217 if (i == G4String::npos) { << 926 if (i == G4String::npos) { // Does not contain "xX+-". Assume single number 1218 // Does not contain "xX+-". << 1219 // Is it a single number? << 1220 std::istringstream iss(geomString); 927 std::istringstream iss(geomString); 1221 G4int size; 928 G4int size; 1222 iss >> size; 929 iss >> size; 1223 if (iss) { << 930 if (!iss) { 1224 // It is a number << 931 size = 600; 1225 fWindowSizeHintX = size; << 932 G4cout << "Unrecognised windowSizeHint string: \"" 1226 fWindowSizeHintY = size; << 933 << geomString 1227 } << 934 << "\". Asuuming " << size << G4endl; 1228 // Accept other or all defaults (in G4Vie << 935 } 1229 // Reconstruct a geometry string coherent << 1230 char signX, signY; << 1231 if (fWindowLocationHintXNegative) signX = << 1232 if (fWindowLocationHintYNegative) signY = << 1233 std::ostringstream oss; 936 std::ostringstream oss; 1234 oss << fWindowSizeHintX << 'x' << fWindow << 937 oss << size << 'x' << size; 1235 << signX << fWindowLocationHintX << signY << 938 geomString = oss.str(); 1236 fXGeometryString = oss.str(); << 1237 return; << 1238 } 939 } 1239 << 940 1240 // Assume it's a parseable X geometry strin << 1241 G4int x = 0, y = 0; << 1242 unsigned int w = 0, h = 0; << 1243 fGeometryMask = ParseGeometry( geomString, 941 fGeometryMask = ParseGeometry( geomString, &x, &y, &w, &h ); 1244 942 1245 // Handle special case : 943 // Handle special case : 1246 if ((fGeometryMask & fYValue) == 0) 944 if ((fGeometryMask & fYValue) == 0) 1247 { // Using default 945 { // Using default 1248 y = fWindowLocationHintY; 946 y = fWindowLocationHintY; 1249 } 947 } 1250 if ((fGeometryMask & fXValue) == 0) 948 if ((fGeometryMask & fXValue) == 0) 1251 { // Using default 949 { // Using default 1252 x = fWindowLocationHintX; 950 x = fWindowLocationHintX; 1253 } 951 } 1254 952 1255 // Check errors 953 // Check errors 1256 // if there is no Width and Height 954 // if there is no Width and Height 1257 if ( ((fGeometryMask & fHeightValue) == 0 ) 955 if ( ((fGeometryMask & fHeightValue) == 0 ) && 1258 ((fGeometryMask & fWidthValue) == 0 ) 956 ((fGeometryMask & fWidthValue) == 0 )) { 1259 h = fWindowSizeHintY; 957 h = fWindowSizeHintY; 1260 w = fWindowSizeHintX; 958 w = fWindowSizeHintX; 1261 } else if ((fGeometryMask & fHeightValue) 959 } else if ((fGeometryMask & fHeightValue) == 0 ) { 1262 960 1263 // if there is only Width. Special case t 961 // if there is only Width. Special case to be backward compatible 1264 // We set Width and Height the same to ob 962 // We set Width and Height the same to obtain a square windows. 1265 963 1266 G4warn << "Unrecognised geometry string \ << 964 G4cout << "Unrecognised geometry string \"" 1267 << geomString 965 << geomString 1268 << "\". No Height found. Using Wi 966 << "\". No Height found. Using Width value instead" 1269 << G4endl; 967 << G4endl; 1270 h = w; 968 h = w; 1271 } 969 } 1272 if ( ((fGeometryMask & fXValue) == 0 ) || 970 if ( ((fGeometryMask & fXValue) == 0 ) || 1273 ((fGeometryMask & fYValue) == 0 )) { 971 ((fGeometryMask & fYValue) == 0 )) { 1274 //Using defaults 972 //Using defaults 1275 x = fWindowLocationHintX; 973 x = fWindowLocationHintX; 1276 y = fWindowLocationHintY; 974 y = fWindowLocationHintY; 1277 } 975 } 1278 // Set the string 976 // Set the string 1279 fXGeometryString = geomString; 977 fXGeometryString = geomString; 1280 978 1281 // Set values 979 // Set values 1282 fWindowSizeHintX = w; 980 fWindowSizeHintX = w; 1283 fWindowSizeHintY = h; 981 fWindowSizeHintY = h; 1284 fWindowLocationHintX = x; 982 fWindowLocationHintX = x; 1285 fWindowLocationHintY = y; 983 fWindowLocationHintY = y; 1286 984 1287 if ( ((fGeometryMask & fXValue)) && 985 if ( ((fGeometryMask & fXValue)) && 1288 ((fGeometryMask & fYValue))) { 986 ((fGeometryMask & fYValue))) { 1289 987 1290 if ( (fGeometryMask & fXNegative) ) { 988 if ( (fGeometryMask & fXNegative) ) { 1291 fWindowLocationHintXNegative = true; 989 fWindowLocationHintXNegative = true; 1292 } else { 990 } else { 1293 fWindowLocationHintXNegative = false; 991 fWindowLocationHintXNegative = false; 1294 } 992 } 1295 if ( (fGeometryMask & fYNegative) ) { 993 if ( (fGeometryMask & fYNegative) ) { 1296 fWindowLocationHintYNegative = true; 994 fWindowLocationHintYNegative = true; 1297 } else { 995 } else { 1298 fWindowLocationHintYNegative = false; 996 fWindowLocationHintYNegative = false; 1299 } 997 } 1300 } 998 } 1301 } 999 } 1302 1000 1303 G4int G4ViewParameters::GetWindowAbsoluteLoca 1001 G4int G4ViewParameters::GetWindowAbsoluteLocationHintX (G4int sizeX ) const { 1304 if ( fWindowLocationHintXNegative ) { 1002 if ( fWindowLocationHintXNegative ) { 1305 return sizeX + fWindowLocationHintX - f 1003 return sizeX + fWindowLocationHintX - fWindowSizeHintX; 1306 } 1004 } 1307 return fWindowLocationHintX; 1005 return fWindowLocationHintX; 1308 } 1006 } 1309 1007 1310 G4int G4ViewParameters::GetWindowAbsoluteLoca 1008 G4int G4ViewParameters::GetWindowAbsoluteLocationHintY (G4int sizeY ) const { 1311 if ( fWindowLocationHintYNegative ) { 1009 if ( fWindowLocationHintYNegative ) { 1312 return sizeY + fWindowLocationHintY - f 1010 return sizeY + fWindowLocationHintY - fWindowSizeHintY; 1313 } 1011 } 1314 return fWindowLocationHintY; 1012 return fWindowLocationHintY; 1315 } 1013 } 1316 1014 1317 /* Keep from : 1015 /* Keep from : 1318 * ftp://ftp.trolltech.com/qt/source/qt-embed 1016 * ftp://ftp.trolltech.com/qt/source/qt-embedded-free-3.0.6.tar.gz/qt-embedded-free-3.0.6/src/kernel/qapplication_qws.cpp 1319 * 1017 * 1320 * ParseGeometry parses strings of the for 1018 * ParseGeometry parses strings of the form 1321 * "=<width>x<height>{+-}<xoffset>{+-}<yoff 1019 * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where 1322 * width, height, xoffset, and yoffset are 1020 * width, height, xoffset, and yoffset are unsigned integers. 1323 * Example: "=80x24+300-49" 1021 * Example: "=80x24+300-49" 1324 * The equal sign is optional. 1022 * The equal sign is optional. 1325 * It returns a bitmask that indicates whic 1023 * It returns a bitmask that indicates which of the four values 1326 * were actually found in the string. For e 1024 * were actually found in the string. For each value found, 1327 * the corresponding argument is updated; 1025 * the corresponding argument is updated; for each value 1328 * not found, the corresponding argument is 1026 * not found, the corresponding argument is left unchanged. 1329 */ 1027 */ 1330 1028 1331 int G4ViewParameters::ParseGeometry ( 1029 int G4ViewParameters::ParseGeometry ( 1332 const char *string, 1030 const char *string, 1333 G4int *x, 1031 G4int *x, 1334 G4int *y, 1032 G4int *y, 1335 unsigned int *width, 1033 unsigned int *width, 1336 unsigned int *height) 1034 unsigned int *height) 1337 { 1035 { 1338 1036 1339 G4int mask = fNoValue; 1037 G4int mask = fNoValue; 1340 char *strind; 1038 char *strind; 1341 unsigned int tempWidth = 0; 1039 unsigned int tempWidth = 0; 1342 unsigned int tempHeight = 0; 1040 unsigned int tempHeight = 0; 1343 G4int tempX = 0; 1041 G4int tempX = 0; 1344 G4int tempY = 0; 1042 G4int tempY = 0; 1345 char *nextCharacter; 1043 char *nextCharacter; 1346 if ( (string == NULL) || (*string == '\0')) 1044 if ( (string == NULL) || (*string == '\0')) { 1347 return(mask); 1045 return(mask); 1348 } 1046 } 1349 if (*string == '=') 1047 if (*string == '=') 1350 string++; /* ignore possible '=' at beg 1048 string++; /* ignore possible '=' at beg of geometry spec */ 1351 strind = (char *)string; 1049 strind = (char *)string; 1352 if (*strind != '+' && *strind != '-' && *st 1050 if (*strind != '+' && *strind != '-' && *strind != 'x') { 1353 tempWidth = ReadInteger(strind, &nextChar 1051 tempWidth = ReadInteger(strind, &nextCharacter); 1354 if (strind == nextCharacter) 1052 if (strind == nextCharacter) 1355 return (0); 1053 return (0); 1356 strind = nextCharacter; 1054 strind = nextCharacter; 1357 mask |= fWidthValue; 1055 mask |= fWidthValue; 1358 } 1056 } 1359 if (*strind == 'x' || *strind == 'X') { 1057 if (*strind == 'x' || *strind == 'X') { 1360 strind++; 1058 strind++; 1361 tempHeight = ReadInteger(strind, &nextCha 1059 tempHeight = ReadInteger(strind, &nextCharacter); 1362 if (strind == nextCharacter) 1060 if (strind == nextCharacter) 1363 return (0); 1061 return (0); 1364 strind = nextCharacter; 1062 strind = nextCharacter; 1365 mask |= fHeightValue; 1063 mask |= fHeightValue; 1366 } 1064 } 1367 1065 1368 if ((*strind == '+') || (*strind == '-')) { 1066 if ((*strind == '+') || (*strind == '-')) { 1369 if (*strind == '-') { 1067 if (*strind == '-') { 1370 strind++; 1068 strind++; 1371 tempX = -ReadInteger(strind, &nextChara 1069 tempX = -ReadInteger(strind, &nextCharacter); 1372 if (strind == nextCharacter) 1070 if (strind == nextCharacter) 1373 return (0); 1071 return (0); 1374 strind = nextCharacter; 1072 strind = nextCharacter; 1375 mask |= fXNegative; 1073 mask |= fXNegative; 1376 1074 1377 } 1075 } 1378 else 1076 else 1379 { strind++; 1077 { strind++; 1380 tempX = ReadInteger(strind, &nextChar 1078 tempX = ReadInteger(strind, &nextCharacter); 1381 if (strind == nextCharacter) 1079 if (strind == nextCharacter) 1382 return(0); 1080 return(0); 1383 strind = nextCharacter; 1081 strind = nextCharacter; 1384 } 1082 } 1385 mask |= fXValue; 1083 mask |= fXValue; 1386 if ((*strind == '+') || (*strind == '-')) 1084 if ((*strind == '+') || (*strind == '-')) { 1387 if (*strind == '-') { 1085 if (*strind == '-') { 1388 strind++; 1086 strind++; 1389 tempY = -ReadInteger(strind, &nextCha 1087 tempY = -ReadInteger(strind, &nextCharacter); 1390 if (strind == nextCharacter) 1088 if (strind == nextCharacter) 1391 return(0); 1089 return(0); 1392 strind = nextCharacter; 1090 strind = nextCharacter; 1393 mask |= fYNegative; 1091 mask |= fYNegative; 1394 } 1092 } 1395 else 1093 else 1396 { 1094 { 1397 strind++; 1095 strind++; 1398 tempY = ReadInteger(strind, &nextCh 1096 tempY = ReadInteger(strind, &nextCharacter); 1399 if (strind == nextCharacter) 1097 if (strind == nextCharacter) 1400 return(0); 1098 return(0); 1401 strind = nextCharacter; 1099 strind = nextCharacter; 1402 } 1100 } 1403 mask |= fYValue; 1101 mask |= fYValue; 1404 } 1102 } 1405 } 1103 } 1406 /* If strind isn't at the end of the string 1104 /* If strind isn't at the end of the string the it's an invalid 1407 geometry specification. */ 1105 geometry specification. */ 1408 if (*strind != '\0') return (0); 1106 if (*strind != '\0') return (0); 1409 if (mask & fXValue) 1107 if (mask & fXValue) 1410 *x = tempX; 1108 *x = tempX; 1411 if (mask & fYValue) 1109 if (mask & fYValue) 1412 *y = tempY; 1110 *y = tempY; 1413 if (mask & fWidthValue) 1111 if (mask & fWidthValue) 1414 *width = tempWidth; 1112 *width = tempWidth; 1415 if (mask & fHeightValue) 1113 if (mask & fHeightValue) 1416 *height = tempHeight; 1114 *height = tempHeight; 1417 return (mask); 1115 return (mask); 1418 } 1116 } 1419 1117 1420 /* Keep from : 1118 /* Keep from : 1421 * ftp://ftp.trolltech.com/qt/source/qt-embed 1119 * ftp://ftp.trolltech.com/qt/source/qt-embedded-free-3.0.6.tar.gz/qt-embedded-free-3.0.6/src/kernel/qapplication_qws.cpp 1422 * 1120 * 1423 */ 1121 */ 1424 G4int G4ViewParameters::ReadInteger(char *str 1122 G4int G4ViewParameters::ReadInteger(char *string, char **NextString) 1425 { 1123 { 1426 G4int Result = 0; 1124 G4int Result = 0; 1427 G4int Sign = 1; 1125 G4int Sign = 1; 1428 1126 1429 if (*string == '+') 1127 if (*string == '+') 1430 string++; 1128 string++; 1431 else if (*string == '-') 1129 else if (*string == '-') 1432 { 1130 { 1433 string++; 1131 string++; 1434 Sign = -1; 1132 Sign = -1; 1435 } 1133 } 1436 for (; (*string >= '0') && (*string <= '9 1134 for (; (*string >= '0') && (*string <= '9'); string++) 1437 { 1135 { 1438 Result = (Result * 10) + (*string - '0'); 1136 Result = (Result * 10) + (*string - '0'); 1439 } 1137 } 1440 *NextString = string; 1138 *NextString = string; 1441 if (Sign >= 0) 1139 if (Sign >= 0) 1442 return (Result); 1140 return (Result); 1443 else 1141 else 1444 return (-Result); 1142 return (-Result); 1445 } 1143 } 1446 1144 1447 G4ViewParameters* G4ViewParameters::CatmullRo 1145 G4ViewParameters* G4ViewParameters::CatmullRomCubicSplineInterpolation 1448 (const std::vector<G4ViewParameters>& views, 1146 (const std::vector<G4ViewParameters>& views, 1449 G4int nInterpolationPoints) // No of interp 1147 G4int nInterpolationPoints) // No of interpolations points per interval 1450 { 1148 { 1451 // Returns a null pointer when no more to b 1149 // Returns a null pointer when no more to be done. For example: 1452 // do { 1150 // do { 1453 // G4ViewParameters* vp = 1151 // G4ViewParameters* vp = 1454 // G4ViewParameters::CatmullRomCubicSplin 1152 // G4ViewParameters::CatmullRomCubicSplineInterpolation(viewVector,nInterpolationPoints); 1455 // if (!vp) break; 1153 // if (!vp) break; 1456 // ... 1154 // ... 1457 // } while (true); 1155 // } while (true); 1458 1156 1459 // See https://en.wikipedia.org/wiki/Cubic_ 1157 // See https://en.wikipedia.org/wiki/Cubic_Hermite_spline 1460 1158 1461 // Assumes equal intervals 1159 // Assumes equal intervals 1462 1160 1463 if (views.size() < 2) { 1161 if (views.size() < 2) { 1464 G4Exception 1162 G4Exception 1465 ("G4ViewParameters::CatmullRomCubicSpline 1163 ("G4ViewParameters::CatmullRomCubicSplineInterpolation", 1466 "visman0301", JustWarning, 1164 "visman0301", JustWarning, 1467 "There must be at least two views."); 1165 "There must be at least two views."); 1468 return 0; 1166 return 0; 1469 } 1167 } 1470 1168 1471 if (nInterpolationPoints < 1) { 1169 if (nInterpolationPoints < 1) { 1472 G4Exception 1170 G4Exception 1473 ("G4ViewParameters::CatmullRomCubicSpline 1171 ("G4ViewParameters::CatmullRomCubicSplineInterpolation", 1474 "visman0302", JustWarning, 1172 "visman0302", JustWarning, 1475 "Number of interpolation points cannot b 1173 "Number of interpolation points cannot be zero or negative."); 1476 return 0; 1174 return 0; 1477 } 1175 } 1478 1176 1479 const size_t nIntervals = views.size() - 1; 1177 const size_t nIntervals = views.size() - 1; 1480 const G4double dt = 1./nInterpolationPoints 1178 const G4double dt = 1./nInterpolationPoints; 1481 1179 1482 static G4ViewParameters holdingValues; 1180 static G4ViewParameters holdingValues; 1483 static G4double t = 0.; // 0. <= t <= 1. 1181 static G4double t = 0.; // 0. <= t <= 1. 1484 static G4int iInterpolationPoint = 0; 1182 static G4int iInterpolationPoint = 0; 1485 static size_t iInterval = 0; 1183 static size_t iInterval = 0; 1486 1184 1487 // G4cout << "Interval " << iInterval << ", 1185 // G4cout << "Interval " << iInterval << ", t = " << t << G4endl; 1488 1186 1489 // Hermite polynomials. 1187 // Hermite polynomials. 1490 const G4double h00 = 2.*t*t*t - 3.*t*t +1; 1188 const G4double h00 = 2.*t*t*t - 3.*t*t +1; 1491 const G4double h10 = t*t*t -2.*t*t + t; 1189 const G4double h10 = t*t*t -2.*t*t + t; 1492 const G4double h01 = -2.*t*t*t + 3.*t*t; 1190 const G4double h01 = -2.*t*t*t + 3.*t*t; 1493 const G4double h11 = t*t*t - t*t; 1191 const G4double h11 = t*t*t - t*t; 1494 1192 1495 // Aliases (to simplify code) 1193 // Aliases (to simplify code) 1496 const size_t& n = nIntervals; 1194 const size_t& n = nIntervals; 1497 size_t& i = iInterval; 1195 size_t& i = iInterval; 1498 const std::vector<G4ViewParameters>& v = vi 1196 const std::vector<G4ViewParameters>& v = views; 1499 1197 1500 // The Catmull-Rom cubic spline prescriptio 1198 // The Catmull-Rom cubic spline prescription is as follows: 1501 // Slope at first way point is v[1] - v[0]. 1199 // Slope at first way point is v[1] - v[0]. 1502 // Slope at last way point is v[n] - v[n-1] 1200 // Slope at last way point is v[n] - v[n-1]. 1503 // Otherwise slope at way point i is 0.5*(v 1201 // Otherwise slope at way point i is 0.5*(v[i+1] - v[i-1]). 1504 // Result = h00*v[i] + h10*m[i] + h01*v[i+1 1202 // Result = h00*v[i] + h10*m[i] + h01*v[i+1] + h11*m[i+1], 1505 // where m[i] amd m[i+1] are the slopes at 1203 // where m[i] amd m[i+1] are the slopes at the start and end 1506 // of the interval for the particular value 1204 // of the interval for the particular value. 1507 // If (n == 1), linear interpolation result 1205 // If (n == 1), linear interpolation results. 1508 // If (n == 2), quadratic interpolation res 1206 // If (n == 2), quadratic interpolation results. 1509 1207 1510 // Working variables 1208 // Working variables 1511 G4double mi, mi1, real, x, y, z; 1209 G4double mi, mi1, real, x, y, z; 1512 1210 1513 // First, a crude interpolation of all para 1211 // First, a crude interpolation of all parameters. Then, below, a 1514 // smooth interpolation of those for which 1212 // smooth interpolation of those for which it makes sense. 1515 holdingValues = t < 0.5? v[i]: v[i+1]; 1213 holdingValues = t < 0.5? v[i]: v[i+1]; 1516 1214 1517 // Catmull-Rom cubic spline interpolation 1215 // Catmull-Rom cubic spline interpolation 1518 #define INTERPOLATE(param) \ 1216 #define INTERPOLATE(param) \ 1519 /* This works out the interpolated param in i << 1217 /* This works out the interpolated param in i'th interval */ \ 1520 /* Assumes n >= 1 */ \ << 1218 /* Assumes n >= 1 */ \ 1521 if (i == 0) { \ << 1219 if (i == 0) { \ 1522 /* First interval */ \ << 1220 /* First interval */ \ 1523 mi = v[1].param - v[0].param; \ << 1221 mi = v[1].param - v[0].param; \ 1524 /* If there is only one interval, make start << 1222 /* If there is only one interval, make start and end slopes equal */ \ 1525 /* (This results in a linear interpolation) * << 1223 /* (This results in a linear interpolation) */ \ 1526 if (n == 1) mi1 = mi; \ << 1224 if (n == 1) mi1 = mi; \ 1527 /* else the end slope of the interval takes a << 1225 /* else the end slope of the interval takes account of the next waypoint along */ \ 1528 else mi1 = 0.5 * (v[2].param - v[0].param); \ << 1226 else mi1 = 0.5 * (v[2].param - v[0].param); \ 1529 } else if (i >= n - 1) { \ << 1227 } else if (i >= n - 1) { \ 1530 /* Similarly for last interval */ \ << 1228 /* Similarly for last interval */ \ 1531 mi1 = v[i+1].param - v[i].param; \ << 1229 mi1 = v[i+1].param - v[i].param; \ 1532 /* If there is only one interval, make start << 1230 /* If there is only one interval, make start and end slopes equal */ \ 1533 if (n == 1) mi = mi1; \ << 1231 if (n == 1) mi = mi1; \ 1534 /* else the start slope of the interval takes << 1232 /* else the start slope of the interval takes account of the previous waypoint */ \ 1535 else mi = 0.5 * (v[i+1].param - v[i-1].param) << 1233 else mi = 0.5 * (v[i+1].param - v[i-1].param); \ 1536 } else { \ << 1234 } else { \ 1537 /* Full Catmull-Rom slopes use previous AND n << 1235 /* Full Catmull-Rom slopes use previous AND next waypoints */ \ 1538 mi = 0.5 * (v[i+1].param - v[i-1].param); \ << 1236 mi = 0.5 * (v[i+1].param - v[i-1].param); \ 1539 mi1 = 0.5 * (v[i+2].param - v[i ].param); \ << 1237 mi1 = 0.5 * (v[i+2].param - v[i ].param); \ 1540 } \ << 1238 } \ 1541 real = h00 * v[i].param + h10 * mi + h01 * v[ << 1239 real = h00 * v[i].param + h10 * mi + h01 * v[i+1].param + h11 * mi1; 1542 << 1543 #define INTERPOLATELOG(param) \ << 1544 if (i == 0) { \ << 1545 mi = std::log(v[1].param) - std::log(v[0].par << 1546 if (n == 1) mi1 = mi; \ << 1547 else mi1 = 0.5 * (std::log(v[2].param) - std: << 1548 } else if (i >= n - 1) { \ << 1549 mi1 = std::log(v[i+1].param) - std::log(v[i]. << 1550 if (n == 1) mi = mi1; \ << 1551 else mi = 0.5 * (std::log(v[i+1].param) - std << 1552 } else { \ << 1553 mi = 0.5 * (std::log(v[i+1].param) - std::lo << 1554 mi1 = 0.5 * (std::log(v[i+2].param) - std::lo << 1555 } \ << 1556 real = std::exp(h00 * std::log(v[i].param) + << 1557 1240 1558 // Real parameters 1241 // Real parameters 1559 INTERPOLATE(fVisibleDensity); 1242 INTERPOLATE(fVisibleDensity); 1560 if (real < 0.) real = 0.; 1243 if (real < 0.) real = 0.; 1561 holdingValues.fVisibleDensity = real; 1244 holdingValues.fVisibleDensity = real; 1562 INTERPOLATELOG(fExplodeFactor); << 1245 INTERPOLATE(fExplodeFactor); >> 1246 if (real < 0.) real = 0.; 1563 holdingValues.fExplodeFactor = real; 1247 holdingValues.fExplodeFactor = real; 1564 INTERPOLATE(fFieldHalfAngle); 1248 INTERPOLATE(fFieldHalfAngle); 1565 if (real < 0.) real = 0.; 1249 if (real < 0.) real = 0.; 1566 holdingValues.fFieldHalfAngle = real; 1250 holdingValues.fFieldHalfAngle = real; 1567 INTERPOLATELOG(fZoomFactor); << 1251 INTERPOLATE(fZoomFactor); >> 1252 if (real < 0.) real = 0.; 1568 holdingValues.fZoomFactor = real; 1253 holdingValues.fZoomFactor = real; 1569 INTERPOLATE(fDolly); 1254 INTERPOLATE(fDolly); 1570 holdingValues.fDolly = real; 1255 holdingValues.fDolly = real; 1571 INTERPOLATE(fGlobalMarkerScale); 1256 INTERPOLATE(fGlobalMarkerScale); 1572 if (real < 0.) real = 0.; 1257 if (real < 0.) real = 0.; 1573 holdingValues.fGlobalMarkerScale = real; 1258 holdingValues.fGlobalMarkerScale = real; 1574 INTERPOLATE(fGlobalLineWidthScale); 1259 INTERPOLATE(fGlobalLineWidthScale); 1575 if (real < 0.) real = 0.; 1260 if (real < 0.) real = 0.; 1576 holdingValues.fGlobalLineWidthScale = real; 1261 holdingValues.fGlobalLineWidthScale = real; 1577 1262 1578 // Unit vectors 1263 // Unit vectors 1579 #define INTERPOLATEUNITVECTOR(vector) \ 1264 #define INTERPOLATEUNITVECTOR(vector) \ 1580 INTERPOLATE(vector.x()); x = real; \ 1265 INTERPOLATE(vector.x()); x = real; \ 1581 INTERPOLATE(vector.y()); y = real; \ 1266 INTERPOLATE(vector.y()); y = real; \ 1582 INTERPOLATE(vector.z()); z = real; 1267 INTERPOLATE(vector.z()); z = real; 1583 INTERPOLATEUNITVECTOR(fViewpointDirection); 1268 INTERPOLATEUNITVECTOR(fViewpointDirection); 1584 holdingValues.fViewpointDirection 1269 holdingValues.fViewpointDirection = G4Vector3D(x,y,z).unit(); 1585 INTERPOLATEUNITVECTOR(fUpVector); 1270 INTERPOLATEUNITVECTOR(fUpVector); 1586 holdingValues.fUpVector 1271 holdingValues.fUpVector = G4Vector3D(x,y,z).unit(); 1587 INTERPOLATEUNITVECTOR(fRelativeLightpointDi 1272 INTERPOLATEUNITVECTOR(fRelativeLightpointDirection); 1588 holdingValues.fRelativeLightpointDirection 1273 holdingValues.fRelativeLightpointDirection = G4Vector3D(x,y,z).unit(); 1589 INTERPOLATEUNITVECTOR(fActualLightpointDire 1274 INTERPOLATEUNITVECTOR(fActualLightpointDirection); 1590 holdingValues.fActualLightpointDirection 1275 holdingValues.fActualLightpointDirection = G4Vector3D(x,y,z).unit(); 1591 1276 1592 // Un-normalised vectors 1277 // Un-normalised vectors 1593 #define INTERPOLATEVECTOR(vector) \ 1278 #define INTERPOLATEVECTOR(vector) \ 1594 INTERPOLATE(vector.x()); x = real; \ 1279 INTERPOLATE(vector.x()); x = real; \ 1595 INTERPOLATE(vector.y()); y = real; \ 1280 INTERPOLATE(vector.y()); y = real; \ 1596 INTERPOLATE(vector.z()); z = real; 1281 INTERPOLATE(vector.z()); z = real; 1597 INTERPOLATEVECTOR(fScaleFactor); 1282 INTERPOLATEVECTOR(fScaleFactor); 1598 holdingValues.fScaleFactor = G4Vector3D(x,y 1283 holdingValues.fScaleFactor = G4Vector3D(x,y,z); 1599 1284 1600 // Points 1285 // Points 1601 #define INTERPOLATEPOINT(point) \ 1286 #define INTERPOLATEPOINT(point) \ 1602 INTERPOLATE(point.x()); x = real; \ 1287 INTERPOLATE(point.x()); x = real; \ 1603 INTERPOLATE(point.y()); y = real; \ 1288 INTERPOLATE(point.y()); y = real; \ 1604 INTERPOLATE(point.z()); z = real; 1289 INTERPOLATE(point.z()); z = real; 1605 INTERPOLATEPOINT(fExplodeCentre); 1290 INTERPOLATEPOINT(fExplodeCentre); 1606 holdingValues.fExplodeCentre = G4Point 1291 holdingValues.fExplodeCentre = G4Point3D(x,y,z); 1607 INTERPOLATEPOINT(fCurrentTargetPoint); 1292 INTERPOLATEPOINT(fCurrentTargetPoint); 1608 holdingValues.fCurrentTargetPoint = G4Point 1293 holdingValues.fCurrentTargetPoint = G4Point3D(x,y,z); 1609 1294 1610 // Colour 1295 // Colour 1611 G4double red, green, blue, alpha; 1296 G4double red, green, blue, alpha; 1612 #define INTERPOLATECOLOUR(colour) \ 1297 #define INTERPOLATECOLOUR(colour) \ 1613 INTERPOLATE(colour.GetRed()); red = real; 1298 INTERPOLATE(colour.GetRed()); red = real; \ 1614 INTERPOLATE(colour.GetGreen()); green = real; 1299 INTERPOLATE(colour.GetGreen()); green = real; \ 1615 INTERPOLATE(colour.GetBlue()); blue = real; 1300 INTERPOLATE(colour.GetBlue()); blue = real; \ 1616 INTERPOLATE(colour.GetAlpha()); alpha = real; 1301 INTERPOLATE(colour.GetAlpha()); alpha = real; 1617 INTERPOLATECOLOUR(fBackgroundColour); 1302 INTERPOLATECOLOUR(fBackgroundColour); 1618 // Components are clamped to 0. <= componen 1303 // Components are clamped to 0. <= component <= 1. 1619 holdingValues.fBackgroundColour = G4Colour( 1304 holdingValues.fBackgroundColour = G4Colour(red,green,blue,alpha); 1620 1305 1621 // For some parameters we need to check som 1306 // For some parameters we need to check some continuity 1622 G4bool continuous; 1307 G4bool continuous; 1623 #define CONTINUITY(quantity) \ 1308 #define CONTINUITY(quantity) \ 1624 continuous = false; \ 1309 continuous = false; \ 1625 /* This follows the logic of the INTERPOLAT 1310 /* This follows the logic of the INTERPOLATE macro above; see comments therein */ \ 1626 if (i == 0) { \ 1311 if (i == 0) { \ 1627 if (v[1].quantity == v[0].quantity) { \ 1312 if (v[1].quantity == v[0].quantity) { \ 1628 if (n == 1) continuous = true; \ 1313 if (n == 1) continuous = true; \ 1629 else if (v[2].quantity == v[0].quantit 1314 else if (v[2].quantity == v[0].quantity) \ 1630 continuous = true; \ 1315 continuous = true; \ 1631 } \ 1316 } \ 1632 } else if (i >= n - 1) { \ 1317 } else if (i >= n - 1) { \ 1633 if (v[i+1].quantity == v[i].quantity) { \ 1318 if (v[i+1].quantity == v[i].quantity) { \ 1634 if (n == 1) continuous = true; \ 1319 if (n == 1) continuous = true; \ 1635 else if (v[i+1].quantity == v[i-1].quan 1320 else if (v[i+1].quantity == v[i-1].quantity) \ 1636 continuous = true; \ 1321 continuous = true; \ 1637 } \ 1322 } \ 1638 } else { \ 1323 } else { \ 1639 if (v[i-1].quantity == v[i].quantity && \ 1324 if (v[i-1].quantity == v[i].quantity && \ 1640 v[i+1].quantity == v[i].quantity && \ 1325 v[i+1].quantity == v[i].quantity && \ 1641 v[i+2].quantity == v[i].quantity) \ 1326 v[i+2].quantity == v[i].quantity) \ 1642 continuous = true; \ 1327 continuous = true; \ 1643 } 1328 } 1644 1329 1645 G4double a, b, c, d; 1330 G4double a, b, c, d; 1646 #define INTERPOLATEPLANE(plane) \ 1331 #define INTERPOLATEPLANE(plane) \ 1647 INTERPOLATE(plane.a()); a = real; \ 1332 INTERPOLATE(plane.a()); a = real; \ 1648 INTERPOLATE(plane.b()); b = real; \ 1333 INTERPOLATE(plane.b()); b = real; \ 1649 INTERPOLATE(plane.c()); c = real; \ 1334 INTERPOLATE(plane.c()); c = real; \ 1650 INTERPOLATE(plane.d()); d = real; 1335 INTERPOLATE(plane.d()); d = real; 1651 1336 1652 // Section plane 1337 // Section plane 1653 CONTINUITY(fSection); 1338 CONTINUITY(fSection); 1654 if (continuous) { 1339 if (continuous) { 1655 INTERPOLATEPLANE(fSectionPlane); 1340 INTERPOLATEPLANE(fSectionPlane); 1656 holdingValues.fSectionPlane = G4Plane3D(a 1341 holdingValues.fSectionPlane = G4Plane3D(a,b,c,d); 1657 } 1342 } 1658 1343 1659 // Cutaway planes 1344 // Cutaway planes 1660 if (v[i].fCutawayPlanes.size()) { 1345 if (v[i].fCutawayPlanes.size()) { 1661 CONTINUITY(fCutawayPlanes.size()); 1346 CONTINUITY(fCutawayPlanes.size()); 1662 if (continuous) { 1347 if (continuous) { 1663 for (size_t j = 0; j < v[i].fCutawayPla 1348 for (size_t j = 0; j < v[i].fCutawayPlanes.size(); ++j) { 1664 INTERPOLATEPLANE(fCutawayPlanes[j]); 1349 INTERPOLATEPLANE(fCutawayPlanes[j]); 1665 holdingValues.fCutawayPlanes[j] = G4P 1350 holdingValues.fCutawayPlanes[j] = G4Plane3D(a,b,c,d); 1666 } 1351 } 1667 } 1352 } 1668 } 1353 } 1669 1354 1670 // Vis attributes modifiers 1355 // Vis attributes modifiers 1671 // Really, we are only interested in colour 1356 // Really, we are only interested in colour - other attributes can follow 1672 // the "crude" interpolation that is guaran 1357 // the "crude" interpolation that is guaranteed above. 1673 static G4VisAttributes workingVA; 1358 static G4VisAttributes workingVA; 1674 if (v[i].fVisAttributesModifiers.size()) { 1359 if (v[i].fVisAttributesModifiers.size()) { 1675 CONTINUITY(fVisAttributesModifiers.size() 1360 CONTINUITY(fVisAttributesModifiers.size()); 1676 if (continuous) { << 1361 if (continuous) { \ 1677 for (size_t j = 0; j < v[i].fVisAttribu << 1362 for (size_t j = 0; j < v[i].fVisAttributesModifiers.size(); ++j) { \ 1678 CONTINUITY(fVisAttributesModifiers[j] 1363 CONTINUITY(fVisAttributesModifiers[j].GetPVNameCopyNoPath()); 1679 if (continuous) { 1364 if (continuous) { 1680 CONTINUITY(fVisAttributesModifiers[ 1365 CONTINUITY(fVisAttributesModifiers[j].GetVisAttributesSignifier()); 1681 if (continuous) { 1366 if (continuous) { 1682 if (v[i].fVisAttributesModifiers[ 1367 if (v[i].fVisAttributesModifiers[j].GetVisAttributesSignifier() == 1683 G4ModelingParameters::VASColo 1368 G4ModelingParameters::VASColour) { 1684 INTERPOLATECOLOUR(fVisAttribute 1369 INTERPOLATECOLOUR(fVisAttributesModifiers[j].GetVisAttributes().GetColour()); 1685 workingVA = v[i].fVisAttributes 1370 workingVA = v[i].fVisAttributesModifiers[j].GetVisAttributes(); 1686 workingVA.SetColour(G4Colour(re 1371 workingVA.SetColour(G4Colour(red,green,blue,alpha)); 1687 holdingValues.fVisAttributesMod 1372 holdingValues.fVisAttributesModifiers[j].SetVisAttributes(workingVA); 1688 } 1373 } 1689 } 1374 } 1690 } 1375 } 1691 } 1376 } 1692 } 1377 } 1693 } 1378 } 1694 << 1695 // Time window parameters (for showing part << 1696 // Only two parameters are interpolated. Th << 1697 // once and for all by the user for a given << 1698 // if not, they will be interpolated by the << 1699 INTERPOLATE(fStartTime) << 1700 holdingValues.fStartTime = real; << 1701 INTERPOLATE(fEndTime) << 1702 holdingValues.fEndTime = real; << 1703 1379 1704 // Increment counters 1380 // Increment counters 1705 iInterpolationPoint++; 1381 iInterpolationPoint++; 1706 t += dt; 1382 t += dt; 1707 if (iInterpolationPoint > nInterpolationPoi 1383 if (iInterpolationPoint > nInterpolationPoints) { 1708 iInterpolationPoint = 1; // Ready for ne 1384 iInterpolationPoint = 1; // Ready for next interval. 1709 t = dt; 1385 t = dt; 1710 iInterval++; 1386 iInterval++; 1711 } 1387 } 1712 if (iInterval >= nIntervals) { 1388 if (iInterval >= nIntervals) { 1713 iInterpolationPoint = 0; // Ready for a 1389 iInterpolationPoint = 0; // Ready for a complete restart. 1714 t = 0.; 1390 t = 0.; 1715 iInterval = 0; 1391 iInterval = 0; 1716 return 0; 1392 return 0; 1717 } 1393 } 1718 1394 1719 return &holdingValues; 1395 return &holdingValues; 1720 } 1396 } 1721 1397