Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4HepRepFileSceneHandler Class Reference

#include <G4HepRepFileSceneHandler.hh>

+ Inheritance diagram for G4HepRepFileSceneHandler:

Public Member Functions

 G4HepRepFileSceneHandler (G4VGraphicsSystem &system, const G4String &name)
 
virtual ~G4HepRepFileSceneHandler ()
 
void AddSolid (const G4Box &)
 
void AddSolid (const G4Cons &)
 
void AddSolid (const G4Tubs &)
 
void AddSolid (const G4Trd &)
 
void AddSolid (const G4Trap &)
 
void AddSolid (const G4Sphere &)
 
void AddSolid (const G4Para &)
 
void AddSolid (const G4Torus &)
 
void AddSolid (const G4Polycone &)
 
void AddSolid (const G4Polyhedra &)
 
void AddSolid (const G4Orb &)
 
void AddSolid (const G4Ellipsoid &)
 
void AddSolid (const G4TessellatedSolid &)
 
void AddSolid (const G4VSolid &)
 
void AddCompound (const G4VTrajectory &)
 
void InitTrajectory ()
 
void AddCompound (const G4VHit &)
 
void InitHit ()
 
void AddCompound (const G4THitsMap< G4double > &hits)
 
void AddCompound (const G4THitsMap< G4StatDouble > &hits)
 
void AddCompound (const G4VDigi &digi)
 
void AddPrimitive (const G4Polyline &)
 
void AddPrimitive (const G4Text &)
 
void AddPrimitive (const G4Circle &)
 
void AddPrimitive (const G4Square &)
 
void AddPrimitive (const G4Polyhedron &)
 
void AddPrimitive (const G4Polymarker &)
 
void AddPrimitive (const G4Scale &scale)
 
void BeginModeling ()
 
void EndModeling ()
 
void BeginPrimitives2D (const G4Transform3D &objectTransformation)
 
void EndPrimitives2D ()
 
void ClearTransientStore ()
 
G4HepRepFileXMLWriterGetHepRepXMLWriter ()
 
- Public Member Functions inherited from G4VSceneHandler
 G4VSceneHandler (G4VGraphicsSystem &system, G4int id, const G4String &name="")
 
virtual ~G4VSceneHandler ()
 
virtual void PreAddSolid (const G4Transform3D &objectTransformation, const G4VisAttributes &)
 
virtual void PostAddSolid ()
 
virtual void AddSolid (const G4Box &)
 
virtual void AddSolid (const G4Cons &)
 
virtual void AddSolid (const G4Orb &)
 
virtual void AddSolid (const G4Para &)
 
virtual void AddSolid (const G4Sphere &)
 
virtual void AddSolid (const G4Torus &)
 
virtual void AddSolid (const G4Trap &)
 
virtual void AddSolid (const G4Trd &)
 
virtual void AddSolid (const G4Tubs &)
 
virtual void AddSolid (const G4Ellipsoid &)
 
virtual void AddSolid (const G4Polycone &)
 
virtual void AddSolid (const G4Polyhedra &)
 
virtual void AddSolid (const G4TessellatedSolid &)
 
virtual void AddSolid (const G4VSolid &)
 
virtual void AddCompound (const G4VTrajectory &)
 
virtual void AddCompound (const G4VHit &)
 
virtual void AddCompound (const G4VDigi &)
 
virtual void AddCompound (const G4THitsMap< G4double > &)
 
virtual void AddCompound (const G4THitsMap< G4StatDouble > &)
 
virtual void BeginModeling ()
 
virtual void EndModeling ()
 
virtual void BeginPrimitives (const G4Transform3D &objectTransformation=G4Transform3D())
 
virtual void EndPrimitives ()
 
virtual void BeginPrimitives2D (const G4Transform3D &objectTransformation=G4Transform3D())
 
virtual void EndPrimitives2D ()
 
virtual void AddPrimitive (const G4Polyline &)=0
 
virtual void AddPrimitive (const G4Scale &)
 
virtual void AddPrimitive (const G4Text &)=0
 
virtual void AddPrimitive (const G4Circle &)=0
 
virtual void AddPrimitive (const G4Square &)=0
 
virtual void AddPrimitive (const G4Polymarker &)
 
virtual void AddPrimitive (const G4Polyhedron &)=0
 
virtual const G4VisExtentGetExtent () const
 
const G4StringGetName () const
 
G4int GetSceneHandlerId () const
 
G4int GetViewCount () const
 
G4VGraphicsSystemGetGraphicsSystem () const
 
G4SceneGetScene () const
 
const G4ViewerListGetViewerList () const
 
G4VModelGetModel () const
 
G4VViewerGetCurrentViewer () const
 
G4bool GetMarkForClearingTransientStore () const
 
G4bool IsReadyForTransients () const
 
G4bool GetTransientsDrawnThisEvent () const
 
G4bool GetTransientsDrawnThisRun () const
 
const G4Transform3DGetObjectTransformation () const
 
void SetName (const G4String &)
 
void SetCurrentViewer (G4VViewer *)
 
virtual void SetScene (G4Scene *)
 
G4ViewerListSetViewerList ()
 
void SetModel (G4VModel *)
 
void SetMarkForClearingTransientStore (G4bool)
 
void SetTransientsDrawnThisEvent (G4bool)
 
void SetTransientsDrawnThisRun (G4bool)
 
void SetObjectTransformation (const G4Transform3D &)
 
const G4ColourGetColour ()
 
const G4ColourGetColor ()
 
const G4ColourGetTextColour (const G4Text &)
 
const G4ColourGetTextColor (const G4Text &)
 
G4double GetLineWidth (const G4VisAttributes *)
 
G4ViewParameters::DrawingStyle GetDrawingStyle (const G4VisAttributes *)
 
G4int GetNumberOfCloudPoints (const G4VisAttributes *) const
 
G4bool GetAuxEdgeVisible (const G4VisAttributes *)
 
G4int GetNoOfSides (const G4VisAttributes *)
 
G4double GetMarkerSize (const G4VMarker &, MarkerSizeType &)
 
G4double GetMarkerDiameter (const G4VMarker &, MarkerSizeType &)
 
G4double GetMarkerRadius (const G4VMarker &, MarkerSizeType &)
 
G4ModelingParametersCreateModelingParameters ()
 
void DrawEvent (const G4Event *)
 
void DrawEndOfRunModels ()
 
template<class T >
void AddSolidT (const T &solid)
 
template<class T >
void AddSolidWithAuxiliaryEdges (const T &solid)
 
G4int IncrementViewCount ()
 
virtual void ClearStore ()
 
virtual void ClearTransientStore ()
 
void AddViewerToList (G4VViewer *pView)
 
void RemoveViewerFromList (G4VViewer *pView)
 
- Public Member Functions inherited from G4VGraphicsScene
 G4VGraphicsScene ()
 
virtual ~G4VGraphicsScene ()
 
virtual void PreAddSolid (const G4Transform3D &objectTransformation, const G4VisAttributes &visAttribs)=0
 
virtual void PostAddSolid ()=0
 
virtual void AddSolid (const G4Box &)=0
 
virtual void AddSolid (const G4Cons &)=0
 
virtual void AddSolid (const G4Orb &)=0
 
virtual void AddSolid (const G4Para &)=0
 
virtual void AddSolid (const G4Sphere &)=0
 
virtual void AddSolid (const G4Torus &)=0
 
virtual void AddSolid (const G4Trap &)=0
 
virtual void AddSolid (const G4Trd &)=0
 
virtual void AddSolid (const G4Tubs &)=0
 
virtual void AddSolid (const G4Ellipsoid &)=0
 
virtual void AddSolid (const G4Polycone &)=0
 
virtual void AddSolid (const G4Polyhedra &)=0
 
virtual void AddSolid (const G4TessellatedSolid &)=0
 
virtual void AddSolid (const G4VSolid &)=0
 
virtual void AddCompound (const G4VTrajectory &)=0
 
virtual void AddCompound (const G4VHit &)=0
 
virtual void AddCompound (const G4VDigi &)=0
 
virtual void AddCompound (const G4THitsMap< G4double > &)=0
 
virtual void AddCompound (const G4THitsMap< G4StatDouble > &)=0
 
virtual void BeginPrimitives (const G4Transform3D &objectTransformation=G4Transform3D())=0
 
virtual void EndPrimitives ()=0
 
virtual void BeginPrimitives2D (const G4Transform3D &objectTransformation=G4Transform3D())=0
 
virtual void EndPrimitives2D ()=0
 
virtual void AddPrimitive (const G4Polyline &)=0
 
virtual void AddPrimitive (const G4Scale &)=0
 
virtual void AddPrimitive (const G4Text &)=0
 
virtual void AddPrimitive (const G4Circle &)=0
 
virtual void AddPrimitive (const G4Square &)=0
 
virtual void AddPrimitive (const G4Polymarker &)=0
 
virtual void AddPrimitive (const G4Polyhedron &)=0
 
virtual const G4VisExtentGetExtent () const
 

Static Protected Attributes

static G4int fSceneIdCount = 0
 

Additional Inherited Members

- Public Types inherited from G4VSceneHandler
enum  MarkerSizeType { world , screen }
 
- Protected Member Functions inherited from G4VSceneHandler
virtual void ProcessScene ()
 
virtual void RequestPrimitives (const G4VSolid &solid)
 
virtual G4DisplacedSolidCreateSectionSolid ()
 
virtual G4DisplacedSolidCreateCutawaySolid ()
 
void LoadAtts (const G4Visible &, G4AttHolder *)
 
- Protected Attributes inherited from G4VSceneHandler
G4VGraphicsSystemfSystem
 
const G4int fSceneHandlerId
 
G4String fName
 
G4int fViewCount
 
G4ViewerList fViewerList
 
G4VViewerfpViewer
 
G4ScenefpScene
 
G4bool fMarkForClearingTransientStore
 
G4bool fReadyForTransients
 
G4bool fTransientsDrawnThisEvent
 
G4bool fTransientsDrawnThisRun
 
G4bool fProcessingSolid
 
G4bool fProcessing2D
 
G4VModelfpModel
 
G4Transform3D fObjectTransformation
 
G4int fNestingDepth
 
const G4VisAttributesfpVisAttribs
 
const G4Transform3D fIdentityTransformation
 

Detailed Description

Definition at line 58 of file G4HepRepFileSceneHandler.hh.

Constructor & Destructor Documentation

◆ G4HepRepFileSceneHandler()

G4HepRepFileSceneHandler::G4HepRepFileSceneHandler ( G4VGraphicsSystem system,
const G4String name 
)

Definition at line 69 of file G4HepRepFileSceneHandler.cc.

70 :
71G4VSceneHandler(system, fSceneIdCount++, name)
72{
73 hepRepXMLWriter = ((G4HepRepFile*)(&system))->GetHepRepXMLWriter();
74 fileCounter = 0;
75
76 inPrimitives2D = false;
77 warnedAbout3DText = false;
78 warnedAbout2DMarkers = false;
79 haveVisible = false;
80 drawingTraj = false;
81 doneInitTraj = false;
82 drawingHit = false;
83 doneInitHit = false;
84 trajContext = 0;
85 trajAttValues = 0;
86 trajAttDefs = 0;
87 hitAttValues = 0;
88 hitAttDefs = 0;
89}
G4HepRepFileXMLWriter * GetHepRepXMLWriter()

◆ ~G4HepRepFileSceneHandler()

G4HepRepFileSceneHandler::~G4HepRepFileSceneHandler ( )
virtual

Definition at line 92 of file G4HepRepFileSceneHandler.cc.

92{}

Member Function Documentation

◆ AddCompound() [1/5]

void G4HepRepFileSceneHandler::AddCompound ( const G4THitsMap< G4double > &  hits)
inlinevirtual

Reimplemented from G4VSceneHandler.

Definition at line 85 of file G4HepRepFileSceneHandler.hh.

85 {
87 }
virtual void AddCompound(const G4VTrajectory &)

◆ AddCompound() [2/5]

void G4HepRepFileSceneHandler::AddCompound ( const G4THitsMap< G4StatDouble > &  hits)
inlinevirtual

Reimplemented from G4VSceneHandler.

Definition at line 88 of file G4HepRepFileSceneHandler.hh.

88 {
90 }

◆ AddCompound() [3/5]

void G4HepRepFileSceneHandler::AddCompound ( const G4VDigi digi)
inlinevirtual

Reimplemented from G4VSceneHandler.

Definition at line 91 of file G4HepRepFileSceneHandler.hh.

91 {
93 }

◆ AddCompound() [4/5]

void G4HepRepFileSceneHandler::AddCompound ( const G4VHit hit)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 893 of file G4HepRepFileSceneHandler.cc.

893 {
894#ifdef G4HEPREPFILEDEBUG
895 G4cout << "G4HepRepFileSceneHandler::AddCompound(G4VHit&) " << G4endl;
896#endif
897
898 // Pointers to hold hit attribute values and definitions.
899 std::vector<G4AttValue>* rawHitAttValues = hit.CreateAttValues();
900 hitAttValues =
901 new std::vector<G4AttValue>;
902 hitAttDefs =
903 new std::map<G4String,G4AttDef>;
904
905 // Iterators to use with attribute values and definitions.
906 std::vector<G4AttValue>::iterator iAttVal;
907 std::map<G4String,G4AttDef>::const_iterator iAttDef;
908
909 // Get hit attributes and definitions in standard HepRep style
910 // (uniform units, 3Vectors decomposed).
911 if (rawHitAttValues) {
912 G4bool error = G4AttCheck(rawHitAttValues,
913 hit.GetAttDefs()).Standard(hitAttValues,hitAttDefs);
914 if (error) {
915 G4cout << "G4HepRepFileSceneHandler::AddCompound(hit):"
916 "\nERROR found during conversion to standard hit attributes."
917 << G4endl;
918 }
919#ifdef G4HEPREPFILEDEBUG
920 G4cout <<
921 "G4HepRepFileSceneHandler::AddCompound(hit): standardised attributes:\n"
922 << G4AttCheck(hitAttValues,hitAttDefs) << G4endl;
923#endif
924 delete rawHitAttValues;
925 }
926
927 // Open the HepRep output file if it is not already open.
928 CheckFileOpen();
929
930 // Add the Event Data Type if it hasn't already been added.
931 if (strcmp("Event Data",hepRepXMLWriter->prevTypeName[0])!=0) {
932 hepRepXMLWriter->addType("Event Data",0);
933 hepRepXMLWriter->addInstance();
934 }
935
936 // Find out the current HitType.
937 G4String hitType = "Hits";
938 if (hitAttValues) {
939 G4bool found = false;
940 for (iAttVal = hitAttValues->begin();
941 iAttVal != hitAttValues->end() && !found; ++iAttVal) {
942 if (strcmp(iAttVal->GetName(),"HitType")==0) {
943 hitType = iAttVal->GetValue();
944 found = true;
945 }
946 }
947 }
948
949 // Add the Hits Type.
950 G4String previousName = hepRepXMLWriter->prevTypeName[1];
951 hepRepXMLWriter->addType(hitType,1);
952
953 // If this is the first hit of this event,
954 // specify attribute values common to all hits.
955 if (strcmp(hitType,previousName)!=0) {
956 hepRepXMLWriter->addAttValue("Layer",130);
957
958 // Take all Hit attDefs from first hit.
959 // Would rather be able to get these attDefs without needing a reference from any
960 // particular hit, but don't know how to do that.
961 // Write out hit attribute definitions.
962 if (hitAttValues && hitAttDefs) {
963 for (iAttVal = hitAttValues->begin();
964 iAttVal != hitAttValues->end(); ++iAttVal) {
965 iAttDef = hitAttDefs->find(iAttVal->GetName());
966 if (iAttDef != hitAttDefs->end()) {
967 // Protect against incorrect use of Category. Anything value other than the
968 // standard ones will be considered to be in the physics category.
969 G4String category = iAttDef->second.GetCategory();
970 if (strcmp(category,"Draw")!=0 &&
971 strcmp(category,"Physics")!=0 &&
972 strcmp(category,"Association")!=0 &&
973 strcmp(category,"PickAction")!=0)
974 category = "Physics";
975 hepRepXMLWriter->addAttDef(iAttVal->GetName(), iAttDef->second.GetDesc(),
976 category, iAttDef->second.GetExtra());
977 }
978 }
979 }
980 } // end of special treatment for when this is the first hit.
981
982 // Now that we have written out all of the attributes that are based on the
983 // hit's particulars, call base class to deconstruct hit into a primitives.
984 drawingHit = true;
985 doneInitHit = false;
986 G4VSceneHandler::AddCompound(hit); // Invoke default action.
987 drawingHit = false;
988}
bool G4bool
Definition: G4Types.hh:86
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4bool Standard(std::vector< G4AttValue > *standardValues, std::map< G4String, G4AttDef > *standardDefinitions) const
Definition: G4AttCheck.cc:350
void addAttValue(const char *name, const char *value)
void addType(const char *name, int newTypeDepth)
void addAttDef(const char *name, const char *desc, const char *type, const char *extra)
virtual std::vector< G4AttValue > * CreateAttValues() const
Definition: G4VHit.hh:66
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
Definition: G4VHit.hh:59

◆ AddCompound() [5/5]

void G4HepRepFileSceneHandler::AddCompound ( const G4VTrajectory traj)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 528 of file G4HepRepFileSceneHandler.cc.

528 {
529#ifdef G4HEPREPFILEDEBUG
530 G4cout << "G4HepRepFileSceneHandler::AddCompound(const G4VTrajectory&) " << G4endl;
531#endif
532
533 G4TrajectoriesModel* pTrModel =
534 dynamic_cast<G4TrajectoriesModel*>(fpModel);
535 if (!pTrModel) G4Exception
536 ("G4HepRepFileSceneHandler::AddCompound(const G4VTrajectory&)",
537 "vis-HepRep0001", FatalException, "Not a G4TrajectoriesModel.");
538
539 // Pointers to hold trajectory attribute values and definitions.
540 std::vector<G4AttValue>* rawTrajAttValues = traj.CreateAttValues();
541 trajAttValues =
542 new std::vector<G4AttValue>;
543 trajAttDefs =
544 new std::map<G4String,G4AttDef>;
545
546 // Iterators to use with attribute values and definitions.
547 std::vector<G4AttValue>::iterator iAttVal;
548 std::map<G4String,G4AttDef>::const_iterator iAttDef;
549 G4int i;
550
551 // Get trajectory attributes and definitions in standard HepRep style
552 // (uniform units, 3Vectors decomposed).
553 if (rawTrajAttValues) {
554 G4bool error = G4AttCheck(rawTrajAttValues,
555 traj.GetAttDefs()).Standard(trajAttValues,trajAttDefs);
556 if (error) {
557 G4cout << "G4HepRepFileSceneHandler::AddCompound(traj):"
558 "\nERROR found during conversion to standard trajectory attributes."
559 << G4endl;
560 }
561#ifdef G4HEPREPFILEDEBUG
562 G4cout <<
563 "G4HepRepFileSceneHandler::AddCompound(traj): standardised attributes:\n"
564 << G4AttCheck(trajAttValues,trajAttDefs) << G4endl;
565#endif
566 delete rawTrajAttValues;
567 }
568
569 // Open the HepRep output file if it is not already open.
570 CheckFileOpen();
571
572 // Add the Event Data Type if it hasn't already been added.
573 if (strcmp("Event Data",hepRepXMLWriter->prevTypeName[0])!=0) {
574 hepRepXMLWriter->addType("Event Data",0);
575 hepRepXMLWriter->addInstance();
576 }
577
578 // Add the Trajectories Type.
579 G4String previousName = hepRepXMLWriter->prevTypeName[1];
580 hepRepXMLWriter->addType("Trajectories",1);
581
582 // If this is the first trajectory of this event,
583 // specify attribute values common to all trajectories.
584 if (strcmp("Trajectories",previousName)!=0) {
585 hepRepXMLWriter->addAttValue("Layer",100);
586
587 // Take all Trajectory attDefs from first trajectory.
588 // Would rather be able to get these attDefs without needing a reference from any
589 // particular trajectory, but don't know how to do that.
590 // Write out trajectory attribute definitions.
591 if (trajAttValues && trajAttDefs) {
592 for (iAttVal = trajAttValues->begin();
593 iAttVal != trajAttValues->end(); ++iAttVal) {
594 iAttDef = trajAttDefs->find(iAttVal->GetName());
595 if (iAttDef != trajAttDefs->end()) {
596 // Protect against incorrect use of Category. Anything value other than the
597 // standard ones will be considered to be in the physics category.
598 G4String category = iAttDef->second.GetCategory();
599 if (strcmp(category,"Draw")!=0 &&
600 strcmp(category,"Physics")!=0 &&
601 strcmp(category,"Association")!=0 &&
602 strcmp(category,"PickAction")!=0)
603 category = "Physics";
604 hepRepXMLWriter->addAttDef(iAttVal->GetName(), iAttDef->second.GetDesc(),
605 category, iAttDef->second.GetExtra());
606 }
607 }
608 }
609
610 // Take all TrajectoryPoint attDefs from first point of first trajectory.
611 // Would rather be able to get these attDefs without needing a reference from any
612 // particular point, but don't know how to do that.
613 if ((trajContext->GetDrawStepPts() || trajContext->GetDrawAuxPts())
614 && traj.GetPointEntries()>0) {
615 G4VTrajectoryPoint* aTrajectoryPoint = traj.GetPoint(0);
616
617 // Pointers to hold trajectory point attribute values and definitions.
618 std::vector<G4AttValue>* rawPointAttValues = aTrajectoryPoint->CreateAttValues();
619 std::vector<G4AttValue>* pointAttValues =
620 new std::vector<G4AttValue>;
621 std::map<G4String,G4AttDef>* pointAttDefs =
622 new std::map<G4String,G4AttDef>;
623
624 // Get first trajectory point's attributes and definitions in standard HepRep style
625 // (uniform units, 3Vectors decomposed).
626 if (rawPointAttValues) {
627 G4bool error = G4AttCheck(rawPointAttValues,
628 aTrajectoryPoint->GetAttDefs()).Standard(pointAttValues,pointAttDefs);
629 if (error) {
630 G4cout << "G4HepRepFileSceneHandler::AddCompound(traj):"
631 "\nERROR found during conversion to standard first point attributes." << G4endl;
632 }
633
634 // Write out point attribute definitions.
635 if (pointAttValues && pointAttDefs) {
636 for (iAttVal = pointAttValues->begin();
637 iAttVal != pointAttValues->end(); ++iAttVal) {
638 iAttDef =
639 pointAttDefs->find(iAttVal->GetName());
640 if (iAttDef != pointAttDefs->end()) {
641 // Protect against incorrect use of Category. Anything value other than the
642 // standard ones will be considered to be in the physics category.
643 G4String category = iAttDef->second.GetCategory();
644 if (strcmp(category,"Draw")!=0 &&
645 strcmp(category,"Physics")!=0 &&
646 strcmp(category,"Association")!=0 &&
647 strcmp(category,"PickAction")!=0)
648 category = "Physics";
649 // Do not write out the Aux or Pos attribute. Aux does not conform to the HepRep rule
650 // that each object can have only one instance of a given AttValue.
651 // Both of these attributes are redundant to actual position information of the point.
652 if (strcmp(iAttVal->GetName(),"Aux-X")!=0 &&
653 strcmp(iAttVal->GetName(),"Aux-Y")!=0 &&
654 strcmp(iAttVal->GetName(),"Aux-Z")!=0 &&
655 strcmp(iAttVal->GetName(),"Pos-X")!=0 &&
656 strcmp(iAttVal->GetName(),"Pos-Y")!=0 &&
657 strcmp(iAttVal->GetName(),"Pos-Z")!=0)
658 hepRepXMLWriter->addAttDef(iAttVal->GetName(), iAttDef->second.GetDesc(),
659 category, iAttDef->second.GetExtra());
660 }
661 }
662 }
663 delete rawPointAttValues;
664 }
665
666 // Clean up point attributes.
667 if (pointAttValues)
668 delete pointAttValues;
669 if (pointAttDefs)
670 delete pointAttDefs;
671 }
672 } // end of special treatment for when this is the first trajectory.
673
674 // Now that we have written out all of the attributes that are based on the
675 // trajectory's particulars, call base class to deconstruct trajectory into polyline and/or points
676 // (or nothing if trajectory is to be filtered out).
677 // If base class calls for drawing points, no points will actually be drawn there since we
678 // instead need to do point drawing from here (in order to obtain the points attributes,
679 // not available from AddPrimitive(...point). Instead, such a call will just serve to set the
680 // flag that tells us that point drawing was requested for this trajectory (depends on several
681 // factors including trajContext and filtering).
682 drawingTraj = true;
683 doneInitTraj = false;
685 drawingTraj = false;
686
687 // Draw step points.
688 if (trajContext->GetDrawStepPts()) {
689 if (!doneInitTraj)
691 // Create Trajectory Points as a subType of Trajectories.
692 // Note that we should create this heprep type even if there are no actual points.
693 // This allows the user to tell that points don't exist (admittedly odd) rather
694 // than that they were omitted by the drawing mode.
695 previousName = hepRepXMLWriter->prevTypeName[2];
696 hepRepXMLWriter->addType("Trajectory Step Points",2);
697
698 float redness;
699 float greenness;
700 float blueness;
701 G4int markSize;
702 G4bool visible;
703 G4bool square;
704 G4Colour colour = trajContext->GetStepPtsColour();
705 redness = colour.GetRed();
706 greenness = colour.GetGreen();
707 blueness = colour.GetBlue();
708 markSize = (G4int) trajContext->GetStepPtsSize();
709 visible = (G4int) trajContext->GetStepPtsVisible();
710 square = (trajContext->GetStepPtsType()==G4Polymarker::squares);
711
712 // Avoiding drawing anything black on black.
713 if (redness==0. && greenness==0. && blueness==0.) {
714 redness = 1.;
715 greenness = 1.;
716 blueness = 1.;
717 }
718
719 // Specify attributes common to all trajectory points.
720 if (strcmp("Trajectory Step Points",previousName)!=0) {
721 hepRepXMLWriter->addAttValue("DrawAs","Point");
722 hepRepXMLWriter->addAttValue("MarkColor", redness, greenness, blueness);
723 hepRepXMLWriter->addAttValue("MarkSize",markSize);
724 hepRepXMLWriter->addAttValue("Layer",110);
725 hepRepXMLWriter->addAttValue("Visibility",visible);
726 if (square)
727 hepRepXMLWriter->addAttValue("MarkName","square");
728 else
729 hepRepXMLWriter->addAttValue("MarkName","dot");
730 }
731
732 // Loop over all points on this trajectory.
733 for (i = 0; i < traj.GetPointEntries(); i++) {
734 G4VTrajectoryPoint* aTrajectoryPoint = traj.GetPoint(i);
735
736 // Each point is a separate instance of the type Trajectory Points.
737 hepRepXMLWriter->addInstance();
738
739 // Pointers to hold trajectory point attribute values and definitions.
740 std::vector<G4AttValue>* rawPointAttValues = aTrajectoryPoint->CreateAttValues();
741 std::vector<G4AttValue>* pointAttValues =
742 new std::vector<G4AttValue>;
743 std::map<G4String,G4AttDef>* pointAttDefs =
744 new std::map<G4String,G4AttDef>;
745
746 // Get trajectory point attributes and definitions in standard HepRep style
747 // (uniform units, 3Vectors decomposed).
748 if (rawPointAttValues) {
749 G4bool error = G4AttCheck(rawPointAttValues,
750 aTrajectoryPoint->GetAttDefs()).Standard(pointAttValues,pointAttDefs);
751 if (error) {
752 G4cout << "G4HepRepFileSceneHandler::AddCompound(traj):"
753 "\nERROR found during conversion to standard point attributes." << G4endl;
754 }
755
756 // Write out point attribute values.
757 if (pointAttValues) {
758 for (iAttVal = pointAttValues->begin();
759 iAttVal != pointAttValues->end(); ++iAttVal)
760 // Do not write out the Aux or Pos attribute. Aux does not conform to the HepRep rule
761 // that each object can have only one instance of a given AttValue.
762 // Both of these attributes are redundant to actual position information of the point.
763 if (strcmp(iAttVal->GetName(),"Aux-X")!=0 &&
764 strcmp(iAttVal->GetName(),"Aux-Y")!=0 &&
765 strcmp(iAttVal->GetName(),"Aux-Z")!=0 &&
766 strcmp(iAttVal->GetName(),"Pos-X")!=0 &&
767 strcmp(iAttVal->GetName(),"Pos-Y")!=0 &&
768 strcmp(iAttVal->GetName(),"Pos-Z")!=0)
769 hepRepXMLWriter->addAttValue(iAttVal->GetName(), iAttVal->GetValue());
770 }
771 }
772
773 // Clean up point attributes.
774 delete pointAttDefs;
775 delete pointAttValues;
776 delete rawPointAttValues;
777
778 // Each trajectory point is made of a single primitive, a point.
779 hepRepXMLWriter->addPrimitive();
780 G4Point3D vertex = aTrajectoryPoint->GetPosition();
781 hepRepXMLWriter->addPoint(vertex.x(), vertex.y(), vertex.z());
782 }
783 }
784
785 // Draw Auxiliary Points
786 if (trajContext->GetDrawAuxPts()) {
787 if (!doneInitTraj)
789 // Create Trajectory Points as a subType of Trajectories.
790 // Note that we should create this heprep type even if there are no actual points.
791 // This allows the user to tell that points don't exist (admittedly odd) rather
792 // than that they were omitted by the drawing mode.
793 previousName = hepRepXMLWriter->prevTypeName[2];
794 hepRepXMLWriter->addType("Trajectory Auxiliary Points",2);
795
796 float redness;
797 float greenness;
798 float blueness;
799 G4int markSize;
800 G4bool visible;
801 G4bool square;
802 G4Colour colour = trajContext->GetAuxPtsColour();
803 redness = colour.GetRed();
804 greenness = colour.GetGreen();
805 blueness = colour.GetBlue();
806 markSize = (G4int) trajContext->GetAuxPtsSize();
807 visible = (G4int) trajContext->GetAuxPtsVisible();
808 square = (trajContext->GetAuxPtsType()==G4Polymarker::squares);
809
810 // Avoiding drawing anything black on black.
811 if (redness==0. && greenness==0. && blueness==0.) {
812 redness = 1.;
813 greenness = 1.;
814 blueness = 1.;
815 }
816
817 // Specify attributes common to all trajectory points.
818 if (strcmp("Trajectory Auxiliary Points",previousName)!=0) {
819 hepRepXMLWriter->addAttValue("DrawAs","Point");
820 hepRepXMLWriter->addAttValue("MarkColor", redness, greenness, blueness);
821 hepRepXMLWriter->addAttValue("MarkSize",markSize);
822 hepRepXMLWriter->addAttValue("Layer",110);
823 hepRepXMLWriter->addAttValue("Visibility",visible);
824 if (square)
825 hepRepXMLWriter->addAttValue("MarkName","Square");
826 else
827 hepRepXMLWriter->addAttValue("MarkName","Dot");
828 }
829
830 // Loop over all points on this trajectory.
831 for (i = 0; i < traj.GetPointEntries(); i++) {
832 G4VTrajectoryPoint* aTrajectoryPoint = traj.GetPoint(i);
833
834 // Each point is a separate instance of the type Trajectory Points.
835 hepRepXMLWriter->addInstance();
836
837 // Pointers to hold trajectory point attribute values and definitions.
838 std::vector<G4AttValue>* rawPointAttValues = aTrajectoryPoint->CreateAttValues();
839 std::vector<G4AttValue>* pointAttValues =
840 new std::vector<G4AttValue>;
841 std::map<G4String,G4AttDef>* pointAttDefs =
842 new std::map<G4String,G4AttDef>;
843
844 // Get trajectory point attributes and definitions in standard HepRep style
845 // (uniform units, 3Vectors decomposed).
846 if (rawPointAttValues) {
847 G4bool error = G4AttCheck(rawPointAttValues,
848 aTrajectoryPoint->GetAttDefs()).Standard(pointAttValues,pointAttDefs);
849 if (error) {
850 G4cout << "G4HepRepFileSceneHandler::AddCompound(traj):"
851 "\nERROR found during conversion to standard point attributes." << G4endl;
852 }
853
854 // Write out point attribute values.
855 if (pointAttValues) {
856 for (iAttVal = pointAttValues->begin();
857 iAttVal != pointAttValues->end(); ++iAttVal)
858 // Do not write out the Aux or Pos attribute. Aux does not conform to the HepRep rule
859 // that each object can have only one instance of a given AttValue.
860 // Both of these attributes are redundant to actual position information of the point.
861 if (strcmp(iAttVal->GetName(),"Aux-X")!=0 &&
862 strcmp(iAttVal->GetName(),"Aux-Y")!=0 &&
863 strcmp(iAttVal->GetName(),"Aux-Z")!=0 &&
864 strcmp(iAttVal->GetName(),"Pos-X")!=0 &&
865 strcmp(iAttVal->GetName(),"Pos-Y")!=0 &&
866 strcmp(iAttVal->GetName(),"Pos-Z")!=0)
867 hepRepXMLWriter->addAttValue(iAttVal->GetName(), iAttVal->GetValue());
868 }
869 }
870
871 // Clean up point attributes.
872 delete pointAttDefs;
873 delete pointAttValues;
874 delete rawPointAttValues;
875
876 // Each trajectory point is made of a single primitive, a point.
877 G4Point3D vertex = aTrajectoryPoint->GetPosition();
878
879 // Loop over auxiliary points associated with this Trajectory Point.
880 const std::vector<G4ThreeVector>* auxiliaries = aTrajectoryPoint->GetAuxiliaryPoints();
881 if (0 != auxiliaries) {
882 for (size_t iAux=0; iAux<auxiliaries->size(); ++iAux) {
883 const G4ThreeVector auxPos((*auxiliaries)[iAux]);
884 hepRepXMLWriter->addPrimitive();
885 hepRepXMLWriter->addPoint(auxPos.x(), auxPos.y(), auxPos.z());
886 }
887 }
888 }
889 }
890}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
int G4int
Definition: G4Types.hh:85
G4double GetBlue() const
Definition: G4Colour.hh:152
G4double GetRed() const
Definition: G4Colour.hh:150
G4double GetGreen() const
Definition: G4Colour.hh:151
void addPoint(double x, double y, double z)
virtual std::vector< G4AttValue > * CreateAttValues() const
virtual const std::vector< G4ThreeVector > * GetAuxiliaryPoints() const
virtual const G4ThreeVector GetPosition() const =0
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
virtual G4VTrajectoryPoint * GetPoint(G4int i) const =0
virtual G4int GetPointEntries() const =0
virtual std::vector< G4AttValue > * CreateAttValues() const
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
G4bool GetDrawAuxPts() const
G4Colour GetStepPtsColour() const
G4double GetStepPtsSize() const
G4Polymarker::MarkerType GetAuxPtsType() const
G4double GetAuxPtsSize() const
G4Colour GetAuxPtsColour() const
G4bool GetAuxPtsVisible() const
G4bool GetStepPtsVisible() const
G4Polymarker::MarkerType GetStepPtsType() const
G4bool GetDrawStepPts() const

◆ AddPrimitive() [1/7]

void G4HepRepFileSceneHandler::AddPrimitive ( const G4Circle circle)
virtual

Implements G4VSceneHandler.

Definition at line 1181 of file G4HepRepFileSceneHandler.cc.

1181 {
1182#ifdef G4HEPREPFILEDEBUG
1183 G4cout <<
1184 "G4HepRepFileSceneHandler::AddPrimitive(const G4Circle& circle) called:"
1185 "\n radius: " << circle.GetWorldRadius()
1186 << G4endl;
1187 PrintThings();
1188#endif
1189
1191
1192 if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && messenger->getCullInvisibles())
1193 return;
1194
1195 if (inPrimitives2D) {
1196 if (!warnedAbout2DMarkers) {
1197 G4cout << "HepRepFile does not currently support 2D circles." << G4endl;
1198 warnedAbout2DMarkers = true;
1199 }
1200 return;
1201 }
1202
1203 MarkerSizeType sizeType;
1204 G4double size = GetMarkerSize (circle, sizeType);
1205 if (sizeType==world)
1206 size = 4.;
1207
1208 if (drawingTraj)
1209 return;
1210
1211 if (drawingHit)
1212 InitHit();
1213
1214 haveVisible = true;
1215 AddHepRepInstance("Point", circle);
1216
1217 hepRepXMLWriter->addAttValue("MarkName", "Dot");
1218 hepRepXMLWriter->addAttValue("MarkSize", (G4int) size);
1219
1220 hepRepXMLWriter->addPrimitive();
1221
1222 G4Point3D center = (fObjectTransformation) * circle.GetPosition();
1223 hepRepXMLWriter->addPoint(center.x(), center.y(), center.z());
1224}
double G4double
Definition: G4Types.hh:83
virtual G4bool getCullInvisibles()
static G4HepRepMessenger * GetInstance()
G4Point3D GetPosition() const
G4double GetWorldRadius() const
G4Transform3D fObjectTransformation
G4double GetMarkerSize(const G4VMarker &, MarkerSizeType &)
const G4VisAttributes * fpVisAttribs
G4bool IsVisible() const

◆ AddPrimitive() [2/7]

void G4HepRepFileSceneHandler::AddPrimitive ( const G4Polyhedron polyhedron)
virtual

Implements G4VSceneHandler.

Definition at line 1273 of file G4HepRepFileSceneHandler.cc.

1273 {
1274#ifdef G4HEPREPFILEDEBUG
1275 G4cout <<
1276 "G4HepRepFileSceneHandler::AddPrimitive(const G4Polyhedron& polyhedron) called."
1277 << G4endl;
1278 PrintThings();
1279#endif
1280
1282
1283 if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && messenger->getCullInvisibles())
1284 return;
1285
1286 if(polyhedron.GetNoFacets()==0)return;
1287
1288 if (drawingTraj)
1289 return;
1290
1291 if (drawingHit)
1292 InitHit();
1293
1294 haveVisible = true;
1295 AddHepRepInstance("Polygon", polyhedron);
1296
1297 G4Normal3D surfaceNormal;
1298 G4Point3D vertex;
1299
1300 G4bool notLastFace;
1301 do {
1302 hepRepXMLWriter->addPrimitive();
1303 notLastFace = polyhedron.GetNextNormal (surfaceNormal);
1304
1305 G4int edgeFlag = 1;
1306 G4bool notLastEdge;
1307 do {
1308 notLastEdge = polyhedron.GetNextVertex (vertex, edgeFlag);
1309 vertex = (fObjectTransformation) * vertex;
1310 hepRepXMLWriter->addPoint(vertex.x(), vertex.y(), vertex.z());
1311 } while (notLastEdge);
1312 } while (notLastFace);
1313}
G4bool GetNextNormal(G4Normal3D &normal) const
G4bool GetNextVertex(G4Point3D &vertex, G4int &edgeFlag) const
G4int GetNoFacets() const

◆ AddPrimitive() [3/7]

void G4HepRepFileSceneHandler::AddPrimitive ( const G4Polyline polyline)
virtual

Implements G4VSceneHandler.

Definition at line 1037 of file G4HepRepFileSceneHandler.cc.

1037 {
1038#ifdef G4HEPREPFILEDEBUG
1039 G4cout <<
1040 "G4HepRepFileSceneHandler::AddPrimitive(const G4Polyline& polyline) called:"
1041 "\n polyline: " << polyline
1042 << G4endl;
1043 PrintThings();
1044#endif
1045
1047
1048 if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && messenger->getCullInvisibles())
1049 return;
1050
1051 if (inPrimitives2D) {
1052 if (!warnedAbout2DMarkers) {
1053 G4cout << "HepRepFile does not currently support 2D lines." << G4endl;
1054 warnedAbout2DMarkers = true;
1055 }
1056 return;
1057 }
1058
1059 if (drawingTraj)
1061
1062 if (drawingHit)
1063 InitHit();
1064
1065 haveVisible = true;
1066 AddHepRepInstance("Line", polyline);
1067
1068 hepRepXMLWriter->addPrimitive();
1069
1070 for (size_t i=0; i < polyline.size(); i++) {
1071 G4Point3D vertex = (fObjectTransformation) * polyline[i];
1072 hepRepXMLWriter->addPoint(vertex.x(), vertex.y(), vertex.z());
1073 }
1074}

◆ AddPrimitive() [4/7]

void G4HepRepFileSceneHandler::AddPrimitive ( const G4Polymarker line)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 1078 of file G4HepRepFileSceneHandler.cc.

1078 {
1079#ifdef G4HEPREPFILEDEBUG
1080 G4cout <<
1081 "G4HepRepFileSceneHandler::AddPrimitive(const G4Polymarker& line) called"
1082 << G4endl;
1083 PrintThings();
1084#endif
1085
1087
1088 if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && messenger->getCullInvisibles())
1089 return;
1090
1091 if (inPrimitives2D) {
1092 if (!warnedAbout2DMarkers) {
1093 G4cout << "HepRepFile does not currently support 2D lines." << G4endl;
1094 warnedAbout2DMarkers = true;
1095 }
1096 return;
1097 }
1098
1099 MarkerSizeType sizeType;
1100 G4double size = GetMarkerSize (line, sizeType);
1101 if (sizeType==world)
1102 size = 4.;
1103
1104 if (drawingTraj)
1105 return;
1106
1107 if (drawingHit)
1108 InitHit();
1109
1110 haveVisible = true;
1111 AddHepRepInstance("Point", line);
1112
1113 hepRepXMLWriter->addAttValue("MarkName", "Dot");
1114 hepRepXMLWriter->addAttValue("MarkSize", (G4int) size);
1115
1116 hepRepXMLWriter->addPrimitive();
1117
1118 for (size_t i=0; i < line.size(); i++) {
1119 G4Point3D vertex = (fObjectTransformation) * line[i];
1120 hepRepXMLWriter->addPoint(vertex.x(), vertex.y(), vertex.z());
1121 }
1122}

◆ AddPrimitive() [5/7]

void G4HepRepFileSceneHandler::AddPrimitive ( const G4Scale scale)
inlinevirtual

Reimplemented from G4VSceneHandler.

Definition at line 113 of file G4HepRepFileSceneHandler.hh.

113 {
115 }
virtual void AddPrimitive(const G4Polyline &)=0

◆ AddPrimitive() [6/7]

void G4HepRepFileSceneHandler::AddPrimitive ( const G4Square square)
virtual

Implements G4VSceneHandler.

Definition at line 1227 of file G4HepRepFileSceneHandler.cc.

1227 {
1228#ifdef G4HEPREPFILEDEBUG
1229 G4cout <<
1230 "G4HepRepFileSceneHandler::AddPrimitive(const G4Square& square) called:"
1231 "\n side: " << square.GetWorldRadius()
1232 << G4endl;
1233 PrintThings();
1234#endif
1235
1237
1238 if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && messenger->getCullInvisibles())
1239 return;
1240
1241 if (inPrimitives2D) {
1242 if (!warnedAbout2DMarkers) {
1243 G4cout << "HepRepFile does not currently support 2D squares." << G4endl;
1244 warnedAbout2DMarkers = true;
1245 }
1246 return;
1247 }
1248
1249 MarkerSizeType sizeType;
1250 G4double size = GetMarkerSize (square, sizeType);
1251 if (sizeType==world)
1252 size = 4.;
1253
1254 if (drawingTraj)
1255 return;
1256
1257 if (drawingHit)
1258 InitHit();
1259
1260 haveVisible = true;
1261 AddHepRepInstance("Point", square);
1262
1263 hepRepXMLWriter->addAttValue("MarkName", "Square");
1264 hepRepXMLWriter->addAttValue("MarkSize", (G4int) size);
1265
1266 hepRepXMLWriter->addPrimitive();
1267
1268 G4Point3D center = (fObjectTransformation) * square.GetPosition();
1269 hepRepXMLWriter->addPoint(center.x(), center.y(), center.z());
1270}

◆ AddPrimitive() [7/7]

void G4HepRepFileSceneHandler::AddPrimitive ( const G4Text text)
virtual

Implements G4VSceneHandler.

Definition at line 1125 of file G4HepRepFileSceneHandler.cc.

1125 {
1126#ifdef G4HEPREPFILEDEBUG
1127 G4cout <<
1128 "G4HepRepFileSceneHandler::AddPrimitive(const G4Text& text) called:"
1129 "\n text: " << text.GetText()
1130 << G4endl;
1131 PrintThings();
1132#endif
1133
1134 if (!inPrimitives2D) {
1135 if (!warnedAbout3DText) {
1136 G4cout << "HepRepFile does not currently support 3D text." << G4endl;
1137 G4cout << "HepRep browsers can directly display text attributes on request." << G4endl;
1138 G4cout << "See Application Developers Guide for how to attach attributes to viewable objects." << G4endl;
1139 warnedAbout3DText = true;
1140 }
1141 return;
1142 }
1143
1144 MarkerSizeType sizeType;
1145 G4double size = GetMarkerSize (text, sizeType);
1146 if (sizeType==world)
1147 size = 12.;
1148
1149 haveVisible = true;
1150 AddHepRepInstance("Text", text);
1151
1152 hepRepXMLWriter->addAttValue("VAlign", "Top");
1153 hepRepXMLWriter->addAttValue("HAlign", "Left");
1154 hepRepXMLWriter->addAttValue("FontName", "Arial");
1155 hepRepXMLWriter->addAttValue("FontStyle", "Plain");
1156 hepRepXMLWriter->addAttValue("FontSize", (G4int) size);
1157 hepRepXMLWriter->addAttValue("FontHasBanner", "TRUE");
1158 hepRepXMLWriter->addAttValue("FontBannerColor", "0,0,0");
1159
1160 const G4Colour& colour = GetTextColour(text);
1161 float redness = colour.GetRed();
1162 float greenness = colour.GetGreen();
1163 float blueness = colour.GetBlue();
1164
1165 // Avoiding drawing anything black on black.
1166 if (redness==0. && greenness==0. && blueness==0.) {
1167 redness = 1.;
1168 greenness = 1.;
1169 blueness = 1.;
1170 }
1171 hepRepXMLWriter->addAttValue("FontColor",redness,greenness,blueness);
1172
1173 hepRepXMLWriter->addPrimitive();
1174
1175 hepRepXMLWriter->addAttValue("Text", text.GetText());
1176 hepRepXMLWriter->addAttValue("VPos", .99-text.GetYOffset());
1177 hepRepXMLWriter->addAttValue("HPos", text.GetXOffset());
1178}
G4double GetYOffset() const
G4double GetXOffset() const
G4String GetText() const
const G4Colour & GetTextColour(const G4Text &)

◆ AddSolid() [1/14]

void G4HepRepFileSceneHandler::AddSolid ( const G4Box box)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 150 of file G4HepRepFileSceneHandler.cc.

150 {
151#ifdef G4HEPREPFILEDEBUG
152 G4cout <<
153 "G4HepRepFileSceneHandler::AddSolid(const G4Box& box) called for "
154 << box.GetName()
155 << G4endl;
156 PrintThings();
157#endif
158
159 if (drawingTraj)
160 return;
161
162 if (drawingHit)
163 InitHit();
164
165 haveVisible = false;
166 AddHepRepInstance("Prism", NULL);
167
169
170 // Get and check applicable vis attributes.
172 if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && messenger->getCullInvisibles())
173 return;
174
175 hepRepXMLWriter->addPrimitive();
176
177 G4double dx = box.GetXHalfLength();
178 G4double dy = box.GetYHalfLength();
179 G4double dz = box.GetZHalfLength();
180
181 G4Point3D vertex1(G4Point3D( dx, dy,-dz));
182 G4Point3D vertex2(G4Point3D( dx,-dy,-dz));
183 G4Point3D vertex3(G4Point3D(-dx,-dy,-dz));
184 G4Point3D vertex4(G4Point3D(-dx, dy,-dz));
185 G4Point3D vertex5(G4Point3D( dx, dy, dz));
186 G4Point3D vertex6(G4Point3D( dx,-dy, dz));
187 G4Point3D vertex7(G4Point3D(-dx,-dy, dz));
188 G4Point3D vertex8(G4Point3D(-dx, dy, dz));
189
190 vertex1 = (fObjectTransformation) * vertex1;
191 vertex2 = (fObjectTransformation) * vertex2;
192 vertex3 = (fObjectTransformation) * vertex3;
193 vertex4 = (fObjectTransformation) * vertex4;
194 vertex5 = (fObjectTransformation) * vertex5;
195 vertex6 = (fObjectTransformation) * vertex6;
196 vertex7 = (fObjectTransformation) * vertex7;
197 vertex8 = (fObjectTransformation) * vertex8;
198
199 hepRepXMLWriter->addPoint(vertex1.x(), vertex1.y(), vertex1.z());
200 hepRepXMLWriter->addPoint(vertex2.x(), vertex2.y(), vertex2.z());
201 hepRepXMLWriter->addPoint(vertex3.x(), vertex3.y(), vertex3.z());
202 hepRepXMLWriter->addPoint(vertex4.x(), vertex4.y(), vertex4.z());
203 hepRepXMLWriter->addPoint(vertex5.x(), vertex5.y(), vertex5.z());
204 hepRepXMLWriter->addPoint(vertex6.x(), vertex6.y(), vertex6.z());
205 hepRepXMLWriter->addPoint(vertex7.x(), vertex7.y(), vertex7.z());
206 hepRepXMLWriter->addPoint(vertex8.x(), vertex8.y(), vertex8.z());
207}
HepGeom::Point3D< G4double > G4Point3D
Definition: G4Point3D.hh:34
G4double GetYHalfLength() const
G4double GetZHalfLength() const
G4double GetXHalfLength() const
G4VViewer * fpViewer
G4String GetName() const
const G4VisAttributes * GetApplicableVisAttributes(const G4VisAttributes *) const

◆ AddSolid() [2/14]

void G4HepRepFileSceneHandler::AddSolid ( const G4Cons cons)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 210 of file G4HepRepFileSceneHandler.cc.

210 {
211#ifdef G4HEPREPFILEDEBUG
212 G4cout <<
213 "G4HepRepFileSceneHandler::AddSolid(const G4Cons& cons) called for "
214 << cons.GetName()
215 << G4endl;
216 PrintThings();
217#endif
218
219 // HepRApp does not correctly represent the end faces of cones at
220 // non-standard angles, let the base class convert these solids to polygons.
222 G4bool linedUpWithAnAxis = (std::fabs(r.phiX())<=.001 ||
223 std::fabs(r.phiY())<=.001 ||
224 std::fabs(r.phiZ())<=.001 ||
225 std::fabs(r.phiX()-pi)<=.001 ||
226 std::fabs(r.phiY()-pi)<=.001 ||
227 std::fabs(r.phiZ()-pi)<=.001);
228 //G4cout << "Angle X:" << r.phiX() << ", Angle Y:" << r.phiY() << ", Angle Z:" << r.phiZ() << G4endl;
229 //G4cout << "linedUpWithAnAxis:" << linedUpWithAnAxis << G4endl;
230
231 // HepRep does not have a primitive for a cut cone,
232 // so if this cone is cut, let the base class convert this
233 // solid to polygons.
235 if (cons.GetDeltaPhiAngle() < twopi || !linedUpWithAnAxis || messenger->renderCylAsPolygons())
236 {
237 G4VSceneHandler::AddSolid(cons); // Invoke default action.
238 } else {
239
240 if (drawingTraj)
241 return;
242
243 if (drawingHit)
244 InitHit();
245
246 haveVisible = false;
247 AddHepRepInstance("Cylinder", NULL);
248
249 // Get and check applicable vis attributes.
251 if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && messenger->getCullInvisibles())
252 return;
253
254 G4Point3D vertex1(G4Point3D( 0., 0., -cons.GetZHalfLength()));
255 G4Point3D vertex2(G4Point3D( 0., 0., cons.GetZHalfLength()));
256
257 vertex1 = (fObjectTransformation) * vertex1;
258 vertex2 = (fObjectTransformation) * vertex2;
259
260 // Outer cylinder.
261 hepRepXMLWriter->addPrimitive();
262 hepRepXMLWriter->addAttValue("Radius1",messenger->getScale() * cons.GetOuterRadiusMinusZ());
263 hepRepXMLWriter->addAttValue("Radius2",messenger->getScale() * cons.GetOuterRadiusPlusZ());
264 hepRepXMLWriter->addPoint(vertex1.x(), vertex1.y(), vertex1.z());
265 hepRepXMLWriter->addPoint(vertex2.x(), vertex2.y(), vertex2.z());
266
267 // Inner cylinder.
268 hepRepXMLWriter->addPrimitive();
269 hepRepXMLWriter->addAttValue("Radius1",messenger->getScale() * cons.GetInnerRadiusMinusZ());
270 hepRepXMLWriter->addAttValue("Radius2",messenger->getScale() * cons.GetInnerRadiusPlusZ());
271 hepRepXMLWriter->addPoint(vertex1.x(), vertex1.y(), vertex1.z());
272 hepRepXMLWriter->addPoint(vertex2.x(), vertex2.y(), vertex2.z());
273 }
274}
double phiY() const
Definition: Rotation.cc:128
double phiX() const
Definition: Rotation.cc:124
double phiZ() const
Definition: Rotation.cc:132
G4double GetOuterRadiusPlusZ() const
G4double GetDeltaPhiAngle() const
G4double GetInnerRadiusMinusZ() const
G4double GetInnerRadiusPlusZ() const
G4double GetOuterRadiusMinusZ() const
G4double GetZHalfLength() const
virtual G4bool renderCylAsPolygons()
virtual G4double getScale()
virtual void AddSolid(const G4Box &)
CLHEP::HepRotation getRotation() const

◆ AddSolid() [3/14]

void G4HepRepFileSceneHandler::AddSolid ( const G4Ellipsoid ellipsoid)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 492 of file G4HepRepFileSceneHandler.cc.

492 {
493#ifdef G4HEPREPFILEDEBUG
494 G4cout <<
495 "G4HepRepFileSceneHandler::AddSolid(const G4Ellipsoid& ellipsoid) called for "
496 << ellipsoid.GetName()
497 << G4endl;
498 PrintThings();
499#endif
500 G4VSceneHandler::AddSolid(ellipsoid); // Invoke default action.
501}

◆ AddSolid() [4/14]

void G4HepRepFileSceneHandler::AddSolid ( const G4Orb orb)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 480 of file G4HepRepFileSceneHandler.cc.

480 {
481#ifdef G4HEPREPFILEDEBUG
482 G4cout <<
483 "G4HepRepFileSceneHandler::AddSolid(const G4Orb& orb) called for "
484 << orb.GetName()
485 << G4endl;
486 PrintThings();
487#endif
488 G4VSceneHandler::AddSolid(orb); // Invoke default action.
489}

◆ AddSolid() [5/14]

void G4HepRepFileSceneHandler::AddSolid ( const G4Para para)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 432 of file G4HepRepFileSceneHandler.cc.

432 {
433#ifdef G4HEPREPFILEDEBUG
434 G4cout <<
435 "G4HepRepFileSceneHandler::AddSolid(const G4Para& para) called for "
436 << para.GetName()
437 << G4endl;
438 PrintThings();
439#endif
440 G4VSceneHandler::AddSolid(para); // Invoke default action.
441}

◆ AddSolid() [6/14]

void G4HepRepFileSceneHandler::AddSolid ( const G4Polycone polycone)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 456 of file G4HepRepFileSceneHandler.cc.

456 {
457#ifdef G4HEPREPFILEDEBUG
458 G4cout <<
459 "G4HepRepFileSceneHandler::AddSolid(const G4Polycone& polycone) called for "
460 << polycone.GetName()
461 << G4endl;
462 PrintThings();
463#endif
464 G4VSceneHandler::AddSolid(polycone); // Invoke default action.
465}

◆ AddSolid() [7/14]

void G4HepRepFileSceneHandler::AddSolid ( const G4Polyhedra polyhedra)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 468 of file G4HepRepFileSceneHandler.cc.

468 {
469#ifdef G4HEPREPFILEDEBUG
470 G4cout <<
471 "G4HepRepFileSceneHandler::AddSolid(const G4Polyhedra& polyhedra) called for "
472 << polyhedra.GetName()
473 << G4endl;
474 PrintThings();
475#endif
476 G4VSceneHandler::AddSolid(polyhedra); // Invoke default action.
477}

◆ AddSolid() [8/14]

void G4HepRepFileSceneHandler::AddSolid ( const G4Sphere sphere)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 420 of file G4HepRepFileSceneHandler.cc.

420 {
421#ifdef G4HEPREPFILEDEBUG
422 G4cout <<
423 "G4HepRepFileSceneHandler::AddSolid(const G4Sphere& sphere) called for "
424 << sphere.GetName()
425 << G4endl;
426 PrintThings();
427#endif
428 G4VSceneHandler::AddSolid(sphere); // Invoke default action.
429}

◆ AddSolid() [9/14]

void G4HepRepFileSceneHandler::AddSolid ( const G4TessellatedSolid tess)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 504 of file G4HepRepFileSceneHandler.cc.

504 {
505#ifdef G4HEPREPFILEDEBUG
506 G4cout <<
507 "G4HepRepFileSceneHandler::AddSolid(const G4TessellatedSolid& ) called for "
508 << tess.GetName()
509 << G4endl;
510 PrintThings();
511#endif
512 G4VSceneHandler::AddSolid(tess); // Invoke default action.
513}

◆ AddSolid() [10/14]

void G4HepRepFileSceneHandler::AddSolid ( const G4Torus torus)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 444 of file G4HepRepFileSceneHandler.cc.

444 {
445#ifdef G4HEPREPFILEDEBUG
446 G4cout <<
447 "G4HepRepFileSceneHandler::AddSolid(const G4Torus& torus) called for "
448 << torus.GetName()
449 << G4endl;
450 PrintThings();
451#endif
452 G4VSceneHandler::AddSolid(torus); // Invoke default action.
453}

◆ AddSolid() [11/14]

void G4HepRepFileSceneHandler::AddSolid ( const G4Trap trap)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 408 of file G4HepRepFileSceneHandler.cc.

408 {
409#ifdef G4HEPREPFILEDEBUG
410 G4cout <<
411 "G4HepRepFileSceneHandler::AddSolid(const G4Trap& trap) called for "
412 << trap.GetName()
413 << G4endl;
414 PrintThings();
415#endif
416 G4VSceneHandler::AddSolid(trap); // Invoke default action.
417}

◆ AddSolid() [12/14]

void G4HepRepFileSceneHandler::AddSolid ( const G4Trd trd)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 346 of file G4HepRepFileSceneHandler.cc.

346 {
347#ifdef G4HEPREPFILEDEBUG
348 G4cout <<
349 "G4HepRepFileSceneHandler::AddSolid(const G4Trd& trd) called for "
350 << trd.GetName()
351 << G4endl;
352 PrintThings();
353#endif
354
355 if (drawingTraj)
356 return;
357
358 if (drawingHit)
359 InitHit();
360
361 haveVisible = false;
362 AddHepRepInstance("Prism", NULL);
363
365
366 // Get and check applicable vis attributes.
368 if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && messenger->getCullInvisibles())
369 return;
370
371 hepRepXMLWriter->addPrimitive();
372
373 G4double dx1 = trd.GetXHalfLength1();
374 G4double dy1 = trd.GetYHalfLength1();
375 G4double dx2 = trd.GetXHalfLength2();
376 G4double dy2 = trd.GetYHalfLength2();
377 G4double dz = trd.GetZHalfLength();
378
379 G4Point3D vertex1(G4Point3D( dx1, dy1,-dz));
380 G4Point3D vertex2(G4Point3D( dx1,-dy1,-dz));
381 G4Point3D vertex3(G4Point3D(-dx1,-dy1,-dz));
382 G4Point3D vertex4(G4Point3D(-dx1, dy1,-dz));
383 G4Point3D vertex5(G4Point3D( dx2, dy2, dz));
384 G4Point3D vertex6(G4Point3D( dx2,-dy2, dz));
385 G4Point3D vertex7(G4Point3D(-dx2,-dy2, dz));
386 G4Point3D vertex8(G4Point3D(-dx2, dy2, dz));
387
388 vertex1 = (fObjectTransformation) * vertex1;
389 vertex2 = (fObjectTransformation) * vertex2;
390 vertex3 = (fObjectTransformation) * vertex3;
391 vertex4 = (fObjectTransformation) * vertex4;
392 vertex5 = (fObjectTransformation) * vertex5;
393 vertex6 = (fObjectTransformation) * vertex6;
394 vertex7 = (fObjectTransformation) * vertex7;
395 vertex8 = (fObjectTransformation) * vertex8;
396
397 hepRepXMLWriter->addPoint(vertex1.x(), vertex1.y(), vertex1.z());
398 hepRepXMLWriter->addPoint(vertex2.x(), vertex2.y(), vertex2.z());
399 hepRepXMLWriter->addPoint(vertex3.x(), vertex3.y(), vertex3.z());
400 hepRepXMLWriter->addPoint(vertex4.x(), vertex4.y(), vertex4.z());
401 hepRepXMLWriter->addPoint(vertex5.x(), vertex5.y(), vertex5.z());
402 hepRepXMLWriter->addPoint(vertex6.x(), vertex6.y(), vertex6.z());
403 hepRepXMLWriter->addPoint(vertex7.x(), vertex7.y(), vertex7.z());
404 hepRepXMLWriter->addPoint(vertex8.x(), vertex8.y(), vertex8.z());
405}
G4double GetXHalfLength2() const
G4double GetYHalfLength2() const
G4double GetXHalfLength1() const
G4double GetYHalfLength1() const
G4double GetZHalfLength() const

◆ AddSolid() [13/14]

void G4HepRepFileSceneHandler::AddSolid ( const G4Tubs tubs)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 277 of file G4HepRepFileSceneHandler.cc.

277 {
278#ifdef G4HEPREPFILEDEBUG
279 G4cout <<
280 "G4HepRepFileSceneHandler::AddSolid(const G4Tubs& tubs) called for "
281 << tubs.GetName()
282 << G4endl;
283 PrintThings();
284#endif
285
286 // HepRApp does not correctly represent the end faces of cylinders at
287 // non-standard angles, let the base class convert these solids to polygons.
289 G4bool linedUpWithAnAxis = (std::fabs(r.phiX())<=.001 ||
290 std::fabs(r.phiY())<=.001 ||
291 std::fabs(r.phiZ())<=.001 ||
292 std::fabs(r.phiX()-pi)<=.001 ||
293 std::fabs(r.phiY()-pi)<=.001 ||
294 std::fabs(r.phiZ()-pi)<=.001);
295 //G4cout << "Angle X:" << r.phiX() << ", Angle Y:" << r.phiY() << ", Angle Z:" << r.phiZ() << G4endl;
296 //G4cout << "linedUpWithAnAxis:" << linedUpWithAnAxis << G4endl;
297
298 // HepRep does not have a primitive for a cut cylinder,
299 // so if this cylinder is cut, let the base class convert this
300 // solid to polygons.
302 if (tubs.GetDeltaPhiAngle() < twopi || !linedUpWithAnAxis || messenger->renderCylAsPolygons())
303 {
304 G4VSceneHandler::AddSolid(tubs); // Invoke default action.
305 } else {
306
307 if (drawingTraj)
308 return;
309
310 if (drawingHit)
311 InitHit();
312
313 haveVisible = false;
314 AddHepRepInstance("Cylinder", NULL);
315
316 // Get and check applicable vis attributes.
318 if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && messenger->getCullInvisibles())
319 return;
320
321 G4Point3D vertex1(G4Point3D( 0., 0., -tubs.GetZHalfLength()));
322 G4Point3D vertex2(G4Point3D( 0., 0., tubs.GetZHalfLength()));
323
324 vertex1 = (fObjectTransformation) * vertex1;
325 vertex2 = (fObjectTransformation) * vertex2;
326
327 // Outer cylinder.
328 hepRepXMLWriter->addPrimitive();
329 hepRepXMLWriter->addAttValue("Radius1", messenger->getScale() * tubs.GetOuterRadius());
330 hepRepXMLWriter->addAttValue("Radius2", messenger->getScale() * tubs.GetOuterRadius());
331 hepRepXMLWriter->addPoint(vertex1.x(), vertex1.y(), vertex1.z());
332 hepRepXMLWriter->addPoint(vertex2.x(), vertex2.y(), vertex2.z());
333
334 // Inner cylinder.
335 if (tubs.GetInnerRadius() != 0.) {
336 hepRepXMLWriter->addPrimitive();
337 hepRepXMLWriter->addAttValue("Radius1", messenger->getScale() * tubs.GetInnerRadius());
338 hepRepXMLWriter->addAttValue("Radius2", messenger->getScale() * tubs.GetInnerRadius());
339 hepRepXMLWriter->addPoint(vertex1.x(), vertex1.y(), vertex1.z());
340 hepRepXMLWriter->addPoint(vertex2.x(), vertex2.y(), vertex2.z());
341 }
342 }
343}
G4double GetZHalfLength() const
G4double GetInnerRadius() const
G4double GetOuterRadius() const
G4double GetDeltaPhiAngle() const

◆ AddSolid() [14/14]

void G4HepRepFileSceneHandler::AddSolid ( const G4VSolid solid)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 516 of file G4HepRepFileSceneHandler.cc.

516 {
517#ifdef G4HEPREPFILEDEBUG
518 G4cout <<
519 "G4HepRepFileSceneHandler::AddSolid(const G4Solid& solid) called for "
520 << solid.GetName()
521 << G4endl;
522 PrintThings();
523#endif
524 G4VSceneHandler::AddSolid(solid); // Invoke default action.
525}

◆ BeginModeling()

void G4HepRepFileSceneHandler::BeginModeling ( )
virtual

Reimplemented from G4VSceneHandler.

Definition at line 95 of file G4HepRepFileSceneHandler.cc.

95 {
97 const G4VTrajectoryModel* model = visManager->CurrentTrajDrawModel();
98 trajContext = & model->GetContext();
99
100 G4VSceneHandler::BeginModeling(); // Required: see G4VSceneHandler.hh.
101}
virtual void BeginModeling()
const G4VisTrajContext & GetContext() const
const G4VTrajectoryModel * CurrentTrajDrawModel() const
static G4VisManager * GetInstance()

◆ BeginPrimitives2D()

void G4HepRepFileSceneHandler::BeginPrimitives2D ( const G4Transform3D objectTransformation)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 108 of file G4HepRepFileSceneHandler.cc.

109 {
110#ifdef G4HEPREPFILEDEBUG
111 G4cout << "G4HepRepFileSceneHandler::BeginPrimitives2D() " << G4endl;
112#endif
113 inPrimitives2D = true;
114 G4VSceneHandler::BeginPrimitives2D(objectTransformation);
115}
virtual void BeginPrimitives2D(const G4Transform3D &objectTransformation=G4Transform3D())

◆ ClearTransientStore()

void G4HepRepFileSceneHandler::ClearTransientStore ( )
virtual

Reimplemented from G4VSceneHandler.

Definition at line 1591 of file G4HepRepFileSceneHandler.cc.

1591 {
1592 // This is typically called after an update and before drawing hits
1593 // of the next event. To simulate the clearing of "transients"
1594 // (hits, etc.) the detector is redrawn...
1595 if (fpViewer) {
1596 fpViewer -> SetView();
1597 fpViewer -> ClearView();
1598 fpViewer -> DrawView();
1599 }
1600}

◆ EndModeling()

void G4HepRepFileSceneHandler::EndModeling ( )
virtual

Reimplemented from G4VSceneHandler.

Definition at line 104 of file G4HepRepFileSceneHandler.cc.

104 {
105 G4VSceneHandler::EndModeling(); // Required: see G4VSceneHandler.hh.
106}
virtual void EndModeling()

◆ EndPrimitives2D()

void G4HepRepFileSceneHandler::EndPrimitives2D ( )
virtual

Reimplemented from G4VSceneHandler.

Definition at line 117 of file G4HepRepFileSceneHandler.cc.

117 {
118#ifdef G4HEPREPFILEDEBUG
119 G4cout << "G4HepRepFileSceneHandler::EndPrimitives2D() " << G4endl;
120#endif
122 inPrimitives2D = false;
123}
virtual void EndPrimitives2D()

◆ GetHepRepXMLWriter()

G4HepRepFileXMLWriter * G4HepRepFileSceneHandler::GetHepRepXMLWriter ( )

Definition at line 1316 of file G4HepRepFileSceneHandler.cc.

1316 {
1317 return hepRepXMLWriter;
1318}

Referenced by G4HepRepFileSceneHandler().

◆ InitHit()

void G4HepRepFileSceneHandler::InitHit ( )

Definition at line 1014 of file G4HepRepFileSceneHandler.cc.

1014 {
1015 if (!doneInitHit) {
1016 // For every hit, add an instance of Type Hit.
1017 hepRepXMLWriter->addInstance();
1018
1019 // Write out the hit's attribute values.
1020 if (hitAttValues) {
1021 std::vector<G4AttValue>::iterator iAttVal;
1022 for (iAttVal = hitAttValues->begin();
1023 iAttVal != hitAttValues->end(); ++iAttVal)
1024 hepRepXMLWriter->addAttValue(iAttVal->GetName(), iAttVal->GetValue());
1025 delete hitAttValues;
1026 }
1027
1028 // Clean up hit attributes.
1029 if (hitAttDefs)
1030 delete hitAttDefs;
1031
1032 doneInitHit = true;
1033 }
1034}

Referenced by AddPrimitive(), and AddSolid().

◆ InitTrajectory()

void G4HepRepFileSceneHandler::InitTrajectory ( )

Definition at line 991 of file G4HepRepFileSceneHandler.cc.

991 {
992 if (!doneInitTraj) {
993 // For every trajectory, add an instance of Type Trajectory.
994 hepRepXMLWriter->addInstance();
995
996 // Write out the trajectory's attribute values.
997 if (trajAttValues) {
998 std::vector<G4AttValue>::iterator iAttVal;
999 for (iAttVal = trajAttValues->begin();
1000 iAttVal != trajAttValues->end(); ++iAttVal)
1001 hepRepXMLWriter->addAttValue(iAttVal->GetName(), iAttVal->GetValue());
1002 delete trajAttValues;
1003 }
1004
1005 // Clean up trajectory attributes.
1006 if (trajAttDefs)
1007 delete trajAttDefs;
1008
1009 doneInitTraj = true;
1010 }
1011}

Referenced by AddCompound(), and AddPrimitive().

Member Data Documentation

◆ fSceneIdCount

G4int G4HepRepFileSceneHandler::fSceneIdCount = 0
staticprotected

Definition at line 141 of file G4HepRepFileSceneHandler.hh.


The documentation for this class was generated from the following files: