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());
148 return cameraDistance;
155 if (nearDistance < small) nearDistance = small;
163 if (farDistance < nearDistance) farDistance = nearDistance;
176 return frontHalfHeight;
186 "ERROR: G4ViewParameters::AddCutawayPlane:"
187 "\n A maximum of 3 cutaway planes supported." <<
G4endl;
193 if (index >= fCutawayPlanes.size()) {
195 "ERROR: G4ViewParameters::ChangeCutawayPlane:"
196 "\n Plane " << index <<
" does not exist." <<
G4endl;
198 fCutawayPlanes[index] = cutawayPlane;
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?"
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
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) {
264 G4Vector3D xprime = (fUpVector.cross (zprime)).unit ();
266 fActualLightpointDirection =
267 fRelativeLightpointDirection.
x () * xprime +
268 fRelativeLightpointDirection.
y () * yprime +
269 fRelativeLightpointDirection.
x () * zprime;
271 fActualLightpointDirection = fRelativeLightpointDirection;
277 fRelativeLightpointDirection = lightpointDirection;
278 SetViewAndLights (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);
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 ";
371 if (fRotationStyle == constrainUpDirection) {
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 ";
424 oss <<
"\n/vis/viewer/set/hiddenEdge ";
431 oss <<
"\n/vis/viewer/set/auxiliaryEdge ";
438 oss <<
"\n/vis/viewer/set/hiddenMarker ";
445 oss <<
"\n/vis/viewer/set/globalLineWidthScale "
448 oss <<
"\n/vis/viewer/set/globalMarkerScale "
451 oss <<
"\n/vis/viewer/set/numberOfCloudPoints "
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 ";
479 oss <<
"\n/vis/viewer/set/culling density ";
486 oss <<
"\n/vis/viewer/set/culling coveredDaughters ";
493 oss <<
"\n/vis/viewer/colourByDensity "
496 oss <<
' ' <<
p/(
g/
cm3);
499 oss <<
"\n/vis/viewer/set/sectionPlane ";
510 oss <<
"\n/vis/viewer/set/cutawayMode ";
514 oss <<
"intersection";
517 oss <<
"\n/vis/viewer/clearCutawayPlanes";
520 oss <<
"\n/vis/viewer/addCutawayPlane "
527 oss <<
"\n# No cutaway planes defined.";
530 oss <<
"\n/vis/viewer/set/explodeFactor "
534 oss <<
"\n/vis/viewer/set/lineSegmentsPerCircle "
544 std::ostringstream oss;
546 oss <<
"#\n# Touchable commands";
548 const std::vector<G4ModelingParameters::VisAttributesModifier>& vams =
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 "
696 <<
"\n/vis/viewer/set/timeWindow/endTime "
699 oss <<
"\n/vis/viewer/set/timeWindow/fadeFactor "
703 <<
"\n/vis/viewer/set/timeWindow/displayHeadTime ";
718 <<
"\n/vis/viewer/set/timeWindow/displayLightFront ";
786 G4cout <<
"Difference in number of colour by density parameters." <<
G4endl;
788 G4cout <<
"Difference in values of colour by density parameters." <<
G4endl;
794 G4cout <<
"Difference in section planes batch." << G4endl;
799 G4cout <<
"Difference in no of cutaway planes." <<
G4endl;
804 G4cout <<
"Difference in cutaway plane no. " << i << G4endl;
817 G4cout <<
"Difference in vis attributes modifiers." <<
G4endl;
826 G4cout <<
"Difference in time window fade factor." <<
G4endl;
830 G4cout <<
"Difference in display head time flag." <<
G4endl;
838 G4cout <<
"Difference in display head time parameters." <<
G4endl;
843 G4cout <<
"Difference in display light front flag." <<
G4endl;
852 G4cout <<
"Difference in display light front parameters." <<
G4endl;
857 std::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:";
883 os <<
"\n Auxiliary edges: ";
887 os <<
"\n Culling: ";
891 os <<
"\n Culling invisible objects: ";
895 os <<
"\n Density culling: ";
897 os <<
"on - invisible if density less than "
902 os <<
"\n Culling daughters covered by opaque mothers: ";
906 os <<
"\n Colour by density: ";
916 os <<
"\n Section flag: ";
921 os <<
"\n Cutaway planes: ";
927 os <<
"\n No cutaway planes";
933 os <<
"\n No. of sides used in circle polygon approximation: "
948 os <<
"\n Dolly distance: " << v.
fDolly;
952 else os <<
"does not move";
953 os <<
" with camera";
955 os <<
"\n Relative lightpoint direction: "
958 os <<
"\n Actual lightpoint direction: "
961 os <<
"\n Derived parameters for standard view of object of unit radius:";
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;
989 os <<
"hidden by surfaces.";
991 os <<
"\n Window size hint: "
995 os <<
"\n X geometry mask: "
997 << std::noshowbase << std::dec;
999 os <<
"\n Auto refresh: ";
1005 os <<
"\n Picking requested: ";
1009 os <<
"\n Rotation style: ";
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 =
1027 os <<
"\n Time window parameters:"
1032 os <<
"\n Head time display not requested.";
1035 <<
"\n Head time position: "
1042 os <<
"\n Light front display not requested.";
1045 <<
"\n Light front position: "
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();
1206 G4cout <<
"Unrecognised geometry string \""
1208 <<
"\". No Height found. Using Width value instead"
1275 unsigned int *width,
1276 unsigned int *height)
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') {
1294 if (strind == nextCharacter)
1296 strind = nextCharacter;
1299 if (*strind ==
'x' || *strind ==
'X') {
1302 if (strind == nextCharacter)
1304 strind = nextCharacter;
1308 if ((*strind ==
'+') || (*strind ==
'-')) {
1309 if (*strind ==
'-') {
1312 if (strind == nextCharacter)
1314 strind = nextCharacter;
1321 if (strind == nextCharacter)
1323 strind = nextCharacter;
1326 if ((*strind ==
'+') || (*strind ==
'-')) {
1327 if (*strind ==
'-') {
1330 if (strind == nextCharacter)
1332 strind = nextCharacter;
1339 if (strind == nextCharacter)
1341 strind = nextCharacter;
1348 if (*strind !=
'\0')
return (0);
1356 *height = tempHeight;
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;
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) \
1463 mi = v[1].param - v[0].param; \
1466 if (n == 1) mi1 = mi; \
1468 else mi1 = 0.5 * (v[2].param - v[0].param); \
1469 } else if (i >= n - 1) { \
1471 mi1 = v[i+1].param - v[i].param; \
1473 if (n == 1) mi = mi1; \
1475 else mi = 0.5 * (v[i+1].param - v[i-1].param); \
1478 mi = 0.5 * (v[i+1].param - v[i-1].param); \
1479 mi1 = 0.5 * (v[i+2].param - v[i ].param); \
1481 real = h00 * v[i].param + h10 * mi + h01 * v[i+1].param + h11 * mi1;
1483 #define INTERPOLATELOG(param) \
1485 mi = std::log(v[1].param) - std::log(v[0].param); \
1486 if (n == 1) mi1 = mi; \
1487 else mi1 = 0.5 * (std::log(v[2].param) - std::log(v[0].param)); \
1488 } else if (i >= n - 1) { \
1489 mi1 = std::log(v[i+1].param) - std::log(v[i].param); \
1490 if (n == 1) mi = mi1; \
1491 else mi = 0.5 * (std::log(v[i+1].param) - std::log(v[i-1].param)); \
1493 mi = 0.5 * (std::log(v[i+1].param) - std::log(v[i-1].param)); \
1494 mi1 = 0.5 * (std::log(v[i+2].param) - std::log(v[i ].param)); \
1496 real = 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.;
1505 if (real < 0.) real = 0.;
1510 holdingValues.
fDolly = real;
1512 if (real < 0.) real = 0.;
1515 if (real < 0.) real = 0.;
1519 #define INTERPOLATEUNITVECTOR(vector) \
1520 INTERPOLATE(vector.x()); x = real; \
1521 INTERPOLATE(vector.y()); y = real; \
1522 INTERPOLATE(vector.z()); z = real;
1533 #define INTERPOLATEVECTOR(vector) \
1534 INTERPOLATE(vector.x()); x = real; \
1535 INTERPOLATE(vector.y()); y = real; \
1536 INTERPOLATE(vector.z()); z = real;
1541 #define INTERPOLATEPOINT(point) \
1542 INTERPOLATE(point.x()); x = real; \
1543 INTERPOLATE(point.y()); y = real; \
1544 INTERPOLATE(point.z()); z = real;
1552 #define INTERPOLATECOLOUR(colour) \
1553 INTERPOLATE(colour.GetRed()); red = real; \
1554 INTERPOLATE(colour.GetGreen()); green = real; \
1555 INTERPOLATE(colour.GetBlue()); blue = real; \
1556 INTERPOLATE(colour.GetAlpha()); alpha = real;
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) \
1587 INTERPOLATE(plane.a()); a = real; \
1588 INTERPOLATE(plane.b()); b = real; \
1589 INTERPOLATE(plane.c()); c = real; \
1590 INTERPOLATE(plane.d()); d = real;
1600 if (v[i].fCutawayPlanes.size()) {
1603 for (
size_t j = 0; j < v[i].fCutawayPlanes.size(); ++j) {
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();
1645 iInterpolationPoint++;
1647 if (iInterpolationPoint > nInterpolationPoints) {
1648 iInterpolationPoint = 1;
1652 if (iInterval >= nIntervals) {
1653 iInterpolationPoint = 0;
1659 return &holdingValues;