Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4ViewParameters.cc
이 파일의 문서화 페이지로 가기
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4ViewParameters.cc 109510 2018-04-26 07:15:57Z gcosmo $
28 //
29 //
30 // John Allison 19th July 1996
31 // View parameters and options.
32 
33 #include <sstream>
34 
35 #include "G4ViewParameters.hh"
36 
37 #include "G4VisManager.hh"
38 #include "G4VPhysicalVolume.hh"
39 #include "G4UnitsTable.hh"
40 #include "G4SystemOfUnits.hh"
41 #include "G4ios.hh"
42 
44  fDrawingStyle (wireframe),
45  fAuxEdgeVisible (false),
46  fCulling (true),
47  fCullInvisible (true),
48  fDensityCulling (false),
49  fVisibleDensity (0.01 * g / cm3),
50  fCullCovered (false),
51  fCBDAlgorithmNumber (0),
52  fSection (false),
53  fSectionPlane (),
54  fCutawayMode (cutawayUnion),
55  fCutawayPlanes (),
56  fExplodeFactor (1.),
57  fNoOfSides (24),
58  fViewpointDirection (G4Vector3D (0., 0., 1.)), // On z-axis.
59  fUpVector (G4Vector3D (0., 1., 0.)), // y-axis up.
60  fFieldHalfAngle (0.), // Orthogonal projection.
61  fZoomFactor (1.),
62  fScaleFactor (G4Vector3D (1., 1., 1.)),
63  fCurrentTargetPoint (),
64  fDolly (0.),
65  fLightsMoveWithCamera (false),
66  fRelativeLightpointDirection (G4Vector3D (1., 1., 1.)),
67  fActualLightpointDirection (G4Vector3D (1., 1., 1.)),
68  fDefaultVisAttributes (),
69  fDefaultTextVisAttributes (G4Colour (0., 0., 1.)),
70  fDefaultMarker (),
71  fGlobalMarkerScale (1.),
72  fGlobalLineWidthScale (1.),
73  fMarkerNotHidden (true),
74  fWindowSizeHintX (600),
75  fWindowSizeHintY (600),
76  fWindowLocationHintX(0),
77  fWindowLocationHintY(0),
78  fWindowLocationHintXNegative(true),
79  fWindowLocationHintYNegative(false),
80  fGeometryMask(0),
81  fAutoRefresh (false),
82  fBackgroundColour (G4Colour(0.,0.,0.)), // Black
83  fPicking (false),
84  fRotationStyle (constrainUpDirection),
85  fStartTime(-G4VisAttributes::fVeryLongTime),
86  fEndTime(G4VisAttributes::fVeryLongTime),
87  fFadeFactor(0.),
88  fDisplayHeadTime(false),
89  fDisplayHeadTimeX(-0.9),
90  fDisplayHeadTimeY(-0.9),
91  fDisplayHeadTimeSize(24.),
92  fDisplayHeadTimeRed(0.),
93  fDisplayHeadTimeGreen(1.),
94  fDisplayHeadTimeBlue(1.),
95  fDisplayLightFront(false),
96  fDisplayLightFrontX(0.),
97  fDisplayLightFrontY(0.),
98  fDisplayLightFrontZ(0.),
99  fDisplayLightFrontT(0.),
100  fDisplayLightFrontRed(0.),
101  fDisplayLightFrontGreen(1.),
102  fDisplayLightFrontBlue(0.)
103 {
105  // Markers are 5 pixels "overall" size, i.e., diameter.
106 }
107 
109 
111 (const G4Vector3D& scaleFactorMultiplier) {
112  fScaleFactor.setX(fScaleFactor.x() * scaleFactorMultiplier.x());
113  fScaleFactor.setY(fScaleFactor.y() * scaleFactorMultiplier.y());
114  fScaleFactor.setZ(fScaleFactor.z() * scaleFactorMultiplier.z());
115 }
116 
120 }
121 
122 // Useful quantities - begin snippet.
123 // Here Follow functions to evaluate the above algorithms as a
124 // function of the radius of the Bounding Sphere of the object being
125 // viewed. Call them in the order given - for efficiency, later
126 // functions depend on the results of earlier ones (Store the
127 // results of earlier functions in your own temporary variables -
128 // see, for example, G4OpenGLView::SetView ().)
129 
131  G4double cameraDistance;
132  if (fFieldHalfAngle == 0.) {
133  cameraDistance = radius;
134  }
135  else {
136  cameraDistance = radius / std::sin (fFieldHalfAngle) - fDolly;
137  }
138  return cameraDistance;
139 }
140 
142  G4double radius) const {
143  const G4double small = 1.e-6 * radius;
144  G4double nearDistance = cameraDistance - radius;
145  if (nearDistance < small) nearDistance = small;
146  return nearDistance;
147 }
148 
150  G4double nearDistance,
151  G4double radius) const {
152  G4double farDistance = cameraDistance + radius;
153  if (farDistance < nearDistance) farDistance = nearDistance;
154  return farDistance;
155 }
156 
158  G4double radius) const {
159  G4double frontHalfHeight;
160  if (fFieldHalfAngle == 0.) {
161  frontHalfHeight = radius / fZoomFactor;
162  }
163  else {
164  frontHalfHeight = nearDistance * std::tan (fFieldHalfAngle) / fZoomFactor;
165  }
166  return frontHalfHeight;
167 }
168 // Useful quantities - end snippet.
169 
170 void G4ViewParameters::AddCutawayPlane (const G4Plane3D& cutawayPlane) {
171  if (fCutawayPlanes.size () < 3 ) {
172  fCutawayPlanes.push_back (cutawayPlane);
173  }
174  else {
175  G4cerr <<
176  "ERROR: G4ViewParameters::AddCutawayPlane:"
177  "\n A maximum of 3 cutaway planes supported." << G4endl;
178  }
179 }
180 
182 (size_t index, const G4Plane3D& cutawayPlane) {
183  if (index >= fCutawayPlanes.size()) {
184  G4cerr <<
185  "ERROR: G4ViewParameters::ChangeCutawayPlane:"
186  "\n Plane " << index << " does not exist." << G4endl;
187  } else {
188  fCutawayPlanes[index] = cutawayPlane;
189  }
190 }
191 
193  const G4double reasonableMaximum = 10.0 * g / cm3;
194  if (visibleDensity < 0) {
195  G4cout << "G4ViewParameters::SetVisibleDensity: attempt to set negative "
196  "density - ignored." << G4endl;
197  }
198  else {
199  if (visibleDensity > reasonableMaximum) {
200  G4cout << "G4ViewParameters::SetVisibleDensity: density > "
201  << G4BestUnit (reasonableMaximum, "Volumic Mass")
202  << " - did you mean this?"
203  << G4endl;
204  }
205  fVisibleDensity = visibleDensity;
206  }
207 }
208 
211  if (nSides < nSidesMin) {
212  nSides = nSidesMin;
213  G4cout << "G4ViewParameters::SetNoOfSides: attempt to set the"
214  "\nnumber of sides per circle < " << nSidesMin
215  << "; forced to " << nSides << G4endl;
216  }
217  fNoOfSides = nSides;
218  return fNoOfSides;
219 }
220 
222 (const G4Vector3D& viewpointDirection) {
223 
224  fViewpointDirection = viewpointDirection;
225 
226  // If the requested viewpoint direction is parallel to the up
227  // vector, the orientation of the view is undefined...
228  if (fViewpointDirection.unit() * fUpVector.unit() > .9999) {
229  static G4bool firstTime = true;
230  if (firstTime) {
231  firstTime = false;
232  G4cout <<
233  "WARNING: Viewpoint direction is very close to the up vector direction."
234  "\n Consider setting the up vector to obtain definable behaviour."
235  << G4endl;
236  }
237  }
238 
239  // Move the lights too if requested...
240  if (fLightsMoveWithCamera) {
241  G4Vector3D zprime = fViewpointDirection.unit ();
242  G4Vector3D xprime = (fUpVector.cross (zprime)).unit ();
243  G4Vector3D yprime = zprime.cross (xprime);
244  fActualLightpointDirection =
245  fRelativeLightpointDirection.x () * xprime +
246  fRelativeLightpointDirection.y () * yprime +
247  fRelativeLightpointDirection.x () * zprime;
248  } else {
249  fActualLightpointDirection = fRelativeLightpointDirection;
250  }
251 }
252 
254 (const G4Vector3D& lightpointDirection) {
255  fRelativeLightpointDirection = lightpointDirection;
256  SetViewAndLights (fViewpointDirection);
257 }
258 
260  G4Vector3D unitRight = (fUpVector.cross (fViewpointDirection)).unit();
261  G4Vector3D unitUp = (fViewpointDirection.cross (unitRight)).unit();
262  fCurrentTargetPoint = right * unitRight + up * unitUp;
263 }
264 
266  IncrementPan (right,up, 0);
267 }
268 
270  G4Vector3D unitRight = (fUpVector.cross (fViewpointDirection)).unit();
271  G4Vector3D unitUp = (fViewpointDirection.cross (unitRight)).unit();
272  fCurrentTargetPoint += right * unitRight + up * unitUp + distance * fViewpointDirection;
273 }
274 
277  // If target exists with same signifier just change vis attributes.
278  G4bool duplicateTarget = false;
279  auto i = fVisAttributesModifiers.begin();
280  for (; i < fVisAttributesModifiers.end(); ++i) {
281  if (vam.GetPVNameCopyNoPath() == (*i).GetPVNameCopyNoPath() &&
282  vam.GetVisAttributesSignifier() == (*i).GetVisAttributesSignifier()) {
283  duplicateTarget = true;
284  break;
285  }
286  }
287  if (duplicateTarget) (*i).SetVisAttributes(vam.GetVisAttributes());
288  else fVisAttributesModifiers.push_back(vam);
289 }
290 
292 (const G4Point3D standardTargetPoint) const
293 {
294  std::ostringstream oss;
295 
296  oss << "#\n# Camera and lights commands";
297 
298  oss << "\n/vis/viewer/set/viewpointVector "
299  << fViewpointDirection.x()
300  << ' ' << fViewpointDirection.y()
301  << ' ' << fViewpointDirection.z();
302 
303  oss << "\n/vis/viewer/set/upVector "
304  << fUpVector.x()
305  << ' ' << fUpVector.y()
306  << ' ' << fUpVector.z();
307 
308  oss << "\n/vis/viewer/set/projection ";
309  if (fFieldHalfAngle == 0.) {
310  oss
311  << "orthogonal";
312  } else {
313  oss
314  << "perspective "
315  << fFieldHalfAngle/deg
316  << " deg";
317  }
318 
319  oss << "\n/vis/viewer/zoomTo "
320  << fZoomFactor;
321 
322  oss << "\n/vis/viewer/scaleTo "
323  << fScaleFactor.x()
324  << ' ' << fScaleFactor.y()
325  << ' ' << fScaleFactor.z();
326 
327  oss << "\n/vis/viewer/set/targetPoint "
328  << G4BestUnit(standardTargetPoint+fCurrentTargetPoint,"Length")
329  << "\n# Note that if you have not set a target point, the vis system sets"
330  << "\n# a target point based on the scene - plus any panning and dollying -"
331  << "\n# so don't be alarmed by strange coordinates here.";
332 
333  oss << "\n/vis/viewer/dollyTo "
334  << G4BestUnit(fDolly,"Length");
335 
336  oss << "\n/vis/viewer/set/lightsMove ";
337  if (fLightsMoveWithCamera) {
338  oss << "camera";
339  } else {
340  oss << "object";
341  }
342 
343  oss << "\n/vis/viewer/set/lightsVector "
344  << fRelativeLightpointDirection.x()
345  << ' ' << fRelativeLightpointDirection.y()
346  << ' ' << fRelativeLightpointDirection.z();
347 
348  oss << "\n/vis/viewer/set/rotationStyle ";
349  if (fRotationStyle == constrainUpDirection) {
350  oss << "constrainUpDirection";
351  } else {
352  oss << "freeRotation";
353  }
354 
355  G4Colour c = fBackgroundColour;
356  oss << "\n/vis/viewer/set/background "
357  << c.GetRed()
358  << ' ' << c.GetGreen()
359  << ' ' << c.GetBlue()
360  << ' ' << c.GetAlpha();
361 
362  c = fDefaultVisAttributes.GetColour();
363  oss << "\n/vis/viewer/set/defaultColour "
364  << c.GetRed()
365  << ' ' << c.GetGreen()
366  << ' ' << c.GetBlue()
367  << ' ' << c.GetAlpha();
368 
369  c = fDefaultTextVisAttributes.GetColour();
370  oss << "\n/vis/viewer/set/defaultTextColour "
371  << c.GetRed()
372  << ' ' << c.GetGreen()
373  << ' ' << c.GetBlue()
374  << ' ' << c.GetAlpha();
375 
376  oss << std::endl;
377 
378  return oss.str();
379 }
380 
382 {
383  std::ostringstream oss;
384 
385  oss << "#\n# Drawing style commands";
386 
387  oss << "\n/vis/viewer/set/style ";
388  if (fDrawingStyle == wireframe || fDrawingStyle == hlr) {
389  oss << "wireframe";
390  } else {
391  oss << "surface";
392  }
393 
394  oss << "\n/vis/viewer/set/hiddenEdge ";
395  if (fDrawingStyle == hlr || fDrawingStyle == hlhsr) {
396  oss << "true";
397  } else {
398  oss << "false";
399  }
400 
401  oss << "\n/vis/viewer/set/auxiliaryEdge ";
402  if (fAuxEdgeVisible) {
403  oss << "true";
404  } else {
405  oss << "false";
406  }
407 
408  oss << "\n/vis/viewer/set/hiddenMarker ";
409  if (fMarkerNotHidden) {
410  oss << "false";
411  } else {
412  oss << "true";
413  }
414 
415  oss << "\n/vis/viewer/set/globalLineWidthScale "
417 
418  oss << "\n/vis/viewer/set/globalMarkerScale "
420 
421  oss << std::endl;
422 
423  return oss.str();
424 }
425 
427 {
428  std::ostringstream oss;
429 
430  oss << "#\n# Scene-modifying commands";
431 
432  oss << "\n/vis/viewer/set/culling global ";
433  if (fCulling) {
434  oss << "true";
435  } else {
436  oss << "false";
437  }
438 
439  oss << "\n/vis/viewer/set/culling invisible ";
440  if (fCullInvisible) {
441  oss << "true";
442  } else {
443  oss << "false";
444  }
445 
446  oss << "\n/vis/viewer/set/culling density ";
447  if (fDensityCulling) {
448  oss << "true " << fVisibleDensity/(g/cm3) << " g/cm3";
449  } else {
450  oss << "false";
451  }
452 
453  oss << "\n/vis/viewer/set/culling coveredDaughters ";
454  if (fCullCovered) {
455  oss << "true";
456  } else {
457  oss << "false";
458  }
459 
460  oss << "\n/vis/viewer/colourByDensity "
461  << fCBDAlgorithmNumber << " g/cm3";
462  for (auto p: fCBDParameters) {
463  oss << ' ' << p/(g/cm3);
464  }
465 
466  oss << "\n/vis/viewer/set/sectionPlane ";
467  if (fSection) {
468  oss << "on "
469  << G4BestUnit(fSectionPlane.point(),"Length")
470  << fSectionPlane.normal().x()
471  << ' ' << fSectionPlane.normal().y()
472  << ' ' << fSectionPlane.normal().z();
473  } else {
474  oss << "off";
475  }
476 
477  oss << "\n/vis/viewer/set/cutawayMode ";
478  if (fCutawayMode == cutawayUnion) {
479  oss << "union";
480  } else {
481  oss << "intersection";
482  }
483 
484  oss << "\n/vis/viewer/clearCutawayPlanes";
485  if (fCutawayPlanes.size()) {
486  for (size_t i = 0; i < fCutawayPlanes.size(); i++) {
487  oss << "\n/vis/viewer/addCutawayPlane "
488  << G4BestUnit(fCutawayPlanes[i].point(),"Length")
489  << fCutawayPlanes[i].normal().x()
490  << ' ' << fCutawayPlanes[i].normal().y()
491  << ' ' << fCutawayPlanes[i].normal().z();
492  }
493  } else {
494  oss << "\n# No cutaway planes defined.";
495  }
496 
497  oss << "\n/vis/viewer/set/explodeFactor "
498  << fExplodeFactor
499  << ' ' << G4BestUnit(fExplodeCentre,"Length");
500 
501  oss << "\n/vis/viewer/set/lineSegmentsPerCircle "
502  << fNoOfSides;
503 
504  oss << std::endl;
505 
506  return oss.str();
507 }
508 
510 {
511  std::ostringstream oss;
512 
513  oss << "#\n# Touchable commands";
514 
515  const std::vector<G4ModelingParameters::VisAttributesModifier>& vams =
517 
518  if (vams.empty()) {
519  oss
520  << "\n# None"
521  << "\n/vis/viewer/clearVisAttributesModifiers";
522  oss << std::endl;
523  return oss.str();
524  }
525 
526  oss
527  << "\n/vis/viewer/clearVisAttributesModifiers";
528 
530  std::vector<G4ModelingParameters::VisAttributesModifier>::const_iterator
531  iModifier;
532  for (iModifier = vams.begin();
533  iModifier != vams.end();
534  ++iModifier) {
536  iModifier->GetPVNameCopyNoPath();
537  if (vamPath != lastPath) {
538  lastPath = vamPath;
539  oss << "\n/vis/set/touchable";
541  for (iVAM = vamPath.begin();
542  iVAM != vamPath.end();
543  ++iVAM) {
544  oss << ' ' << iVAM->GetName() << ' ' << iVAM->GetCopyNo();
545  }
546  }
547  const G4VisAttributes& vamVisAtts = iModifier->GetVisAttributes();
548  const G4Colour& c = vamVisAtts.GetColour();
549  switch (iModifier->GetVisAttributesSignifier()) {
551  oss << "\n/vis/touchable/set/visibility ";
552  if (vamVisAtts.IsVisible()) {
553  oss << "true";
554  } else {
555  oss << "false";
556  }
557  break;
559  oss << "\n/vis/touchable/set/daughtersInvisible ";
560  if (vamVisAtts.IsDaughtersInvisible()) {
561  oss << "true";
562  } else {
563  oss << "false";
564  }
565  break;
567  oss << "\n/vis/touchable/set/colour "
568  << c.GetRed()
569  << ' ' << c.GetGreen()
570  << ' ' << c.GetBlue()
571  << ' ' << c.GetAlpha();
572  break;
574  oss << "\n/vis/touchable/set/lineStyle ";
575  switch (vamVisAtts.GetLineStyle()) {
577  oss << "unbroken";
578  break;
580  oss << "dashed";
581  break;
583  oss << "dotted";
584  }
585  break;
587  oss << "\n/vis/touchable/set/lineWidth "
588  << vamVisAtts.GetLineWidth();
589  break;
591  if (vamVisAtts.IsForceDrawingStyle()) {
593  oss << "\n/vis/touchable/set/forceWireframe ";
594  if (vamVisAtts.IsForceDrawingStyle()) {
595  oss << "true";
596  } else {
597  oss << "false";
598  }
599  }
600  }
601  break;
603  if (vamVisAtts.IsForceDrawingStyle()) {
604  if (vamVisAtts.GetForcedDrawingStyle() == G4VisAttributes::solid) {
605  oss << "\n/vis/touchable/set/forceSolid ";
606  if (vamVisAtts.IsForceDrawingStyle()) {
607  oss << "true";
608  } else {
609  oss << "false";
610  }
611  }
612  }
613  break;
615  if (vamVisAtts.IsForceAuxEdgeVisible()) {
616  oss << "\n/vis/touchable/set/forceAuxEdgeVisible ";
617  if (vamVisAtts.IsForcedAuxEdgeVisible()) {
618  oss << "true";
619  } else {
620  oss << "false";
621  }
622  }
623  break;
625  if (vamVisAtts.GetForcedLineSegmentsPerCircle() > 0) {
626  oss << "\n/vis/touchable/set/lineSegmentsPerCircle "
627  << vamVisAtts.GetForcedLineSegmentsPerCircle();
628  }
629  break;
630  }
631  }
632 
633  oss << std::endl;
634 
635  return oss.str();
636 }
637 
639 {
640  std::ostringstream oss;
641 
642  oss << "#\n# Time window commands";
643 
644  oss
645  << "\n/vis/viewer/set/timeWindow/startTime "
646  << fStartTime/ns << " ns ";
647 
648  oss
649  << "\n/vis/viewer/set/timeWindow/endTime "
650  << fEndTime/ns << " ns ";
651 
652  oss << "\n/vis/viewer/set/timeWindow/fadeFactor "
653  << fFadeFactor;
654 
655  oss
656  << "\n/vis/viewer/set/timeWindow/displayHeadTime ";
657  if (!fDisplayHeadTime) {
658  oss << "false";
659  } else {
660  oss
661  << "true"
662  << ' ' << fDisplayHeadTimeX
663  << ' ' << fDisplayHeadTimeY
664  << ' ' << fDisplayHeadTimeSize
665  << ' ' << fDisplayHeadTimeRed
666  << ' ' << fDisplayHeadTimeGreen
667  << ' ' << fDisplayHeadTimeBlue;
668  }
669 
670  oss
671  << "\n/vis/viewer/set/timeWindow/displayLightFront ";
672  if (!fDisplayLightFront) {
673  oss << "false";
674  } else {
675  oss
676  << "true"
677  << ' ' << fDisplayLightFrontX/mm
678  << ' ' << fDisplayLightFrontY/mm
679  << ' ' << fDisplayLightFrontZ/mm
680  << " mm"
681  << ' ' << fDisplayLightFrontT/ns
682  << " ns"
683  << ' ' << fDisplayLightFrontRed
684  << ' ' << fDisplayLightFrontGreen
685  << ' ' << fDisplayLightFrontBlue;
686  }
687 
688  oss << std::endl;
689 
690  return oss.str();
691 }
692 
694 
695  // Put performance-sensitive parameters first.
696  if (
697  // This first to optimise spin, etc.
699 
700  // No particular order from here on.
701  (fDrawingStyle != v.fDrawingStyle) ||
703  (fCulling != v.fCulling) ||
707  (fCullCovered != v.fCullCovered) ||
709  (fSection != v.fSection) ||
710  (fNoOfSides != v.fNoOfSides) ||
711  (fUpVector != v.fUpVector) ||
713  (fZoomFactor != v.fZoomFactor) ||
714  (fScaleFactor != v.fScaleFactor) ||
716  (fDolly != v.fDolly) ||
728  (fGeometryMask != v.fGeometryMask) ||
729  (fAutoRefresh != v.fAutoRefresh) ||
731  (fPicking != v.fPicking) ||
733  )
734  G4cout << "Difference in 1st batch." << G4endl;
735 
736  if (fCBDAlgorithmNumber > 0) {
737  if (fCBDParameters.size() != v.fCBDParameters.size()) {
738  G4cout << "Difference in number of colour by density parameters." << G4endl;
739  } else if (fCBDParameters != v.fCBDParameters) {
740  G4cout << "Difference in values of colour by density parameters." << G4endl;
741  }
742  }
743 
744  if (fSection) {
745  if (!(fSectionPlane == v.fSectionPlane))
746  G4cout << "Difference in section planes batch." << G4endl;
747  }
748 
749  if (IsCutaway()) {
750  if (fCutawayPlanes.size () != v.fCutawayPlanes.size ()) {
751  G4cout << "Difference in no of cutaway planes." << G4endl;
752  }
753  else {
754  for (size_t i = 0; i < fCutawayPlanes.size (); i++) {
755  if (!(fCutawayPlanes[i] == v.fCutawayPlanes[i]))
756  G4cout << "Difference in cutaway plane no. " << i << G4endl;
757  }
758  }
759  }
760 
761  if (IsExplode()) {
763  G4cout << "Difference in explode factor." << G4endl;
765  G4cout << "Difference in explode centre." << G4endl;
766  }
767 
769  G4cout << "Difference in vis attributes modifiers." << G4endl;
770  }
771 
772  if (fStartTime != v.fStartTime ||
773  fEndTime != v.fEndTime) {
774  G4cout << "Difference in time window." << G4endl;
775  }
776 
777  if (fFadeFactor != v.fFadeFactor) {
778  G4cout << "Difference in time window fade factor." << G4endl;
779  }
780 
782  G4cout << "Difference in display head time flag." << G4endl;
783  } else {
790  G4cout << "Difference in display head time parameters." << G4endl;
791  }
792  }
793 
795  G4cout << "Difference in display light front flag." << G4endl;
796  } else {
804  G4cout << "Difference in display light front parameters." << G4endl;
805  }
806  }
807 }
808 
809 std::ostream& operator <<
810 (std::ostream& os, const G4ViewParameters::DrawingStyle& style)
811 {
812  switch (style) {
814  os << "wireframe"; break;
816  os << "hlr - hidden lines removed"; break;
818  os << "hsr - hidden surfaces removed"; break;
820  os << "hlhsr - hidden line, hidden surface removed"; break;
821  default: os << "unrecognised"; break;
822  }
823  return os;
824 }
825 
826 std::ostream& operator << (std::ostream& os, const G4ViewParameters& v) {
827  os << "View parameters and options:";
828 
829  os << "\n Drawing style: ";
830  switch (v.fDrawingStyle) {
832  os << "edges, wireframe"; break;
834  os << "edges, hidden line removal"; break;
836  os << "surfaces, hidden surface removal"; break;
838  os << "surfaces and edges, hidden line and surface removal"; break;
839  default: os << "unrecognised"; break;
840  }
841 
842  os << "\n Auxiliary edges: ";
843  if (!v.fAuxEdgeVisible) os << "in";
844  os << "visible";
845 
846  os << "\n Culling: ";
847  if (v.fCulling) os << "on";
848  else os << "off";
849 
850  os << "\n Culling invisible objects: ";
851  if (v.fCullInvisible) os << "on";
852  else os << "off";
853 
854  os << "\n Density culling: ";
855  if (v.fDensityCulling) {
856  os << "on - invisible if density less than "
857  << v.fVisibleDensity / (1. * g / cm3) << " g cm^-3";
858  }
859  else os << "off";
860 
861  os << "\n Culling daughters covered by opaque mothers: ";
862  if (v.fCullCovered) os << "on";
863  else os << "off";
864 
865  os << "\n Colour by density: ";
866  if (v.fCBDAlgorithmNumber <= 0) {
867  os << "inactive";
868  } else {
869  os << "Algorithm " << v.fCBDAlgorithmNumber << ", Parameters:";
870  for (auto p: v.fCBDParameters) {
871  os << ' ' << G4BestUnit(p,"Volumic Mass");
872  }
873  }
874 
875  os << "\n Section flag: ";
876  if (v.fSection) os << "true, section/cut plane: " << v.fSectionPlane;
877  else os << "false";
878 
879  if (v.IsCutaway()) {
880  os << "\n Cutaway planes: ";
881  for (size_t i = 0; i < v.fCutawayPlanes.size (); i++) {
882  os << ' ' << v.fCutawayPlanes[i];
883  }
884  }
885  else {
886  os << "\n No cutaway planes";
887  }
888 
889  os << "\n Explode factor: " << v.fExplodeFactor
890  << " about centre: " << v.fExplodeCentre;
891 
892  os << "\n No. of sides used in circle polygon approximation: "
893  << v.fNoOfSides;
894 
895  os << "\n Viewpoint direction: " << v.fViewpointDirection;
896 
897  os << "\n Up vector: " << v.fUpVector;
898 
899  os << "\n Field half angle: " << v.fFieldHalfAngle;
900 
901  os << "\n Zoom factor: " << v.fZoomFactor;
902 
903  os << "\n Scale factor: " << v.fScaleFactor;
904 
905  os << "\n Current target point: " << v.fCurrentTargetPoint;
906 
907  os << "\n Dolly distance: " << v.fDolly;
908 
909  os << "\n Light ";
910  if (v.fLightsMoveWithCamera) os << "moves";
911  else os << "does not move";
912  os << " with camera";
913 
914  os << "\n Relative lightpoint direction: "
916 
917  os << "\n Actual lightpoint direction: "
919 
920  os << "\n Derived parameters for standard view of object of unit radius:";
921  G4ViewParameters tempVP = v;
922  tempVP.fDolly = 0.;
923  tempVP.fZoomFactor = 1.;
924  const G4double radius = 1.;
925  const G4double cameraDistance = tempVP.GetCameraDistance (radius);
926  const G4double nearDistance =
927  tempVP.GetNearDistance (cameraDistance, radius);
928  const G4double farDistance =
929  tempVP.GetFarDistance (cameraDistance, nearDistance, radius);
930  const G4double right = tempVP.GetFrontHalfHeight (nearDistance, radius);
931  os << "\n Camera distance: " << cameraDistance;
932  os << "\n Near distance: " << nearDistance;
933  os << "\n Far distance: " << farDistance;
934  os << "\n Front half height: " << right;
935 
936  os << "\n Default VisAttributes:\n " << v.fDefaultVisAttributes;
937 
938  os << "\n Default TextVisAttributes:\n " << v.fDefaultTextVisAttributes;
939 
940  os << "\n Default marker: " << v.fDefaultMarker;
941 
942  os << "\n Global marker scale: " << v.fGlobalMarkerScale;
943 
944  os << "\n Global lineWidth scale: " << v.fGlobalLineWidthScale;
945 
946  os << "\n Marker ";
947  if (v.fMarkerNotHidden) os << "not ";
948  os << "hidden by surfaces.";
949 
950  os << "\n Window size hint: "
951  << v.fWindowSizeHintX << 'x'<< v.fWindowSizeHintX;
952 
953  os << "\n X geometry string: " << v.fXGeometryString;
954  os << "\n X geometry mask: "
955  << std::showbase << std::hex << v.fGeometryMask
956  << std::noshowbase << std::dec;
957 
958  os << "\n Auto refresh: ";
959  if (v.fAutoRefresh) os << "true";
960  else os << "false";
961 
962  os << "\n Background colour: " << v.fBackgroundColour;
963 
964  os << "\n Picking requested: ";
965  if (v.fPicking) os << "true";
966  else os << "false";
967 
968  os << "\n Rotation style: ";
969  switch (v.fRotationStyle) {
971  os << "constrainUpDirection (conventional HEP view)"; break;
973  os << "freeRotation (Google-like rotation, using mouse-grab)"; break;
974  default: os << "unrecognised"; break;
975  }
976 
977  os << "\n Vis attributes modifiers: ";
978  const std::vector<G4ModelingParameters::VisAttributesModifier>& vams =
980  if (vams.empty()) {
981  os << "None";
982  } else {
983  os << vams;
984  }
985 
986  os << "\n Time window parameters:"
987  << "\n Start time: " << v.fStartTime/ns << " ns"
988  << "\n End time: " << v.fEndTime/ns << " ns"
989  << "\n Fade factor: " << v.fFadeFactor;
990  if (!v.fDisplayHeadTime) {
991  os << "\n Head time display not requested.";
992  } else {
993  os
994  << "\n Head time position: "
995  << v.fDisplayHeadTimeX << ' ' << v.fDisplayHeadTimeY
996  << "\n Head time size: " << v.fDisplayHeadTimeSize
997  << "\n Head time colour: " << v.fDisplayHeadTimeRed
998  << ' ' << v.fDisplayHeadTimeGreen << ' ' << v.fDisplayHeadTimeBlue;
999  }
1000  if (!v.fDisplayLightFront) {
1001  os << "\n Light front display not requested.";
1002  } else {
1003  os
1004  << "\n Light front position: "
1005  << v.fDisplayLightFrontX/mm << ' ' << v.fDisplayLightFrontY/mm
1006  << v.fDisplayLightFrontZ/mm << " mm"
1007  << "\n Light front time: " << v.fDisplayLightFrontT/ns << " ns"
1008  << "\n Light front colour: " << v.fDisplayLightFrontRed
1009  << ' ' << v.fDisplayLightFrontGreen << ' ' << v.fDisplayLightFrontBlue;
1010  }
1011 
1012  return os;
1013 }
1014 
1016 
1017  // Put performance-sensitive parameters first.
1018  if (
1019  // This first to optimise spin, etc.
1021 
1022  // No particular order from here on.
1023  (fDrawingStyle != v.fDrawingStyle) ||
1025  (fCulling != v.fCulling) ||
1026  (fCullInvisible != v.fCullInvisible) ||
1028  (fCullCovered != v.fCullCovered) ||
1030  (fSection != v.fSection) ||
1031  (IsCutaway() != v.IsCutaway()) ||
1032  (IsExplode() != v.IsExplode()) ||
1033  (fNoOfSides != v.fNoOfSides) ||
1034  (fUpVector != v.fUpVector) ||
1036  (fZoomFactor != v.fZoomFactor) ||
1037  (fScaleFactor != v.fScaleFactor) ||
1039  (fDolly != v.fDolly) ||
1044  (fDefaultMarker != v.fDefaultMarker) ||
1051  (fGeometryMask != v.fGeometryMask) ||
1052  (fAutoRefresh != v.fAutoRefresh) ||
1054  (fPicking != v.fPicking) ||
1056  )
1057  return true;
1058 
1059  if (fDensityCulling &&
1060  (fVisibleDensity != v.fVisibleDensity)) return true;
1061 
1062  if (fCBDAlgorithmNumber > 0) {
1063  if (fCBDParameters.size() != v.fCBDParameters.size()) return true;
1064  else if (fCBDParameters != v.fCBDParameters) return true;
1065  }
1066 
1067  if (fSection &&
1068  (!(fSectionPlane == v.fSectionPlane))) return true;
1069 
1070  if (IsCutaway()) {
1071  if (fCutawayPlanes.size () != v.fCutawayPlanes.size ())
1072  return true;
1073  else {
1074  for (size_t i = 0; i < fCutawayPlanes.size (); i++) {
1075  if (!(fCutawayPlanes[i] == v.fCutawayPlanes[i])) return true;
1076  }
1077  }
1078  }
1079 
1080  if (IsExplode() &&
1081  ((fExplodeFactor != v.fExplodeFactor) ||
1082  (fExplodeCentre != v.fExplodeCentre))) return true;
1083 
1084  if (fVisAttributesModifiers != v.fVisAttributesModifiers) return true;
1085 
1086  if (fStartTime != v.fStartTime ||
1087  fEndTime != v.fEndTime ||
1088  fFadeFactor != v.fFadeFactor) return true;
1089 
1090  if (fDisplayHeadTime != v.fDisplayHeadTime) return true;
1091  if (fDisplayHeadTime) {
1098  return true;
1099  }
1100  }
1101 
1102  if (fDisplayLightFront != v.fDisplayLightFront) return true;
1103  if (fDisplayLightFront) {
1111  return true;
1112  }
1113  }
1114 
1115  return false;
1116 }
1117 
1119 {
1120  G4int x = 0, y = 0;
1121  unsigned int w = 0, h = 0;
1122  G4String geomString = geomStringArg;
1123  // Parse windowSizeHintString for backwards compatibility...
1124  const G4String delimiters("xX+-");
1125  G4String::size_type i = geomString.find_first_of(delimiters);
1126  if (i == G4String::npos) { // Does not contain "xX+-". Assume single number
1127  std::istringstream iss(geomString);
1128  G4int size;
1129  iss >> size;
1130  if (!iss) {
1131  size = 600;
1132  G4cout << "Unrecognised windowSizeHint string: \""
1133  << geomString
1134  << "\". Asuuming " << size << G4endl;
1135  }
1136  std::ostringstream oss;
1137  oss << size << 'x' << size;
1138  geomString = oss.str();
1139  }
1140 
1141  fGeometryMask = ParseGeometry( geomString, &x, &y, &w, &h );
1142 
1143  // Handle special case :
1144  if ((fGeometryMask & fYValue) == 0)
1145  { // Using default
1147  }
1148  if ((fGeometryMask & fXValue) == 0)
1149  { // Using default
1151  }
1152 
1153  // Check errors
1154  // if there is no Width and Height
1155  if ( ((fGeometryMask & fHeightValue) == 0 ) &&
1156  ((fGeometryMask & fWidthValue) == 0 )) {
1157  h = fWindowSizeHintY;
1158  w = fWindowSizeHintX;
1159  } else if ((fGeometryMask & fHeightValue) == 0 ) {
1160 
1161  // if there is only Width. Special case to be backward compatible
1162  // We set Width and Height the same to obtain a square windows.
1163 
1164  G4cout << "Unrecognised geometry string \""
1165  << geomString
1166  << "\". No Height found. Using Width value instead"
1167  << G4endl;
1168  h = w;
1169  }
1170  if ( ((fGeometryMask & fXValue) == 0 ) ||
1171  ((fGeometryMask & fYValue) == 0 )) {
1172  //Using defaults
1175  }
1176  // Set the string
1177  fXGeometryString = geomString;
1178 
1179  // Set values
1180  fWindowSizeHintX = w;
1181  fWindowSizeHintY = h;
1184 
1185  if ( ((fGeometryMask & fXValue)) &&
1186  ((fGeometryMask & fYValue))) {
1187 
1188  if ( (fGeometryMask & fXNegative) ) {
1190  } else {
1192  }
1193  if ( (fGeometryMask & fYNegative) ) {
1195  } else {
1197  }
1198  }
1199 }
1200 
1203  return sizeX + fWindowLocationHintX - fWindowSizeHintX;
1204  }
1205  return fWindowLocationHintX;
1206 }
1207 
1210  return sizeY + fWindowLocationHintY - fWindowSizeHintY;
1211  }
1212  return fWindowLocationHintY;
1213 }
1214 
1215 /* Keep from :
1216  * 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
1217  *
1218  * ParseGeometry parses strings of the form
1219  * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
1220  * width, height, xoffset, and yoffset are unsigned integers.
1221  * Example: "=80x24+300-49"
1222  * The equal sign is optional.
1223  * It returns a bitmask that indicates which of the four values
1224  * were actually found in the string. For each value found,
1225  * the corresponding argument is updated; for each value
1226  * not found, the corresponding argument is left unchanged.
1227  */
1228 
1230  const char *string,
1231  G4int *x,
1232  G4int *y,
1233  unsigned int *width,
1234  unsigned int *height)
1235 {
1236 
1237  G4int mask = fNoValue;
1238  char *strind;
1239  unsigned int tempWidth = 0;
1240  unsigned int tempHeight = 0;
1241  G4int tempX = 0;
1242  G4int tempY = 0;
1243  char *nextCharacter;
1244  if ( (string == NULL) || (*string == '\0')) {
1245  return(mask);
1246  }
1247  if (*string == '=')
1248  string++; /* ignore possible '=' at beg of geometry spec */
1249  strind = (char *)string;
1250  if (*strind != '+' && *strind != '-' && *strind != 'x') {
1251  tempWidth = ReadInteger(strind, &nextCharacter);
1252  if (strind == nextCharacter)
1253  return (0);
1254  strind = nextCharacter;
1255  mask |= fWidthValue;
1256  }
1257  if (*strind == 'x' || *strind == 'X') {
1258  strind++;
1259  tempHeight = ReadInteger(strind, &nextCharacter);
1260  if (strind == nextCharacter)
1261  return (0);
1262  strind = nextCharacter;
1263  mask |= fHeightValue;
1264  }
1265 
1266  if ((*strind == '+') || (*strind == '-')) {
1267  if (*strind == '-') {
1268  strind++;
1269  tempX = -ReadInteger(strind, &nextCharacter);
1270  if (strind == nextCharacter)
1271  return (0);
1272  strind = nextCharacter;
1273  mask |= fXNegative;
1274 
1275  }
1276  else
1277  { strind++;
1278  tempX = ReadInteger(strind, &nextCharacter);
1279  if (strind == nextCharacter)
1280  return(0);
1281  strind = nextCharacter;
1282  }
1283  mask |= fXValue;
1284  if ((*strind == '+') || (*strind == '-')) {
1285  if (*strind == '-') {
1286  strind++;
1287  tempY = -ReadInteger(strind, &nextCharacter);
1288  if (strind == nextCharacter)
1289  return(0);
1290  strind = nextCharacter;
1291  mask |= fYNegative;
1292  }
1293  else
1294  {
1295  strind++;
1296  tempY = ReadInteger(strind, &nextCharacter);
1297  if (strind == nextCharacter)
1298  return(0);
1299  strind = nextCharacter;
1300  }
1301  mask |= fYValue;
1302  }
1303  }
1304  /* If strind isn't at the end of the string the it's an invalid
1305  geometry specification. */
1306  if (*strind != '\0') return (0);
1307  if (mask & fXValue)
1308  *x = tempX;
1309  if (mask & fYValue)
1310  *y = tempY;
1311  if (mask & fWidthValue)
1312  *width = tempWidth;
1313  if (mask & fHeightValue)
1314  *height = tempHeight;
1315  return (mask);
1316 }
1317 
1318 /* Keep from :
1319  * 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
1320  *
1321  */
1322 G4int G4ViewParameters::ReadInteger(char *string, char **NextString)
1323 {
1324  G4int Result = 0;
1325  G4int Sign = 1;
1326 
1327  if (*string == '+')
1328  string++;
1329  else if (*string == '-')
1330  {
1331  string++;
1332  Sign = -1;
1333  }
1334  for (; (*string >= '0') && (*string <= '9'); string++)
1335  {
1336  Result = (Result * 10) + (*string - '0');
1337  }
1338  *NextString = string;
1339  if (Sign >= 0)
1340  return (Result);
1341  else
1342  return (-Result);
1343 }
1344 
1346 (const std::vector<G4ViewParameters>& views,
1347  G4int nInterpolationPoints) // No of interpolations points per interval
1348 {
1349  // Returns a null pointer when no more to be done. For example:
1350  // do {
1351  // G4ViewParameters* vp =
1352  // G4ViewParameters::CatmullRomCubicSplineInterpolation(viewVector,nInterpolationPoints);
1353  // if (!vp) break;
1354  // ...
1355  // } while (true);
1356 
1357  // See https://en.wikipedia.org/wiki/Cubic_Hermite_spline
1358 
1359  // Assumes equal intervals
1360 
1361  if (views.size() < 2) {
1362  G4Exception
1363  ("G4ViewParameters::CatmullRomCubicSplineInterpolation",
1364  "visman0301", JustWarning,
1365  "There must be at least two views.");
1366  return 0;
1367  }
1368 
1369  if (nInterpolationPoints < 1) {
1370  G4Exception
1371  ("G4ViewParameters::CatmullRomCubicSplineInterpolation",
1372  "visman0302", JustWarning,
1373  "Number of interpolation points cannot be zero or negative.");
1374  return 0;
1375  }
1376 
1377  const size_t nIntervals = views.size() - 1;
1378  const G4double dt = 1./nInterpolationPoints;
1379 
1380  static G4ViewParameters holdingValues;
1381  static G4double t = 0.; // 0. <= t <= 1.
1382  static G4int iInterpolationPoint = 0;
1383  static size_t iInterval = 0;
1384 
1385 // G4cout << "Interval " << iInterval << ", t = " << t << G4endl;
1386 
1387  // Hermite polynomials.
1388  const G4double h00 = 2.*t*t*t - 3.*t*t +1;
1389  const G4double h10 = t*t*t -2.*t*t + t;
1390  const G4double h01 = -2.*t*t*t + 3.*t*t;
1391  const G4double h11 = t*t*t - t*t;
1392 
1393  // Aliases (to simplify code)
1394  const size_t& n = nIntervals;
1395  size_t& i = iInterval;
1396  const std::vector<G4ViewParameters>& v = views;
1397 
1398  // The Catmull-Rom cubic spline prescription is as follows:
1399  // Slope at first way point is v[1] - v[0].
1400  // Slope at last way point is v[n] - v[n-1].
1401  // Otherwise slope at way point i is 0.5*(v[i+1] - v[i-1]).
1402  // Result = h00*v[i] + h10*m[i] + h01*v[i+1] + h11*m[i+1],
1403  // where m[i] amd m[i+1] are the slopes at the start and end
1404  // of the interval for the particular value.
1405  // If (n == 1), linear interpolation results.
1406  // If (n == 2), quadratic interpolation results.
1407 
1408  // Working variables
1409  G4double mi, mi1, real, x, y, z;
1410 
1411  // First, a crude interpolation of all parameters. Then, below, a
1412  // smooth interpolation of those for which it makes sense.
1413  holdingValues = t < 0.5? v[i]: v[i+1];
1414 
1415  // Catmull-Rom cubic spline interpolation
1416 #define INTERPOLATE(param) \
1417  /* This works out the interpolated param in i'th interval */ \
1418  /* Assumes n >= 1 */ \
1419  if (i == 0) { \
1420  /* First interval */ \
1421  mi = v[1].param - v[0].param; \
1422  /* If there is only one interval, make start and end slopes equal */ \
1423  /* (This results in a linear interpolation) */ \
1424  if (n == 1) mi1 = mi; \
1425  /* else the end slope of the interval takes account of the next waypoint along */ \
1426  else mi1 = 0.5 * (v[2].param - v[0].param); \
1427  } else if (i >= n - 1) { \
1428  /* Similarly for last interval */ \
1429  mi1 = v[i+1].param - v[i].param; \
1430  /* If there is only one interval, make start and end slopes equal */ \
1431  if (n == 1) mi = mi1; \
1432  /* else the start slope of the interval takes account of the previous waypoint */ \
1433  else mi = 0.5 * (v[i+1].param - v[i-1].param); \
1434  } else { \
1435  /* Full Catmull-Rom slopes use previous AND next waypoints */ \
1436  mi = 0.5 * (v[i+1].param - v[i-1].param); \
1437  mi1 = 0.5 * (v[i+2].param - v[i ].param); \
1438  } \
1439  real = h00 * v[i].param + h10 * mi + h01 * v[i+1].param + h11 * mi1;
1440 
1441  // Real parameters
1442  INTERPOLATE(fVisibleDensity);
1443  if (real < 0.) real = 0.;
1444  holdingValues.fVisibleDensity = real;
1445  INTERPOLATE(fExplodeFactor);
1446  if (real < 0.) real = 0.;
1447  holdingValues.fExplodeFactor = real;
1448  INTERPOLATE(fFieldHalfAngle);
1449  if (real < 0.) real = 0.;
1450  holdingValues.fFieldHalfAngle = real;
1451  INTERPOLATE(fZoomFactor);
1452  if (real < 0.) real = 0.;
1453  holdingValues.fZoomFactor = real;
1454  INTERPOLATE(fDolly);
1455  holdingValues.fDolly = real;
1456  INTERPOLATE(fGlobalMarkerScale);
1457  if (real < 0.) real = 0.;
1458  holdingValues.fGlobalMarkerScale = real;
1459  INTERPOLATE(fGlobalLineWidthScale);
1460  if (real < 0.) real = 0.;
1461  holdingValues.fGlobalLineWidthScale = real;
1462 
1463  // Unit vectors
1464 #define INTERPOLATEUNITVECTOR(vector) \
1465 INTERPOLATE(vector.x()); x = real; \
1466 INTERPOLATE(vector.y()); y = real; \
1467 INTERPOLATE(vector.z()); z = real;
1468  INTERPOLATEUNITVECTOR(fViewpointDirection);
1469  holdingValues.fViewpointDirection = G4Vector3D(x,y,z).unit();
1470  INTERPOLATEUNITVECTOR(fUpVector);
1471  holdingValues.fUpVector = G4Vector3D(x,y,z).unit();
1472  INTERPOLATEUNITVECTOR(fRelativeLightpointDirection);
1473  holdingValues.fRelativeLightpointDirection = G4Vector3D(x,y,z).unit();
1474  INTERPOLATEUNITVECTOR(fActualLightpointDirection);
1475  holdingValues.fActualLightpointDirection = G4Vector3D(x,y,z).unit();
1476 
1477  // Un-normalised vectors
1478 #define INTERPOLATEVECTOR(vector) \
1479 INTERPOLATE(vector.x()); x = real; \
1480 INTERPOLATE(vector.y()); y = real; \
1481 INTERPOLATE(vector.z()); z = real;
1482  INTERPOLATEVECTOR(fScaleFactor);
1483  holdingValues.fScaleFactor = G4Vector3D(x,y,z);
1484 
1485  // Points
1486 #define INTERPOLATEPOINT(point) \
1487 INTERPOLATE(point.x()); x = real; \
1488 INTERPOLATE(point.y()); y = real; \
1489 INTERPOLATE(point.z()); z = real;
1490  INTERPOLATEPOINT(fExplodeCentre);
1491  holdingValues.fExplodeCentre = G4Point3D(x,y,z);
1492  INTERPOLATEPOINT(fCurrentTargetPoint);
1493  holdingValues.fCurrentTargetPoint = G4Point3D(x,y,z);
1494 
1495  // Colour
1496  G4double red, green, blue, alpha;
1497 #define INTERPOLATECOLOUR(colour) \
1498 INTERPOLATE(colour.GetRed()); red = real; \
1499 INTERPOLATE(colour.GetGreen()); green = real; \
1500 INTERPOLATE(colour.GetBlue()); blue = real; \
1501 INTERPOLATE(colour.GetAlpha()); alpha = real;
1502  INTERPOLATECOLOUR(fBackgroundColour);
1503  // Components are clamped to 0. <= component <= 1.
1504  holdingValues.fBackgroundColour = G4Colour(red,green,blue,alpha);
1505 
1506  // For some parameters we need to check some continuity
1507  G4bool continuous;
1508 #define CONTINUITY(quantity) \
1509  continuous = false; \
1510  /* This follows the logic of the INTERPOLATE macro above; see comments therein */ \
1511  if (i == 0) { \
1512  if (v[1].quantity == v[0].quantity) { \
1513  if (n == 1) continuous = true; \
1514  else if (v[2].quantity == v[0].quantity) \
1515  continuous = true; \
1516  } \
1517  } else if (i >= n - 1) { \
1518  if (v[i+1].quantity == v[i].quantity) { \
1519  if (n == 1) continuous = true; \
1520  else if (v[i+1].quantity == v[i-1].quantity) \
1521  continuous = true; \
1522  } \
1523  } else { \
1524  if (v[i-1].quantity == v[i].quantity && \
1525  v[i+1].quantity == v[i].quantity && \
1526  v[i+2].quantity == v[i].quantity) \
1527  continuous = true; \
1528  }
1529 
1530  G4double a, b, c, d;
1531 #define INTERPOLATEPLANE(plane) \
1532 INTERPOLATE(plane.a()); a = real; \
1533 INTERPOLATE(plane.b()); b = real; \
1534 INTERPOLATE(plane.c()); c = real; \
1535 INTERPOLATE(plane.d()); d = real;
1536 
1537  // Section plane
1538  CONTINUITY(fSection);
1539  if (continuous) {
1540  INTERPOLATEPLANE(fSectionPlane);
1541  holdingValues.fSectionPlane = G4Plane3D(a,b,c,d);
1542  }
1543 
1544  // Cutaway planes
1545  if (v[i].fCutawayPlanes.size()) {
1546  CONTINUITY(fCutawayPlanes.size());
1547  if (continuous) {
1548  for (size_t j = 0; j < v[i].fCutawayPlanes.size(); ++j) {
1549  INTERPOLATEPLANE(fCutawayPlanes[j]);
1550  holdingValues.fCutawayPlanes[j] = G4Plane3D(a,b,c,d);
1551  }
1552  }
1553  }
1554 
1555  // Vis attributes modifiers
1556  // Really, we are only interested in colour - other attributes can follow
1557  // the "crude" interpolation that is guaranteed above.
1558  static G4VisAttributes workingVA;
1559  if (v[i].fVisAttributesModifiers.size()) {
1560  CONTINUITY(fVisAttributesModifiers.size());
1561  if (continuous) {
1562  for (size_t j = 0; j < v[i].fVisAttributesModifiers.size(); ++j) {
1563  CONTINUITY(fVisAttributesModifiers[j].GetPVNameCopyNoPath());
1564  if (continuous) {
1565  CONTINUITY(fVisAttributesModifiers[j].GetVisAttributesSignifier());
1566  if (continuous) {
1567  if (v[i].fVisAttributesModifiers[j].GetVisAttributesSignifier() ==
1569  INTERPOLATECOLOUR(fVisAttributesModifiers[j].GetVisAttributes().GetColour());
1570  workingVA = v[i].fVisAttributesModifiers[j].GetVisAttributes();
1571  workingVA.SetColour(G4Colour(red,green,blue,alpha));
1572  holdingValues.fVisAttributesModifiers[j].SetVisAttributes(workingVA);
1573  }
1574  }
1575  }
1576  }
1577  }
1578  }
1579 
1580  // Time window parameters (for showing particles in flight)
1581  // Only two parameters are interpolated. The others are usually chosen
1582  // once and for all by the user for a given series of views - or at least,
1583  // if not, they will be interpolated by the default "crude" method above.
1584  INTERPOLATE(fStartTime)
1585  holdingValues.fStartTime = real;
1586  INTERPOLATE(fEndTime)
1587  holdingValues.fEndTime = real;
1588 
1589  // Increment counters
1590  iInterpolationPoint++;
1591  t += dt;
1592  if (iInterpolationPoint > nInterpolationPoints) {
1593  iInterpolationPoint = 1; // Ready for next interval.
1594  t = dt;
1595  iInterval++;
1596  }
1597  if (iInterval >= nIntervals) {
1598  iInterpolationPoint = 0; // Ready for a complete restart.
1599  t = 0.;
1600  iInterval = 0;
1601  return 0;
1602  }
1603 
1604  return &holdingValues;
1605 }
Float_t x
Definition: compare.C:6
std::vector< PVNameCopyNo > PVNameCopyNoPath
G4Vector3D fActualLightpointDirection
void SetVisibleDensity(G4double visibleDensity)
#define INTERPOLATE(param)
void PrintDifferences(const G4ViewParameters &v) const
void AddCutawayPlane(const G4Plane3D &cutawayPlane)
G4Vector3D & GetActualLightpointDirection()
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
G4bool fWindowLocationHintXNegative
Definition: test07.cc:36
std::ostream & operator<<(std::ostream &, const BasicVector3D< float > &)
#define INTERPOLATEVECTOR(vector)
Point3D< T > point(const Point3D< T > &p) const
Definition: Plane3D.h:108
CutawayMode fCutawayMode
G4double fDisplayHeadTimeSize
RotationStyle fRotationStyle
G4double fDisplayLightFrontY
static constexpr double mm
Definition: G4SIunits.hh:115
static ush mask[]
Definition: csz_inflate.cc:317
G4double GetFarDistance(G4double cameraDistance, G4double nearDistance, G4double radius) const
BasicVector3D< T > unit() const
#define G4endl
Definition: G4ios.hh:61
Float_t y
Definition: compare.C:6
ForcedDrawingStyle GetForcedDrawingStyle() const
const char * p
Definition: xmltok.h:285
Double_t z
std::vector< G4ModelingParameters::VisAttributesModifier > fVisAttributesModifiers
void ChangeCutawayPlane(size_t index, const G4Plane3D &cutawayPlane)
G4double GetFrontHalfHeight(G4double nearDistance, G4double radius) const
#define CONTINUITY(quantity)
BasicVector3D< T > cross(const BasicVector3D< T > &v) const
G4Point3D fCurrentTargetPoint
G4double fDisplayHeadTimeGreen
G4double fGlobalLineWidthScale
G4bool IsVisible() const
G4double fDisplayHeadTimeRed
G4int ParseGeometry(const char *string, G4int *x, G4int *y, unsigned int *width, unsigned int *height)
static G4ViewParameters * CatmullRomCubicSplineInterpolation(const std::vector< G4ViewParameters > &views, G4int nInterpolationPoints=50)
TH1F * h10
G4VisAttributes fDefaultVisAttributes
Normal3D< T > normal() const
Definition: Plane3D.h:90
G4String CameraAndLightingCommands(const G4Point3D standardTargetPoint) const
Definition: test07.cc:36
G4Vector3D fViewpointDirection
G4Vector3D fRelativeLightpointDirection
void SetLightpointDirection(const G4Vector3D &lightpointDirection)
G4bool IsForceAuxEdgeVisible() const
#define INTERPOLATEPLANE(plane)
DrawingStyle fDrawingStyle
G4double GetCameraDistance(G4double radius) const
G4double fDisplayLightFrontRed
G4double fDisplayLightFrontT
G4bool IsForcedAuxEdgeVisible() const
static G4int GetMinLineSegmentsPerCircle()
void SetScreenSize(G4double)
static constexpr double g
Definition: G4SIunits.hh:183
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
G4String TimeWindowCommands() const
#define width
G4String TouchableCommands() const
G4bool IsExplode() const
G4double fDisplayLightFrontBlue
static constexpr double deg
Definition: G4SIunits.hh:152
G4bool operator!=(const G4ViewParameters &) const
G4double fDisplayLightFrontGreen
void SetPan(G4double right, G4double up)
static const G4double alpha
std::vector< G4double > fCBDParameters
G4bool fWindowLocationHintYNegative
void IncrementPan(G4double right, G4double up)
G4int SetNoOfSides(G4int nSides)
G4double GetLineWidth() const
G4bool IsCutaway() const
Float_t d
HepGeom::Plane3D< G4double > G4Plane3D
Definition: G4Plane3D.hh:37
const PVNameCopyNoPath & GetPVNameCopyNoPath() const
Double_t radius
G4double GetRed() const
Definition: G4Colour.hh:151
G4GLOB_DLL std::ostream G4cerr
HepGeom::Vector3D< G4double > G4Vector3D
Definition: G4Vector3D.hh:35
#define INTERPOLATEUNITVECTOR(vector)
#define INTERPOLATECOLOUR(colour)
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
TH1F * h11
G4double fDisplayLightFrontZ
int G4int
Definition: G4Types.hh:78
G4bool IsForceDrawingStyle() const
VisAttributesSignifier GetVisAttributesSignifier() const
G4double fDisplayLightFrontX
void AddVisAttributesModifier(const G4ModelingParameters::VisAttributesModifier &)
G4String SceneModifyingCommands() const
G4double GetAlpha() const
Definition: G4Colour.hh:154
G4GLOB_DLL std::ostream G4cout
void SetXGeometryString(const G4String &)
const G4VisAttributes & GetVisAttributes() const
void SetColour(const G4Colour &)
G4double GetBlue() const
Definition: G4Colour.hh:153
Char_t n[5]
G4double GetGreen() const
Definition: G4Colour.hh:152
void MultiplyScaleFactor(const G4Vector3D &scaleFactorMultiplier)
G4double fDisplayHeadTimeBlue
G4double GetNearDistance(G4double cameraDistance, G4double radius) const
void SetViewAndLights(const G4Vector3D &viewpointDirection)
PVNameCopyNoPath::const_iterator PVNameCopyNoPathConstIterator
static constexpr double cm3
Definition: G4SIunits.hh:121
G4int GetWindowAbsoluteLocationHintY(G4int) const
HepGeom::Point3D< G4double > G4Point3D
Definition: G4Point3D.hh:35
LineStyle GetLineStyle() const
G4int GetForcedLineSegmentsPerCircle() const
G4VisAttributes fDefaultTextVisAttributes
#define ns
Definition: xmlparse.cc:614
G4String DrawingStyleCommands() const
G4int ReadInteger(char *string, char **NextString)
const G4Colour & GetColour() const
G4bool IsDaughtersInvisible() const
static G4bool GetColour(const G4String &key, G4Colour &result)
Definition: G4Colour.cc:163
G4int GetWindowAbsoluteLocationHintX(G4int) const
#define INTERPOLATEPOINT(point)