44 fDrawingStyle (wireframe),
45 fAuxEdgeVisible (false),
47 fCullInvisible (true),
48 fDensityCulling (false),
49 fVisibleDensity (0.01 *
g /
cm3),
53 fCutawayMode (cutawayUnion),
62 fCurrentTargetPoint (),
64 fLightsMoveWithCamera (false),
65 fRelativeLightpointDirection (
G4Vector3D (1., 1., 1.)),
66 fActualLightpointDirection (
G4Vector3D (1., 1., 1.)),
67 fDefaultVisAttributes (),
68 fDefaultTextVisAttributes (
G4Colour (0., 0., 1.)),
70 fGlobalMarkerScale (1.),
71 fGlobalLineWidthScale (1.),
72 fMarkerNotHidden (true),
73 fWindowSizeHintX (600),
74 fWindowSizeHintY (600),
75 fWindowLocationHintX(0),
76 fWindowLocationHintY(0),
77 fWindowLocationHintXNegative(true),
78 fWindowLocationHintYNegative(false),
81 fBackgroundColour (
G4Colour(0.,0.,0.)),
83 fRotationStyle (constrainUpDirection)
93 fScaleFactor.setX(fScaleFactor.x() * scaleFactorMultiplier.
x());
94 fScaleFactor.setY(fScaleFactor.y() * scaleFactorMultiplier.
y());
95 fScaleFactor.setZ(fScaleFactor.z() * scaleFactorMultiplier.
z());
100 return fActualLightpointDirection;
113 if (fFieldHalfAngle == 0.) {
114 cameraDistance = radius;
117 cameraDistance = radius / std::sin (fFieldHalfAngle) - fDolly;
119 return cameraDistance;
124 const G4double small = 1.e-6 * radius;
125 G4double nearDistance = cameraDistance - radius;
126 if (nearDistance < small) nearDistance = small;
133 G4double farDistance = cameraDistance + radius;
134 if (farDistance < nearDistance) farDistance = nearDistance;
141 if (fFieldHalfAngle == 0.) {
142 frontHalfHeight = radius / fZoomFactor;
145 frontHalfHeight = nearDistance * std::tan (fFieldHalfAngle) / fZoomFactor;
147 return frontHalfHeight;
152 if (fCutawayPlanes.size () < 3 ) {
153 fCutawayPlanes.push_back (cutawayPlane);
157 "ERROR: G4ViewParameters::AddCutawayPlane:"
158 "\n A maximum of 3 cutaway planes supported." <<
G4endl;
164 if (index >= fCutawayPlanes.size()) {
166 "ERROR: G4ViewParameters::ChangeCutawayPlane:"
167 "\n Plane " << index <<
" does not exist." <<
G4endl;
169 fCutawayPlanes[index] = cutawayPlane;
175 if (visibleDensity < 0) {
176 G4cout <<
"G4ViewParameters::SetVisibleDensity: attempt to set negative "
177 "density - ignored." <<
G4endl;
180 if (visibleDensity > reasonableMaximum) {
181 G4cout <<
"G4ViewParameters::SetVisibleDensity: density > "
182 <<
G4BestUnit (reasonableMaximum,
"Volumic Mass")
183 <<
" - did you mean this?"
186 fVisibleDensity = visibleDensity;
192 if (nSides < nSidesMin) {
194 G4cout <<
"G4ViewParameters::SetNoOfSides: attempt to set the"
195 "\nnumber of sides per circle < " << nSidesMin
196 <<
"; forced to " << nSides <<
G4endl;
205 fViewpointDirection = viewpointDirection;
209 if (fViewpointDirection.unit() * fUpVector.unit() > .9999) {
210 static G4bool firstTime =
true;
214 "WARNING: Viewpoint direction is very close to the up vector direction."
215 "\n Consider setting the up vector to obtain definable behaviour."
221 if (fLightsMoveWithCamera) {
223 G4Vector3D xprime = (fUpVector.cross (zprime)).unit ();
225 fActualLightpointDirection =
226 fRelativeLightpointDirection.
x () * xprime +
227 fRelativeLightpointDirection.
y () * yprime +
228 fRelativeLightpointDirection.
x () * zprime;
230 fActualLightpointDirection = fRelativeLightpointDirection;
236 fRelativeLightpointDirection = lightpointDirection;
237 SetViewAndLights (fViewpointDirection);
243 fCurrentTargetPoint = right * unitRight + up * unitUp;
253 fCurrentTargetPoint += right * unitRight + up * unitUp + distance * fViewpointDirection;
259 G4bool duplicateTarget =
false;
260 auto i = fVisAttributesModifiers.begin();
261 for (; i < fVisAttributesModifiers.end(); ++i) {
264 duplicateTarget =
true;
269 else fVisAttributesModifiers.push_back(vam);
275 std::ostringstream oss;
277 oss <<
"#\n# Camera and lights commands";
279 oss <<
"\n/vis/viewer/set/viewpointVector "
280 << fViewpointDirection.x()
281 <<
' ' << fViewpointDirection.y()
282 <<
' ' << fViewpointDirection.z();
284 oss <<
"\n/vis/viewer/set/upVector "
286 <<
' ' << fUpVector.y()
287 <<
' ' << fUpVector.z();
289 oss <<
"\n/vis/viewer/set/projection ";
290 if (fFieldHalfAngle == 0.) {
296 << fFieldHalfAngle/
deg
300 oss <<
"\n/vis/viewer/zoomTo "
303 oss <<
"\n/vis/viewer/scaleTo "
305 <<
' ' << fScaleFactor.y()
306 <<
' ' << fScaleFactor.z();
308 oss <<
"\n/vis/viewer/set/targetPoint "
309 <<
G4BestUnit(standardTargetPoint+fCurrentTargetPoint,
"Length")
310 <<
"\n# Note that if you have not set a target point, the vis system sets"
311 <<
"\n# a target point based on the scene - plus any panning and dollying -"
312 <<
"\n# so don't be alarmed by strange coordinates here.";
314 oss <<
"\n/vis/viewer/dollyTo "
317 oss <<
"\n/vis/viewer/set/lightsMove ";
318 if (fLightsMoveWithCamera) {
324 oss <<
"\n/vis/viewer/set/lightsVector "
325 << fRelativeLightpointDirection.x()
326 <<
' ' << fRelativeLightpointDirection.y()
327 <<
' ' << fRelativeLightpointDirection.z();
329 oss <<
"\n/vis/viewer/set/rotationStyle ";
330 if (fRotationStyle == constrainUpDirection) {
331 oss <<
"constrainUpDirection";
333 oss <<
"freeRotation";
337 oss <<
"\n/vis/viewer/set/background "
344 oss <<
"\n/vis/viewer/set/defaultColour "
350 c = fDefaultTextVisAttributes.
GetColour();
351 oss <<
"\n/vis/viewer/set/defaultTextColour "
364 std::ostringstream oss;
366 oss <<
"#\n# Drawing style commands";
368 oss <<
"\n/vis/viewer/set/style ";
369 if (fDrawingStyle ==
wireframe || fDrawingStyle ==
hlr) {
375 oss <<
"\n/vis/viewer/set/hiddenEdge ";
376 if (fDrawingStyle ==
hlr || fDrawingStyle ==
hlhsr) {
382 oss <<
"\n/vis/viewer/set/auxiliaryEdge ";
383 if (fAuxEdgeVisible) {
389 oss <<
"\n/vis/viewer/set/hiddenMarker ";
390 if (fMarkerNotHidden) {
396 oss <<
"\n/vis/viewer/set/globalLineWidthScale "
397 << fGlobalLineWidthScale;
399 oss <<
"\n/vis/viewer/set/globalMarkerScale "
400 << fGlobalMarkerScale;
409 std::ostringstream oss;
411 oss <<
"#\n# Scene-modifying commands";
413 oss <<
"\n/vis/viewer/set/culling global ";
420 oss <<
"\n/vis/viewer/set/culling invisible ";
421 if (fCullInvisible) {
427 oss <<
"\n/vis/viewer/set/culling density ";
428 if (fDensityCulling) {
429 oss <<
"true " << fVisibleDensity/(
g/
cm3) <<
" g/cm3";
434 oss <<
"\n/vis/viewer/set/culling coveredDaughters ";
441 oss <<
"\n/vis/viewer/set/sectionPlane ";
445 << fSectionPlane.
normal().x()
446 <<
' ' << fSectionPlane.
normal().y()
447 <<
' ' << fSectionPlane.
normal().z();
452 oss <<
"\n/vis/viewer/set/cutawayMode ";
456 oss <<
"intersection";
459 oss <<
"\n/vis/viewer/clearCutawayPlanes";
460 if (fCutawayPlanes.size()) {
461 for (
size_t i = 0; i < fCutawayPlanes.size(); i++) {
462 oss <<
"\n/vis/viewer/addCutawayPlane "
463 <<
G4BestUnit(fCutawayPlanes[i].point(),
"Length")
464 << fCutawayPlanes[i].normal().x()
465 <<
' ' << fCutawayPlanes[i].normal().y()
466 <<
' ' << fCutawayPlanes[i].normal().z();
469 oss <<
"\n# No cutaway planes defined.";
472 oss <<
"\n/vis/viewer/set/explodeFactor "
474 <<
' ' <<
G4BestUnit(fExplodeCentre,
"Length");
476 oss <<
"\n/vis/viewer/set/lineSegmentsPerCircle "
486 std::ostringstream oss;
489 <<
"#\n# Touchable commands"
490 <<
"\n/vis/viewer/clearVisAttributesModifiers";
492 const std::vector<G4ModelingParameters::VisAttributesModifier>& vams =
493 fVisAttributesModifiers;
502 std::vector<G4ModelingParameters::VisAttributesModifier>::const_iterator
504 for (iModifier = vams.begin();
505 iModifier != vams.end();
508 iModifier->GetPVNameCopyNoPath();
509 if (vamPath != lastPath) {
511 oss <<
"\n/vis/set/touchable";
513 for (iVAM = vamPath.begin();
514 iVAM != vamPath.end();
516 oss <<
' ' << iVAM->GetName() <<
' ' << iVAM->GetCopyNo();
521 switch (iModifier->GetVisAttributesSignifier()) {
523 oss <<
"\n/vis/touchable/set/visibility ";
531 oss <<
"\n/vis/touchable/set/daughtersInvisible ";
539 oss <<
"\n/vis/touchable/set/colour "
546 oss <<
"\n/vis/touchable/set/lineStyle ";
559 oss <<
"\n/vis/touchable/set/lineWidth "
565 oss <<
"\n/vis/touchable/set/forceWireframe ";
577 oss <<
"\n/vis/touchable/set/forceSolid ";
588 oss <<
"\n/vis/touchable/set/forceAuxEdgeVisible ";
598 oss <<
"\n/vis/touchable/set/lineSegmentsPerCircle "
615 (fViewpointDirection != v.fViewpointDirection) ||
618 (fDrawingStyle != v.fDrawingStyle) ||
619 (fAuxEdgeVisible != v.fAuxEdgeVisible) ||
620 (fCulling != v.fCulling) ||
621 (fCullInvisible != v.fCullInvisible) ||
622 (fDensityCulling != v.fDensityCulling) ||
623 (fVisibleDensity != v.fVisibleDensity) ||
624 (fCullCovered != v.fCullCovered) ||
625 (fSection != v.fSection) ||
626 (fNoOfSides != v.fNoOfSides) ||
627 (fUpVector != v.fUpVector) ||
628 (fFieldHalfAngle != v.fFieldHalfAngle) ||
629 (fZoomFactor != v.fZoomFactor) ||
630 (fScaleFactor != v.fScaleFactor) ||
631 (fCurrentTargetPoint != v.fCurrentTargetPoint) ||
632 (fDolly != v.fDolly) ||
633 (fRelativeLightpointDirection != v.fRelativeLightpointDirection) ||
634 (fLightsMoveWithCamera != v.fLightsMoveWithCamera) ||
635 (fDefaultVisAttributes != v.fDefaultVisAttributes) ||
636 (fDefaultTextVisAttributes != v.fDefaultTextVisAttributes) ||
637 (fDefaultMarker != v.fDefaultMarker) ||
638 (fGlobalMarkerScale != v.fGlobalMarkerScale) ||
639 (fGlobalLineWidthScale != v.fGlobalLineWidthScale) ||
640 (fMarkerNotHidden != v.fMarkerNotHidden) ||
641 (fWindowSizeHintX != v.fWindowSizeHintX) ||
642 (fWindowSizeHintY != v.fWindowSizeHintY) ||
643 (fXGeometryString != v.fXGeometryString) ||
644 (fGeometryMask != v.fGeometryMask) ||
645 (fAutoRefresh != v.fAutoRefresh) ||
646 (fBackgroundColour != v.fBackgroundColour) ||
647 (fPicking != v.fPicking) ||
648 (fRotationStyle != v.fRotationStyle)
653 if (!(fSectionPlane == v.fSectionPlane))
654 G4cout <<
"Difference in section planes batch." <<
G4endl;
658 if (fCutawayPlanes.size () != v.fCutawayPlanes.size ()) {
659 G4cout <<
"Difference in no of cutaway planes." <<
G4endl;
662 for (
size_t i = 0; i < fCutawayPlanes.size (); i++) {
663 if (!(fCutawayPlanes[i] == v.fCutawayPlanes[i]))
664 G4cout <<
"Difference in cutaway plane no. " << i << G4endl;
670 if (fExplodeFactor != v.fExplodeFactor)
672 if (fExplodeCentre != v.fExplodeCentre)
676 if (fVisAttributesModifiers != v.fVisAttributesModifiers) {
677 G4cout <<
"Difference in vis attributes modifiers." <<
G4endl;
685 os <<
"wireframe";
break;
687 os <<
"hlr - hidden lines removed";
break;
689 os <<
"hsr - hidden surfaces removed";
break;
691 os <<
"hlhsr - hidden line, hidden surface removed";
break;
692 default: os <<
"unrecognised";
break;
698 os <<
"View parameters and options:";
700 os <<
"\n Drawing style: ";
701 switch (v.fDrawingStyle) {
703 os <<
"edges, wireframe";
break;
705 os <<
"edges, hidden line removal";
break;
707 os <<
"surfaces, hidden surface removal";
break;
709 os <<
"surfaces and edges, hidden line and surface removal";
break;
710 default: os <<
"unrecognised";
break;
713 os <<
"\n Auxiliary edges: ";
714 if (!v.fAuxEdgeVisible) os <<
"in";
717 os <<
"\n Culling: ";
718 if (v.fCulling) os <<
"on";
721 os <<
"\n Culling invisible objects: ";
722 if (v.fCullInvisible) os <<
"on";
725 os <<
"\n Density culling: ";
726 if (v.fDensityCulling) {
727 os <<
"on - invisible if density less than "
728 << v.fVisibleDensity / (1. *
g /
cm3) <<
" g cm^-3";
732 os <<
"\n Culling daughters covered by opaque mothers: ";
733 if (v.fCullCovered) os <<
"on";
736 os <<
"\n Section flag: ";
737 if (v.fSection) os <<
"true, section/cut plane: " << v.fSectionPlane;
741 os <<
"\n Cutaway planes: ";
742 for (
size_t i = 0; i < v.fCutawayPlanes.size (); i++) {
743 os <<
' ' << v.fCutawayPlanes[i];
747 os <<
"\n No cutaway planes";
750 os <<
"\n Explode factor: " << v.fExplodeFactor
751 <<
" about centre: " << v.fExplodeCentre;
753 os <<
"\n No. of sides used in circle polygon approximation: "
756 os <<
"\n Viewpoint direction: " << v.fViewpointDirection;
758 os <<
"\n Up vector: " << v.fUpVector;
760 os <<
"\n Field half angle: " << v.fFieldHalfAngle;
762 os <<
"\n Zoom factor: " << v.fZoomFactor;
764 os <<
"\n Scale factor: " << v.fScaleFactor;
766 os <<
"\n Current target point: " << v.fCurrentTargetPoint;
768 os <<
"\n Dolly distance: " << v.fDolly;
771 if (v.fLightsMoveWithCamera) os <<
"moves";
772 else os <<
"does not move";
773 os <<
" with camera";
775 os <<
"\n Relative lightpoint direction: "
776 << v.fRelativeLightpointDirection;
778 os <<
"\n Actual lightpoint direction: "
779 << v.fActualLightpointDirection;
781 os <<
"\n Derived parameters for standard view of object of unit radius:";
784 tempVP.fZoomFactor = 1.;
792 os <<
"\n Camera distance: " << cameraDistance;
793 os <<
"\n Near distance: " << nearDistance;
794 os <<
"\n Far distance: " << farDistance;
795 os <<
"\n Front half height: " <<
right;
797 os <<
"\n Default VisAttributes:\n " << v.fDefaultVisAttributes;
799 os <<
"\n Default TextVisAttributes:\n " << v.fDefaultTextVisAttributes;
801 os <<
"\n Default marker: " << v.fDefaultMarker;
803 os <<
"\n Global marker scale: " << v.fGlobalMarkerScale;
805 os <<
"\n Global lineWidth scale: " << v.fGlobalLineWidthScale;
808 if (v.fMarkerNotHidden) os <<
"not ";
809 os <<
"hidden by surfaces.";
811 os <<
"\n Window size hint: "
812 << v.fWindowSizeHintX <<
'x'<< v.fWindowSizeHintX;
814 os <<
"\n X geometry string: " << v.fXGeometryString;
815 os <<
"\n X geometry mask: "
816 << std::showbase << std::hex << v.fGeometryMask
817 << std::noshowbase << std::dec;
819 os <<
"\n Auto refresh: ";
820 if (v.fAutoRefresh) os <<
"true";
823 os <<
"\n Background colour: " << v.fBackgroundColour;
825 os <<
"\n Picking requested: ";
826 if (v.fPicking) os <<
"true";
829 os <<
"\n Rotation style: ";
830 switch (v.fRotationStyle) {
832 os <<
"constrainUpDirection (conventional HEP view)";
break;
834 os <<
"freeRotation (Google-like rotation, using mouse-grab)";
break;
835 default: os <<
"unrecognised";
break;
838 os <<
"\n Vis attributes modifiers: ";
839 const std::vector<G4ModelingParameters::VisAttributesModifier>& vams =
840 v.fVisAttributesModifiers;
855 (fViewpointDirection != v.fViewpointDirection) ||
858 (fDrawingStyle != v.fDrawingStyle) ||
859 (fAuxEdgeVisible != v.fAuxEdgeVisible) ||
860 (fCulling != v.fCulling) ||
861 (fCullInvisible != v.fCullInvisible) ||
862 (fDensityCulling != v.fDensityCulling) ||
863 (fCullCovered != v.fCullCovered) ||
864 (fSection != v.fSection) ||
867 (fNoOfSides != v.fNoOfSides) ||
868 (fUpVector != v.fUpVector) ||
869 (fFieldHalfAngle != v.fFieldHalfAngle) ||
870 (fZoomFactor != v.fZoomFactor) ||
871 (fScaleFactor != v.fScaleFactor) ||
872 (fCurrentTargetPoint != v.fCurrentTargetPoint) ||
873 (fDolly != v.fDolly) ||
874 (fRelativeLightpointDirection != v.fRelativeLightpointDirection) ||
875 (fLightsMoveWithCamera != v.fLightsMoveWithCamera) ||
876 (fDefaultVisAttributes != v.fDefaultVisAttributes) ||
877 (fDefaultTextVisAttributes != v.fDefaultTextVisAttributes) ||
878 (fDefaultMarker != v.fDefaultMarker) ||
879 (fGlobalMarkerScale != v.fGlobalMarkerScale) ||
880 (fGlobalLineWidthScale != v.fGlobalLineWidthScale) ||
881 (fMarkerNotHidden != v.fMarkerNotHidden) ||
882 (fWindowSizeHintX != v.fWindowSizeHintX) ||
883 (fWindowSizeHintY != v.fWindowSizeHintY) ||
884 (fXGeometryString != v.fXGeometryString) ||
885 (fGeometryMask != v.fGeometryMask) ||
886 (fAutoRefresh != v.fAutoRefresh) ||
887 (fBackgroundColour != v.fBackgroundColour) ||
888 (fPicking != v.fPicking) ||
889 (fRotationStyle != v.fRotationStyle)
893 if (fDensityCulling &&
894 (fVisibleDensity != v.fVisibleDensity))
return true;
897 (!(fSectionPlane == v.fSectionPlane)))
return true;
900 if (fCutawayPlanes.size () != v.fCutawayPlanes.size ())
903 for (
size_t i = 0; i < fCutawayPlanes.size (); i++) {
904 if (!(fCutawayPlanes[i] == v.fCutawayPlanes[i]))
return true;
910 ((fExplodeFactor != v.fExplodeFactor) ||
911 (fExplodeCentre != v.fExplodeCentre)))
return true;
913 if (fVisAttributesModifiers != v.fVisAttributesModifiers)
return true;
921 unsigned int w = 0, h = 0;
922 G4String geomString = geomStringArg;
925 G4String::size_type i = geomString.find_first_of(delimiters);
926 if (i == G4String::npos) {
927 std::istringstream iss(geomString);
932 G4cout <<
"Unrecognised windowSizeHint string: \""
934 <<
"\". Asuuming " << size <<
G4endl;
936 std::ostringstream oss;
937 oss << size <<
'x' << size;
938 geomString = oss.str();
941 fGeometryMask = ParseGeometry( geomString, &x, &y, &w, &h );
944 if ((fGeometryMask & fYValue) == 0)
946 y = fWindowLocationHintY;
948 if ((fGeometryMask & fXValue) == 0)
950 x = fWindowLocationHintX;
955 if ( ((fGeometryMask & fHeightValue) == 0 ) &&
956 ((fGeometryMask & fWidthValue) == 0 )) {
957 h = fWindowSizeHintY;
958 w = fWindowSizeHintX;
959 }
else if ((fGeometryMask & fHeightValue) == 0 ) {
964 G4cout <<
"Unrecognised geometry string \""
966 <<
"\". No Height found. Using Width value instead"
970 if ( ((fGeometryMask & fXValue) == 0 ) ||
971 ((fGeometryMask & fYValue) == 0 )) {
973 x = fWindowLocationHintX;
974 y = fWindowLocationHintY;
977 fXGeometryString = geomString;
980 fWindowSizeHintX = w;
981 fWindowSizeHintY = h;
982 fWindowLocationHintX =
x;
983 fWindowLocationHintY = y;
985 if ( ((fGeometryMask & fXValue)) &&
986 ((fGeometryMask & fYValue))) {
988 if ( (fGeometryMask & fXNegative) ) {
989 fWindowLocationHintXNegative =
true;
991 fWindowLocationHintXNegative =
false;
993 if ( (fGeometryMask & fYNegative) ) {
994 fWindowLocationHintYNegative =
true;
996 fWindowLocationHintYNegative =
false;
1002 if ( fWindowLocationHintXNegative ) {
1003 return sizeX + fWindowLocationHintX - fWindowSizeHintX;
1005 return fWindowLocationHintX;
1009 if ( fWindowLocationHintYNegative ) {
1010 return sizeY + fWindowLocationHintY - fWindowSizeHintY;
1012 return fWindowLocationHintY;
1029 int G4ViewParameters::ParseGeometry (
1033 unsigned int *
width,
1034 unsigned int *height)
1039 unsigned int tempWidth = 0;
1040 unsigned int tempHeight = 0;
1043 char *nextCharacter;
1044 if ( (
string == NULL) || (*
string ==
'\0')) {
1049 strind = (
char *)
string;
1050 if (*strind !=
'+' && *strind !=
'-' && *strind !=
'x') {
1051 tempWidth = ReadInteger(strind, &nextCharacter);
1052 if (strind == nextCharacter)
1054 strind = nextCharacter;
1055 mask |= fWidthValue;
1057 if (*strind ==
'x' || *strind ==
'X') {
1059 tempHeight = ReadInteger(strind, &nextCharacter);
1060 if (strind == nextCharacter)
1062 strind = nextCharacter;
1063 mask |= fHeightValue;
1066 if ((*strind ==
'+') || (*strind ==
'-')) {
1067 if (*strind ==
'-') {
1069 tempX = -ReadInteger(strind, &nextCharacter);
1070 if (strind == nextCharacter)
1072 strind = nextCharacter;
1078 tempX = ReadInteger(strind, &nextCharacter);
1079 if (strind == nextCharacter)
1081 strind = nextCharacter;
1084 if ((*strind ==
'+') || (*strind ==
'-')) {
1085 if (*strind ==
'-') {
1087 tempY = -ReadInteger(strind, &nextCharacter);
1088 if (strind == nextCharacter)
1090 strind = nextCharacter;
1096 tempY = ReadInteger(strind, &nextCharacter);
1097 if (strind == nextCharacter)
1099 strind = nextCharacter;
1106 if (*strind !=
'\0')
return (0);
1111 if (mask & fWidthValue)
1113 if (mask & fHeightValue)
1114 *height = tempHeight;
1122 G4int G4ViewParameters::ReadInteger(
char *
string,
char **NextString)
1129 else if (*
string ==
'-')
1134 for (; (*
string >=
'0') && (*
string <=
'9');
string++)
1136 Result = (Result * 10) + (*
string -
'0');
1138 *NextString = string;
1146 (
const std::vector<G4ViewParameters>& views,
1147 G4int nInterpolationPoints)
1161 if (views.size() < 2) {
1163 (
"G4ViewParameters::CatmullRomCubicSplineInterpolation",
1165 "There must be at least two views.");
1169 if (nInterpolationPoints < 1) {
1171 (
"G4ViewParameters::CatmullRomCubicSplineInterpolation",
1173 "Number of interpolation points cannot be zero or negative.");
1177 const size_t nIntervals = views.size() - 1;
1178 const G4double dt = 1./nInterpolationPoints;
1182 static G4int iInterpolationPoint = 0;
1183 static size_t iInterval = 0;
1188 const G4double h00 = 2.*t*t*t - 3.*t*t +1;
1189 const G4double h10 = t*t*t -2.*t*t + t;
1190 const G4double h01 = -2.*t*t*t + 3.*t*t;
1194 const size_t&
n = nIntervals;
1195 size_t& i = iInterval;
1196 const std::vector<G4ViewParameters>&
v = views;
1213 holdingValues = t < 0.5? v[i]: v[i+1];
1216 #define INTERPOLATE(param) \
1221 mi = v[1].param - v[0].param; \
1224 if (n == 1) mi1 = mi; \
1226 else mi1 = 0.5 * (v[2].param - v[0].param); \
1227 } else if (i >= n - 1) { \
1229 mi1 = v[i+1].param - v[i].param; \
1231 if (n == 1) mi = mi1; \
1233 else mi = 0.5 * (v[i+1].param - v[i-1].param); \
1236 mi = 0.5 * (v[i+1].param - v[i-1].param); \
1237 mi1 = 0.5 * (v[i+2].param - v[i ].param); \
1239 real = h00 * v[i].param + h10 * mi + h01 * v[i+1].param + h11 * mi1;
1243 if (real < 0.) real = 0.;
1244 holdingValues.fVisibleDensity = real;
1246 if (real < 0.) real = 0.;
1247 holdingValues.fExplodeFactor = real;
1249 if (real < 0.) real = 0.;
1250 holdingValues.fFieldHalfAngle = real;
1252 if (real < 0.) real = 0.;
1253 holdingValues.fZoomFactor = real;
1255 holdingValues.fDolly = real;
1257 if (real < 0.) real = 0.;
1258 holdingValues.fGlobalMarkerScale = real;
1260 if (real < 0.) real = 0.;
1261 holdingValues.fGlobalLineWidthScale = real;
1264 #define INTERPOLATEUNITVECTOR(vector) \
1265 INTERPOLATE(vector.x()); x = real; \
1266 INTERPOLATE(vector.y()); y = real; \
1267 INTERPOLATE(vector.z()); z = real;
1273 holdingValues.fRelativeLightpointDirection =
G4Vector3D(x,y,z).
unit();
1275 holdingValues.fActualLightpointDirection =
G4Vector3D(x,y,z).
unit();
1278 #define INTERPOLATEVECTOR(vector) \
1279 INTERPOLATE(vector.x()); x = real; \
1280 INTERPOLATE(vector.y()); y = real; \
1281 INTERPOLATE(vector.z()); z = real;
1283 holdingValues.fScaleFactor =
G4Vector3D(x,y,z);
1286 #define INTERPOLATEPOINT(point) \
1287 INTERPOLATE(point.x()); x = real; \
1288 INTERPOLATE(point.y()); y = real; \
1289 INTERPOLATE(point.z()); z = real;
1291 holdingValues.fExplodeCentre =
G4Point3D(x,y,z);
1293 holdingValues.fCurrentTargetPoint =
G4Point3D(x,y,z);
1297 #define INTERPOLATECOLOUR(colour) \
1298 INTERPOLATE(colour.GetRed()); red = real; \
1299 INTERPOLATE(colour.GetGreen()); green = real; \
1300 INTERPOLATE(colour.GetBlue()); blue = real; \
1301 INTERPOLATE(colour.GetAlpha()); alpha = real;
1304 holdingValues.fBackgroundColour =
G4Colour(red,green,blue,alpha);
1308 #define CONTINUITY(quantity) \
1309 continuous = false; \
1312 if (v[1].quantity == v[0].quantity) { \
1313 if (n == 1) continuous = true; \
1314 else if (v[2].quantity == v[0].quantity) \
1315 continuous = true; \
1317 } else if (i >= n - 1) { \
1318 if (v[i+1].quantity == v[i].quantity) { \
1319 if (n == 1) continuous = true; \
1320 else if (v[i+1].quantity == v[i-1].quantity) \
1321 continuous = true; \
1324 if (v[i-1].quantity == v[i].quantity && \
1325 v[i+1].quantity == v[i].quantity && \
1326 v[i+2].quantity == v[i].quantity) \
1327 continuous = true; \
1331 #define INTERPOLATEPLANE(plane) \
1332 INTERPOLATE(plane.a()); a = real; \
1333 INTERPOLATE(plane.b()); b = real; \
1334 INTERPOLATE(plane.c()); c = real; \
1335 INTERPOLATE(plane.d()); d = real;
1341 holdingValues.fSectionPlane =
G4Plane3D(a,b,c,d);
1345 if (v[i].fCutawayPlanes.size()) {
1348 for (
size_t j = 0; j < v[i].fCutawayPlanes.size(); ++j) {
1350 holdingValues.fCutawayPlanes[j] =
G4Plane3D(a,b,c,d);
1359 if (v[i].fVisAttributesModifiers.size()) {
1362 for (
size_t j = 0; j < v[i].fVisAttributesModifiers.size(); ++j) {
\
1363 CONTINUITY(fVisAttributesModifiers[j].GetPVNameCopyNoPath());
1365 CONTINUITY(fVisAttributesModifiers[j].GetVisAttributesSignifier());
1367 if (v[i].fVisAttributesModifiers[j].GetVisAttributesSignifier() ==
1370 workingVA = v[i].fVisAttributesModifiers[j].GetVisAttributes();
1372 holdingValues.fVisAttributesModifiers[j].SetVisAttributes(workingVA);
1381 iInterpolationPoint++;
1383 if (iInterpolationPoint > nInterpolationPoints) {
1384 iInterpolationPoint = 1;
1388 if (iInterval >= nIntervals) {
1389 iInterpolationPoint = 0;
1395 return &holdingValues;
G4bool IsForceAuxEdgeVisible() const
G4String TouchableCommands() const
void IncrementPan(G4double right, G4double up)
void SetColour(const G4Colour &)
G4Vector3D & GetActualLightpointDirection()
G4double GetAlpha() const
const G4VisAttributes & GetVisAttributes() const
void AddCutawayPlane(const G4Plane3D &cutawayPlane)
void SetLightpointDirection(const G4Vector3D &lightpointDirection)
void SetPan(G4double right, G4double up)
G4int SetNoOfSides(G4int nSides)
G4int GetWindowAbsoluteLocationHintX(G4int) const
G4double GetLineWidth() const
std::vector< ExP01TrackerHit * > a
G4bool operator!=(const G4ViewParameters &) const
#define INTERPOLATEUNITVECTOR(vector)
BasicVector3D< T > unit() const
G4int GetWindowAbsoluteLocationHintY(G4int) const
static G4bool GetColour(const G4String &key, G4Colour &result)
const G4Colour & GetColour() const
#define INTERPOLATECOLOUR(colour)
G4String SceneModifyingCommands() const
HepGeom::Point3D< G4double > G4Point3D
HepGeom::Vector3D< G4double > G4Vector3D
Normal3D< T > normal() const
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
G4double GetFarDistance(G4double cameraDistance, G4double nearDistance, G4double radius) const
void SetVisibleDensity(G4double visibleDensity)
LineStyle GetLineStyle() const
G4double GetCameraDistance(G4double radius) const
void SetViewAndLights(const G4Vector3D &viewpointDirection)
G4double GetNearDistance(G4double cameraDistance, G4double radius) const
#define INTERPOLATEPLANE(plane)
G4GLOB_DLL std::ostream G4cout
static G4int GetMinLineSegmentsPerCircle()
void ChangeCutawayPlane(size_t index, const G4Plane3D &cutawayPlane)
G4bool IsDaughtersInvisible() const
G4double GetGreen() const
G4double GetFrontHalfHeight(G4double nearDistance, G4double radius) const
void SetXGeometryString(const G4String &)
#define INTERPOLATEVECTOR(vector)
G4bool IsForcedAuxEdgeVisible() const
Point3D< T > point(const Point3D< T > &p) const
static constexpr double cm3
G4String DrawingStyleCommands() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
#define INTERPOLATE(param)
G4int GetForcedLineSegmentsPerCircle() const
void PrintDifferences(const G4ViewParameters &v) const
std::vector< PVNameCopyNo > PVNameCopyNoPath
void AddVisAttributesModifier(const G4ModelingParameters::VisAttributesModifier &)
const PVNameCopyNoPath & GetPVNameCopyNoPath() const
G4bool IsForceDrawingStyle() const
std::ostream & operator<<(std::ostream &, const BasicVector3D< float > &)
HepGeom::Plane3D< G4double > G4Plane3D
G4String CameraAndLightingCommands(const G4Point3D standardTargetPoint) const
void MultiplyScaleFactor(const G4Vector3D &scaleFactorMultiplier)
static constexpr double deg
static G4ViewParameters * CatmullRomCubicSplineInterpolation(const std::vector< G4ViewParameters > &views, G4int nInterpolationPoints=50)
static const G4double alpha
VisAttributesSignifier GetVisAttributesSignifier() const
BasicVector3D< T > cross(const BasicVector3D< T > &v) const
ForcedDrawingStyle GetForcedDrawingStyle() const
for(G4int i1=0;i1< theStableOnes.GetNumberOfIsotopes(static_cast< G4int >(anE->GetZ()));i1++)
PVNameCopyNoPath::const_iterator PVNameCopyNoPathConstIterator
#define INTERPOLATEPOINT(point)
#define CONTINUITY(quantity)
G4GLOB_DLL std::ostream G4cerr
void SetScreenSize(G4double)