44 fDrawingStyle (wireframe),
45 fNumberOfCloudPoints(10000),
46 fAuxEdgeVisible (false),
48 fCullInvisible (true),
49 fDensityCulling (false),
50 fVisibleDensity (0.01 * g / cm3),
52 fCBDAlgorithmNumber (0),
55 fCutawayMode (cutawayUnion),
64 fCurrentTargetPoint (),
66 fLightsMoveWithCamera (false),
67 fRelativeLightpointDirection (
G4Vector3D (1., 1., 1.)),
68 fActualLightpointDirection (
G4Vector3D (1., 1., 1.)),
69 fDefaultVisAttributes (),
70 fDefaultTextVisAttributes (
G4Colour (0., 0., 1.)),
72 fGlobalMarkerScale (1.),
73 fGlobalLineWidthScale (1.),
74 fMarkerNotHidden (true),
75 fWindowSizeHintX (600),
76 fWindowSizeHintY (600),
77 fWindowLocationHintX(0),
78 fWindowLocationHintY(0),
79 fWindowLocationHintXNegative(true),
80 fWindowLocationHintYNegative(false),
83 fBackgroundColour (
G4Colour(0.,0.,0.)),
85 fRotationStyle (constrainUpDirection),
89 fDisplayHeadTime(false),
90 fDisplayHeadTimeX(-0.9),
91 fDisplayHeadTimeY(-0.9),
92 fDisplayHeadTimeSize(24.),
93 fDisplayHeadTimeRed(0.),
94 fDisplayHeadTimeGreen(1.),
95 fDisplayHeadTimeBlue(1.),
96 fDisplayLightFront(false),
97 fDisplayLightFrontX(0.),
98 fDisplayLightFrontY(0.),
99 fDisplayLightFrontZ(0.),
100 fDisplayLightFrontT(0.),
101 fDisplayLightFrontRed(0.),
102 fDisplayLightFrontGreen(1.),
103 fDisplayLightFrontBlue(0.)
122 fScaleFactor.
setX(fScaleFactor.
x() * scaleFactorMultiplier.
x());
123 fScaleFactor.
setY(fScaleFactor.
y() * scaleFactorMultiplier.
y());
124 fScaleFactor.
setZ(fScaleFactor.
z() * scaleFactorMultiplier.
z());
129 return fActualLightpointDirection;
142 if (fFieldHalfAngle == 0.) {
143 cameraDistance = radius;
146 cameraDistance = radius / std::sin (fFieldHalfAngle) - fDolly;
148 return cameraDistance;
153 const G4double small = 1.e-6 * radius;
154 G4double nearDistance = cameraDistance - radius;
155 if (nearDistance < small) nearDistance = small;
162 G4double farDistance = cameraDistance + radius;
163 if (farDistance < nearDistance) farDistance = nearDistance;
170 if (fFieldHalfAngle == 0.) {
171 frontHalfHeight = radius / fZoomFactor;
174 frontHalfHeight = nearDistance * std::tan (fFieldHalfAngle) / fZoomFactor;
176 return frontHalfHeight;
181 if (fCutawayPlanes.size () < 3 ) {
182 fCutawayPlanes.push_back (cutawayPlane);
186 "ERROR: G4ViewParameters::AddCutawayPlane:"
187 "\n A maximum of 3 cutaway planes supported." <<
G4endl;
192(
size_t index,
const G4Plane3D& cutawayPlane) {
193 if (index >= fCutawayPlanes.size()) {
195 "ERROR: G4ViewParameters::ChangeCutawayPlane:"
196 "\n Plane " << index <<
" does not exist." <<
G4endl;
198 fCutawayPlanes[index] = cutawayPlane;
203 const G4double reasonableMaximum = 10.0 * g / cm3;
204 if (visibleDensity < 0) {
205 G4cout <<
"G4ViewParameters::SetVisibleDensity: attempt to set negative "
206 "density - ignored." <<
G4endl;
209 if (visibleDensity > reasonableMaximum) {
210 G4cout <<
"G4ViewParameters::SetVisibleDensity: density > "
211 <<
G4BestUnit (reasonableMaximum,
"Volumic Mass")
212 <<
" - did you mean this?"
215 fVisibleDensity = visibleDensity;
221 if (nSides < nSidesMin) {
223 G4cout <<
"G4ViewParameters::SetNoOfSides: attempt to set the"
224 "\nnumber of sides per circle < " << nSidesMin
225 <<
"; forced to " << nSides <<
G4endl;
232 const G4int nPointsMin = 100;
233 if (nPoints < nPointsMin) {
234 nPoints = nPointsMin;
235 G4cout <<
"G4ViewParameters::SetNumberOfCloudPoints:"
236 "\nnumber of points per cloud set to minimum " << nPoints
239 fNumberOfCloudPoints = nPoints;
240 return fNumberOfCloudPoints;
246 fViewpointDirection = viewpointDirection;
250 if (fViewpointDirection.
unit() * fUpVector.
unit() > .9999) {
251 static G4bool firstTime =
true;
255 "WARNING: Viewpoint direction is very close to the up vector direction."
256 "\n Change the up vector or \"/vis/viewer/set/rotationStyle freeRotation\"."
262 if (fLightsMoveWithCamera) {
266 fActualLightpointDirection =
267 fRelativeLightpointDirection.
x () * xprime +
268 fRelativeLightpointDirection.
y () * yprime +
269 fRelativeLightpointDirection.
x () * zprime;
271 fActualLightpointDirection = fRelativeLightpointDirection;
277 fRelativeLightpointDirection = lightpointDirection;
284 fCurrentTargetPoint = right * unitRight + up * unitUp;
294 fCurrentTargetPoint += right * unitRight + up * unitUp + distance * fViewpointDirection;
300 G4bool duplicateTarget =
false;
301 auto i = fVisAttributesModifiers.begin();
302 for (; i < fVisAttributesModifiers.end(); ++i) {
305 duplicateTarget =
true;
310 else fVisAttributesModifiers.push_back(vam);
314(
const G4Point3D standardTargetPoint)
const
316 std::ostringstream oss;
318 oss <<
"#\n# Camera and lights commands";
320 oss <<
"\n/vis/viewer/set/viewpointVector "
321 << fViewpointDirection.
x()
322 <<
' ' << fViewpointDirection.
y()
323 <<
' ' << fViewpointDirection.
z();
325 oss <<
"\n/vis/viewer/set/upVector "
327 <<
' ' << fUpVector.
y()
328 <<
' ' << fUpVector.
z();
330 oss <<
"\n/vis/viewer/set/projection ";
331 if (fFieldHalfAngle == 0.) {
337 << fFieldHalfAngle/deg
341 oss <<
"\n/vis/viewer/zoomTo "
344 oss <<
"\n/vis/viewer/scaleTo "
346 <<
' ' << fScaleFactor.
y()
347 <<
' ' << fScaleFactor.
z();
349 oss <<
"\n/vis/viewer/set/targetPoint "
350 <<
G4BestUnit(standardTargetPoint+fCurrentTargetPoint,
"Length")
351 <<
"\n# Note that if you have not set a target point, the vis system sets"
352 <<
"\n# a target point based on the scene - plus any panning and dollying -"
353 <<
"\n# so don't be alarmed by strange coordinates here.";
355 oss <<
"\n/vis/viewer/dollyTo "
358 oss <<
"\n/vis/viewer/set/lightsMove ";
359 if (fLightsMoveWithCamera) {
365 oss <<
"\n/vis/viewer/set/lightsVector "
366 << fRelativeLightpointDirection.
x()
367 <<
' ' << fRelativeLightpointDirection.
y()
368 <<
' ' << fRelativeLightpointDirection.
z();
370 oss <<
"\n/vis/viewer/set/rotationStyle ";
372 oss <<
"constrainUpDirection";
374 oss <<
"freeRotation";
378 oss <<
"\n/vis/viewer/set/background "
385 oss <<
"\n/vis/viewer/set/defaultColour "
391 c = fDefaultTextVisAttributes.
GetColour();
392 oss <<
"\n/vis/viewer/set/defaultTextColour "
405 std::ostringstream oss;
407 oss <<
"#\n# Drawing style commands";
409 oss <<
"\n/vis/viewer/set/style ";
410 switch (fDrawingStyle) {
424 oss <<
"\n/vis/viewer/set/hiddenEdge ";
425 if (fDrawingStyle ==
hlr || fDrawingStyle ==
hlhsr) {
431 oss <<
"\n/vis/viewer/set/auxiliaryEdge ";
432 if (fAuxEdgeVisible) {
438 oss <<
"\n/vis/viewer/set/hiddenMarker ";
439 if (fMarkerNotHidden) {
445 oss <<
"\n/vis/viewer/set/globalLineWidthScale "
446 << fGlobalLineWidthScale;
448 oss <<
"\n/vis/viewer/set/globalMarkerScale "
449 << fGlobalMarkerScale;
451 oss <<
"\n/vis/viewer/set/numberOfCloudPoints "
452 << fNumberOfCloudPoints;
461 std::ostringstream oss;
463 oss <<
"#\n# Scene-modifying commands";
465 oss <<
"\n/vis/viewer/set/culling global ";
472 oss <<
"\n/vis/viewer/set/culling invisible ";
473 if (fCullInvisible) {
479 oss <<
"\n/vis/viewer/set/culling density ";
480 if (fDensityCulling) {
481 oss <<
"true " << fVisibleDensity/(g/cm3) <<
" g/cm3";
486 oss <<
"\n/vis/viewer/set/culling coveredDaughters ";
493 oss <<
"\n/vis/viewer/colourByDensity "
494 << fCBDAlgorithmNumber <<
" g/cm3";
495 for (
auto p: fCBDParameters) {
496 oss <<
' ' << p/(g/cm3);
499 oss <<
"\n/vis/viewer/set/sectionPlane ";
503 << fSectionPlane.
normal().x()
504 <<
' ' << fSectionPlane.
normal().y()
505 <<
' ' << fSectionPlane.
normal().z();
510 oss <<
"\n/vis/viewer/set/cutawayMode ";
514 oss <<
"intersection";
517 oss <<
"\n/vis/viewer/clearCutawayPlanes";
518 if (fCutawayPlanes.size()) {
519 for (
size_t i = 0; i < fCutawayPlanes.size(); i++) {
520 oss <<
"\n/vis/viewer/addCutawayPlane "
521 <<
G4BestUnit(fCutawayPlanes[i].point(),
"Length")
522 << fCutawayPlanes[i].normal().x()
523 <<
' ' << fCutawayPlanes[i].normal().y()
524 <<
' ' << fCutawayPlanes[i].normal().z();
527 oss <<
"\n# No cutaway planes defined.";
530 oss <<
"\n/vis/viewer/set/explodeFactor "
532 <<
' ' <<
G4BestUnit(fExplodeCentre,
"Length");
534 oss <<
"\n/vis/viewer/set/lineSegmentsPerCircle "
544 std::ostringstream oss;
546 oss <<
"#\n# Touchable commands";
548 const std::vector<G4ModelingParameters::VisAttributesModifier>& vams =
549 fVisAttributesModifiers;
554 <<
"\n/vis/viewer/clearVisAttributesModifiers";
560 <<
"\n/vis/viewer/clearVisAttributesModifiers";
563 std::vector<G4ModelingParameters::VisAttributesModifier>::const_iterator
565 for (iModifier = vams.begin();
566 iModifier != vams.end();
569 iModifier->GetPVNameCopyNoPath();
570 if (vamPath != lastPath) {
572 oss <<
"\n/vis/set/touchable";
574 for (iVAM = vamPath.begin();
575 iVAM != vamPath.end();
577 oss <<
' ' << iVAM->GetName() <<
' ' << iVAM->GetCopyNo();
582 switch (iModifier->GetVisAttributesSignifier()) {
584 oss <<
"\n/vis/touchable/set/visibility ";
592 oss <<
"\n/vis/touchable/set/daughtersInvisible ";
600 oss <<
"\n/vis/touchable/set/colour "
607 oss <<
"\n/vis/touchable/set/lineStyle ";
620 oss <<
"\n/vis/touchable/set/lineWidth "
626 oss <<
"\n/vis/touchable/set/forceWireframe ";
638 oss <<
"\n/vis/touchable/set/forceSolid ";
650 oss <<
"\n/vis/touchable/set/forceCloud ";
661 oss <<
"\n/vis/touchable/set/forceAuxEdgeVisible ";
670 oss <<
"\n/vis/touchable/set/lineSegmentsPerCircle "
674 oss <<
"\n/vis/touchable/set/numberOfCloudPoints "
687 std::ostringstream oss;
689 oss <<
"#\n# Time window commands";
692 <<
"\n/vis/viewer/set/timeWindow/startTime "
693 << fStartTime/
ns <<
" ns ";
696 <<
"\n/vis/viewer/set/timeWindow/endTime "
697 << fEndTime/
ns <<
" ns ";
699 oss <<
"\n/vis/viewer/set/timeWindow/fadeFactor "
703 <<
"\n/vis/viewer/set/timeWindow/displayHeadTime ";
704 if (!fDisplayHeadTime) {
709 <<
' ' << fDisplayHeadTimeX
710 <<
' ' << fDisplayHeadTimeY
711 <<
' ' << fDisplayHeadTimeSize
712 <<
' ' << fDisplayHeadTimeRed
713 <<
' ' << fDisplayHeadTimeGreen
714 <<
' ' << fDisplayHeadTimeBlue;
718 <<
"\n/vis/viewer/set/timeWindow/displayLightFront ";
719 if (!fDisplayLightFront) {
724 <<
' ' << fDisplayLightFrontX/mm
725 <<
' ' << fDisplayLightFrontY/mm
726 <<
' ' << fDisplayLightFrontZ/mm
728 <<
' ' << fDisplayLightFrontT/
ns
730 <<
' ' << fDisplayLightFrontRed
731 <<
' ' << fDisplayLightFrontGreen
732 <<
' ' << fDisplayLightFrontBlue;
745 (fViewpointDirection != v.fViewpointDirection) ||
748 (fDrawingStyle != v.fDrawingStyle) ||
749 (fNumberOfCloudPoints != v.fNumberOfCloudPoints) ||
750 (fAuxEdgeVisible != v.fAuxEdgeVisible) ||
751 (fCulling != v.fCulling) ||
752 (fCullInvisible != v.fCullInvisible) ||
753 (fDensityCulling != v.fDensityCulling) ||
754 (fVisibleDensity != v.fVisibleDensity) ||
755 (fCullCovered != v.fCullCovered) ||
756 (fCBDAlgorithmNumber != v.fCBDAlgorithmNumber) ||
757 (fSection != v.fSection) ||
758 (fNoOfSides != v.fNoOfSides) ||
759 (fUpVector != v.fUpVector) ||
760 (fFieldHalfAngle != v.fFieldHalfAngle) ||
761 (fZoomFactor != v.fZoomFactor) ||
762 (fScaleFactor != v.fScaleFactor) ||
763 (fCurrentTargetPoint != v.fCurrentTargetPoint) ||
764 (fDolly != v.fDolly) ||
765 (fRelativeLightpointDirection != v.fRelativeLightpointDirection) ||
766 (fLightsMoveWithCamera != v.fLightsMoveWithCamera) ||
767 (fDefaultVisAttributes != v.fDefaultVisAttributes) ||
768 (fDefaultTextVisAttributes != v.fDefaultTextVisAttributes) ||
769 (fDefaultMarker != v.fDefaultMarker) ||
770 (fGlobalMarkerScale != v.fGlobalMarkerScale) ||
771 (fGlobalLineWidthScale != v.fGlobalLineWidthScale) ||
772 (fMarkerNotHidden != v.fMarkerNotHidden) ||
773 (fWindowSizeHintX != v.fWindowSizeHintX) ||
774 (fWindowSizeHintY != v.fWindowSizeHintY) ||
775 (fXGeometryString != v.fXGeometryString) ||
776 (fGeometryMask != v.fGeometryMask) ||
777 (fAutoRefresh != v.fAutoRefresh) ||
778 (fBackgroundColour != v.fBackgroundColour) ||
779 (fPicking != v.fPicking) ||
780 (fRotationStyle != v.fRotationStyle)
784 if (fCBDAlgorithmNumber > 0) {
785 if (fCBDParameters.size() != v.fCBDParameters.size()) {
786 G4cout <<
"Difference in number of colour by density parameters." <<
G4endl;
787 }
else if (fCBDParameters != v.fCBDParameters) {
788 G4cout <<
"Difference in values of colour by density parameters." <<
G4endl;
793 if (!(fSectionPlane == v.fSectionPlane))
794 G4cout <<
"Difference in section planes batch." <<
G4endl;
798 if (fCutawayPlanes.size () != v.fCutawayPlanes.size ()) {
799 G4cout <<
"Difference in no of cutaway planes." <<
G4endl;
802 for (
size_t i = 0; i < fCutawayPlanes.size (); i++) {
803 if (!(fCutawayPlanes[i] == v.fCutawayPlanes[i]))
804 G4cout <<
"Difference in cutaway plane no. " << i <<
G4endl;
810 if (fExplodeFactor != v.fExplodeFactor)
812 if (fExplodeCentre != v.fExplodeCentre)
816 if (fVisAttributesModifiers != v.fVisAttributesModifiers) {
817 G4cout <<
"Difference in vis attributes modifiers." <<
G4endl;
820 if (fStartTime != v.fStartTime ||
821 fEndTime != v.fEndTime) {
825 if (fFadeFactor != v.fFadeFactor) {
826 G4cout <<
"Difference in time window fade factor." <<
G4endl;
829 if (fDisplayHeadTime != v.fDisplayHeadTime) {
830 G4cout <<
"Difference in display head time flag." <<
G4endl;
832 if (fDisplayHeadTimeX != v.fDisplayHeadTimeX ||
833 fDisplayHeadTimeY != v.fDisplayHeadTimeY ||
834 fDisplayHeadTimeSize != v.fDisplayHeadTimeSize ||
835 fDisplayHeadTimeRed != v.fDisplayHeadTimeRed ||
836 fDisplayHeadTimeGreen != v.fDisplayHeadTimeGreen ||
837 fDisplayHeadTimeBlue != v.fDisplayHeadTimeBlue) {
838 G4cout <<
"Difference in display head time parameters." <<
G4endl;
842 if (fDisplayLightFront != v.fDisplayLightFront) {
843 G4cout <<
"Difference in display light front flag." <<
G4endl;
845 if (fDisplayLightFrontX != v.fDisplayLightFrontX ||
846 fDisplayLightFrontY != v.fDisplayLightFrontY ||
847 fDisplayLightFrontZ != v.fDisplayLightFrontZ ||
848 fDisplayLightFrontT != v.fDisplayLightFrontT ||
849 fDisplayLightFrontRed != v.fDisplayLightFrontRed ||
850 fDisplayLightFrontGreen != v.fDisplayLightFrontGreen ||
851 fDisplayLightFrontBlue != v.fDisplayLightFrontBlue) {
852 G4cout <<
"Difference in display light front parameters." <<
G4endl;
857std::ostream&
operator <<
862 os <<
"wireframe";
break;
864 os <<
"hlr - hidden lines removed";
break;
866 os <<
"hsr - hidden surfaces removed";
break;
868 os <<
"hlhsr - hidden line, hidden surface removed";
break;
870 os <<
"cloud - draw volume as a cloud of dots";
break;
871 default: os <<
"unrecognised";
break;
877 os <<
"View parameters and options:";
879 os <<
"\n Drawing style: " << v.fDrawingStyle;
881 os <<
"\n Number of cloud points: " << v.fNumberOfCloudPoints;
883 os <<
"\n Auxiliary edges: ";
884 if (!v.fAuxEdgeVisible) os <<
"in";
887 os <<
"\n Culling: ";
888 if (v.fCulling) os <<
"on";
891 os <<
"\n Culling invisible objects: ";
892 if (v.fCullInvisible) os <<
"on";
895 os <<
"\n Density culling: ";
896 if (v.fDensityCulling) {
897 os <<
"on - invisible if density less than "
898 << v.fVisibleDensity / (1. * g / cm3) <<
" g cm^-3";
902 os <<
"\n Culling daughters covered by opaque mothers: ";
903 if (v.fCullCovered) os <<
"on";
906 os <<
"\n Colour by density: ";
907 if (v.fCBDAlgorithmNumber <= 0) {
910 os <<
"Algorithm " << v.fCBDAlgorithmNumber <<
", Parameters:";
911 for (
auto p: v.fCBDParameters) {
916 os <<
"\n Section flag: ";
917 if (v.fSection) os <<
"true, section/cut plane: " << v.fSectionPlane;
921 os <<
"\n Cutaway planes: ";
922 for (
size_t i = 0; i < v.fCutawayPlanes.size (); i++) {
923 os <<
' ' << v.fCutawayPlanes[i];
927 os <<
"\n No cutaway planes";
930 os <<
"\n Explode factor: " << v.fExplodeFactor
931 <<
" about centre: " << v.fExplodeCentre;
933 os <<
"\n No. of sides used in circle polygon approximation: "
936 os <<
"\n Viewpoint direction: " << v.fViewpointDirection;
938 os <<
"\n Up vector: " << v.fUpVector;
940 os <<
"\n Field half angle: " << v.fFieldHalfAngle;
942 os <<
"\n Zoom factor: " << v.fZoomFactor;
944 os <<
"\n Scale factor: " << v.fScaleFactor;
946 os <<
"\n Current target point: " << v.fCurrentTargetPoint;
948 os <<
"\n Dolly distance: " << v.fDolly;
951 if (v.fLightsMoveWithCamera) os <<
"moves";
952 else os <<
"does not move";
953 os <<
" with camera";
955 os <<
"\n Relative lightpoint direction: "
956 << v.fRelativeLightpointDirection;
958 os <<
"\n Actual lightpoint direction: "
959 << v.fActualLightpointDirection;
961 os <<
"\n Derived parameters for standard view of object of unit radius:";
964 tempVP.fZoomFactor = 1.;
972 os <<
"\n Camera distance: " << cameraDistance;
973 os <<
"\n Near distance: " << nearDistance;
974 os <<
"\n Far distance: " << farDistance;
975 os <<
"\n Front half height: " << right;
977 os <<
"\n Default VisAttributes:\n " << v.fDefaultVisAttributes;
979 os <<
"\n Default TextVisAttributes:\n " << v.fDefaultTextVisAttributes;
981 os <<
"\n Default marker: " << v.fDefaultMarker;
983 os <<
"\n Global marker scale: " << v.fGlobalMarkerScale;
985 os <<
"\n Global lineWidth scale: " << v.fGlobalLineWidthScale;
988 if (v.fMarkerNotHidden) os <<
"not ";
989 os <<
"hidden by surfaces.";
991 os <<
"\n Window size hint: "
992 << v.fWindowSizeHintX <<
'x'<< v.fWindowSizeHintX;
994 os <<
"\n X geometry string: " << v.fXGeometryString;
995 os <<
"\n X geometry mask: "
996 << std::showbase << std::hex << v.fGeometryMask
997 << std::noshowbase << std::dec;
999 os <<
"\n Auto refresh: ";
1000 if (v.fAutoRefresh) os <<
"true";
1003 os <<
"\n Background colour: " << v.fBackgroundColour;
1005 os <<
"\n Picking requested: ";
1006 if (v.fPicking) os <<
"true";
1009 os <<
"\n Rotation style: ";
1010 switch (v.fRotationStyle) {
1012 os <<
"constrainUpDirection (conventional HEP view)";
break;
1014 os <<
"freeRotation (Google-like rotation, using mouse-grab)";
break;
1015 default: os <<
"unrecognised";
break;
1018 os <<
"\n Vis attributes modifiers: ";
1019 const std::vector<G4ModelingParameters::VisAttributesModifier>& vams =
1020 v.fVisAttributesModifiers;
1027 os <<
"\n Time window parameters:"
1028 <<
"\n Start time: " << v.fStartTime/
ns <<
" ns"
1029 <<
"\n End time: " << v.fEndTime/
ns <<
" ns"
1030 <<
"\n Fade factor: " << v.fFadeFactor;
1031 if (!v.fDisplayHeadTime) {
1032 os <<
"\n Head time display not requested.";
1035 <<
"\n Head time position: "
1036 << v.fDisplayHeadTimeX <<
' ' << v.fDisplayHeadTimeY
1037 <<
"\n Head time size: " << v.fDisplayHeadTimeSize
1038 <<
"\n Head time colour: " << v.fDisplayHeadTimeRed
1039 <<
' ' << v.fDisplayHeadTimeGreen <<
' ' << v.fDisplayHeadTimeBlue;
1041 if (!v.fDisplayLightFront) {
1042 os <<
"\n Light front display not requested.";
1045 <<
"\n Light front position: "
1046 << v.fDisplayLightFrontX/mm <<
' ' << v.fDisplayLightFrontY/mm
1047 <<
' ' << v.fDisplayLightFrontZ/mm <<
" mm"
1048 <<
"\n Light front time: " << v.fDisplayLightFrontT/
ns <<
" ns"
1049 <<
"\n Light front colour: " << v.fDisplayLightFrontRed
1050 <<
' ' << v.fDisplayLightFrontGreen <<
' ' << v.fDisplayLightFrontBlue;
1061 (fViewpointDirection != v.fViewpointDirection) ||
1064 (fDrawingStyle != v.fDrawingStyle) ||
1065 (fNumberOfCloudPoints != v.fNumberOfCloudPoints) ||
1066 (fAuxEdgeVisible != v.fAuxEdgeVisible) ||
1067 (fCulling != v.fCulling) ||
1068 (fCullInvisible != v.fCullInvisible) ||
1069 (fDensityCulling != v.fDensityCulling) ||
1070 (fCullCovered != v.fCullCovered) ||
1071 (fCBDAlgorithmNumber != v.fCBDAlgorithmNumber) ||
1072 (fSection != v.fSection) ||
1075 (fNoOfSides != v.fNoOfSides) ||
1076 (fUpVector != v.fUpVector) ||
1077 (fFieldHalfAngle != v.fFieldHalfAngle) ||
1078 (fZoomFactor != v.fZoomFactor) ||
1079 (fScaleFactor != v.fScaleFactor) ||
1080 (fCurrentTargetPoint != v.fCurrentTargetPoint) ||
1081 (fDolly != v.fDolly) ||
1082 (fRelativeLightpointDirection != v.fRelativeLightpointDirection) ||
1083 (fLightsMoveWithCamera != v.fLightsMoveWithCamera) ||
1084 (fDefaultVisAttributes != v.fDefaultVisAttributes) ||
1085 (fDefaultTextVisAttributes != v.fDefaultTextVisAttributes) ||
1086 (fDefaultMarker != v.fDefaultMarker) ||
1087 (fGlobalMarkerScale != v.fGlobalMarkerScale) ||
1088 (fGlobalLineWidthScale != v.fGlobalLineWidthScale) ||
1089 (fMarkerNotHidden != v.fMarkerNotHidden) ||
1090 (fWindowSizeHintX != v.fWindowSizeHintX) ||
1091 (fWindowSizeHintY != v.fWindowSizeHintY) ||
1092 (fXGeometryString != v.fXGeometryString) ||
1093 (fGeometryMask != v.fGeometryMask) ||
1094 (fAutoRefresh != v.fAutoRefresh) ||
1095 (fBackgroundColour != v.fBackgroundColour) ||
1096 (fPicking != v.fPicking) ||
1097 (fRotationStyle != v.fRotationStyle)
1101 if (fDensityCulling &&
1102 (fVisibleDensity != v.fVisibleDensity))
return true;
1104 if (fCBDAlgorithmNumber > 0) {
1105 if (fCBDParameters.size() != v.fCBDParameters.size())
return true;
1106 else if (fCBDParameters != v.fCBDParameters)
return true;
1110 (!(fSectionPlane == v.fSectionPlane)))
return true;
1113 if (fCutawayPlanes.size () != v.fCutawayPlanes.size ())
1116 for (
size_t i = 0; i < fCutawayPlanes.size (); i++) {
1117 if (!(fCutawayPlanes[i] == v.fCutawayPlanes[i]))
return true;
1123 ((fExplodeFactor != v.fExplodeFactor) ||
1124 (fExplodeCentre != v.fExplodeCentre)))
return true;
1126 if (fVisAttributesModifiers != v.fVisAttributesModifiers)
return true;
1128 if (fStartTime != v.fStartTime ||
1129 fEndTime != v.fEndTime ||
1130 fFadeFactor != v.fFadeFactor)
return true;
1132 if (fDisplayHeadTime != v.fDisplayHeadTime)
return true;
1133 if (fDisplayHeadTime) {
1134 if (fDisplayHeadTimeX != v.fDisplayHeadTimeX ||
1135 fDisplayHeadTimeY != v.fDisplayHeadTimeY ||
1136 fDisplayHeadTimeSize != v.fDisplayHeadTimeSize ||
1137 fDisplayHeadTimeRed != v.fDisplayHeadTimeRed ||
1138 fDisplayHeadTimeGreen != v.fDisplayHeadTimeGreen ||
1139 fDisplayHeadTimeBlue != v.fDisplayHeadTimeBlue) {
1144 if (fDisplayLightFront != v.fDisplayLightFront)
return true;
1145 if (fDisplayLightFront) {
1146 if (fDisplayLightFrontX != v.fDisplayLightFrontX ||
1147 fDisplayLightFrontY != v.fDisplayLightFrontY ||
1148 fDisplayLightFrontZ != v.fDisplayLightFrontZ ||
1149 fDisplayLightFrontT != v.fDisplayLightFrontT ||
1150 fDisplayLightFrontRed != v.fDisplayLightFrontRed ||
1151 fDisplayLightFrontGreen != v.fDisplayLightFrontGreen ||
1152 fDisplayLightFrontBlue != v.fDisplayLightFrontBlue) {
1163 unsigned int w = 0, h = 0;
1164 G4String geomString = geomStringArg;
1167 G4String::size_type i = geomString.find_first_of(delimiters);
1168 if (i == G4String::npos) {
1169 std::istringstream iss(geomString);
1174 G4cout <<
"Unrecognised windowSizeHint string: \""
1176 <<
"\". Asuuming " << size <<
G4endl;
1178 std::ostringstream oss;
1179 oss << size <<
'x' << size;
1180 geomString = oss.str();
1183 fGeometryMask = ParseGeometry( geomString, &x, &y, &w, &h );
1186 if ((fGeometryMask & fYValue) == 0)
1188 y = fWindowLocationHintY;
1190 if ((fGeometryMask & fXValue) == 0)
1192 x = fWindowLocationHintX;
1197 if ( ((fGeometryMask & fHeightValue) == 0 ) &&
1198 ((fGeometryMask & fWidthValue) == 0 )) {
1199 h = fWindowSizeHintY;
1200 w = fWindowSizeHintX;
1201 }
else if ((fGeometryMask & fHeightValue) == 0 ) {
1206 G4cout <<
"Unrecognised geometry string \""
1208 <<
"\". No Height found. Using Width value instead"
1212 if ( ((fGeometryMask & fXValue) == 0 ) ||
1213 ((fGeometryMask & fYValue) == 0 )) {
1215 x = fWindowLocationHintX;
1216 y = fWindowLocationHintY;
1219 fXGeometryString = geomString;
1222 fWindowSizeHintX = w;
1223 fWindowSizeHintY = h;
1224 fWindowLocationHintX = x;
1225 fWindowLocationHintY = y;
1227 if ( ((fGeometryMask & fXValue)) &&
1228 ((fGeometryMask & fYValue))) {
1230 if ( (fGeometryMask & fXNegative) ) {
1231 fWindowLocationHintXNegative =
true;
1233 fWindowLocationHintXNegative =
false;
1235 if ( (fGeometryMask & fYNegative) ) {
1236 fWindowLocationHintYNegative =
true;
1238 fWindowLocationHintYNegative =
false;
1244 if ( fWindowLocationHintXNegative ) {
1245 return sizeX + fWindowLocationHintX - fWindowSizeHintX;
1247 return fWindowLocationHintX;
1251 if ( fWindowLocationHintYNegative ) {
1252 return sizeY + fWindowLocationHintY - fWindowSizeHintY;
1254 return fWindowLocationHintY;
1271int G4ViewParameters::ParseGeometry (
1275 unsigned int *width,
1276 unsigned int *height)
1279 G4int mask = fNoValue;
1281 unsigned int tempWidth = 0;
1282 unsigned int tempHeight = 0;
1285 char *nextCharacter;
1286 if ( (
string == NULL) || (*
string ==
'\0')) {
1291 strind = (
char *)
string;
1292 if (*strind !=
'+' && *strind !=
'-' && *strind !=
'x') {
1293 tempWidth = ReadInteger(strind, &nextCharacter);
1294 if (strind == nextCharacter)
1296 strind = nextCharacter;
1297 mask |= fWidthValue;
1299 if (*strind ==
'x' || *strind ==
'X') {
1301 tempHeight = ReadInteger(strind, &nextCharacter);
1302 if (strind == nextCharacter)
1304 strind = nextCharacter;
1305 mask |= fHeightValue;
1308 if ((*strind ==
'+') || (*strind ==
'-')) {
1309 if (*strind ==
'-') {
1311 tempX = -ReadInteger(strind, &nextCharacter);
1312 if (strind == nextCharacter)
1314 strind = nextCharacter;
1320 tempX = ReadInteger(strind, &nextCharacter);
1321 if (strind == nextCharacter)
1323 strind = nextCharacter;
1326 if ((*strind ==
'+') || (*strind ==
'-')) {
1327 if (*strind ==
'-') {
1329 tempY = -ReadInteger(strind, &nextCharacter);
1330 if (strind == nextCharacter)
1332 strind = nextCharacter;
1338 tempY = ReadInteger(strind, &nextCharacter);
1339 if (strind == nextCharacter)
1341 strind = nextCharacter;
1348 if (*strind !=
'\0')
return (0);
1353 if (mask & fWidthValue)
1355 if (mask & fHeightValue)
1356 *height = tempHeight;
1364G4int G4ViewParameters::ReadInteger(
char *
string,
char **NextString)
1371 else if (*
string ==
'-')
1376 for (; (*
string >=
'0') && (*
string <=
'9');
string++)
1378 Result = (Result * 10) + (*
string -
'0');
1380 *NextString = string;
1388(
const std::vector<G4ViewParameters>& views,
1389 G4int nInterpolationPoints)
1403 if (views.size() < 2) {
1405 (
"G4ViewParameters::CatmullRomCubicSplineInterpolation",
1407 "There must be at least two views.");
1411 if (nInterpolationPoints < 1) {
1413 (
"G4ViewParameters::CatmullRomCubicSplineInterpolation",
1415 "Number of interpolation points cannot be zero or negative.");
1419 const size_t nIntervals = views.size() - 1;
1420 const G4double dt = 1./nInterpolationPoints;
1424 static G4int iInterpolationPoint = 0;
1425 static size_t iInterval = 0;
1430 const G4double h00 = 2.*t*t*t - 3.*t*t +1;
1431 const G4double h10 = t*t*t -2.*t*t + t;
1432 const G4double h01 = -2.*t*t*t + 3.*t*t;
1436 const size_t& n = nIntervals;
1437 size_t& i = iInterval;
1438 const std::vector<G4ViewParameters>& v = views;
1455 holdingValues = t < 0.5? v[i]: v[i+1];
1458#define INTERPOLATE(param) \
1463mi = v[1].param - v[0].param; \
1466if (n == 1) mi1 = mi; \
1468else mi1 = 0.5 * (v[2].param - v[0].param); \
1469} else if (i >= n - 1) { \
1471mi1 = v[i+1].param - v[i].param; \
1473if (n == 1) mi = mi1; \
1475else mi = 0.5 * (v[i+1].param - v[i-1].param); \
1478mi = 0.5 * (v[i+1].param - v[i-1].param); \
1479mi1 = 0.5 * (v[i+2].param - v[i ].param); \
1481real = h00 * v[i].param + h10 * mi + h01 * v[i+1].param + h11 * mi1;
1483#define INTERPOLATELOG(param) \
1485mi = std::log(v[1].param) - std::log(v[0].param); \
1486if (n == 1) mi1 = mi; \
1487else mi1 = 0.5 * (std::log(v[2].param) - std::log(v[0].param)); \
1488} else if (i >= n - 1) { \
1489mi1 = std::log(v[i+1].param) - std::log(v[i].param); \
1490if (n == 1) mi = mi1; \
1491else mi = 0.5 * (std::log(v[i+1].param) - std::log(v[i-1].param)); \
1493mi = 0.5 * (std::log(v[i+1].param) - std::log(v[i-1].param)); \
1494mi1 = 0.5 * (std::log(v[i+2].param) - std::log(v[i ].param)); \
1496real = std::exp(h00 * std::log(v[i].param) + h10 * mi + h01 * std::log(v[i+1].param) + h11 * mi1);
1500 if (real < 0.) real = 0.;
1501 holdingValues.fVisibleDensity = real;
1503 holdingValues.fExplodeFactor = real;
1505 if (real < 0.) real = 0.;
1506 holdingValues.fFieldHalfAngle = real;
1508 holdingValues.fZoomFactor = real;
1510 holdingValues.fDolly = real;
1512 if (real < 0.) real = 0.;
1513 holdingValues.fGlobalMarkerScale = real;
1515 if (real < 0.) real = 0.;
1516 holdingValues.fGlobalLineWidthScale = real;
1519#define INTERPOLATEUNITVECTOR(vector) \
1520INTERPOLATE(vector.x()); x = real; \
1521INTERPOLATE(vector.y()); y = real; \
1522INTERPOLATE(vector.z()); z = real;
1528 holdingValues.fRelativeLightpointDirection =
G4Vector3D(x,y,z).
unit();
1530 holdingValues.fActualLightpointDirection =
G4Vector3D(x,y,z).
unit();
1533#define INTERPOLATEVECTOR(vector) \
1534INTERPOLATE(vector.x()); x = real; \
1535INTERPOLATE(vector.y()); y = real; \
1536INTERPOLATE(vector.z()); z = real;
1538 holdingValues.fScaleFactor =
G4Vector3D(x,y,z);
1541#define INTERPOLATEPOINT(point) \
1542INTERPOLATE(point.x()); x = real; \
1543INTERPOLATE(point.y()); y = real; \
1544INTERPOLATE(point.z()); z = real;
1546 holdingValues.fExplodeCentre =
G4Point3D(x,y,z);
1548 holdingValues.fCurrentTargetPoint =
G4Point3D(x,y,z);
1552#define INTERPOLATECOLOUR(colour) \
1553INTERPOLATE(colour.GetRed()); red = real; \
1554INTERPOLATE(colour.GetGreen()); green = real; \
1555INTERPOLATE(colour.GetBlue()); blue = real; \
1556INTERPOLATE(colour.GetAlpha()); alpha = real;
1559 holdingValues.fBackgroundColour =
G4Colour(red,green,blue,alpha);
1563#define CONTINUITY(quantity) \
1564 continuous = false; \
1567 if (v[1].quantity == v[0].quantity) { \
1568 if (n == 1) continuous = true; \
1569 else if (v[2].quantity == v[0].quantity) \
1570 continuous = true; \
1572 } else if (i >= n - 1) { \
1573 if (v[i+1].quantity == v[i].quantity) { \
1574 if (n == 1) continuous = true; \
1575 else if (v[i+1].quantity == v[i-1].quantity) \
1576 continuous = true; \
1579 if (v[i-1].quantity == v[i].quantity && \
1580 v[i+1].quantity == v[i].quantity && \
1581 v[i+2].quantity == v[i].quantity) \
1582 continuous = true; \
1586#define INTERPOLATEPLANE(plane) \
1587INTERPOLATE(plane.a()); a = real; \
1588INTERPOLATE(plane.b()); b = real; \
1589INTERPOLATE(plane.c()); c = real; \
1590INTERPOLATE(plane.d()); d = real;
1596 holdingValues.fSectionPlane =
G4Plane3D(a,b,c,d);
1600 if (v[i].fCutawayPlanes.size()) {
1603 for (
size_t j = 0; j < v[i].fCutawayPlanes.size(); ++j) {
1605 holdingValues.fCutawayPlanes[j] =
G4Plane3D(a,b,c,d);
1614 if (v[i].fVisAttributesModifiers.size()) {
1617 for (
size_t j = 0; j < v[i].fVisAttributesModifiers.size(); ++j) {
1618 CONTINUITY(fVisAttributesModifiers[j].GetPVNameCopyNoPath());
1620 CONTINUITY(fVisAttributesModifiers[j].GetVisAttributesSignifier());
1622 if (v[i].fVisAttributesModifiers[j].GetVisAttributesSignifier() ==
1625 workingVA = v[i].fVisAttributesModifiers[j].GetVisAttributes();
1627 holdingValues.fVisAttributesModifiers[j].SetVisAttributes(workingVA);
1640 holdingValues.fStartTime = real;
1642 holdingValues.fEndTime = real;
1645 iInterpolationPoint++;
1647 if (iInterpolationPoint > nInterpolationPoints) {
1648 iInterpolationPoint = 1;
1652 if (iInterval >= nIntervals) {
1653 iInterpolationPoint = 0;
1659 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)
#define INTERPOLATEVECTOR(vector)
#define INTERPOLATE(param)
std::ostream & operator<<(std::ostream &os, const G4ViewParameters::DrawingStyle &style)
#define INTERPOLATEPLANE(plane)
#define CONTINUITY(quantity)
#define INTERPOLATEPOINT(point)
#define INTERPOLATEUNITVECTOR(vector)
#define INTERPOLATELOG(param)
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
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
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()