46 fDrawingStyle (wireframe),
47 fNumberOfCloudPoints(10000),
48 fAuxEdgeVisible (false),
50 fCullInvisible (true),
51 fDensityCulling (false),
52 fVisibleDensity (0.01 * g / cm3),
54 fCBDAlgorithmNumber (0),
57 fCutawayMode (cutawayUnion),
66 fCurrentTargetPoint (),
68 fLightsMoveWithCamera (false),
69 fRelativeLightpointDirection (
G4Vector3D (1., 1., 1.)),
70 fActualLightpointDirection (
G4Vector3D (1., 1., 1.)),
71 fDefaultVisAttributes (),
72 fDefaultTextVisAttributes (
G4Colour (0., 0., 1.)),
74 fGlobalMarkerScale (1.),
75 fGlobalLineWidthScale (1.),
76 fMarkerNotHidden (true),
77 fWindowSizeHintX (600),
78 fWindowSizeHintY (600),
79 fWindowLocationHintX(0),
80 fWindowLocationHintY(0),
81 fWindowLocationHintXNegative(true),
82 fWindowLocationHintYNegative(false),
85 fBackgroundColour (
G4Colour(0.,0.,0.)),
87 fRotationStyle (constrainUpDirection),
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)
126 fScaleFactor.
setX(fScaleFactor.
x() * scaleFactorMultiplier.
x());
127 fScaleFactor.
setY(fScaleFactor.
y() * scaleFactorMultiplier.
y());
128 fScaleFactor.
setZ(fScaleFactor.
z() * scaleFactorMultiplier.
z());
133 return fActualLightpointDirection;
146 if (fFieldHalfAngle == 0.) {
147 cameraDistance = radius;
150 cameraDistance = radius / std::sin (fFieldHalfAngle) - fDolly;
152 return cameraDistance;
157 const G4double small = 1.e-6 * radius;
158 G4double nearDistance = cameraDistance - radius;
159 if (nearDistance < small) nearDistance = small;
166 G4double farDistance = cameraDistance + radius;
167 if (farDistance < nearDistance) farDistance = nearDistance;
174 if (fFieldHalfAngle == 0.) {
175 frontHalfHeight = radius / fZoomFactor;
178 frontHalfHeight = nearDistance * std::tan (fFieldHalfAngle) / fZoomFactor;
180 return frontHalfHeight;
185 if (fCutawayPlanes.size () < 3 ) {
186 fCutawayPlanes.push_back (cutawayPlane);
190 "ERROR: G4ViewParameters::AddCutawayPlane:"
191 "\n A maximum of 3 cutaway planes supported." <<
G4endl;
196(
size_t index,
const G4Plane3D& cutawayPlane) {
197 if (index >= fCutawayPlanes.size()) {
199 "ERROR: G4ViewParameters::ChangeCutawayPlane:"
200 "\n Plane " << index <<
" does not exist." <<
G4endl;
202 fCutawayPlanes[index] = cutawayPlane;
207 const G4double reasonableMaximum = 10.0 * g / cm3;
208 if (visibleDensity < 0) {
209 G4warn <<
"G4ViewParameters::SetVisibleDensity: attempt to set negative "
210 "density - ignored." <<
G4endl;
213 if (visibleDensity > reasonableMaximum) {
214 G4warn <<
"G4ViewParameters::SetVisibleDensity: density > "
215 <<
G4BestUnit (reasonableMaximum,
"Volumic Mass")
216 <<
" - did you mean this?"
219 fVisibleDensity = visibleDensity;
225 if (nSides < nSidesMin) {
227 G4warn <<
"G4ViewParameters::SetNoOfSides: attempt to set the"
228 "\nnumber of sides per circle < " << nSidesMin
229 <<
"; forced to " << nSides <<
G4endl;
236 const G4int nPointsMin = 100;
237 if (nPoints < nPointsMin) {
238 nPoints = nPointsMin;
239 G4warn <<
"G4ViewParameters::SetNumberOfCloudPoints:"
240 "\nnumber of points per cloud set to minimum " << nPoints
243 fNumberOfCloudPoints = nPoints;
244 return fNumberOfCloudPoints;
250 fViewpointDirection = viewpointDirection;
254 if (fViewpointDirection.
unit() * fUpVector.
unit() > .9999) {
255 static G4bool firstTime =
true;
259 "WARNING: Viewpoint direction is very close to the up vector direction."
260 "\n Change the up vector or \"/vis/viewer/set/rotationStyle freeRotation\"."
266 if (fLightsMoveWithCamera) {
270 fActualLightpointDirection =
271 fRelativeLightpointDirection.
x () * xprime +
272 fRelativeLightpointDirection.
y () * yprime +
273 fRelativeLightpointDirection.
x () * zprime;
275 fActualLightpointDirection = fRelativeLightpointDirection;
281 fRelativeLightpointDirection = lightpointDirection;
288 fCurrentTargetPoint = right * unitRight + up * unitUp;
298 fCurrentTargetPoint += right * unitRight + up * unitUp + distance * fViewpointDirection;
304 G4bool duplicateTarget =
false;
305 auto i = fVisAttributesModifiers.begin();
306 for (; i < fVisAttributesModifiers.end(); ++i) {
309 duplicateTarget =
true;
314 else fVisAttributesModifiers.push_back(vam);
318(
const G4Point3D standardTargetPoint)
const
320 std::ostringstream oss;
322 oss <<
"#\n# Camera and lights commands";
324 oss <<
"\n/vis/viewer/set/viewpointVector "
325 << fViewpointDirection.
x()
326 <<
' ' << fViewpointDirection.
y()
327 <<
' ' << fViewpointDirection.
z();
329 oss <<
"\n/vis/viewer/set/upVector "
331 <<
' ' << fUpVector.
y()
332 <<
' ' << fUpVector.
z();
334 oss <<
"\n/vis/viewer/set/projection ";
335 if (fFieldHalfAngle == 0.) {
341 << fFieldHalfAngle/deg
345 oss <<
"\n/vis/viewer/zoomTo "
348 oss <<
"\n/vis/viewer/scaleTo "
350 <<
' ' << fScaleFactor.
y()
351 <<
' ' << fScaleFactor.
z();
353 oss <<
"\n/vis/viewer/set/targetPoint "
354 <<
G4BestUnit(standardTargetPoint+fCurrentTargetPoint,
"Length")
355 <<
"\n# Note that if you have not set a target point, the vis system sets"
356 <<
"\n# a target point based on the scene - plus any panning and dollying -"
357 <<
"\n# so don't be alarmed by strange coordinates here.";
359 oss <<
"\n/vis/viewer/dollyTo "
362 oss <<
"\n/vis/viewer/set/lightsMove ";
363 if (fLightsMoveWithCamera) {
369 oss <<
"\n/vis/viewer/set/lightsVector "
370 << fRelativeLightpointDirection.
x()
371 <<
' ' << fRelativeLightpointDirection.
y()
372 <<
' ' << fRelativeLightpointDirection.
z();
374 oss <<
"\n/vis/viewer/set/rotationStyle ";
376 oss <<
"constrainUpDirection";
378 oss <<
"freeRotation";
382 oss <<
"\n/vis/viewer/set/background "
389 oss <<
"\n/vis/viewer/set/defaultColour "
395 c = fDefaultTextVisAttributes.
GetColour();
396 oss <<
"\n/vis/viewer/set/defaultTextColour "
409 std::ostringstream oss;
411 oss <<
"#\n# Drawing style commands";
413 oss <<
"\n/vis/viewer/set/style ";
414 switch (fDrawingStyle) {
428 oss <<
"\n/vis/viewer/set/hiddenEdge ";
429 if (fDrawingStyle ==
hlr || fDrawingStyle ==
hlhsr) {
435 oss <<
"\n/vis/viewer/set/auxiliaryEdge ";
436 if (fAuxEdgeVisible) {
442 oss <<
"\n/vis/viewer/set/hiddenMarker ";
443 if (fMarkerNotHidden) {
449 oss <<
"\n/vis/viewer/set/globalLineWidthScale "
450 << fGlobalLineWidthScale;
452 oss <<
"\n/vis/viewer/set/globalMarkerScale "
453 << fGlobalMarkerScale;
455 oss <<
"\n/vis/viewer/set/numberOfCloudPoints "
456 << fNumberOfCloudPoints;
458 oss <<
"\n/vis/viewer/set/specialMeshRendering ";
459 if (fSpecialMeshRendering) {
465 oss <<
"\n/vis/viewer/set/specialMeshRenderingOption "
466 << fSpecialMeshRenderingOption;
468 oss <<
"\n/vis/viewer/set/specialMeshVolumes";
469 for (
const auto& volume : fSpecialMeshVolumes) {
470 oss <<
' ' << volume.GetName() <<
' ' << volume.GetCopyNo();
480 std::ostringstream oss;
482 oss <<
"#\n# Scene-modifying commands";
484 oss <<
"\n/vis/viewer/set/culling global ";
491 oss <<
"\n/vis/viewer/set/culling invisible ";
492 if (fCullInvisible) {
498 oss <<
"\n/vis/viewer/set/culling density ";
499 if (fDensityCulling) {
500 oss <<
"true " << fVisibleDensity/(g/cm3) <<
" g/cm3";
505 oss <<
"\n/vis/viewer/set/culling coveredDaughters ";
512 oss <<
"\n/vis/viewer/colourByDensity "
513 << fCBDAlgorithmNumber <<
" g/cm3";
514 for (
auto p: fCBDParameters) {
515 oss <<
' ' << p/(g/cm3);
518 oss <<
"\n/vis/viewer/set/sectionPlane ";
522 << fSectionPlane.
normal().x()
523 <<
' ' << fSectionPlane.
normal().y()
524 <<
' ' << fSectionPlane.
normal().z();
529 oss <<
"\n/vis/viewer/set/cutawayMode ";
533 oss <<
"intersection";
536 oss <<
"\n/vis/viewer/clearCutawayPlanes";
537 if (fCutawayPlanes.size()) {
538 for (
size_t i = 0; i < fCutawayPlanes.size(); i++) {
539 oss <<
"\n/vis/viewer/addCutawayPlane "
540 <<
G4BestUnit(fCutawayPlanes[i].point(),
"Length")
541 << fCutawayPlanes[i].normal().x()
542 <<
' ' << fCutawayPlanes[i].normal().y()
543 <<
' ' << fCutawayPlanes[i].normal().z();
546 oss <<
"\n# No cutaway planes defined.";
549 oss <<
"\n/vis/viewer/set/explodeFactor "
551 <<
' ' <<
G4BestUnit(fExplodeCentre,
"Length");
553 oss <<
"\n/vis/viewer/set/lineSegmentsPerCircle "
563 std::ostringstream oss;
565 oss <<
"#\n# Touchable commands";
567 const std::vector<G4ModelingParameters::VisAttributesModifier>& vams =
568 fVisAttributesModifiers;
573 <<
"\n/vis/viewer/clearVisAttributesModifiers";
579 <<
"\n/vis/viewer/clearVisAttributesModifiers";
582 std::vector<G4ModelingParameters::VisAttributesModifier>::const_iterator
584 for (iModifier = vams.begin();
585 iModifier != vams.end();
588 iModifier->GetPVNameCopyNoPath();
589 if (vamPath != lastPath) {
591 oss <<
"\n/vis/set/touchable";
593 for (iVAM = vamPath.begin();
594 iVAM != vamPath.end();
596 oss <<
' ' << iVAM->GetName() <<
' ' << iVAM->GetCopyNo();
601 switch (iModifier->GetVisAttributesSignifier()) {
603 oss <<
"\n/vis/touchable/set/visibility ";
611 oss <<
"\n/vis/touchable/set/daughtersInvisible ";
619 oss <<
"\n/vis/touchable/set/colour "
626 oss <<
"\n/vis/touchable/set/lineStyle ";
639 oss <<
"\n/vis/touchable/set/lineWidth "
645 oss <<
"\n/vis/touchable/set/forceWireframe ";
657 oss <<
"\n/vis/touchable/set/forceSolid ";
669 oss <<
"\n/vis/touchable/set/forceCloud ";
680 oss <<
"\n/vis/touchable/set/forceAuxEdgeVisible ";
689 oss <<
"\n/vis/touchable/set/lineSegmentsPerCircle "
693 oss <<
"\n/vis/touchable/set/numberOfCloudPoints "
706 std::ostringstream oss;
708 oss <<
"#\n# Time window commands";
711 <<
"\n/vis/viewer/set/timeWindow/startTime "
712 << fStartTime/ns <<
" ns ";
715 <<
"\n/vis/viewer/set/timeWindow/endTime "
716 << fEndTime/ns <<
" ns ";
718 oss <<
"\n/vis/viewer/set/timeWindow/fadeFactor "
722 <<
"\n/vis/viewer/set/timeWindow/displayHeadTime ";
723 if (!fDisplayHeadTime) {
728 <<
' ' << fDisplayHeadTimeX
729 <<
' ' << fDisplayHeadTimeY
730 <<
' ' << fDisplayHeadTimeSize
731 <<
' ' << fDisplayHeadTimeRed
732 <<
' ' << fDisplayHeadTimeGreen
733 <<
' ' << fDisplayHeadTimeBlue;
737 <<
"\n/vis/viewer/set/timeWindow/displayLightFront ";
738 if (!fDisplayLightFront) {
743 <<
' ' << fDisplayLightFrontX/mm
744 <<
' ' << fDisplayLightFrontY/mm
745 <<
' ' << fDisplayLightFrontZ/mm
747 <<
' ' << fDisplayLightFrontT/ns
749 <<
' ' << fDisplayLightFrontRed
750 <<
' ' << fDisplayLightFrontGreen
751 <<
' ' << fDisplayLightFrontBlue;
764 (fViewpointDirection != v.fViewpointDirection) ||
767 (fDrawingStyle != v.fDrawingStyle) ||
768 (fNumberOfCloudPoints != v.fNumberOfCloudPoints) ||
769 (fAuxEdgeVisible != v.fAuxEdgeVisible) ||
770 (fCulling != v.fCulling) ||
771 (fCullInvisible != v.fCullInvisible) ||
772 (fDensityCulling != v.fDensityCulling) ||
773 (fVisibleDensity != v.fVisibleDensity) ||
774 (fCullCovered != v.fCullCovered) ||
775 (fCBDAlgorithmNumber != v.fCBDAlgorithmNumber) ||
776 (fSection != v.fSection) ||
777 (fNoOfSides != v.fNoOfSides) ||
778 (fUpVector != v.fUpVector) ||
779 (fFieldHalfAngle != v.fFieldHalfAngle) ||
780 (fZoomFactor != v.fZoomFactor) ||
781 (fScaleFactor != v.fScaleFactor) ||
782 (fCurrentTargetPoint != v.fCurrentTargetPoint) ||
783 (fDolly != v.fDolly) ||
784 (fRelativeLightpointDirection != v.fRelativeLightpointDirection) ||
785 (fLightsMoveWithCamera != v.fLightsMoveWithCamera) ||
786 (fDefaultVisAttributes != v.fDefaultVisAttributes) ||
787 (fDefaultTextVisAttributes != v.fDefaultTextVisAttributes) ||
788 (fDefaultMarker != v.fDefaultMarker) ||
789 (fGlobalMarkerScale != v.fGlobalMarkerScale) ||
790 (fGlobalLineWidthScale != v.fGlobalLineWidthScale) ||
791 (fMarkerNotHidden != v.fMarkerNotHidden) ||
792 (fWindowSizeHintX != v.fWindowSizeHintX) ||
793 (fWindowSizeHintY != v.fWindowSizeHintY) ||
794 (fXGeometryString != v.fXGeometryString) ||
795 (fGeometryMask != v.fGeometryMask) ||
796 (fAutoRefresh != v.fAutoRefresh) ||
797 (fBackgroundColour != v.fBackgroundColour) ||
798 (fPicking != v.fPicking) ||
799 (fRotationStyle != v.fRotationStyle)
803 if (fCBDAlgorithmNumber > 0) {
804 if (fCBDParameters.size() != v.fCBDParameters.size()) {
805 G4cout <<
"Difference in number of colour by density parameters." <<
G4endl;
806 }
else if (fCBDParameters != v.fCBDParameters) {
807 G4cout <<
"Difference in values of colour by density parameters." <<
G4endl;
812 if (!(fSectionPlane == v.fSectionPlane))
813 G4cout <<
"Difference in section planes batch." <<
G4endl;
817 if (fCutawayPlanes.size () != v.fCutawayPlanes.size ()) {
818 G4cout <<
"Difference in no of cutaway planes." <<
G4endl;
821 for (
size_t i = 0; i < fCutawayPlanes.size (); i++) {
822 if (!(fCutawayPlanes[i] == v.fCutawayPlanes[i]))
823 G4cout <<
"Difference in cutaway plane no. " << i <<
G4endl;
829 if (fExplodeFactor != v.fExplodeFactor)
831 if (fExplodeCentre != v.fExplodeCentre)
835 if (fVisAttributesModifiers != v.fVisAttributesModifiers) {
836 G4cout <<
"Difference in vis attributes modifiers." <<
G4endl;
839 if (fStartTime != v.fStartTime ||
840 fEndTime != v.fEndTime) {
844 if (fFadeFactor != v.fFadeFactor) {
845 G4cout <<
"Difference in time window fade factor." <<
G4endl;
848 if (fDisplayHeadTime != v.fDisplayHeadTime) {
849 G4cout <<
"Difference in display head time flag." <<
G4endl;
851 if (fDisplayHeadTimeX != v.fDisplayHeadTimeX ||
852 fDisplayHeadTimeY != v.fDisplayHeadTimeY ||
853 fDisplayHeadTimeSize != v.fDisplayHeadTimeSize ||
854 fDisplayHeadTimeRed != v.fDisplayHeadTimeRed ||
855 fDisplayHeadTimeGreen != v.fDisplayHeadTimeGreen ||
856 fDisplayHeadTimeBlue != v.fDisplayHeadTimeBlue) {
857 G4cout <<
"Difference in display head time parameters." <<
G4endl;
861 if (fDisplayLightFront != v.fDisplayLightFront) {
862 G4cout <<
"Difference in display light front flag." <<
G4endl;
864 if (fDisplayLightFrontX != v.fDisplayLightFrontX ||
865 fDisplayLightFrontY != v.fDisplayLightFrontY ||
866 fDisplayLightFrontZ != v.fDisplayLightFrontZ ||
867 fDisplayLightFrontT != v.fDisplayLightFrontT ||
868 fDisplayLightFrontRed != v.fDisplayLightFrontRed ||
869 fDisplayLightFrontGreen != v.fDisplayLightFrontGreen ||
870 fDisplayLightFrontBlue != v.fDisplayLightFrontBlue) {
871 G4cout <<
"Difference in display light front parameters." <<
G4endl;
876std::ostream&
operator <<
881 os <<
"wireframe";
break;
883 os <<
"hlr - hidden lines removed";
break;
885 os <<
"hsr - hidden surfaces removed";
break;
887 os <<
"hlhsr - hidden line, hidden surface removed";
break;
889 os <<
"cloud - draw volume as a cloud of dots";
break;
890 default: os <<
"unrecognised";
break;
895std::ostream&
operator <<
900 os <<
"default";
break;
904 os <<
"surfaces";
break;
910 os <<
"View parameters and options:";
912 os <<
"\n Drawing style: " << v.fDrawingStyle;
914 os <<
"\n Number of cloud points: " << v.fNumberOfCloudPoints;
916 os <<
"\n Auxiliary edges: ";
917 if (!v.fAuxEdgeVisible) os <<
"in";
920 os <<
"\n Culling: ";
921 if (v.fCulling) os <<
"on";
924 os <<
"\n Culling invisible objects: ";
925 if (v.fCullInvisible) os <<
"on";
928 os <<
"\n Density culling: ";
929 if (v.fDensityCulling) {
930 os <<
"on - invisible if density less than "
931 << v.fVisibleDensity / (1. * g / cm3) <<
" g cm^-3";
935 os <<
"\n Culling daughters covered by opaque mothers: ";
936 if (v.fCullCovered) os <<
"on";
939 os <<
"\n Colour by density: ";
940 if (v.fCBDAlgorithmNumber <= 0) {
943 os <<
"Algorithm " << v.fCBDAlgorithmNumber <<
", Parameters:";
944 for (
auto p: v.fCBDParameters) {
949 os <<
"\n Section flag: ";
950 if (v.fSection) os <<
"true, section/cut plane: " << v.fSectionPlane;
954 os <<
"\n Cutaway planes: ";
955 for (
size_t i = 0; i < v.fCutawayPlanes.size (); i++) {
956 os <<
' ' << v.fCutawayPlanes[i];
960 os <<
"\n No cutaway planes";
963 os <<
"\n Explode factor: " << v.fExplodeFactor
964 <<
" about centre: " << v.fExplodeCentre;
966 os <<
"\n No. of sides used in circle polygon approximation: "
969 os <<
"\n Viewpoint direction: " << v.fViewpointDirection;
971 os <<
"\n Up vector: " << v.fUpVector;
973 os <<
"\n Field half angle: " << v.fFieldHalfAngle;
975 os <<
"\n Zoom factor: " << v.fZoomFactor;
977 os <<
"\n Scale factor: " << v.fScaleFactor;
979 os <<
"\n Current target point: " << v.fCurrentTargetPoint;
981 os <<
"\n Dolly distance: " << v.fDolly;
984 if (v.fLightsMoveWithCamera) os <<
"moves";
985 else os <<
"does not move";
986 os <<
" with camera";
988 os <<
"\n Relative lightpoint direction: "
989 << v.fRelativeLightpointDirection;
991 os <<
"\n Actual lightpoint direction: "
992 << v.fActualLightpointDirection;
994 os <<
"\n Derived parameters for standard view of object of unit radius:";
997 tempVP.fZoomFactor = 1.;
1005 os <<
"\n Camera distance: " << cameraDistance;
1006 os <<
"\n Near distance: " << nearDistance;
1007 os <<
"\n Far distance: " << farDistance;
1008 os <<
"\n Front half height: " << right;
1010 os <<
"\n Default VisAttributes:\n " << v.fDefaultVisAttributes;
1012 os <<
"\n Default TextVisAttributes:\n " << v.fDefaultTextVisAttributes;
1014 os <<
"\n Default marker: " << v.fDefaultMarker;
1016 os <<
"\n Global marker scale: " << v.fGlobalMarkerScale;
1018 os <<
"\n Global lineWidth scale: " << v.fGlobalLineWidthScale;
1021 if (v.fMarkerNotHidden) os <<
"not ";
1022 os <<
"hidden by surfaces.";
1024 os <<
"\n Window size hint: "
1025 << v.fWindowSizeHintX <<
'x'<< v.fWindowSizeHintX;
1027 os <<
"\n X geometry string: " << v.fXGeometryString;
1028 os <<
"\n X geometry mask: "
1029 << std::showbase << std::hex << v.fGeometryMask
1030 << std::noshowbase << std::dec;
1032 os <<
"\n Auto refresh: ";
1033 if (v.fAutoRefresh) os <<
"true";
1036 os <<
"\n Background colour: " << v.fBackgroundColour;
1038 os <<
"\n Picking requested: ";
1039 if (v.fPicking) os <<
"true";
1042 os <<
"\n Rotation style: ";
1043 switch (v.fRotationStyle) {
1045 os <<
"constrainUpDirection (conventional HEP view)";
break;
1047 os <<
"freeRotation (Google-like rotation, using mouse-grab)";
break;
1048 default: os <<
"unrecognised";
break;
1051 os <<
"\n Vis attributes modifiers: ";
1052 const std::vector<G4ModelingParameters::VisAttributesModifier>& vams =
1053 v.fVisAttributesModifiers;
1060 os <<
"\n Time window parameters:"
1061 <<
"\n Start time: " << v.fStartTime/ns <<
" ns"
1062 <<
"\n End time: " << v.fEndTime/ns <<
" ns"
1063 <<
"\n Fade factor: " << v.fFadeFactor;
1064 if (!v.fDisplayHeadTime) {
1065 os <<
"\n Head time display not requested.";
1068 <<
"\n Head time position: "
1069 << v.fDisplayHeadTimeX <<
' ' << v.fDisplayHeadTimeY
1070 <<
"\n Head time size: " << v.fDisplayHeadTimeSize
1071 <<
"\n Head time colour: " << v.fDisplayHeadTimeRed
1072 <<
' ' << v.fDisplayHeadTimeGreen <<
' ' << v.fDisplayHeadTimeBlue;
1074 if (!v.fDisplayLightFront) {
1075 os <<
"\n Light front display not requested.";
1078 <<
"\n Light front position: "
1079 << v.fDisplayLightFrontX/mm <<
' ' << v.fDisplayLightFrontY/mm
1080 <<
' ' << v.fDisplayLightFrontZ/mm <<
" mm"
1081 <<
"\n Light front time: " << v.fDisplayLightFrontT/ns <<
" ns"
1082 <<
"\n Light front colour: " << v.fDisplayLightFrontRed
1083 <<
' ' << v.fDisplayLightFrontGreen <<
' ' << v.fDisplayLightFrontBlue;
1086 os <<
"\n Special Mesh Rendering";
1087 if (v.fSpecialMeshRendering) {
1088 os <<
" requested with option \"" << v.fSpecialMeshRenderingOption;
1090 if (v.fSpecialMeshVolumes.empty()) {
1093 os <<
"selected meshes";
1094 for (
const auto& vol: v.fSpecialMeshVolumes) {
1095 os <<
"\n " << vol.GetName() <<
':' << vol.GetCopyNo();
1098 }
else os <<
": off";
1107 (fViewpointDirection != v.fViewpointDirection) ||
1110 (fDrawingStyle != v.fDrawingStyle) ||
1111 (fNumberOfCloudPoints != v.fNumberOfCloudPoints) ||
1112 (fAuxEdgeVisible != v.fAuxEdgeVisible) ||
1113 (fCulling != v.fCulling) ||
1114 (fCullInvisible != v.fCullInvisible) ||
1115 (fDensityCulling != v.fDensityCulling) ||
1116 (fCullCovered != v.fCullCovered) ||
1117 (fCBDAlgorithmNumber != v.fCBDAlgorithmNumber) ||
1118 (fSection != v.fSection) ||
1121 (fNoOfSides != v.fNoOfSides) ||
1122 (fUpVector != v.fUpVector) ||
1123 (fFieldHalfAngle != v.fFieldHalfAngle) ||
1124 (fZoomFactor != v.fZoomFactor) ||
1125 (fScaleFactor != v.fScaleFactor) ||
1126 (fCurrentTargetPoint != v.fCurrentTargetPoint) ||
1127 (fDolly != v.fDolly) ||
1128 (fRelativeLightpointDirection != v.fRelativeLightpointDirection) ||
1129 (fLightsMoveWithCamera != v.fLightsMoveWithCamera) ||
1130 (fDefaultVisAttributes != v.fDefaultVisAttributes) ||
1131 (fDefaultTextVisAttributes != v.fDefaultTextVisAttributes) ||
1132 (fDefaultMarker != v.fDefaultMarker) ||
1133 (fGlobalMarkerScale != v.fGlobalMarkerScale) ||
1134 (fGlobalLineWidthScale != v.fGlobalLineWidthScale) ||
1135 (fMarkerNotHidden != v.fMarkerNotHidden) ||
1136 (fWindowSizeHintX != v.fWindowSizeHintX) ||
1137 (fWindowSizeHintY != v.fWindowSizeHintY) ||
1138 (fXGeometryString != v.fXGeometryString) ||
1139 (fGeometryMask != v.fGeometryMask) ||
1140 (fAutoRefresh != v.fAutoRefresh) ||
1141 (fBackgroundColour != v.fBackgroundColour) ||
1142 (fPicking != v.fPicking) ||
1143 (fRotationStyle != v.fRotationStyle) ||
1144 (fSpecialMeshRendering != v.fSpecialMeshRendering) ||
1145 (fSpecialMeshRenderingOption != v.fSpecialMeshRenderingOption)
1149 if (fDensityCulling &&
1150 (fVisibleDensity != v.fVisibleDensity))
return true;
1152 if (fCBDAlgorithmNumber > 0) {
1153 if (fCBDParameters.size() != v.fCBDParameters.size())
return true;
1154 else if (fCBDParameters != v.fCBDParameters)
return true;
1158 (!(fSectionPlane == v.fSectionPlane)))
return true;
1161 if (fCutawayPlanes.size () != v.fCutawayPlanes.size ())
1164 for (
size_t i = 0; i < fCutawayPlanes.size (); i++) {
1165 if (!(fCutawayPlanes[i] == v.fCutawayPlanes[i]))
return true;
1171 ((fExplodeFactor != v.fExplodeFactor) ||
1172 (fExplodeCentre != v.fExplodeCentre)))
return true;
1174 if (fVisAttributesModifiers != v.fVisAttributesModifiers)
return true;
1176 if (fStartTime != v.fStartTime ||
1177 fEndTime != v.fEndTime ||
1178 fFadeFactor != v.fFadeFactor)
return true;
1180 if (fDisplayHeadTime != v.fDisplayHeadTime)
return true;
1181 if (fDisplayHeadTime) {
1182 if (fDisplayHeadTimeX != v.fDisplayHeadTimeX ||
1183 fDisplayHeadTimeY != v.fDisplayHeadTimeY ||
1184 fDisplayHeadTimeSize != v.fDisplayHeadTimeSize ||
1185 fDisplayHeadTimeRed != v.fDisplayHeadTimeRed ||
1186 fDisplayHeadTimeGreen != v.fDisplayHeadTimeGreen ||
1187 fDisplayHeadTimeBlue != v.fDisplayHeadTimeBlue) {
1192 if (fDisplayLightFront != v.fDisplayLightFront)
return true;
1193 if (fDisplayLightFront) {
1194 if (fDisplayLightFrontX != v.fDisplayLightFrontX ||
1195 fDisplayLightFrontY != v.fDisplayLightFrontY ||
1196 fDisplayLightFrontZ != v.fDisplayLightFrontZ ||
1197 fDisplayLightFrontT != v.fDisplayLightFrontT ||
1198 fDisplayLightFrontRed != v.fDisplayLightFrontRed ||
1199 fDisplayLightFrontGreen != v.fDisplayLightFrontGreen ||
1200 fDisplayLightFrontBlue != v.fDisplayLightFrontBlue) {
1205 if (fSpecialMeshRendering) {
1206 if (fSpecialMeshVolumes != v.fSpecialMeshVolumes)
1216 G4String::size_type i = geomString.find_first_of(delimiters);
1217 if (i == G4String::npos) {
1220 std::istringstream iss(geomString);
1225 fWindowSizeHintX = size;
1226 fWindowSizeHintY = size;
1231 if (fWindowLocationHintXNegative) signX =
'-';
else signX =
'+';
1232 if (fWindowLocationHintYNegative) signY =
'-';
else signY =
'+';
1233 std::ostringstream oss;
1234 oss << fWindowSizeHintX <<
'x' << fWindowSizeHintY
1235 << signX << fWindowLocationHintX << signY << fWindowLocationHintY;
1236 fXGeometryString = oss.str();
1242 unsigned int w = 0, h = 0;
1243 fGeometryMask = ParseGeometry( geomString, &x, &y, &w, &h );
1246 if ((fGeometryMask & fYValue) == 0)
1248 y = fWindowLocationHintY;
1250 if ((fGeometryMask & fXValue) == 0)
1252 x = fWindowLocationHintX;
1257 if ( ((fGeometryMask & fHeightValue) == 0 ) &&
1258 ((fGeometryMask & fWidthValue) == 0 )) {
1259 h = fWindowSizeHintY;
1260 w = fWindowSizeHintX;
1261 }
else if ((fGeometryMask & fHeightValue) == 0 ) {
1266 G4warn <<
"Unrecognised geometry string \""
1268 <<
"\". No Height found. Using Width value instead"
1272 if ( ((fGeometryMask & fXValue) == 0 ) ||
1273 ((fGeometryMask & fYValue) == 0 )) {
1275 x = fWindowLocationHintX;
1276 y = fWindowLocationHintY;
1279 fXGeometryString = geomString;
1282 fWindowSizeHintX = w;
1283 fWindowSizeHintY = h;
1284 fWindowLocationHintX = x;
1285 fWindowLocationHintY = y;
1287 if ( ((fGeometryMask & fXValue)) &&
1288 ((fGeometryMask & fYValue))) {
1290 if ( (fGeometryMask & fXNegative) ) {
1291 fWindowLocationHintXNegative =
true;
1293 fWindowLocationHintXNegative =
false;
1295 if ( (fGeometryMask & fYNegative) ) {
1296 fWindowLocationHintYNegative =
true;
1298 fWindowLocationHintYNegative =
false;
1304 if ( fWindowLocationHintXNegative ) {
1305 return sizeX + fWindowLocationHintX - fWindowSizeHintX;
1307 return fWindowLocationHintX;
1311 if ( fWindowLocationHintYNegative ) {
1312 return sizeY + fWindowLocationHintY - fWindowSizeHintY;
1314 return fWindowLocationHintY;
1331int G4ViewParameters::ParseGeometry (
1335 unsigned int *width,
1336 unsigned int *height)
1339 G4int mask = fNoValue;
1341 unsigned int tempWidth = 0;
1342 unsigned int tempHeight = 0;
1345 char *nextCharacter;
1346 if ( (
string == NULL) || (*
string ==
'\0')) {
1351 strind = (
char *)
string;
1352 if (*strind !=
'+' && *strind !=
'-' && *strind !=
'x') {
1353 tempWidth = ReadInteger(strind, &nextCharacter);
1354 if (strind == nextCharacter)
1356 strind = nextCharacter;
1357 mask |= fWidthValue;
1359 if (*strind ==
'x' || *strind ==
'X') {
1361 tempHeight = ReadInteger(strind, &nextCharacter);
1362 if (strind == nextCharacter)
1364 strind = nextCharacter;
1365 mask |= fHeightValue;
1368 if ((*strind ==
'+') || (*strind ==
'-')) {
1369 if (*strind ==
'-') {
1371 tempX = -ReadInteger(strind, &nextCharacter);
1372 if (strind == nextCharacter)
1374 strind = nextCharacter;
1380 tempX = ReadInteger(strind, &nextCharacter);
1381 if (strind == nextCharacter)
1383 strind = nextCharacter;
1386 if ((*strind ==
'+') || (*strind ==
'-')) {
1387 if (*strind ==
'-') {
1389 tempY = -ReadInteger(strind, &nextCharacter);
1390 if (strind == nextCharacter)
1392 strind = nextCharacter;
1398 tempY = ReadInteger(strind, &nextCharacter);
1399 if (strind == nextCharacter)
1401 strind = nextCharacter;
1408 if (*strind !=
'\0')
return (0);
1413 if (mask & fWidthValue)
1415 if (mask & fHeightValue)
1416 *height = tempHeight;
1424G4int G4ViewParameters::ReadInteger(
char *
string,
char **NextString)
1431 else if (*
string ==
'-')
1436 for (; (*
string >=
'0') && (*
string <=
'9');
string++)
1438 Result = (Result * 10) + (*
string -
'0');
1440 *NextString = string;
1448(
const std::vector<G4ViewParameters>& views,
1449 G4int nInterpolationPoints)
1463 if (views.size() < 2) {
1465 (
"G4ViewParameters::CatmullRomCubicSplineInterpolation",
1467 "There must be at least two views.");
1471 if (nInterpolationPoints < 1) {
1473 (
"G4ViewParameters::CatmullRomCubicSplineInterpolation",
1475 "Number of interpolation points cannot be zero or negative.");
1479 const size_t nIntervals = views.size() - 1;
1480 const G4double dt = 1./nInterpolationPoints;
1484 static G4int iInterpolationPoint = 0;
1485 static size_t iInterval = 0;
1490 const G4double h00 = 2.*t*t*t - 3.*t*t +1;
1491 const G4double h10 = t*t*t -2.*t*t + t;
1492 const G4double h01 = -2.*t*t*t + 3.*t*t;
1496 const size_t& n = nIntervals;
1497 size_t& i = iInterval;
1498 const std::vector<G4ViewParameters>& v = views;
1515 holdingValues = t < 0.5? v[i]: v[i+1];
1518#define INTERPOLATE(param) \
1523mi = v[1].param - v[0].param; \
1526if (n == 1) mi1 = mi; \
1528else mi1 = 0.5 * (v[2].param - v[0].param); \
1529} else if (i >= n - 1) { \
1531mi1 = v[i+1].param - v[i].param; \
1533if (n == 1) mi = mi1; \
1535else mi = 0.5 * (v[i+1].param - v[i-1].param); \
1538mi = 0.5 * (v[i+1].param - v[i-1].param); \
1539mi1 = 0.5 * (v[i+2].param - v[i ].param); \
1541real = h00 * v[i].param + h10 * mi + h01 * v[i+1].param + h11 * mi1;
1543#define INTERPOLATELOG(param) \
1545mi = std::log(v[1].param) - std::log(v[0].param); \
1546if (n == 1) mi1 = mi; \
1547else mi1 = 0.5 * (std::log(v[2].param) - std::log(v[0].param)); \
1548} else if (i >= n - 1) { \
1549mi1 = std::log(v[i+1].param) - std::log(v[i].param); \
1550if (n == 1) mi = mi1; \
1551else mi = 0.5 * (std::log(v[i+1].param) - std::log(v[i-1].param)); \
1553mi = 0.5 * (std::log(v[i+1].param) - std::log(v[i-1].param)); \
1554mi1 = 0.5 * (std::log(v[i+2].param) - std::log(v[i ].param)); \
1556real = std::exp(h00 * std::log(v[i].param) + h10 * mi + h01 * std::log(v[i+1].param) + h11 * mi1);
1560 if (real < 0.) real = 0.;
1561 holdingValues.fVisibleDensity = real;
1563 holdingValues.fExplodeFactor = real;
1565 if (real < 0.) real = 0.;
1566 holdingValues.fFieldHalfAngle = real;
1568 holdingValues.fZoomFactor = real;
1570 holdingValues.fDolly = real;
1572 if (real < 0.) real = 0.;
1573 holdingValues.fGlobalMarkerScale = real;
1575 if (real < 0.) real = 0.;
1576 holdingValues.fGlobalLineWidthScale = real;
1579#define INTERPOLATEUNITVECTOR(vector) \
1580INTERPOLATE(vector.x()); x = real; \
1581INTERPOLATE(vector.y()); y = real; \
1582INTERPOLATE(vector.z()); z = real;
1588 holdingValues.fRelativeLightpointDirection =
G4Vector3D(x,y,z).
unit();
1590 holdingValues.fActualLightpointDirection =
G4Vector3D(x,y,z).
unit();
1593#define INTERPOLATEVECTOR(vector) \
1594INTERPOLATE(vector.x()); x = real; \
1595INTERPOLATE(vector.y()); y = real; \
1596INTERPOLATE(vector.z()); z = real;
1598 holdingValues.fScaleFactor =
G4Vector3D(x,y,z);
1601#define INTERPOLATEPOINT(point) \
1602INTERPOLATE(point.x()); x = real; \
1603INTERPOLATE(point.y()); y = real; \
1604INTERPOLATE(point.z()); z = real;
1606 holdingValues.fExplodeCentre =
G4Point3D(x,y,z);
1608 holdingValues.fCurrentTargetPoint =
G4Point3D(x,y,z);
1612#define INTERPOLATECOLOUR(colour) \
1613INTERPOLATE(colour.GetRed()); red = real; \
1614INTERPOLATE(colour.GetGreen()); green = real; \
1615INTERPOLATE(colour.GetBlue()); blue = real; \
1616INTERPOLATE(colour.GetAlpha()); alpha = real;
1619 holdingValues.fBackgroundColour =
G4Colour(red,green,blue,alpha);
1623#define CONTINUITY(quantity) \
1624 continuous = false; \
1627 if (v[1].quantity == v[0].quantity) { \
1628 if (n == 1) continuous = true; \
1629 else if (v[2].quantity == v[0].quantity) \
1630 continuous = true; \
1632 } else if (i >= n - 1) { \
1633 if (v[i+1].quantity == v[i].quantity) { \
1634 if (n == 1) continuous = true; \
1635 else if (v[i+1].quantity == v[i-1].quantity) \
1636 continuous = true; \
1639 if (v[i-1].quantity == v[i].quantity && \
1640 v[i+1].quantity == v[i].quantity && \
1641 v[i+2].quantity == v[i].quantity) \
1642 continuous = true; \
1646#define INTERPOLATEPLANE(plane) \
1647INTERPOLATE(plane.a()); a = real; \
1648INTERPOLATE(plane.b()); b = real; \
1649INTERPOLATE(plane.c()); c = real; \
1650INTERPOLATE(plane.d()); d = real;
1656 holdingValues.fSectionPlane =
G4Plane3D(a,b,c,d);
1660 if (v[i].fCutawayPlanes.size()) {
1663 for (
size_t j = 0; j < v[i].fCutawayPlanes.size(); ++j) {
1665 holdingValues.fCutawayPlanes[j] =
G4Plane3D(a,b,c,d);
1674 if (v[i].fVisAttributesModifiers.size()) {
1677 for (
size_t j = 0; j < v[i].fVisAttributesModifiers.size(); ++j) {
1678 CONTINUITY(fVisAttributesModifiers[j].GetPVNameCopyNoPath());
1680 CONTINUITY(fVisAttributesModifiers[j].GetVisAttributesSignifier());
1682 if (v[i].fVisAttributesModifiers[j].GetVisAttributesSignifier() ==
1685 workingVA = v[i].fVisAttributesModifiers[j].GetVisAttributes();
1687 holdingValues.fVisAttributesModifiers[j].SetVisAttributes(workingVA);
1700 holdingValues.fStartTime = real;
1702 holdingValues.fEndTime = real;
1705 iInterpolationPoint++;
1707 if (iInterpolationPoint > nInterpolationPoints) {
1708 iInterpolationPoint = 1;
1712 if (iInterval >= nIntervals) {
1713 iInterpolationPoint = 0;
1719 return &holdingValues;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
HepGeom::Plane3D< G4double > G4Plane3D
HepGeom::Point3D< G4double > G4Point3D
HepGeom::Vector3D< G4double > G4Vector3D
#define INTERPOLATECOLOUR(colour)
std::ostream & operator<<(std::ostream &os, G4ViewParameters::DrawingStyle style)
#define INTERPOLATEVECTOR(vector)
#define INTERPOLATE(param)
#define INTERPOLATEPLANE(plane)
#define CONTINUITY(quantity)
#define INTERPOLATEPOINT(point)
#define INTERPOLATEUNITVECTOR(vector)
#define INTERPOLATELOG(param)
G4GLOB_DLL std::ostream G4cout
G4double GetAlpha() const
G4double GetGreen() const
const PVNameCopyNoPath & GetPVNameCopyNoPath() const
VisAttributesSignifier GetVisAttributesSignifier() const
const G4VisAttributes & GetVisAttributes() const
std::vector< PVNameCopyNo > PVNameCopyNoPath
PVNameCopyNoPath::const_iterator PVNameCopyNoPathConstIterator
@ VASForceNumberOfCloudPoints
@ VASForceLineSegmentsPerCircle
void SetScreenSize(G4double)
G4int SetNumberOfCloudPoints(G4int)
static G4ViewParameters * CatmullRomCubicSplineInterpolation(const std::vector< G4ViewParameters > &views, G4int nInterpolationPoints=50)
G4int SetNoOfSides(G4int nSides)
void SetViewAndLights(const G4Vector3D &viewpointDirection)
G4int GetWindowAbsoluteLocationHintY(G4int) const
G4String CameraAndLightingCommands(const G4Point3D standardTargetPoint) const
G4double GetCameraDistance(G4double radius) const
void PrintDifferences(const G4ViewParameters &v) const
void SetVisibleDensity(G4double visibleDensity)
void AddVisAttributesModifier(const G4ModelingParameters::VisAttributesModifier &)
G4Vector3D & GetActualLightpointDirection()
void SetXGeometryString(const G4String &)
G4double GetFarDistance(G4double cameraDistance, G4double nearDistance, G4double radius) const
void MultiplyScaleFactor(const G4Vector3D &scaleFactorMultiplier)
G4double GetFrontHalfHeight(G4double nearDistance, G4double radius) const
G4int GetWindowAbsoluteLocationHintX(G4int) const
G4String SceneModifyingCommands() const
void IncrementPan(G4double right, G4double up)
G4String TimeWindowCommands() const
G4String TouchableCommands() const
void ChangeCutawayPlane(size_t index, const G4Plane3D &cutawayPlane)
void SetPan(G4double right, G4double up)
void SetLightpointDirection(const G4Vector3D &lightpointDirection)
G4String DrawingStyleCommands() const
G4bool operator!=(const G4ViewParameters &) const
G4double GetNearDistance(G4double cameraDistance, G4double radius) const
void AddCutawayPlane(const G4Plane3D &cutawayPlane)
G4int GetForcedNumberOfCloudPoints() const
G4double GetLineWidth() const
G4bool IsDaughtersInvisible() const
void SetColour(const G4Colour &)
G4int GetForcedLineSegmentsPerCircle() const
LineStyle GetLineStyle() const
const G4Colour & GetColour() const
G4bool IsForceAuxEdgeVisible() const
G4bool IsForcedAuxEdgeVisible() const
ForcedDrawingStyle GetForcedDrawingStyle() const
static G4int GetMinLineSegmentsPerCircle()
G4bool IsForceDrawingStyle() const
BasicVector3D< T > cross(const BasicVector3D< T > &v) const
BasicVector3D< T > unit() const
Point3D< T > point(const Point3D< T > &p) const
Normal3D< T > normal() const
static G4int GetNumberOfRotationSteps()