47 fNumberOfCloudPoints(10000),
48 fAuxEdgeVisible (false),
50 fCullInvisible (true),
51 fDensityCulling (false),
52 fVisibleDensity (0.01 * g / cm3),
54 fCBDAlgorithmNumber (0),
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.)),
88 fSpecialMeshRendering(false),
90 fTransparencyByDepth(0.),
91 fTransparencyByDepthOption(1),
105 fDefaultMarker.SetScreenSize (5.);
113 fScaleFactor.setX(fScaleFactor.x() * scaleFactorMultiplier.
x());
114 fScaleFactor.setY(fScaleFactor.y() * scaleFactorMultiplier.
y());
115 fScaleFactor.setZ(fScaleFactor.z() * scaleFactorMultiplier.
z());
120 return fActualLightpointDirection;
133 if (fFieldHalfAngle == 0.) {
134 cameraDistance = radius;
137 cameraDistance = radius / std::sin (fFieldHalfAngle) - fDolly;
139 return cameraDistance;
144 const G4double small = 1.e-6 * radius;
145 G4double nearDistance = cameraDistance - radius;
146 if (nearDistance < small) nearDistance = small;
153 G4double farDistance = cameraDistance + radius;
154 if (farDistance < nearDistance) farDistance = nearDistance;
161 if (fFieldHalfAngle == 0.) {
162 frontHalfHeight = radius / fZoomFactor;
165 frontHalfHeight = nearDistance * std::tan (fFieldHalfAngle) / fZoomFactor;
167 return frontHalfHeight;
172 if (fCutawayPlanes.size () < 3 ) {
173 fCutawayPlanes.push_back (cutawayPlane);
177 "ERROR: G4ViewParameters::AddCutawayPlane:"
178 "\n A maximum of 3 cutaway planes supported." <<
G4endl;
183(
size_t index,
const G4Plane3D& cutawayPlane) {
184 if (index >= fCutawayPlanes.size()) {
186 "ERROR: G4ViewParameters::ChangeCutawayPlane:"
187 "\n Plane " << index <<
" does not exist." <<
G4endl;
189 fCutawayPlanes[index] = cutawayPlane;
194 const G4double reasonableMaximum = 10.0 * g / cm3;
195 if (visibleDensity < 0) {
196 G4warn <<
"G4ViewParameters::SetVisibleDensity: attempt to set negative "
197 "density - ignored." <<
G4endl;
200 if (visibleDensity > reasonableMaximum) {
201 G4warn <<
"G4ViewParameters::SetVisibleDensity: density > "
202 <<
G4BestUnit (reasonableMaximum,
"Volumic Mass")
203 <<
" - did you mean this?"
206 fVisibleDensity = visibleDensity;
211 const G4int nSidesMin = fDefaultVisAttributes.GetMinLineSegmentsPerCircle();
212 if (nSides < nSidesMin) {
214 G4warn <<
"G4ViewParameters::SetNoOfSides: attempt to set the"
215 "\nnumber of sides per circle < " << nSidesMin
216 <<
"; forced to " << nSides <<
G4endl;
223 const G4int nPointsMin = 100;
224 if (nPoints < nPointsMin) {
225 nPoints = nPointsMin;
226 G4warn <<
"G4ViewParameters::SetNumberOfCloudPoints:"
227 "\nnumber of points per cloud set to minimum " << nPoints
230 fNumberOfCloudPoints = nPoints;
231 return fNumberOfCloudPoints;
237 fViewpointDirection = viewpointDirection;
241 if (fViewpointDirection.unit() * fUpVector.unit() > .9999) {
242 static G4bool firstTime =
true;
246 "WARNING: Viewpoint direction is very close to the up vector direction."
247 "\n Change the up vector or \"/vis/viewer/set/rotationStyle freeRotation\"."
253 if (fLightsMoveWithCamera) {
254 G4Vector3D zprime = fViewpointDirection.unit ();
255 G4Vector3D xprime = (fUpVector.cross (zprime)).unit ();
257 fActualLightpointDirection =
258 fRelativeLightpointDirection.x () * xprime +
259 fRelativeLightpointDirection.
y () * yprime +
260 fRelativeLightpointDirection.
z () * zprime;
262 fActualLightpointDirection = fRelativeLightpointDirection;
268 fRelativeLightpointDirection = lightpointDirection;
273 G4Vector3D unitRight = (fUpVector.cross (fViewpointDirection)).unit();
274 G4Vector3D unitUp = (fViewpointDirection.cross (unitRight)).unit();
275 fCurrentTargetPoint = right * unitRight + up * unitUp;
283 G4Vector3D unitRight = (fUpVector.cross (fViewpointDirection)).unit();
284 G4Vector3D unitUp = (fViewpointDirection.cross (unitRight)).unit();
285 fCurrentTargetPoint += right * unitRight + up * unitUp + distance * fViewpointDirection;
291 G4bool duplicateTarget =
false;
292 auto i = fVisAttributesModifiers.begin();
293 for (; i < fVisAttributesModifiers.end(); ++i) {
296 duplicateTarget =
true;
301 else fVisAttributesModifiers.push_back(vam);
305(
const G4Point3D standardTargetPoint)
const
307 std::ostringstream oss;
309 oss <<
"#\n# Camera and lights commands";
311 oss <<
"\n/vis/viewer/set/viewpointVector "
312 << fViewpointDirection.x()
313 <<
' ' << fViewpointDirection.y()
314 <<
' ' << fViewpointDirection.z();
316 oss <<
"\n/vis/viewer/set/upVector "
318 <<
' ' << fUpVector.y()
319 <<
' ' << fUpVector.z();
321 oss <<
"\n/vis/viewer/set/projection ";
322 if (fFieldHalfAngle == 0.) {
328 << fFieldHalfAngle/deg
332 oss <<
"\n/vis/viewer/zoomTo "
335 oss <<
"\n/vis/viewer/scaleTo "
337 <<
' ' << fScaleFactor.y()
338 <<
' ' << fScaleFactor.z();
340 oss <<
"\n/vis/viewer/set/targetPoint "
341 <<
G4BestUnit(standardTargetPoint+fCurrentTargetPoint,
"Length")
342 <<
"\n# Note that if you have not set a target point, the vis system sets"
343 <<
"\n# a target point based on the scene - plus any panning and dollying -"
344 <<
"\n# so don't be alarmed by strange coordinates here.";
346 oss <<
"\n/vis/viewer/dollyTo "
349 oss <<
"\n/vis/viewer/set/lightsMove ";
350 if (fLightsMoveWithCamera) {
356 oss <<
"\n/vis/viewer/set/lightsVector "
357 << fRelativeLightpointDirection.x()
358 <<
' ' << fRelativeLightpointDirection.y()
359 <<
' ' << fRelativeLightpointDirection.z();
361 oss <<
"\n/vis/viewer/set/rotationStyle ";
363 oss <<
"constrainUpDirection";
365 oss <<
"freeRotation";
369 oss <<
"\n/vis/viewer/set/background "
376 oss <<
"\n/vis/viewer/set/defaultColour "
382 c = fDefaultTextVisAttributes.
GetColour();
383 oss <<
"\n/vis/viewer/set/defaultTextColour "
396 std::ostringstream oss;
398 oss <<
"#\n# Drawing style commands";
400 oss <<
"\n/vis/viewer/set/style ";
401 switch (fDrawingStyle) {
415 oss <<
"\n/vis/viewer/set/hiddenEdge ";
416 if (fDrawingStyle ==
hlr || fDrawingStyle ==
hlhsr) {
422 oss <<
"\n/vis/viewer/set/auxiliaryEdge ";
423 if (fAuxEdgeVisible) {
429 oss <<
"\n/vis/viewer/set/hiddenMarker ";
430 if (fMarkerNotHidden) {
436 oss <<
"\n/vis/viewer/set/globalLineWidthScale "
437 << fGlobalLineWidthScale;
439 oss <<
"\n/vis/viewer/set/globalMarkerScale "
440 << fGlobalMarkerScale;
442 oss <<
"\n/vis/viewer/set/numberOfCloudPoints "
443 << fNumberOfCloudPoints;
445 oss <<
"\n/vis/viewer/set/specialMeshRendering ";
446 if (fSpecialMeshRendering) {
452 oss <<
"\n/vis/viewer/set/specialMeshRenderingOption "
453 << fSpecialMeshRenderingOption;
455 oss <<
"\n/vis/viewer/set/specialMeshVolumes";
456 for (
const auto& volume : fSpecialMeshVolumes) {
457 oss <<
' ' << volume.GetName() <<
' ' << volume.GetCopyNo();
460 oss <<
"\n/vis/viewer/set/zoomToCursor ";
467 oss <<
"\n/vis/viewer/set/dotsSmooth ";
474 oss <<
"\n/vis/viewer/set/dotsSize " << fDotsSize;
483 std::ostringstream oss;
485 oss <<
"#\n# Scene-modifying commands";
487 oss <<
"\n/vis/viewer/set/culling global ";
494 oss <<
"\n/vis/viewer/set/culling invisible ";
495 if (fCullInvisible) {
501 oss <<
"\n/vis/viewer/set/culling density ";
502 if (fDensityCulling) {
503 oss <<
"true " << fVisibleDensity/(g/cm3) <<
" g/cm3";
508 oss <<
"\n/vis/viewer/set/culling coveredDaughters ";
515 oss <<
"\n/vis/viewer/colourByDensity "
516 << fCBDAlgorithmNumber <<
" g/cm3";
517 for (
auto p: fCBDParameters) {
518 oss <<
' ' << p/(g/cm3);
521 oss <<
"\n/vis/viewer/set/sectionPlane ";
525 << fSectionPlane.normal().x()
526 <<
' ' << fSectionPlane.normal().y()
527 <<
' ' << fSectionPlane.normal().z();
532 oss <<
"\n/vis/viewer/set/cutawayMode ";
536 oss <<
"intersection";
539 oss <<
"\n/vis/viewer/clearCutawayPlanes";
540 if (fCutawayPlanes.size()) {
541 for (
const auto& fCutawayPlane : fCutawayPlanes) {
542 oss <<
"\n/vis/viewer/addCutawayPlane "
544 << fCutawayPlane.normal().x()
545 <<
' ' << fCutawayPlane.normal().y()
546 <<
' ' << fCutawayPlane.normal().z();
549 oss <<
"\n# No cutaway planes defined.";
552 oss <<
"\n/vis/viewer/set/explodeFactor "
554 <<
' ' <<
G4BestUnit(fExplodeCentre,
"Length");
556 oss <<
"\n/vis/viewer/set/lineSegmentsPerCircle "
559 oss <<
"\n/vis/viewer/set/transparencyByDepth "
560 << fTransparencyByDepth <<
' ' << fTransparencyByDepthOption;
569 std::ostringstream oss;
571 oss <<
"#\n# Touchable commands";
573 const std::vector<G4ModelingParameters::VisAttributesModifier>& vams =
574 fVisAttributesModifiers;
579 <<
"\n/vis/viewer/clearVisAttributesModifiers";
585 <<
"\n/vis/viewer/clearVisAttributesModifiers";
588 std::vector<G4ModelingParameters::VisAttributesModifier>::const_iterator
590 for (iModifier = vams.begin();
591 iModifier != vams.end();
594 iModifier->GetPVNameCopyNoPath();
595 if (vamPath != lastPath) {
597 oss <<
"\n/vis/set/touchable";
599 for (iVAM = vamPath.begin();
600 iVAM != vamPath.end();
602 oss <<
' ' << iVAM->GetName() <<
' ' << iVAM->GetCopyNo();
607 switch (iModifier->GetVisAttributesSignifier()) {
609 oss <<
"\n/vis/touchable/set/visibility ";
617 oss <<
"\n/vis/touchable/set/daughtersInvisible ";
625 oss <<
"\n/vis/touchable/set/colour "
632 oss <<
"\n/vis/touchable/set/lineStyle ";
645 oss <<
"\n/vis/touchable/set/lineWidth "
651 oss <<
"\n/vis/touchable/set/forceWireframe ";
663 oss <<
"\n/vis/touchable/set/forceSolid ";
675 oss <<
"\n/vis/touchable/set/forceCloud ";
686 oss <<
"\n/vis/touchable/set/forceAuxEdgeVisible ";
695 oss <<
"\n/vis/touchable/set/lineSegmentsPerCircle "
699 oss <<
"\n/vis/touchable/set/numberOfCloudPoints "
712 std::ostringstream oss;
714 oss <<
"#\n# Time window commands";
717 <<
"\n/vis/viewer/set/timeWindow/startTime "
718 << fTimeParameters.fStartTime/
ns <<
" ns ";
721 <<
"\n/vis/viewer/set/timeWindow/endTime "
722 << fTimeParameters.fEndTime/
ns <<
" ns ";
724 oss <<
"\n/vis/viewer/set/timeWindow/fadeFactor "
725 << fTimeParameters.fFadeFactor;
728 <<
"\n/vis/viewer/set/timeWindow/displayHeadTime ";
729 if (!fTimeParameters.fDisplayHeadTime) {
734 <<
' ' << fTimeParameters.fDisplayHeadTimeX
735 <<
' ' << fTimeParameters.fDisplayHeadTimeY
736 <<
' ' << fTimeParameters.fDisplayHeadTimeSize
737 <<
' ' << fTimeParameters.fDisplayHeadTimeRed
738 <<
' ' << fTimeParameters.fDisplayHeadTimeGreen
739 <<
' ' << fTimeParameters.fDisplayHeadTimeBlue;
743 <<
"\n/vis/viewer/set/timeWindow/displayLightFront ";
744 if (!fTimeParameters.fDisplayLightFront) {
749 <<
' ' << fTimeParameters.fDisplayLightFrontX/mm
750 <<
' ' << fTimeParameters.fDisplayLightFrontY/mm
751 <<
' ' << fTimeParameters.fDisplayLightFrontZ/mm
753 <<
' ' << fTimeParameters.fDisplayLightFrontT/
ns
755 <<
' ' << fTimeParameters.fDisplayLightFrontRed
756 <<
' ' << fTimeParameters.fDisplayLightFrontGreen
757 <<
' ' << fTimeParameters.fDisplayLightFrontBlue;
770 (fViewpointDirection != v.fViewpointDirection) ||
773 (fDrawingStyle != v.fDrawingStyle) ||
774 (fNumberOfCloudPoints != v.fNumberOfCloudPoints) ||
775 (fAuxEdgeVisible != v.fAuxEdgeVisible) ||
776 (fCulling != v.fCulling) ||
777 (fCullInvisible != v.fCullInvisible) ||
778 (fDensityCulling != v.fDensityCulling) ||
779 (fVisibleDensity != v.fVisibleDensity) ||
780 (fCullCovered != v.fCullCovered) ||
781 (fCBDAlgorithmNumber != v.fCBDAlgorithmNumber) ||
782 (fSection != v.fSection) ||
783 (fNoOfSides != v.fNoOfSides) ||
784 (fUpVector != v.fUpVector) ||
785 (fFieldHalfAngle != v.fFieldHalfAngle) ||
786 (fZoomFactor != v.fZoomFactor) ||
787 (fScaleFactor != v.fScaleFactor) ||
788 (fCurrentTargetPoint != v.fCurrentTargetPoint) ||
789 (fDolly != v.fDolly) ||
790 (fRelativeLightpointDirection != v.fRelativeLightpointDirection) ||
791 (fLightsMoveWithCamera != v.fLightsMoveWithCamera) ||
792 (fDefaultVisAttributes != v.fDefaultVisAttributes) ||
793 (fDefaultTextVisAttributes != v.fDefaultTextVisAttributes) ||
794 (fDefaultMarker != v.fDefaultMarker) ||
795 (fGlobalMarkerScale != v.fGlobalMarkerScale) ||
796 (fGlobalLineWidthScale != v.fGlobalLineWidthScale) ||
797 (fMarkerNotHidden != v.fMarkerNotHidden) ||
798 (fWindowSizeHintX != v.fWindowSizeHintX) ||
799 (fWindowSizeHintY != v.fWindowSizeHintY) ||
800 (fXGeometryString != v.fXGeometryString) ||
801 (fGeometryMask != v.fGeometryMask) ||
802 (fAutoRefresh != v.fAutoRefresh) ||
803 (fBackgroundColour != v.fBackgroundColour) ||
804 (fPicking != v.fPicking) ||
805 (fRotationStyle != v.fRotationStyle) ||
806 (fTransparencyByDepth != v.fTransparencyByDepth) ||
807 (fTransparencyByDepthOption != v.fTransparencyByDepthOption) ||
808 (fZoomToCursor != v.fZoomToCursor) ||
809 (fDotsSmooth != v.fDotsSmooth) ||
810 (fDotsSize != v.fDotsSize)
814 if (fCBDAlgorithmNumber > 0) {
815 if (fCBDParameters.size() != v.fCBDParameters.size()) {
816 G4cout <<
"Difference in number of colour by density parameters." <<
G4endl;
817 }
else if (fCBDParameters != v.fCBDParameters) {
818 G4cout <<
"Difference in values of colour by density parameters." <<
G4endl;
823 if (!(fSectionPlane == v.fSectionPlane))
824 G4cout <<
"Difference in section planes batch." <<
G4endl;
828 if (fCutawayPlanes.size () != v.fCutawayPlanes.size ()) {
829 G4cout <<
"Difference in no of cutaway planes." <<
G4endl;
832 for (
size_t i = 0; i < fCutawayPlanes.size (); i++) {
833 if (!(fCutawayPlanes[i] == v.fCutawayPlanes[i]))
834 G4cout <<
"Difference in cutaway plane no. " << i <<
G4endl;
840 if (fExplodeFactor != v.fExplodeFactor)
842 if (fExplodeCentre != v.fExplodeCentre)
846 if (fVisAttributesModifiers != v.fVisAttributesModifiers) {
847 G4cout <<
"Difference in vis attributes modifiers." <<
G4endl;
850 if (fTimeParameters.fStartTime != v.fTimeParameters.
fStartTime ||
851 fTimeParameters.fEndTime != v.fTimeParameters.
fEndTime) {
855 if (fTimeParameters.fFadeFactor != v.fTimeParameters.
fFadeFactor) {
856 G4cout <<
"Difference in time window fade factor." <<
G4endl;
859 if (fTimeParameters.fDisplayHeadTime != v.fTimeParameters.
fDisplayHeadTime) {
860 G4cout <<
"Difference in display head time flag." <<
G4endl;
868 G4cout <<
"Difference in display head time parameters." <<
G4endl;
873 G4cout <<
"Difference in display light front flag." <<
G4endl;
882 G4cout <<
"Difference in display light front parameters." <<
G4endl;
887std::ostream&
operator <<
892 os <<
"wireframe";
break;
894 os <<
"hlr - hidden lines removed";
break;
896 os <<
"hsr - hidden surfaces removed";
break;
898 os <<
"hlhsr - hidden line, hidden surface removed";
break;
900 os <<
"cloud - draw volume as a cloud of dots";
break;
901 default: os <<
"unrecognised";
break;
906std::ostream&
operator <<
911 os <<
"default";
break;
915 os <<
"surfaces";
break;
921 os <<
"View parameters and options:";
923 os <<
"\n Drawing style: " << v.fDrawingStyle;
925 os <<
"\n Number of cloud points: " << v.fNumberOfCloudPoints;
927 os <<
"\n Auxiliary edges: ";
928 if (!v.fAuxEdgeVisible) os <<
"in";
931 os <<
"\n Culling: ";
932 if (v.fCulling) os <<
"on";
935 os <<
"\n Culling invisible objects: ";
936 if (v.fCullInvisible) os <<
"on";
939 os <<
"\n Density culling: ";
940 if (v.fDensityCulling) {
941 os <<
"on - invisible if density less than "
942 << v.fVisibleDensity / (1. * g / cm3) <<
" g cm^-3";
946 os <<
"\n Culling daughters covered by opaque mothers: ";
947 if (v.fCullCovered) os <<
"on";
950 os <<
"\n Colour by density: ";
951 if (v.fCBDAlgorithmNumber <= 0) {
954 os <<
"Algorithm " << v.fCBDAlgorithmNumber <<
", Parameters:";
955 for (
auto p: v.fCBDParameters) {
960 os <<
"\n Section flag: ";
961 if (v.fSection) os <<
"true, section/cut plane: " << v.fSectionPlane;
965 os <<
"\n Cutaway planes: ";
966 for (
const auto& fCutawayPlane : v.fCutawayPlanes) {
967 os <<
' ' << fCutawayPlane;
971 os <<
"\n No cutaway planes";
974 os <<
"\n Explode factor: " << v.fExplodeFactor
975 <<
" about centre: " << v.fExplodeCentre;
977 os <<
"\n No. of sides used in circle polygon approximation: "
980 os <<
"\n Viewpoint direction: " << v.fViewpointDirection;
982 os <<
"\n Up vector: " << v.fUpVector;
984 os <<
"\n Field half angle: " << v.fFieldHalfAngle;
986 os <<
"\n Zoom factor: " << v.fZoomFactor;
988 os <<
"\n Scale factor: " << v.fScaleFactor;
990 os <<
"\n Current target point: " << v.fCurrentTargetPoint;
992 os <<
"\n Dolly distance: " << v.fDolly;
995 if (v.fLightsMoveWithCamera) os <<
"moves";
996 else os <<
"does not move";
997 os <<
" with camera";
999 os <<
"\n Relative lightpoint direction: "
1000 << v.fRelativeLightpointDirection;
1002 os <<
"\n Actual lightpoint direction: "
1003 << v.fActualLightpointDirection;
1005 os <<
"\n Derived parameters for standard view of object of unit radius:";
1008 tempVP.fZoomFactor = 1.;
1016 os <<
"\n Camera distance: " << cameraDistance;
1017 os <<
"\n Near distance: " << nearDistance;
1018 os <<
"\n Far distance: " << farDistance;
1019 os <<
"\n Front half height: " << right;
1021 os <<
"\n Default VisAttributes:\n " << v.fDefaultVisAttributes;
1023 os <<
"\n Default TextVisAttributes:\n " << v.fDefaultTextVisAttributes;
1025 os <<
"\n Default marker:\n " << v.fDefaultMarker;
1027 os <<
"\n Global marker scale: " << v.fGlobalMarkerScale;
1029 os <<
"\n Global lineWidth scale: " << v.fGlobalLineWidthScale;
1032 if (v.fMarkerNotHidden) os <<
"not ";
1033 os <<
"hidden by surfaces.";
1035 os <<
"\n Window size hint: "
1036 << v.fWindowSizeHintX <<
'x'<< v.fWindowSizeHintX;
1038 os <<
"\n X geometry string: " << v.fXGeometryString;
1039 os <<
"\n X geometry mask: "
1040 << std::showbase << std::hex << v.fGeometryMask
1041 << std::noshowbase << std::dec;
1043 os <<
"\n Auto refresh: ";
1044 if (v.fAutoRefresh) os <<
"true";
1047 os <<
"\n Background colour: " << v.fBackgroundColour;
1049 os <<
"\n Picking requested: ";
1050 if (v.fPicking) os <<
"true";
1053 os <<
"\n Rotation style: ";
1054 switch (v.fRotationStyle) {
1056 os <<
"constrainUpDirection (conventional HEP view)";
break;
1058 os <<
"freeRotation (Google-like rotation, using mouse-grab)";
break;
1059 default: os <<
"unrecognised";
break;
1062 os <<
"\nVis attributes modifiers: ";
1063 const std::vector<G4ModelingParameters::VisAttributesModifier>& vams =
1064 v.fVisAttributesModifiers;
1071 os <<
"\nTime window parameters:"
1072 <<
"\n Start time: " << v.fTimeParameters.
fStartTime/
ns <<
" ns"
1073 <<
"\n End time: " << v.fTimeParameters.
fEndTime/
ns <<
" ns"
1074 <<
"\n Fade factor: " << v.fTimeParameters.
fFadeFactor;
1076 os <<
"\n Head time display not requested.";
1079 <<
"\n Head time position: "
1086 os <<
"\n Light front display not requested.";
1089 <<
"\n Light front position: "
1097 os <<
"\nSpecial Mesh Rendering";
1098 if (v.fSpecialMeshRendering) {
1099 os <<
" requested with option \"" << v.fSpecialMeshRenderingOption;
1101 if (v.fSpecialMeshVolumes.empty()) {
1104 os <<
"selected meshes";
1105 for (
const auto& vol: v.fSpecialMeshVolumes) {
1106 os <<
"\n " << vol.GetName() <<
':' << vol.GetCopyNo();
1109 }
else os <<
": off";
1111 os <<
"\nTransparency by depth: " << v.fTransparencyByDepth
1112 <<
", option: " << v.fTransparencyByDepthOption;
1114 os <<
"\nZoom to cursor requested: ";
1115 if (v.fZoomToCursor) os <<
"true";
1118 os <<
"\nSmooth dots requested: ";
1119 if (v.fDotsSmooth) os <<
"true";
1122 os <<
"\nDots size: " << v.fDotsSize;
1132 (fViewpointDirection != v.fViewpointDirection) ||
1135 (fDrawingStyle != v.fDrawingStyle) ||
1136 (fNumberOfCloudPoints != v.fNumberOfCloudPoints) ||
1137 (fAuxEdgeVisible != v.fAuxEdgeVisible) ||
1138 (fCulling != v.fCulling) ||
1139 (fCullInvisible != v.fCullInvisible) ||
1140 (fDensityCulling != v.fDensityCulling) ||
1141 (fCullCovered != v.fCullCovered) ||
1142 (fCBDAlgorithmNumber != v.fCBDAlgorithmNumber) ||
1143 (fSection != v.fSection) ||
1146 (fNoOfSides != v.fNoOfSides) ||
1147 (fUpVector != v.fUpVector) ||
1148 (fFieldHalfAngle != v.fFieldHalfAngle) ||
1149 (fZoomFactor != v.fZoomFactor) ||
1150 (fScaleFactor != v.fScaleFactor) ||
1151 (fCurrentTargetPoint != v.fCurrentTargetPoint) ||
1152 (fDolly != v.fDolly) ||
1153 (fRelativeLightpointDirection != v.fRelativeLightpointDirection) ||
1154 (fLightsMoveWithCamera != v.fLightsMoveWithCamera) ||
1155 (fDefaultVisAttributes != v.fDefaultVisAttributes) ||
1156 (fDefaultTextVisAttributes != v.fDefaultTextVisAttributes) ||
1157 (fDefaultMarker != v.fDefaultMarker) ||
1158 (fGlobalMarkerScale != v.fGlobalMarkerScale) ||
1159 (fGlobalLineWidthScale != v.fGlobalLineWidthScale) ||
1160 (fMarkerNotHidden != v.fMarkerNotHidden) ||
1161 (fWindowSizeHintX != v.fWindowSizeHintX) ||
1162 (fWindowSizeHintY != v.fWindowSizeHintY) ||
1163 (fXGeometryString != v.fXGeometryString) ||
1164 (fGeometryMask != v.fGeometryMask) ||
1165 (fAutoRefresh != v.fAutoRefresh) ||
1166 (fBackgroundColour != v.fBackgroundColour) ||
1167 (fPicking != v.fPicking) ||
1168 (fRotationStyle != v.fRotationStyle) ||
1169 (fSpecialMeshRendering != v.fSpecialMeshRendering) ||
1170 (fSpecialMeshRenderingOption != v.fSpecialMeshRenderingOption) ||
1171 (fTransparencyByDepth != v.fTransparencyByDepth) ||
1172 (fTransparencyByDepthOption != v.fTransparencyByDepthOption) ||
1173 (fZoomToCursor != v.fZoomToCursor) ||
1174 (fDotsSmooth != v.fDotsSmooth) ||
1175 (fDotsSize != v.fDotsSize)
1179 if (fDensityCulling &&
1180 (fVisibleDensity != v.fVisibleDensity))
return true;
1182 if (fCBDAlgorithmNumber > 0) {
1183 if (fCBDParameters.size() != v.fCBDParameters.size())
return true;
1184 else if (fCBDParameters != v.fCBDParameters)
return true;
1188 (!(fSectionPlane == v.fSectionPlane)))
return true;
1191 if (fCutawayPlanes.size () != v.fCutawayPlanes.size ())
1194 for (
size_t i = 0; i < fCutawayPlanes.size (); i++) {
1195 if (!(fCutawayPlanes[i] == v.fCutawayPlanes[i]))
return true;
1201 ((fExplodeFactor != v.fExplodeFactor) ||
1202 (fExplodeCentre != v.fExplodeCentre)))
return true;
1204 if (fVisAttributesModifiers != v.fVisAttributesModifiers)
return true;
1206 if (fTimeParameters.fStartTime != v.fTimeParameters.
fStartTime ||
1207 fTimeParameters.fEndTime != v.fTimeParameters.
fEndTime ||
1208 fTimeParameters.fFadeFactor != v.fTimeParameters.
fFadeFactor)
return true;
1210 if (fTimeParameters.fDisplayHeadTime != v.fTimeParameters.
fDisplayHeadTime)
return true;
1211 if (fTimeParameters.fDisplayHeadTime) {
1222 if (fTimeParameters.fDisplayLightFront != v.fTimeParameters.
fDisplayLightFront)
return true;
1223 if (fTimeParameters.fDisplayLightFront) {
1235 if (fSpecialMeshRendering) {
1236 if (fSpecialMeshVolumes != v.fSpecialMeshVolumes)
1246 G4String::size_type i = geomString.find_first_of(delimiters);
1247 if (i == G4String::npos) {
1250 std::istringstream iss(geomString);
1255 fWindowSizeHintX = size;
1256 fWindowSizeHintY = size;
1261 if (fWindowLocationHintXNegative) signX =
'-';
else signX =
'+';
1262 if (fWindowLocationHintYNegative) signY =
'-';
else signY =
'+';
1263 std::ostringstream oss;
1264 oss << fWindowSizeHintX <<
'x' << fWindowSizeHintY
1265 << signX << fWindowLocationHintX << signY << fWindowLocationHintY;
1266 fXGeometryString = oss.str();
1272 unsigned int w = 0, h = 0;
1273 fGeometryMask = ParseGeometry( geomString, &x, &y, &w, &h );
1276 if ((fGeometryMask & fYValue) == 0)
1278 y = fWindowLocationHintY;
1280 if ((fGeometryMask & fXValue) == 0)
1282 x = fWindowLocationHintX;
1287 if ( ((fGeometryMask & fHeightValue) == 0 ) &&
1288 ((fGeometryMask & fWidthValue) == 0 )) {
1289 h = fWindowSizeHintY;
1290 w = fWindowSizeHintX;
1291 }
else if ((fGeometryMask & fHeightValue) == 0 ) {
1296 G4warn <<
"Unrecognised geometry string \""
1298 <<
"\". No Height found. Using Width value instead"
1302 if ( ((fGeometryMask & fXValue) == 0 ) ||
1303 ((fGeometryMask & fYValue) == 0 )) {
1305 x = fWindowLocationHintX;
1306 y = fWindowLocationHintY;
1309 fXGeometryString = geomString;
1312 fWindowSizeHintX = w;
1313 fWindowSizeHintY = h;
1314 fWindowLocationHintX = x;
1315 fWindowLocationHintY = y;
1317 if ( ((fGeometryMask & fXValue)) &&
1318 ((fGeometryMask & fYValue))) {
1320 if ( (fGeometryMask & fXNegative) ) {
1321 fWindowLocationHintXNegative =
true;
1323 fWindowLocationHintXNegative =
false;
1325 if ( (fGeometryMask & fYNegative) ) {
1326 fWindowLocationHintYNegative =
true;
1328 fWindowLocationHintYNegative =
false;
1334 if ( fWindowLocationHintXNegative ) {
1335 return sizeX + fWindowLocationHintX - fWindowSizeHintX;
1337 return fWindowLocationHintX;
1341 if ( fWindowLocationHintYNegative ) {
1342 return sizeY + fWindowLocationHintY - fWindowSizeHintY;
1344 return fWindowLocationHintY;
1361int G4ViewParameters::ParseGeometry (
1365 unsigned int *width,
1366 unsigned int *height)
1369 G4int mask = fNoValue;
1371 unsigned int tempWidth = 0;
1372 unsigned int tempHeight = 0;
1375 char *nextCharacter;
1376 if ( (
string == NULL) || (*
string ==
'\0')) {
1381 strind = (
char *)
string;
1382 if (*strind !=
'+' && *strind !=
'-' && *strind !=
'x') {
1383 tempWidth = ReadInteger(strind, &nextCharacter);
1384 if (strind == nextCharacter)
1386 strind = nextCharacter;
1387 mask |= fWidthValue;
1389 if (*strind ==
'x' || *strind ==
'X') {
1391 tempHeight = ReadInteger(strind, &nextCharacter);
1392 if (strind == nextCharacter)
1394 strind = nextCharacter;
1395 mask |= fHeightValue;
1398 if ((*strind ==
'+') || (*strind ==
'-')) {
1399 if (*strind ==
'-') {
1401 tempX = -ReadInteger(strind, &nextCharacter);
1402 if (strind == nextCharacter)
1404 strind = nextCharacter;
1410 tempX = ReadInteger(strind, &nextCharacter);
1411 if (strind == nextCharacter)
1413 strind = nextCharacter;
1416 if ((*strind ==
'+') || (*strind ==
'-')) {
1417 if (*strind ==
'-') {
1419 tempY = -ReadInteger(strind, &nextCharacter);
1420 if (strind == nextCharacter)
1422 strind = nextCharacter;
1428 tempY = ReadInteger(strind, &nextCharacter);
1429 if (strind == nextCharacter)
1431 strind = nextCharacter;
1438 if (*strind !=
'\0')
return (0);
1443 if (mask & fWidthValue)
1445 if (mask & fHeightValue)
1446 *height = tempHeight;
1454G4int G4ViewParameters::ReadInteger(
char *
string,
char **NextString)
1461 else if (*
string ==
'-')
1466 for (; (*
string >=
'0') && (*
string <=
'9');
string++)
1468 Result = (Result * 10) + (*
string -
'0');
1478(
const std::vector<G4ViewParameters>& views,
1479 G4int nInterpolationPoints)
1493 if (views.size() < 2) {
1495 (
"G4ViewParameters::CatmullRomCubicSplineInterpolation",
1497 "There must be at least two views.");
1501 if (nInterpolationPoints < 1) {
1503 (
"G4ViewParameters::CatmullRomCubicSplineInterpolation",
1505 "Number of interpolation points cannot be zero or negative.");
1509 const size_t nIntervals = views.size() - 1;
1510 const G4double dt = 1./nInterpolationPoints;
1514 static G4int iInterpolationPoint = 0;
1515 static size_t iInterval = 0;
1520 const G4double h00 = 2.*t*t*t - 3.*t*t +1;
1521 const G4double h10 = t*t*t -2.*t*t + t;
1522 const G4double h01 = -2.*t*t*t + 3.*t*t;
1526 const size_t& n = nIntervals;
1527 size_t& i = iInterval;
1528 const std::vector<G4ViewParameters>& v = views;
1545 holdingValues = t < 0.5? v[i]: v[i+1];
1548#define INTERPOLATE(param) \
1553mi = v[1].param - v[0].param; \
1556if (n == 1) mi1 = mi; \
1558else mi1 = 0.5 * (v[2].param - v[0].param); \
1559} else if (i >= n - 1) { \
1561mi1 = v[i+1].param - v[i].param; \
1563if (n == 1) mi = mi1; \
1565else mi = 0.5 * (v[i+1].param - v[i-1].param); \
1568mi = 0.5 * (v[i+1].param - v[i-1].param); \
1569mi1 = 0.5 * (v[i+2].param - v[i ].param); \
1571real = h00 * v[i].param + h10 * mi + h01 * v[i+1].param + h11 * mi1;
1573#define INTERPOLATELOG(param) \
1575mi = std::log(v[1].param) - std::log(v[0].param); \
1576if (n == 1) mi1 = mi; \
1577else mi1 = 0.5 * (std::log(v[2].param) - std::log(v[0].param)); \
1578} else if (i >= n - 1) { \
1579mi1 = std::log(v[i+1].param) - std::log(v[i].param); \
1580if (n == 1) mi = mi1; \
1581else mi = 0.5 * (std::log(v[i+1].param) - std::log(v[i-1].param)); \
1583mi = 0.5 * (std::log(v[i+1].param) - std::log(v[i-1].param)); \
1584mi1 = 0.5 * (std::log(v[i+2].param) - std::log(v[i ].param)); \
1586real = std::exp(h00 * std::log(v[i].param) + h10 * mi + h01 * std::log(v[i+1].param) + h11 * mi1);
1590 if (real < 0.) real = 0.;
1591 holdingValues.fVisibleDensity = real;
1593 holdingValues.fExplodeFactor = real;
1595 if (real < 0.) real = 0.;
1596 holdingValues.fFieldHalfAngle = real;
1598 holdingValues.fZoomFactor = real;
1600 holdingValues.fDolly = real;
1602 if (real < 0.) real = 0.;
1603 holdingValues.fGlobalMarkerScale = real;
1605 if (real < 0.) real = 0.;
1606 holdingValues.fGlobalLineWidthScale = real;
1609#define INTERPOLATEUNITVECTOR(vector) \
1610INTERPOLATE(vector.x()); x = real; \
1611INTERPOLATE(vector.y()); y = real; \
1612INTERPOLATE(vector.z()); z = real;
1618 holdingValues.fRelativeLightpointDirection =
G4Vector3D(x,y,z).
unit();
1620 holdingValues.fActualLightpointDirection =
G4Vector3D(x,y,z).
unit();
1623#define INTERPOLATEVECTOR(vector) \
1624INTERPOLATE(vector.x()); x = real; \
1625INTERPOLATE(vector.y()); y = real; \
1626INTERPOLATE(vector.z()); z = real;
1628 holdingValues.fScaleFactor =
G4Vector3D(x,y,z);
1631#define INTERPOLATEPOINT(point) \
1632INTERPOLATE(point.x()); x = real; \
1633INTERPOLATE(point.y()); y = real; \
1634INTERPOLATE(point.z()); z = real;
1636 holdingValues.fExplodeCentre =
G4Point3D(x,y,z);
1638 holdingValues.fCurrentTargetPoint =
G4Point3D(x,y,z);
1642#define INTERPOLATECOLOUR(colour) \
1643INTERPOLATE(colour.GetRed()); red = real; \
1644INTERPOLATE(colour.GetGreen()); green = real; \
1645INTERPOLATE(colour.GetBlue()); blue = real; \
1646INTERPOLATE(colour.GetAlpha()); alpha = real;
1649 holdingValues.fBackgroundColour =
G4Colour(red,green,blue,alpha);
1653#define CONTINUITY(quantity) \
1654 continuous = false; \
1657 if (v[1].quantity == v[0].quantity) { \
1658 if (n == 1) continuous = true; \
1659 else if (v[2].quantity == v[0].quantity) \
1660 continuous = true; \
1662 } else if (i >= n - 1) { \
1663 if (v[i+1].quantity == v[i].quantity) { \
1664 if (n == 1) continuous = true; \
1665 else if (v[i+1].quantity == v[i-1].quantity) \
1666 continuous = true; \
1669 if (v[i-1].quantity == v[i].quantity && \
1670 v[i+1].quantity == v[i].quantity && \
1671 v[i+2].quantity == v[i].quantity) \
1672 continuous = true; \
1676#define INTERPOLATEPLANE(plane) \
1677INTERPOLATE(plane.a()); a = real; \
1678INTERPOLATE(plane.b()); b = real; \
1679INTERPOLATE(plane.c()); c = real; \
1680INTERPOLATE(plane.d()); d = real;
1686 holdingValues.fSectionPlane =
G4Plane3D(a,b,c,d);
1690 if (v[i].fCutawayPlanes.size()) {
1693 for (
size_t j = 0; j < v[i].fCutawayPlanes.size(); ++j) {
1695 holdingValues.fCutawayPlanes[j] =
G4Plane3D(a,b,c,d);
1704 if (v[i].fVisAttributesModifiers.size()) {
1707 for (
size_t j = 0; j < v[i].fVisAttributesModifiers.size(); ++j) {
1708 CONTINUITY(fVisAttributesModifiers[j].GetPVNameCopyNoPath());
1710 CONTINUITY(fVisAttributesModifiers[j].GetVisAttributesSignifier());
1712 if (v[i].fVisAttributesModifiers[j].GetVisAttributesSignifier() ==
1715 workingVA = v[i].fVisAttributesModifiers[j].GetVisAttributes();
1717 holdingValues.fVisAttributesModifiers[j].SetVisAttributes(workingVA);
1730 holdingValues.fTimeParameters.
fStartTime = real;
1732 holdingValues.fTimeParameters.
fEndTime = real;
1735 iInterpolationPoint++;
1737 if (iInterpolationPoint > nInterpolationPoints) {
1738 iInterpolationPoint = 1;
1742 if (iInterval >= nIntervals) {
1743 iInterpolationPoint = 0;
1749 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
static G4bool GetColour(const G4String &key, G4Colour &result)
G4double GetAlpha() const
G4double GetGreen() const
const PVNameCopyNoPath & GetPVNameCopyNoPath() const
VisAttributesSignifier GetVisAttributesSignifier() const
const G4VisAttributes & GetVisAttributes() const
PVNameCopyNoPath::const_iterator PVNameCopyNoPathConstIterator
std::vector< PVNameCopyNo > PVNameCopyNoPath
@ VASForceNumberOfCloudPoints
@ VASForceLineSegmentsPerCircle
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
G4bool IsForceDrawingStyle() const
BasicVector3D< T > cross(const BasicVector3D< T > &v) const
BasicVector3D< T > unit() const
static G4int GetNumberOfRotationSteps()
G4double fDisplayLightFrontRed
G4double fDisplayHeadTimeY
G4double fDisplayLightFrontT
G4double fDisplayHeadTimeRed
G4double fDisplayLightFrontY
G4double fDisplayLightFrontZ
G4double fDisplayLightFrontGreen
G4double fDisplayLightFrontBlue
G4bool fDisplayLightFront
G4double fDisplayHeadTimeBlue
G4double fDisplayHeadTimeSize
G4double fDisplayLightFrontX
G4double fDisplayHeadTimeGreen
G4double fDisplayHeadTimeX