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());
114 cameraDistance = radius;
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;
147 return frontHalfHeight;
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?"
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) {
222 G4Vector3D zprime = fViewpointDirection.unit ();
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);
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 ";
375 oss <<
"\n/vis/viewer/set/hiddenEdge ";
382 oss <<
"\n/vis/viewer/set/auxiliaryEdge ";
389 oss <<
"\n/vis/viewer/set/hiddenMarker ";
396 oss <<
"\n/vis/viewer/set/globalLineWidthScale "
399 oss <<
"\n/vis/viewer/set/globalMarkerScale "
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 ";
427 oss <<
"\n/vis/viewer/set/culling density ";
434 oss <<
"\n/vis/viewer/set/culling coveredDaughters ";
441 oss <<
"\n/vis/viewer/set/sectionPlane ";
452 oss <<
"\n/vis/viewer/set/cutawayMode ";
456 oss <<
"intersection";
459 oss <<
"\n/vis/viewer/clearCutawayPlanes";
462 oss <<
"\n/vis/viewer/addCutawayPlane "
469 oss <<
"\n# No cutaway planes defined.";
472 oss <<
"\n/vis/viewer/set/explodeFactor "
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 =
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 "
654 G4cout <<
"Difference in section planes batch." <<
G4endl;
659 G4cout <<
"Difference in no of cutaway planes." <<
G4endl;
664 G4cout <<
"Difference in cutaway plane no. " << i << G4endl;
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: ";
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: ";
717 os <<
"\n Culling: ";
721 os <<
"\n Culling invisible objects: ";
725 os <<
"\n Density culling: ";
727 os <<
"on - invisible if density less than "
732 os <<
"\n Culling daughters covered by opaque mothers: ";
736 os <<
"\n Section flag: ";
741 os <<
"\n Cutaway planes: ";
747 os <<
"\n No cutaway planes";
753 os <<
"\n No. of sides used in circle polygon approximation: "
768 os <<
"\n Dolly distance: " << v.
fDolly;
772 else os <<
"does not move";
773 os <<
" with camera";
775 os <<
"\n Relative lightpoint direction: "
778 os <<
"\n Actual lightpoint direction: "
781 os <<
"\n Derived parameters for standard view of object of unit radius:";
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;
809 os <<
"hidden by surfaces.";
811 os <<
"\n Window size hint: "
815 os <<
"\n X geometry mask: "
817 << std::noshowbase << std::dec;
819 os <<
"\n Auto refresh: ";
825 os <<
"\n Picking requested: ";
829 os <<
"\n Rotation style: ";
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 =
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();
964 G4cout <<
"Unrecognised geometry string \""
966 <<
"\". No Height found. Using Width value instead"
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') {
1052 if (strind == nextCharacter)
1054 strind = nextCharacter;
1057 if (*strind ==
'x' || *strind ==
'X') {
1060 if (strind == nextCharacter)
1062 strind = nextCharacter;
1066 if ((*strind ==
'+') || (*strind ==
'-')) {
1067 if (*strind ==
'-') {
1070 if (strind == nextCharacter)
1072 strind = nextCharacter;
1079 if (strind == nextCharacter)
1081 strind = nextCharacter;
1084 if ((*strind ==
'+') || (*strind ==
'-')) {
1085 if (*strind ==
'-') {
1088 if (strind == nextCharacter)
1090 strind = nextCharacter;
1097 if (strind == nextCharacter)
1099 strind = nextCharacter;
1106 if (*strind !=
'\0')
return (0);
1114 *height = tempHeight;
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.;
1246 if (real < 0.) real = 0.;
1249 if (real < 0.) real = 0.;
1252 if (real < 0.) real = 0.;
1255 holdingValues.
fDolly = real;
1257 if (real < 0.) real = 0.;
1260 if (real < 0.) real = 0.;
1264 #define INTERPOLATEUNITVECTOR(vector) \
1265 INTERPOLATE(vector.x()); x = real; \
1266 INTERPOLATE(vector.y()); y = real; \
1267 INTERPOLATE(vector.z()); z = real;
1278 #define INTERPOLATEVECTOR(vector) \
1279 INTERPOLATE(vector.x()); x = real; \
1280 INTERPOLATE(vector.y()); y = real; \
1281 INTERPOLATE(vector.z()); z = real;
1286 #define INTERPOLATEPOINT(point) \
1287 INTERPOLATE(point.x()); x = real; \
1288 INTERPOLATE(point.y()); y = real; \
1289 INTERPOLATE(point.z()); z = real;
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;
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;
1345 if (v[i].fCutawayPlanes.size()) {
1348 for (
size_t j = 0; j < v[i].fCutawayPlanes.size(); ++j) {
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();
1381 iInterpolationPoint++;
1383 if (iInterpolationPoint > nInterpolationPoints) {
1384 iInterpolationPoint = 1;
1388 if (iInterval >= nIntervals) {
1389 iInterpolationPoint = 0;
1395 return &holdingValues;
G4Colour fBackgroundColour
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 fLightsMoveWithCamera
G4double fGlobalMarkerScale
G4bool operator!=(const G4ViewParameters &) const
#define INTERPOLATEUNITVECTOR(vector)
std::ostream & operator<<(std::ostream &os, const G4ViewParameters::DrawingStyle &style)
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
G4int ReadInteger(char *string, char **NextString)
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
G4double GetFarDistance(G4double cameraDistance, G4double nearDistance, G4double radius) const
void SetVisibleDensity(G4double visibleDensity)
static constexpr double g
G4String fXGeometryString
LineStyle GetLineStyle() const
G4double GetCameraDistance(G4double radius) const
void SetViewAndLights(const G4Vector3D &viewpointDirection)
G4double GetNearDistance(G4double cameraDistance, G4double radius) const
#define INTERPOLATEPLANE(plane)
G4int fWindowLocationHintX
G4GLOB_DLL std::ostream G4cout
static G4int GetMinLineSegmentsPerCircle()
void ChangeCutawayPlane(size_t index, const G4Plane3D &cutawayPlane)
G4Point3D fCurrentTargetPoint
G4bool IsDaughtersInvisible() const
G4double GetGreen() const
G4double GetFrontHalfHeight(G4double nearDistance, G4double radius) const
void SetXGeometryString(const G4String &)
#define INTERPOLATEVECTOR(vector)
G4VisAttributes fDefaultVisAttributes
G4bool IsForcedAuxEdgeVisible() 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
G4double fGlobalLineWidthScale
void PrintDifferences(const G4ViewParameters &v) const
G4int fWindowLocationHintY
std::vector< PVNameCopyNo > PVNameCopyNoPath
void AddVisAttributesModifier(const G4ModelingParameters::VisAttributesModifier &)
G4Vector3D fRelativeLightpointDirection
const PVNameCopyNoPath & GetPVNameCopyNoPath() const
G4bool IsForceDrawingStyle() const
G4bool fWindowLocationHintYNegative
RotationStyle fRotationStyle
HepGeom::Plane3D< G4double > G4Plane3D
G4String CameraAndLightingCommands(const G4Point3D standardTargetPoint) const
G4Vector3D fViewpointDirection
void MultiplyScaleFactor(const G4Vector3D &scaleFactorMultiplier)
G4bool fWindowLocationHintXNegative
G4VisAttributes fDefaultTextVisAttributes
static constexpr double deg
G4int ParseGeometry(const char *string, G4int *x, G4int *y, unsigned int *width, unsigned int *height)
static G4ViewParameters * CatmullRomCubicSplineInterpolation(const std::vector< G4ViewParameters > &views, G4int nInterpolationPoints=50)
static const G4double alpha
VisAttributesSignifier GetVisAttributesSignifier() const
ForcedDrawingStyle GetForcedDrawingStyle() const
G4Vector3D fActualLightpointDirection
PVNameCopyNoPath::const_iterator PVNameCopyNoPathConstIterator
#define INTERPOLATEPOINT(point)
std::vector< G4ModelingParameters::VisAttributesModifier > fVisAttributesModifiers
#define CONTINUITY(quantity)
DrawingStyle fDrawingStyle
G4GLOB_DLL std::ostream G4cerr
void SetScreenSize(G4double)