Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ViewParameters.cc File Reference
#include "G4ViewParameters.hh"
#include "G4VisManager.hh"
#include "G4VPhysicalVolume.hh"
#include "G4UnitsTable.hh"
#include "G4SystemOfUnits.hh"
#include "G4Polyhedron.hh"
#include <sstream>
#include <cmath>

Go to the source code of this file.

Macros

#define INTERPOLATE(param)
 
#define INTERPOLATELOG(param)
 
#define INTERPOLATEUNITVECTOR(vector)
 
#define INTERPOLATEVECTOR(vector)
 
#define INTERPOLATEPOINT(point)
 
#define INTERPOLATECOLOUR(colour)
 
#define CONTINUITY(quantity)
 
#define INTERPOLATEPLANE(plane)
 

Functions

std::ostream & operator<< (std::ostream &os, const G4ViewParameters::DrawingStyle &style)
 
std::ostream & operator<< (std::ostream &os, const G4ViewParameters &v)
 

Macro Definition Documentation

◆ CONTINUITY

#define CONTINUITY (   quantity)
Value:
continuous = false; \
/* This follows the logic of the INTERPOLATE macro above; see comments therein */ \
if (i == 0) { \
if (v[1].quantity == v[0].quantity) { \
if (n == 1) continuous = true; \
else if (v[2].quantity == v[0].quantity) \
continuous = true; \
} \
} else if (i >= n - 1) { \
if (v[i+1].quantity == v[i].quantity) { \
if (n == 1) continuous = true; \
else if (v[i+1].quantity == v[i-1].quantity) \
continuous = true; \
} \
} else { \
if (v[i-1].quantity == v[i].quantity && \
v[i+1].quantity == v[i].quantity && \
v[i+2].quantity == v[i].quantity) \
continuous = true; \
}

◆ INTERPOLATE

#define INTERPOLATE (   param)
Value:
/* This works out the interpolated param in i'th interval */ \
/* Assumes n >= 1 */ \
if (i == 0) { \
/* First interval */ \
mi = v[1].param - v[0].param; \
/* If there is only one interval, make start and end slopes equal */ \
/* (This results in a linear interpolation) */ \
if (n == 1) mi1 = mi; \
/* else the end slope of the interval takes account of the next waypoint along */ \
else mi1 = 0.5 * (v[2].param - v[0].param); \
} else if (i >= n - 1) { \
/* Similarly for last interval */ \
mi1 = v[i+1].param - v[i].param; \
/* If there is only one interval, make start and end slopes equal */ \
if (n == 1) mi = mi1; \
/* else the start slope of the interval takes account of the previous waypoint */ \
else mi = 0.5 * (v[i+1].param - v[i-1].param); \
} else { \
/* Full Catmull-Rom slopes use previous AND next waypoints */ \
mi = 0.5 * (v[i+1].param - v[i-1].param); \
mi1 = 0.5 * (v[i+2].param - v[i ].param); \
} \
real = h00 * v[i].param + h10 * mi + h01 * v[i+1].param + h11 * mi1;

◆ INTERPOLATECOLOUR

#define INTERPOLATECOLOUR (   colour)
Value:
INTERPOLATE(colour.GetRed()); red = real; \
INTERPOLATE(colour.GetGreen()); green = real; \
INTERPOLATE(colour.GetBlue()); blue = real; \
INTERPOLATE(colour.GetAlpha()); alpha = real;
#define INTERPOLATE(param)

◆ INTERPOLATELOG

#define INTERPOLATELOG (   param)
Value:
if (i == 0) { \
mi = std::log(v[1].param) - std::log(v[0].param); \
if (n == 1) mi1 = mi; \
else mi1 = 0.5 * (std::log(v[2].param) - std::log(v[0].param)); \
} else if (i >= n - 1) { \
mi1 = std::log(v[i+1].param) - std::log(v[i].param); \
if (n == 1) mi = mi1; \
else mi = 0.5 * (std::log(v[i+1].param) - std::log(v[i-1].param)); \
} else { \
mi = 0.5 * (std::log(v[i+1].param) - std::log(v[i-1].param)); \
mi1 = 0.5 * (std::log(v[i+2].param) - std::log(v[i ].param)); \
} \
real = std::exp(h00 * std::log(v[i].param) + h10 * mi + h01 * std::log(v[i+1].param) + h11 * mi1);

◆ INTERPOLATEPLANE

#define INTERPOLATEPLANE (   plane)
Value:
INTERPOLATE(plane.a()); a = real; \
INTERPOLATE(plane.b()); b = real; \
INTERPOLATE(plane.c()); c = real; \
INTERPOLATE(plane.d()); d = real;

◆ INTERPOLATEPOINT

#define INTERPOLATEPOINT (   point)
Value:
INTERPOLATE(point.x()); x = real; \
INTERPOLATE(point.y()); y = real; \
INTERPOLATE(point.z()); z = real;

◆ INTERPOLATEUNITVECTOR

#define INTERPOLATEUNITVECTOR (   vector)
Value:
INTERPOLATE(vector.x()); x = real; \
INTERPOLATE(vector.y()); y = real; \
INTERPOLATE(vector.z()); z = real;

◆ INTERPOLATEVECTOR

#define INTERPOLATEVECTOR (   vector)
Value:
INTERPOLATE(vector.x()); x = real; \
INTERPOLATE(vector.y()); y = real; \
INTERPOLATE(vector.z()); z = real;

Function Documentation

◆ operator<<() [1/2]

std::ostream & operator<< ( std::ostream &  os,
const G4ViewParameters v 
)

Definition at line 876 of file G4ViewParameters.cc.

876 {
877 os << "View parameters and options:";
878
879 os << "\n Drawing style: " << v.fDrawingStyle;
880
881 os << "\n Number of cloud points: " << v.fNumberOfCloudPoints;
882
883 os << "\n Auxiliary edges: ";
884 if (!v.fAuxEdgeVisible) os << "in";
885 os << "visible";
886
887 os << "\n Culling: ";
888 if (v.fCulling) os << "on";
889 else os << "off";
890
891 os << "\n Culling invisible objects: ";
892 if (v.fCullInvisible) os << "on";
893 else os << "off";
894
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";
899 }
900 else os << "off";
901
902 os << "\n Culling daughters covered by opaque mothers: ";
903 if (v.fCullCovered) os << "on";
904 else os << "off";
905
906 os << "\n Colour by density: ";
907 if (v.fCBDAlgorithmNumber <= 0) {
908 os << "inactive";
909 } else {
910 os << "Algorithm " << v.fCBDAlgorithmNumber << ", Parameters:";
911 for (auto p: v.fCBDParameters) {
912 os << ' ' << G4BestUnit(p,"Volumic Mass");
913 }
914 }
915
916 os << "\n Section flag: ";
917 if (v.fSection) os << "true, section/cut plane: " << v.fSectionPlane;
918 else os << "false";
919
920 if (v.IsCutaway()) {
921 os << "\n Cutaway planes: ";
922 for (size_t i = 0; i < v.fCutawayPlanes.size (); i++) {
923 os << ' ' << v.fCutawayPlanes[i];
924 }
925 }
926 else {
927 os << "\n No cutaway planes";
928 }
929
930 os << "\n Explode factor: " << v.fExplodeFactor
931 << " about centre: " << v.fExplodeCentre;
932
933 os << "\n No. of sides used in circle polygon approximation: "
934 << v.fNoOfSides;
935
936 os << "\n Viewpoint direction: " << v.fViewpointDirection;
937
938 os << "\n Up vector: " << v.fUpVector;
939
940 os << "\n Field half angle: " << v.fFieldHalfAngle;
941
942 os << "\n Zoom factor: " << v.fZoomFactor;
943
944 os << "\n Scale factor: " << v.fScaleFactor;
945
946 os << "\n Current target point: " << v.fCurrentTargetPoint;
947
948 os << "\n Dolly distance: " << v.fDolly;
949
950 os << "\n Light ";
951 if (v.fLightsMoveWithCamera) os << "moves";
952 else os << "does not move";
953 os << " with camera";
954
955 os << "\n Relative lightpoint direction: "
956 << v.fRelativeLightpointDirection;
957
958 os << "\n Actual lightpoint direction: "
959 << v.fActualLightpointDirection;
960
961 os << "\n Derived parameters for standard view of object of unit radius:";
962 G4ViewParameters tempVP = v;
963 tempVP.fDolly = 0.;
964 tempVP.fZoomFactor = 1.;
965 const G4double radius = 1.;
966 const G4double cameraDistance = tempVP.GetCameraDistance (radius);
967 const G4double nearDistance =
968 tempVP.GetNearDistance (cameraDistance, radius);
969 const G4double farDistance =
970 tempVP.GetFarDistance (cameraDistance, nearDistance, radius);
971 const G4double right = tempVP.GetFrontHalfHeight (nearDistance, 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;
976
977 os << "\n Default VisAttributes:\n " << v.fDefaultVisAttributes;
978
979 os << "\n Default TextVisAttributes:\n " << v.fDefaultTextVisAttributes;
980
981 os << "\n Default marker: " << v.fDefaultMarker;
982
983 os << "\n Global marker scale: " << v.fGlobalMarkerScale;
984
985 os << "\n Global lineWidth scale: " << v.fGlobalLineWidthScale;
986
987 os << "\n Marker ";
988 if (v.fMarkerNotHidden) os << "not ";
989 os << "hidden by surfaces.";
990
991 os << "\n Window size hint: "
992 << v.fWindowSizeHintX << 'x'<< v.fWindowSizeHintX;
993
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;
998
999 os << "\n Auto refresh: ";
1000 if (v.fAutoRefresh) os << "true";
1001 else os << "false";
1002
1003 os << "\n Background colour: " << v.fBackgroundColour;
1004
1005 os << "\n Picking requested: ";
1006 if (v.fPicking) os << "true";
1007 else os << "false";
1008
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;
1016 }
1017
1018 os << "\n Vis attributes modifiers: ";
1019 const std::vector<G4ModelingParameters::VisAttributesModifier>& vams =
1020 v.fVisAttributesModifiers;
1021 if (vams.empty()) {
1022 os << "None";
1023 } else {
1024 os << vams;
1025 }
1026
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.";
1033 } else {
1034 os
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;
1040 }
1041 if (!v.fDisplayLightFront) {
1042 os << "\n Light front display not requested.";
1043 } else {
1044 os
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;
1051 }
1052
1053 return os;
1054}
#define G4BestUnit(a, b)
double G4double
Definition: G4Types.hh:83
G4double GetCameraDistance(G4double radius) const
G4bool IsCutaway() const
G4double GetFarDistance(G4double cameraDistance, G4double nearDistance, G4double radius) const
G4double GetFrontHalfHeight(G4double nearDistance, G4double radius) const
G4double GetNearDistance(G4double cameraDistance, G4double radius) const
#define ns
Definition: xmlparse.cc:614

◆ operator<<() [2/2]

std::ostream & operator<< ( std::ostream &  os,
const G4ViewParameters::DrawingStyle style 
)

Definition at line 857 of file G4ViewParameters.cc.

859{
860 switch (style) {
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;
872 }
873 return os;
874}