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

#include <G4OpenGLSceneHandler.hh>

+ Inheritance diagram for G4OpenGLSceneHandler:

Public Types

enum  FlushAction {
  endOfEvent , endOfRun , eachPrimitive , NthPrimitive ,
  NthEvent , never
}
 
- Public Types inherited from G4VSceneHandler
enum  MarkerSizeType { world , screen }
 

Public Member Functions

virtual void BeginPrimitives (const G4Transform3D &objectTransformation)
 
virtual void EndPrimitives ()
 
virtual void BeginPrimitives2D (const G4Transform3D &objectTransformation)
 
virtual void EndPrimitives2D ()
 
void AddPrimitive (const G4Polyline &)
 
void AddPrimitive (const G4Polymarker &)
 
void AddPrimitive (const G4Text &)
 
void AddPrimitive (const G4Circle &)
 
void AddPrimitive (const G4Square &)
 
void AddPrimitivesCircle (const std::vector< G4VMarker > &)
 
void AddPrimitivesSquare (const std::vector< G4VMarker > &)
 
void AddPrimitive (const G4Polyhedron &)
 
void PreAddSolid (const G4Transform3D &objectTransformation, const G4VisAttributes &)
 
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 AddCompound (const G4VHit &)
 
void AddCompound (const G4VDigi &)
 
void AddCompound (const G4THitsMap< G4double > &)
 
void AddCompound (const G4THitsMap< G4StatDouble > &)
 
void AddCompound (const G4Mesh &)
 
virtual void AddPrimitive (const G4Polyline &)=0
 
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 void AddPrimitive (const G4Plotter &)
 
- 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 AddCompound (const G4Mesh &)
 
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 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 void AddPrimitive (const G4Plotter &)
 
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 G4ColourGetColour (const G4Visible &)
 
const G4ColourGetColor (const G4Visible &)
 
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 AddCompound (const G4Mesh &)=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 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 void AddPrimitive (const G4Plotter &)=0
 
virtual const G4VisExtentGetExtent () const
 

Static Public Member Functions

static G4int GetEntitiesFlushInterval ()
 
static FlushAction GetFlushAction ()
 
static void SetEntitiesFlushInterval (G4int interval)
 
static void SetFlushAction (FlushAction action)
 

Protected Member Functions

 G4OpenGLSceneHandler (G4VGraphicsSystem &system, G4int id, const G4String &name="")
 
virtual ~G4OpenGLSceneHandler ()
 
void ProcessScene ()
 
G4DisplacedSolidCreateSectionSolid ()
 
G4DisplacedSolidCreateCutawaySolid ()
 
void ClearAndDestroyAtts ()
 
void ScaledFlush ()
 
- Protected Member Functions inherited from G4VSceneHandler
virtual void ProcessScene ()
 
virtual void RequestPrimitives (const G4VSolid &solid)
 
virtual G4DisplacedSolidCreateSectionSolid ()
 
virtual G4DisplacedSolidCreateCutawaySolid ()
 
void LoadAtts (const G4Visible &, G4AttHolder *)
 
void StandardSpecialMeshRendering (const G4Mesh &)
 
void Draw3DRectMeshAsDots (const G4Mesh &)
 
void Draw3DRectMeshAsSurfaces (const G4Mesh &)
 
void DrawTetMeshAsDots (const G4Mesh &)
 
void DrawTetMeshAsSurfaces (const G4Mesh &)
 
G4ThreeVector GetPointInBox (const G4ThreeVector &pos, G4double halfX, G4double halfY, G4double halfZ) const
 
G4ThreeVector GetPointInTet (const std::vector< G4ThreeVector > &vertices) const
 

Protected Attributes

GLuint fPickName
 
std::map< GLuint, G4AttHolder * > fPickMap
 
G4bool fThreePassCapable
 
G4bool fSecondPassForTransparencyRequested
 
G4bool fSecondPassForTransparency
 
G4bool fThirdPassForNonHiddenMarkersRequested
 
G4bool fThirdPassForNonHiddenMarkers
 
bool fEdgeFlag
 
- 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
 

Static Protected Attributes

static FlushAction fFlushAction = G4OpenGLSceneHandler::NthEvent
 
static G4int fEntitiesFlushInterval = 100
 
static const GLubyte fStippleMaskHashed [128]
 

Friends

class G4OpenGLViewer
 

Detailed Description

Definition at line 46 of file G4OpenGLSceneHandler.hh.

Member Enumeration Documentation

◆ FlushAction

Enumerator
endOfEvent 
endOfRun 
eachPrimitive 
NthPrimitive 
NthEvent 
never 

Definition at line 89 of file G4OpenGLSceneHandler.hh.

Constructor & Destructor Documentation

◆ G4OpenGLSceneHandler()

G4OpenGLSceneHandler::G4OpenGLSceneHandler ( G4VGraphicsSystem system,
G4int  id,
const G4String name = "" 
)
protected

Definition at line 83 of file G4OpenGLSceneHandler.cc.

85 :
86G4VSceneHandler (system, id, name),
87#ifdef G4OPENGL_VERSION_2
88fEmulate_GL_QUADS(false),
89#endif
90fPickName(0),
96fEdgeFlag(true)
97{
98}

◆ ~G4OpenGLSceneHandler()

G4OpenGLSceneHandler::~G4OpenGLSceneHandler ( )
protectedvirtual

Definition at line 100 of file G4OpenGLSceneHandler.cc.

101{
102 ClearStore ();
103}
virtual void ClearStore()

Member Function Documentation

◆ AddCompound() [1/6]

void G4OpenGLSceneHandler::AddCompound ( const G4Mesh mesh)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 1026 of file G4OpenGLSceneHandler.cc.

1026 {
1028}
void StandardSpecialMeshRendering(const G4Mesh &)

◆ AddCompound() [2/6]

void G4OpenGLSceneHandler::AddCompound ( const G4THitsMap< G4double > &  hits)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 1018 of file G4OpenGLSceneHandler.cc.

1018 {
1019 G4VSceneHandler::AddCompound(hits); // For now.
1020}
virtual void AddCompound(const G4VTrajectory &)

◆ AddCompound() [3/6]

void G4OpenGLSceneHandler::AddCompound ( const G4THitsMap< G4StatDouble > &  hits)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 1022 of file G4OpenGLSceneHandler.cc.

1022 {
1023 G4VSceneHandler::AddCompound(hits); // For now.
1024}

◆ AddCompound() [4/6]

void G4OpenGLSceneHandler::AddCompound ( const G4VDigi digi)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 1014 of file G4OpenGLSceneHandler.cc.

1014 {
1015 G4VSceneHandler::AddCompound(digi); // For now.
1016}

◆ AddCompound() [5/6]

void G4OpenGLSceneHandler::AddCompound ( const G4VHit hit)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 1010 of file G4OpenGLSceneHandler.cc.

1010 {
1011 G4VSceneHandler::AddCompound(hit); // For now.
1012}

◆ AddCompound() [6/6]

void G4OpenGLSceneHandler::AddCompound ( const G4VTrajectory traj)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 1006 of file G4OpenGLSceneHandler.cc.

1006 {
1007 G4VSceneHandler::AddCompound(traj); // For now.
1008}

◆ AddPrimitive() [1/13]

void G4OpenGLSceneHandler::AddPrimitive ( const G4Circle circle)
virtual

Implements G4VSceneHandler.

Reimplemented in G4OpenGLStoredSceneHandler, G4OpenGLImmediateSceneHandler, and G4OpenGLStoredSceneHandler.

Definition at line 554 of file G4OpenGLSceneHandler.cc.

554 {
555 G4Polymarker oneCircle(circle);
556 oneCircle.push_back(circle.GetPosition());
557 oneCircle.SetMarkerType(G4Polymarker::circles);
558 // Call this AddPrimitive to avoid re-doing sub-class code.
560}
void AddPrimitive(const G4Polyline &)
G4Point3D GetPosition() const

◆ AddPrimitive() [2/13]

virtual void G4VSceneHandler::AddPrimitive ( const G4Circle )
virtual

Implements G4VSceneHandler.

Reimplemented in G4OpenGLStoredSceneHandler.

◆ AddPrimitive() [3/13]

void G4VSceneHandler::AddPrimitive ( const G4Plotter )
virtual

Reimplemented from G4VSceneHandler.

Reimplemented in G4OpenGLStoredSceneHandler.

Definition at line 193 of file G4VSceneHandler.cc.

510 {
511 G4warn << "WARNING: Plotter not implemented for " << fSystem.GetName() << G4endl;
512 G4warn << " Open a plotter-aware graphics system or remove plotter with" << G4endl;
513 G4warn << " /vis/scene/removeModel Plotter" << G4endl;
514}
#define G4warn
Definition: G4Scene.cc:41
#define G4endl
Definition: G4ios.hh:57
const G4String & GetName() const
G4VGraphicsSystem & fSystem

◆ AddPrimitive() [4/13]

void G4OpenGLSceneHandler::AddPrimitive ( const G4Polyhedron polyhedron)
virtual

Implements G4VSceneHandler.

Reimplemented in G4OpenGLStoredSceneHandler, G4OpenGLImmediateSceneHandler, and G4OpenGLStoredSceneHandler.

Definition at line 571 of file G4OpenGLSceneHandler.cc.

571 {
572
573 // Assume all facets are planar convex quadrilaterals.
574 // Draw each facet individually
575
576 if (polyhedron.GetNoFacets() == 0) return;
577
578 // Need access to data in G4OpenGLViewer. static_cast doesn't work
579 // with a virtual base class, so use dynamic_cast.
580 G4OpenGLViewer* pGLViewer = dynamic_cast<G4OpenGLViewer*>(fpViewer);
581 if (!pGLViewer) return;
582
583 // Get view parameters that the user can force through the vis
584 // attributes, thereby over-riding the current view parameter.
586
587 // Note that in stored mode, because this call gets embedded in a display
588 // list, it is the colour _at the time of_ creation of the display list, so
589 // even if the colour is changed, for example, by interaction with a Qt
590 // window, current_colour does not change.
591 GLfloat* painting_colour;
592 GLfloat clear_colour[4];
593 GLfloat current_colour[4];
594 glGetFloatv (GL_CURRENT_COLOR, current_colour);
595
596 G4bool isTransparent = false;
597 if (current_colour[3] < 1.) { // This object is transparent
598 isTransparent = true;
599 }
600
601 if (drawing_style == G4ViewParameters::hlr) {
602 // This is the colour used to paint surfaces in hlr mode.
603 glGetFloatv (GL_COLOR_CLEAR_VALUE, clear_colour);
604 painting_colour = clear_colour;
605 } else { // drawing_style == G4ViewParameters::hlhsr
606 painting_colour = current_colour;
607 }
608
610 pGLViewer->ChangeLineWidth(lineWidth);
611
612 G4bool isAuxEdgeVisible = GetAuxEdgeVisible (fpVisAttribs);
613
614 G4bool clipping = pGLViewer->fVP.IsSection() || pGLViewer->fVP.IsCutaway();
615
616 // Lighting disabled unless otherwise requested
617#ifndef G4OPENGL_VERSION_2
618 glDisable (GL_LIGHTING);
619#endif
620
621 switch (drawing_style) {
623 // Set up as for hidden line removal but paint polygon faces later...
625 glEnable (GL_STENCIL_TEST);
626 // The stencil buffer is cleared in G4OpenGLViewer::ClearView.
627 // The procedure below leaves it clear.
628 glStencilFunc (GL_ALWAYS, 0, 1);
629 glStencilOp (GL_INVERT, GL_INVERT, GL_INVERT);
630 glEnable (GL_DEPTH_TEST);
631 glDepthFunc (GL_LEQUAL);
632 if (isTransparent) {
633 // Transparent...
634 glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
635 glEnable(GL_COLOR_MATERIAL);
636 //glDisable (GL_CULL_FACE);
637 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
638 } else {
639 // Opaque...
640 if (clipping) {
641 glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
642 glEnable(GL_COLOR_MATERIAL);
643 //glDisable (GL_CULL_FACE);
644 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
645 } else {
646 glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
647 glEnable(GL_COLOR_MATERIAL);
648 //glEnable (GL_CULL_FACE);
649 //glCullFace (GL_BACK);
650 glPolygonMode (GL_FRONT, GL_LINE);
651 }
652 }
653 break;
655 glEnable (GL_DEPTH_TEST);
656 glDepthFunc (GL_LEQUAL);
657 if (isTransparent) {
658 // Transparent...
659 glDepthMask (GL_FALSE); // Make depth buffer read-only.
660 glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
661#ifndef G4OPENGL_VERSION_2
662 glEnable(GL_COLOR_MATERIAL);
663#endif
664 //glDisable (GL_CULL_FACE);
665 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
666 } else {
667 // Opaque...
668 glDepthMask (GL_TRUE); // Make depth buffer writable (default).
669 if (clipping) {
670 glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
671 glEnable(GL_COLOR_MATERIAL);
672 //glDisable (GL_CULL_FACE);
673 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
674 } else {
675 glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
676#ifndef G4OPENGL_VERSION_2
677 glEnable(GL_COLOR_MATERIAL);
678#endif
679 //glEnable (GL_CULL_FACE);
680 //glCullFace (GL_BACK);
681 glPolygonMode (GL_FRONT, GL_FILL);
682 }
683 }
684#ifndef G4OPENGL_VERSION_2
685 if (!fProcessing2D) glEnable (GL_LIGHTING);
686#endif
687 break;
689 default:
690 glEnable (GL_DEPTH_TEST);
691 glDepthFunc (GL_LEQUAL); //??? was GL_ALWAYS
692 //glDisable (GL_CULL_FACE);
693 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
694 break;
695 }
696
697 //Loop through all the facets...
698 fEdgeFlag = true;
699#ifndef G4OPENGL_VERSION_2
700 glBegin (GL_QUADS);
701 glEdgeFlag (GL_TRUE);
702#else
703 fEmulate_GL_QUADS = true;
704 glBeginVBO(GL_TRIANGLE_STRIP);
705#endif
706 G4bool notLastFace;
707 do {
708
709 //First, find vertices, edgeflags and normals and note "not last facet"...
710 G4Point3D vertex[4];
711 G4int edgeFlag[4];
712 G4Normal3D normals[4];
713 G4int nEdges;
714 notLastFace = polyhedron.GetNextFacet(nEdges, vertex, edgeFlag, normals);
715
716 //Loop through the four edges of each G4Facet...
717 for(G4int edgeCount = 0; edgeCount < nEdges; ++edgeCount) {
718 // Check to see if edge is visible or not...
719 if (isAuxEdgeVisible) {
720 edgeFlag[edgeCount] = 1;
721 }
722#ifndef G4OPENGL_VERSION_2
723 if (edgeFlag[edgeCount] > 0) {
724 if (fEdgeFlag != true) {
725 glEdgeFlag (GL_TRUE);
726 fEdgeFlag = true;
727 }
728 } else {
729 if (fEdgeFlag != false) {
730 glEdgeFlag (GL_FALSE);
731 fEdgeFlag = false;
732 }
733 }
734 glNormal3d (normals[edgeCount].x(),
735 normals[edgeCount].y(),
736 normals[edgeCount].z());
737 glVertex3d (vertex[edgeCount].x(),
738 vertex[edgeCount].y(),
739 vertex[edgeCount].z());
740#else
741
742 fOglVertex.push_back(vertex[edgeCount].x());
743 fOglVertex.push_back(vertex[edgeCount].y());
744 fOglVertex.push_back(vertex[edgeCount].z());
745
746 fOglVertex.push_back(normals[edgeCount].x());
747 fOglVertex.push_back(normals[edgeCount].y());
748 fOglVertex.push_back(normals[edgeCount].z());
749
750#endif
751
752 }
753
754 // HepPolyhedron produces triangles too; in that case add an extra
755 // vertex identical to first...
756 if (nEdges == 3) {
757 G4int edgeCount = 3;
758 normals[edgeCount] = normals[0];
759 vertex[edgeCount] = vertex[0];
760#ifndef G4OPENGL_VERSION_2
761 edgeFlag[edgeCount] = -1;
762 if (fEdgeFlag != false) {
763 glEdgeFlag (GL_FALSE);
764 fEdgeFlag = false;
765 }
766
767 glNormal3d (normals[edgeCount].x(),
768 normals[edgeCount].y(),
769 normals[edgeCount].z());
770 glVertex3d (vertex[edgeCount].x(),
771 vertex[edgeCount].y(),
772 vertex[edgeCount].z());
773#else
774 fOglVertex.push_back(vertex[edgeCount].x());
775 fOglVertex.push_back(vertex[edgeCount].y());
776 fOglVertex.push_back(vertex[edgeCount].z());
777
778 fOglVertex.push_back(normals[edgeCount].x());
779 fOglVertex.push_back(normals[edgeCount].y());
780 fOglVertex.push_back(normals[edgeCount].z());
781
782#endif
783 }
784 // Trap situation where number of edges is > 4...
785 if (nEdges > 4) {
786 G4cerr <<
787 "G4OpenGLSceneHandler::AddPrimitive(G4Polyhedron): WARNING"
788 "\n G4Polyhedron facet with " << nEdges << " edges" << G4endl;
789 }
790
791
792 // Do it all over again (twice) for hlr...
793 if (drawing_style == G4ViewParameters::hlr ||
794 drawing_style == G4ViewParameters::hlhsr) {
795
796#ifndef G4OPENGL_VERSION_2
797 glDisable(GL_COLOR_MATERIAL); // Revert to glMaterial for hlr/sr.
798#endif
799
800#ifndef G4OPENGL_VERSION_2
801 glEnd (); // Placed here to balance glBegin above, allowing GL
802#else
803 glEndVBO();
804#endif
805 // state changes below, then glBegin again. Avoids
806 // having glBegin/End pairs *inside* loop in the more
807 // usual case of no hidden line removal.
808
809 // Lighting disabled unless otherwise requested
810 glDisable (GL_LIGHTING);
811
812 // Draw through stencil...
813 glStencilFunc (GL_EQUAL, 0, 1);
814 glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP);
815 if (drawing_style == G4ViewParameters::hlhsr) {
816 if (!fProcessing2D) glEnable (GL_LIGHTING);
817 }
818 glEnable (GL_DEPTH_TEST);
819 glDepthFunc (GL_LEQUAL);
820 if (isTransparent) {
821 // Transparent...
822 glDepthMask (GL_FALSE); // Make depth buffer read-only.
823 //glDisable (GL_CULL_FACE);
824 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
825 } else {
826 // Opaque...
827 glDepthMask (GL_TRUE); // Make depth buffer writable (default).
828 if (clipping) {
829 //glDisable (GL_CULL_FACE);
830 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
831 } else {
832 //glEnable (GL_CULL_FACE);
833 //glCullFace (GL_BACK);
834 glPolygonMode (GL_FRONT, GL_FILL);
835 }
836 }
837 if (drawing_style == G4ViewParameters::hlr) {
838 if (isTransparent) {
839 // Transparent - don't paint...
840 goto end_of_drawing_through_stencil;
841 }
842 }
843 if (isTransparent) {
844 // Transparent...
845 glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, painting_colour);
846 } else {
847 // Opaque...
848 glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, painting_colour);
849 }
850 glColor4fv (painting_colour);
851#ifndef G4OPENGL_VERSION_2
852 glBegin (GL_QUADS);
853 glEdgeFlag (GL_TRUE);
854 fEdgeFlag = true;
855#else
856 fEmulate_GL_QUADS = true;
857 glBeginVBO(GL_TRIANGLE_STRIP);
858#endif
859
860 for (int edgeCount = 0; edgeCount < 4; ++edgeCount) {
861#ifndef G4OPENGL_VERSION_2
862 if (edgeFlag[edgeCount] > 0) {
863 if (fEdgeFlag != true) {
864 glEdgeFlag (GL_TRUE);
865 fEdgeFlag = true;
866 }
867 } else {
868 if (fEdgeFlag != false) {
869 glEdgeFlag (GL_FALSE);
870 fEdgeFlag = false;
871 }
872 }
873 glNormal3d (normals[edgeCount].x(),
874 normals[edgeCount].y(),
875 normals[edgeCount].z());
876 glVertex3d (vertex[edgeCount].x(),
877 vertex[edgeCount].y(),
878 vertex[edgeCount].z());
879#else
880 fOglVertex.push_back(vertex[edgeCount].x());
881 fOglVertex.push_back(vertex[edgeCount].y());
882 fOglVertex.push_back(vertex[edgeCount].z());
883
884 fOglVertex.push_back(normals[edgeCount].x());
885 fOglVertex.push_back(normals[edgeCount].y());
886 fOglVertex.push_back(normals[edgeCount].z());
887
888#endif
889 }
890#ifndef G4OPENGL_VERSION_2
891 glEnd ();
892#else
893 glEndVBO();
894#endif
895 end_of_drawing_through_stencil:
896
897 // and once more to reset the stencil bits...
898 glStencilFunc (GL_ALWAYS, 0, 1);
899 glStencilOp (GL_INVERT, GL_INVERT, GL_INVERT);
900 glDepthFunc (GL_LEQUAL); // to make sure line gets drawn.
901 if (isTransparent) {
902 // Transparent...
903 //glDisable (GL_CULL_FACE);
904 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
905 } else {
906 // Opaque...
907 if (clipping) {
908 //glDisable (GL_CULL_FACE);
909 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
910 } else {
911 //glEnable (GL_CULL_FACE);
912 //glCullFace (GL_BACK);
913 glPolygonMode (GL_FRONT, GL_LINE);
914 }
915 }
916 glDisable (GL_LIGHTING);
917 glColor4fv (current_colour);
918 fEdgeFlag = true;
919#ifndef G4OPENGL_VERSION_2
920 glBegin (GL_QUADS);
921 glEdgeFlag (GL_TRUE);
922 fEdgeFlag = true;
923#else
924 fEmulate_GL_QUADS = true;
925 glBeginVBO(GL_TRIANGLE_STRIP);
926#endif
927 for (int edgeCount = 0; edgeCount < 4; ++edgeCount) {
928#ifndef G4OPENGL_VERSION_2
929 if (edgeFlag[edgeCount] > 0) {
930 if (fEdgeFlag != true) {
931 glEdgeFlag (GL_TRUE);
932 fEdgeFlag = true;
933 }
934 } else {
935 if (fEdgeFlag != false) {
936 glEdgeFlag (GL_FALSE);
937 fEdgeFlag = false;
938 }
939 }
940 glNormal3d (normals[edgeCount].x(),
941 normals[edgeCount].y(),
942 normals[edgeCount].z());
943 glVertex3d (vertex[edgeCount].x(),
944 vertex[edgeCount].y(),
945 vertex[edgeCount].z());
946#else
947 fOglVertex.push_back(vertex[edgeCount].x());
948 fOglVertex.push_back(vertex[edgeCount].y());
949 fOglVertex.push_back(vertex[edgeCount].z());
950
951 fOglVertex.push_back(normals[edgeCount].x());
952 fOglVertex.push_back(normals[edgeCount].y());
953 fOglVertex.push_back(normals[edgeCount].z());
954
955#endif
956 }
957#ifndef G4OPENGL_VERSION_2
958 glEnd ();
959#else
960 glEndVBO();
961#endif
962
963 glDepthFunc (GL_LEQUAL); // Revert for next facet.
964 fEdgeFlag = true;
965#ifndef G4OPENGL_VERSION_2
966 glBegin (GL_QUADS); // Ready for next facet. GL
967 glEdgeFlag (GL_TRUE);
968 fEdgeFlag = true;
969 // says it ignores incomplete
970 // quadrilaterals, so final empty
971 // glBegin/End sequence should be OK.
972#else
973 fEmulate_GL_QUADS = true;
974 glBeginVBO(GL_TRIANGLE_STRIP);
975#endif
976 }
977 } while (notLastFace);
978
979#ifndef G4OPENGL_VERSION_2
980 glEnd ();
981#else
982
983// FIXME: du grand n'importe quoi en test
984// Cube optimization
985
986 // store old DrawType because in case of optimization it could be changed
987 GLenum oldDrawArrayType = fDrawArrayType;
988
989 if (dynamic_cast<const G4PolyhedronTrd2*>(&polyhedron)) {
990// OptimizeVBOForTrd();
991 } else if (dynamic_cast<const G4PolyhedronCons*>(&polyhedron)) {
992// OptimizeVBOForCons((polyhedron.GetNoVertices()-2)/2 ); // top + bottom + all faces
993 }
994
995 glEndVBO();
996 fDrawArrayType = oldDrawArrayType;
997#endif
998
999 glDisable (GL_STENCIL_TEST); // Revert to default for next primitive.
1000 glDepthMask (GL_TRUE); // Revert to default for next primitive.
1001#ifndef G4OPENGL_VERSION_2
1002 glDisable (GL_LIGHTING); // Revert to default for next primitive.
1003#endif
1004}
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
G4GLOB_DLL std::ostream G4cerr
void ChangeLineWidth(G4double width)
G4VViewer * fpViewer
const G4VisAttributes * fpVisAttribs
G4ViewParameters::DrawingStyle GetDrawingStyle(const G4VisAttributes *)
G4double GetLineWidth(const G4VisAttributes *)
G4bool GetAuxEdgeVisible(const G4VisAttributes *)
G4ViewParameters fVP
Definition: G4VViewer.hh:220
G4bool IsCutaway() const
G4bool IsSection() const
G4int GetNoFacets() const
G4bool GetNextFacet(G4int &n, G4Point3D *nodes, G4int *edgeFlags=nullptr, G4Normal3D *normals=nullptr) const

◆ AddPrimitive() [5/13]

virtual void G4VSceneHandler::AddPrimitive ( const G4Polyhedron )
virtual

Implements G4VSceneHandler.

Reimplemented in G4OpenGLStoredSceneHandler.

◆ AddPrimitive() [6/13]

void G4OpenGLSceneHandler::AddPrimitive ( const G4Polyline line)
virtual

Implements G4VSceneHandler.

Reimplemented in G4OpenGLStoredSceneHandler, G4OpenGLImmediateSceneHandler, and G4OpenGLStoredSceneHandler.

Definition at line 345 of file G4OpenGLSceneHandler.cc.

346{
347 std::size_t nPoints = line.size ();
348 if (nPoints <= 0) return;
349
350 // Note: colour and depth test treated in sub-class.
351
352#ifndef G4OPENGL_VERSION_2
353 glDisable (GL_LIGHTING);
354#endif
355
357 // Need access to method in G4OpenGLViewer. static_cast doesn't
358 // work with a virtual base class, so use dynamic_cast. No need to
359 // test the outcome since viewer is guaranteed to be a
360 // G4OpenGLViewer, but test it anyway to keep Coverity happy.
361 G4OpenGLViewer* pGLViewer = dynamic_cast<G4OpenGLViewer*>(fpViewer);
362 if (pGLViewer) pGLViewer->ChangeLineWidth(lineWidth);
363
364 fEdgeFlag = true;
365#ifndef G4OPENGL_VERSION_2
366 glBegin (GL_LINE_STRIP);
367 // No ned glEdgeFlag for lines :
368 // Boundary and nonboundary edge flags on vertices are significant only if GL_POLYGON_MODE is set to GL_POINT or GL_LINE. See glPolygonMode.
369
370 // glEdgeFlag (GL_TRUE);
371 for (std::size_t iPoint = 0; iPoint < nPoints; ++iPoint) {
372 G4double x, y, z;
373 x = line[iPoint].x();
374 y = line[iPoint].y();
375 z = line[iPoint].z();
376 glVertex3d (x, y, z);
377 }
378 glEnd ();
379#else
380 glBeginVBO(GL_LINE_STRIP);
381
382 for (std::size_t iPoint = 0; iPoint < nPoints; ++iPoint) {
383 fOglVertex.push_back(line[iPoint].x());
384 fOglVertex.push_back(line[iPoint].y());
385 fOglVertex.push_back(line[iPoint].z());
386 // normal
387 fOglVertex.push_back(0);
388 fOglVertex.push_back(0);
389 fOglVertex.push_back(1);
390 }
391
392 glEndVBO();
393#endif
394}

Referenced by AddPrimitive(), G4OpenGLImmediateSceneHandler::AddPrimitive(), and G4OpenGLStoredSceneHandler::AddPrimitive().

◆ AddPrimitive() [7/13]

virtual void G4VSceneHandler::AddPrimitive ( const G4Polyline )
virtual

Implements G4VSceneHandler.

Reimplemented in G4OpenGLStoredSceneHandler.

◆ AddPrimitive() [8/13]

void G4VSceneHandler::AddPrimitive ( const G4Polymarker polymarker)
virtual

Reimplemented from G4VSceneHandler.

Reimplemented in G4OpenGLStoredSceneHandler.

Definition at line 191 of file G4VSceneHandler.cc.

467 {
468 switch (polymarker.GetMarkerType()) {
469 default:
471 {
472 G4Circle dot (polymarker);
473 dot.SetWorldSize (0.);
474 dot.SetScreenSize (0.1); // Very small circle.
475 for (std::size_t iPoint = 0; iPoint < polymarker.size (); ++iPoint) {
476 dot.SetPosition (polymarker[iPoint]);
477 AddPrimitive (dot);
478 }
479 }
480 break;
482 {
483 G4Circle circle (polymarker); // Default circle
484 for (std::size_t iPoint = 0; iPoint < polymarker.size (); ++iPoint) {
485 circle.SetPosition (polymarker[iPoint]);
486 AddPrimitive (circle);
487 }
488 }
489 break;
491 {
492 G4Square square (polymarker); // Default square
493 for (std::size_t iPoint = 0; iPoint < polymarker.size (); ++iPoint) {
494 square.SetPosition (polymarker[iPoint]);
495 AddPrimitive (square);
496 }
497 }
498 break;
499 }
500}
MarkerType GetMarkerType() const

◆ AddPrimitive() [9/13]

void G4OpenGLSceneHandler::AddPrimitive ( const G4Polymarker polymarker)
virtual

Reimplemented from G4VSceneHandler.

Reimplemented in G4OpenGLImmediateSceneHandler, G4OpenGLStoredSceneHandler, and G4OpenGLStoredSceneHandler.

Definition at line 396 of file G4OpenGLSceneHandler.cc.

397{
398 if (polymarker.size() == 0) {
399 return;
400 }
401
402 // Note: colour and depth test treated in sub-class.
403
404#ifndef G4OPENGL_VERSION_2
405 glDisable (GL_LIGHTING);
406#endif
407
408 MarkerSizeType sizeType;
409 G4double size = GetMarkerSize(polymarker, sizeType);
410
411 // Need access to method in G4OpenGLViewer. static_cast doesn't
412 // work with a virtual base class, so use dynamic_cast. No need to
413 // test the outcome since viewer is guaranteed to be a
414 // G4OpenGLViewer, but test it anyway to keep Coverity happy.
415 G4OpenGLViewer* pGLViewer = dynamic_cast<G4OpenGLViewer*>(fpViewer);
416 if (!pGLViewer) return;
417
418 if (sizeType == world) { // Size specified in world coordinates.
420 pGLViewer->ChangeLineWidth(lineWidth);
421
422 G4VMarker::FillStyle style = polymarker.GetFillStyle();
423
424 // G4bool filled = false; Not actually used - comment out to prevent compiler warnings (JA).
425 static G4bool hashedWarned = false;
426
427 switch (style) {
429 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
430 glEdgeFlag (GL_TRUE);
431 //filled = false;
432 break;
434 if (!hashedWarned) {
435 G4cout << "Hashed fill style in G4OpenGLSceneHandler."
436 << "\n Not implemented. Using G4VMarker::filled."
437 << G4endl;
438 hashedWarned = true;
439 }
440 // Maybe use
441 //glPolygonStipple (fStippleMaskHashed);
442 [[fallthrough]]; // Drop through to filled...
444 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
445 //filled = true;
446 break;
447 }
448 }
449
450 // Draw...
451 if (sizeType == world) { // Size specified in world coordinates.
452
453 G4int nSides;
454 G4double startPhi;
455 switch (polymarker.GetMarkerType()) {
456 default:
458 size = 1.;
459 [[fallthrough]]; // Fall through to circles
461 nSides = GetNoOfSides(fpVisAttribs);
462 startPhi = 0.;
463 break;
465 nSides = 4;
466 startPhi = -pi / 4.;
467 break;
468 }
469
470 const G4Vector3D& viewpointDirection =
471 fpViewer -> GetViewParameters().GetViewpointDirection();
473 const G4double dPhi = twopi / nSides;
474 const G4double radius = size / 2.;
475 G4Vector3D start = radius * (up.cross(viewpointDirection)).unit();
476 G4double phi;
477 G4int i;
478 for (size_t iPoint = 0; iPoint < polymarker.size (); iPoint++) {
479 fEdgeFlag = true;
480#ifndef G4OPENGL_VERSION_2
481 glBegin (GL_POLYGON);
482 for (i = 0, phi = startPhi; i < nSides; i++, phi += dPhi) {
483 G4Vector3D r = start; r.rotate(phi, viewpointDirection);
484 G4Vector3D p = polymarker[iPoint] + r;
485 glVertex3d (p.x(), p.y(), p.z());
486 }
487 glEnd ();
488#else
489 glBeginVBO (GL_TRIANGLE_STRIP);
490 for (i = 0, phi = startPhi; i < nSides; i++, phi += dPhi) {
491 G4Vector3D r = start; r.rotate(phi, viewpointDirection);
492 G4Vector3D p = polymarker[iPoint] + r;
493
494 fOglVertex.push_back(p.x());
495 fOglVertex.push_back(p.y());
496 fOglVertex.push_back(p.z());
497 // normal
498 fOglVertex.push_back(0);
499 fOglVertex.push_back(0);
500 fOglVertex.push_back(1);
501 }
502 glEndVBO ();
503#endif
504 }
505
506 } else { // Size specified in screen (window) coordinates.
507
508 pGLViewer->ChangePointSize(size);
509
510 //Antialiasing only for circles
511#ifndef G4OPENGL_VERSION_2
512 switch (polymarker.GetMarkerType()) {
513 default:
516 glEnable (GL_POINT_SMOOTH); break;
518 glDisable (GL_POINT_SMOOTH); break;
519 }
520#endif
521#ifndef G4OPENGL_VERSION_2
522 glBegin (GL_POINTS);
523 for (size_t iPoint = 0; iPoint < polymarker.size (); iPoint++) {
524 G4Point3D centre = polymarker[iPoint];
525 glVertex3d(centre.x(),centre.y(),centre.z());
526 }
527 glEnd();
528#else
529 glBeginVBO(GL_POINTS);
530
531 for (size_t iPoint = 0; iPoint < polymarker.size (); iPoint++) {
532 fOglVertex.push_back(polymarker[iPoint].x());
533 fOglVertex.push_back(polymarker[iPoint].y());
534 fOglVertex.push_back(polymarker[iPoint].z());
535 fOglVertex.push_back(0);
536 fOglVertex.push_back(0);
537 fOglVertex.push_back(1);
538 }
539 glEndVBO();
540#endif
541 }
542}
G4GLOB_DLL std::ostream G4cout
void ChangePointSize(G4double size)
FillStyle GetFillStyle() const
G4int GetNoOfSides(const G4VisAttributes *)
G4double GetMarkerSize(const G4VMarker &, MarkerSizeType &)
const G4ViewParameters & GetViewParameters() const
const G4Vector3D & GetUpVector() const
BasicVector3D< T > cross(const BasicVector3D< T > &v) const
BasicVector3D< T > & rotate(T a, const BasicVector3D< T > &v)
const G4double pi

◆ AddPrimitive() [10/13]

void G4OpenGLSceneHandler::AddPrimitive ( const G4Square square)
virtual

Implements G4VSceneHandler.

Reimplemented in G4OpenGLStoredSceneHandler, G4OpenGLImmediateSceneHandler, and G4OpenGLStoredSceneHandler.

Definition at line 562 of file G4OpenGLSceneHandler.cc.

562 {
563 G4Polymarker oneSquare(square);
564 oneSquare.push_back(square.GetPosition());
565 oneSquare.SetMarkerType(G4Polymarker::squares);
566 // Call this AddPrimitive to avoid re-doing sub-class code.
568}

◆ AddPrimitive() [11/13]

virtual void G4VSceneHandler::AddPrimitive ( const G4Square )
virtual

Implements G4VSceneHandler.

Reimplemented in G4OpenGLStoredSceneHandler.

◆ AddPrimitive() [12/13]

void G4OpenGLSceneHandler::AddPrimitive ( const G4Text text)
virtual

Implements G4VSceneHandler.

Reimplemented in G4OpenGLStoredSceneHandler, G4OpenGLImmediateSceneHandler, and G4OpenGLStoredSceneHandler.

Definition at line 544 of file G4OpenGLSceneHandler.cc.

544 {
545 // Pass to specific viewer via virtual function DrawText.
546 // FIXME : Not ready for OPENGL2 for the moment
547#ifdef G4OPENGL_VERSION_2
548 return;
549#endif
550 G4OpenGLViewer* pGLViewer = dynamic_cast<G4OpenGLViewer*>(fpViewer);
551 if (pGLViewer) pGLViewer->DrawText(text);
552}
virtual void DrawText(const G4Text &)

◆ AddPrimitive() [13/13]

virtual void G4VSceneHandler::AddPrimitive ( const G4Text )
virtual

Implements G4VSceneHandler.

Reimplemented in G4OpenGLStoredSceneHandler.

◆ AddPrimitivesCircle()

void G4OpenGLSceneHandler::AddPrimitivesCircle ( const std::vector< G4VMarker > &  )

◆ AddPrimitivesSquare()

void G4OpenGLSceneHandler::AddPrimitivesSquare ( const std::vector< G4VMarker > &  )

◆ AddSolid() [1/14]

void G4OpenGLSceneHandler::AddSolid ( const G4Box )
virtual

Reimplemented from G4VSceneHandler.

◆ AddSolid() [2/14]

void G4OpenGLSceneHandler::AddSolid ( const G4Cons )
virtual

Reimplemented from G4VSceneHandler.

◆ AddSolid() [3/14]

void G4OpenGLSceneHandler::AddSolid ( const G4Ellipsoid )
virtual

Reimplemented from G4VSceneHandler.

◆ AddSolid() [4/14]

void G4OpenGLSceneHandler::AddSolid ( const G4Orb )
virtual

Reimplemented from G4VSceneHandler.

◆ AddSolid() [5/14]

void G4OpenGLSceneHandler::AddSolid ( const G4Para )
virtual

Reimplemented from G4VSceneHandler.

◆ AddSolid() [6/14]

void G4OpenGLSceneHandler::AddSolid ( const G4Polycone )
virtual

Reimplemented from G4VSceneHandler.

◆ AddSolid() [7/14]

void G4OpenGLSceneHandler::AddSolid ( const G4Polyhedra )
virtual

Reimplemented from G4VSceneHandler.

◆ AddSolid() [8/14]

void G4OpenGLSceneHandler::AddSolid ( const G4Sphere )
virtual

Reimplemented from G4VSceneHandler.

◆ AddSolid() [9/14]

void G4OpenGLSceneHandler::AddSolid ( const G4TessellatedSolid )
virtual

Reimplemented from G4VSceneHandler.

◆ AddSolid() [10/14]

void G4OpenGLSceneHandler::AddSolid ( const G4Torus )
virtual

Reimplemented from G4VSceneHandler.

◆ AddSolid() [11/14]

void G4OpenGLSceneHandler::AddSolid ( const G4Trap )
virtual

Reimplemented from G4VSceneHandler.

◆ AddSolid() [12/14]

void G4OpenGLSceneHandler::AddSolid ( const G4Trd )
virtual

Reimplemented from G4VSceneHandler.

◆ AddSolid() [13/14]

void G4OpenGLSceneHandler::AddSolid ( const G4Tubs )
virtual

Reimplemented from G4VSceneHandler.

◆ AddSolid() [14/14]

void G4OpenGLSceneHandler::AddSolid ( const G4VSolid )
virtual

Reimplemented from G4VSceneHandler.

◆ BeginPrimitives()

void G4OpenGLSceneHandler::BeginPrimitives ( const G4Transform3D objectTransformation)
virtual

Reimplemented from G4VSceneHandler.

Reimplemented in G4OpenGLImmediateSceneHandler, and G4OpenGLStoredSceneHandler.

Definition at line 305 of file G4OpenGLSceneHandler.cc.

307{
308 G4VSceneHandler::BeginPrimitives (objectTransformation);
309}
virtual void BeginPrimitives(const G4Transform3D &objectTransformation=G4Transform3D())

Referenced by G4OpenGLImmediateSceneHandler::BeginPrimitives(), and G4OpenGLStoredSceneHandler::BeginPrimitives().

◆ BeginPrimitives2D()

void G4OpenGLSceneHandler::BeginPrimitives2D ( const G4Transform3D objectTransformation)
virtual

Reimplemented from G4VSceneHandler.

Reimplemented in G4OpenGLImmediateSceneHandler, and G4OpenGLStoredSceneHandler.

Definition at line 316 of file G4OpenGLSceneHandler.cc.

318{
319 G4VSceneHandler::BeginPrimitives2D (objectTransformation);
320}
virtual void BeginPrimitives2D(const G4Transform3D &objectTransformation=G4Transform3D())

Referenced by G4OpenGLImmediateSceneHandler::BeginPrimitives2D(), and G4OpenGLStoredSceneHandler::BeginPrimitives2D().

◆ ClearAndDestroyAtts()

void G4OpenGLSceneHandler::ClearAndDestroyAtts ( )
protected

Definition at line 105 of file G4OpenGLSceneHandler.cc.

106{
107 std::map<GLuint, G4AttHolder*>::iterator i;
108 for (i = fPickMap.begin(); i != fPickMap.end(); ++i) delete i->second;
109 fPickMap.clear();
110}
std::map< GLuint, G4AttHolder * > fPickMap

Referenced by G4OpenGLStoredSceneHandler::ClearStore().

◆ CreateCutawaySolid()

G4DisplacedSolid * G4OpenGLSceneHandler::CreateCutawaySolid ( )
protectedvirtual

Reimplemented from G4VSceneHandler.

Definition at line 336 of file G4OpenGLSceneHandler.cc.

337{
338 // return G4VSceneHandler::CreateCutawaySolid();
339 // If cutaway done in G4OpenGLViewer::SetView.
340 return 0;
341 // Note: if you change this, you must also change
342 // G4OpenGLStoredViewer::CompareForKernelVisit
343}

◆ CreateSectionSolid()

G4DisplacedSolid * G4OpenGLSceneHandler::CreateSectionSolid ( )
protectedvirtual

Reimplemented from G4VSceneHandler.

Definition at line 327 of file G4OpenGLSceneHandler.cc.

328{
330 // If clipping done in G4OpenGLViewer::SetView
331 // return 0;
332 // Note: if you change this, you must also change
333 // G4OpenGLStoredViewer::CompareForKernelVisit
334}
virtual G4DisplacedSolid * CreateSectionSolid()

◆ EndPrimitives()

void G4OpenGLSceneHandler::EndPrimitives ( )
virtual

◆ EndPrimitives2D()

void G4OpenGLSceneHandler::EndPrimitives2D ( )
virtual

◆ GetEntitiesFlushInterval()

static G4int G4OpenGLSceneHandler::GetEntitiesFlushInterval ( )
inlinestatic

Definition at line 97 of file G4OpenGLSceneHandler.hh.

◆ GetFlushAction()

static FlushAction G4OpenGLSceneHandler::GetFlushAction ( )
inlinestatic

Definition at line 99 of file G4OpenGLSceneHandler.hh.

100 {return fFlushAction;}
static FlushAction fFlushAction

◆ PreAddSolid()

void G4OpenGLSceneHandler::PreAddSolid ( const G4Transform3D objectTransformation,
const G4VisAttributes visAttribs 
)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 298 of file G4OpenGLSceneHandler.cc.

301{
302 G4VSceneHandler::PreAddSolid (objectTransformation, visAttribs);
303}
virtual void PreAddSolid(const G4Transform3D &objectTransformation, const G4VisAttributes &)

◆ ProcessScene()

void G4OpenGLSceneHandler::ProcessScene ( )
protectedvirtual

Reimplemented from G4VSceneHandler.

Definition at line 273 of file G4OpenGLSceneHandler.cc.

274{
275 fThreePassCapable = true;
276
278
279 // Repeat if required...
285 }
286
287 // And again if required...
293 }
294
295 fThreePassCapable = false;
296}
virtual void ProcessScene()

◆ ScaledFlush()

void G4OpenGLSceneHandler::ScaledFlush ( )
protected

Definition at line 116 of file G4OpenGLSceneHandler.cc.

117{
119
120 // Drawing transients, e.g., trajectories.
121
122 if (!fpScene) {
123 // No scene - shouldn't happen
124 glFlush();
125 return;
126 }
127 // Get event from modeling parameters
128 if (!fpModel) {
129 // No model - shouldn't happen
130 glFlush();
131 return;
132 }
133 const G4ModelingParameters* modelingParameters =
135 if (!modelingParameters) {
136 // No modeling parameters - shouldn't happen
137 glFlush();
138 return;
139 }
140 const G4Event* thisEvent = modelingParameters->GetEvent();
141 if (!thisEvent) {
142 // No event, so not in event loop.
143 if (fFlushAction == endOfEvent) {
145 } else if (fFlushAction == NthEvent) {
147 }
148 }
150 if (!runMan) {
151 // No run manager - shouldn't happen
152 glFlush();
153 return;
154 }
155 const G4Run* thisRun = runMan->GetCurrentRun();
156 if (!thisRun) {
157 // No run, so not in event loop.
158 if (fFlushAction == endOfRun) {
160 } else if (fFlushAction == NthEvent) {
162 }
163 }
164
165 switch (fFlushAction) {
166 case endOfEvent:
167 // If "/vis/scene/endOfEventAction refresh", primitives are flushed at
168 // end of run anyway, so only scale if false.
170 // But if "/vis/scene/endOfEventAction accumulate", ShowView is not
171 // called until end of run, so we have to watch for a new event.
172 // Get event from modeling parameters
173 G4int thisEventID = thisEvent->GetEventID();
174 static G4int lastEventID = 0;
175 if (thisEventID != lastEventID) {
176 glFlush();
177 lastEventID = thisEventID;
178 }
179 }
180 break;
181 case endOfRun:
182 // If "/vis/scene/endOfRunAction refresh", primitives are flushed at
183 // end of run anyway, so only scale if false.
185 // If "/vis/scene/endOfRunAction accumulate", ShowView is never called
186 // so we have to watch for a new run.
187 G4int thisRunID = thisRun->GetRunID();
188 static G4int lastRunID = 0;
189 if (thisRunID != lastRunID) {
190 glFlush();
191 lastRunID = thisRunID;
192 }
193 }
194 break;
195 case eachPrimitive:
196 // This is equivalent to numeric with fEntitiesFlushInterval == 1.
198 [[fallthrough]]; // Fall through to NthPrimitive.
199 case NthPrimitive:
200 { // Encapsulate in scope {} brackets to satisfy Windows.
201 static G4int primitivesWaitingToBeFlushed = 0;
202 primitivesWaitingToBeFlushed++;
203 if (primitivesWaitingToBeFlushed < fEntitiesFlushInterval) return;
204 glFlush();
205 primitivesWaitingToBeFlushed = 0;
206 break;
207 }
208 case NthEvent:
209 // If "/vis/scene/endOfEventAction refresh", primitives are flushed at
210 // end of event anyway, so only scale if false.
212 G4int thisEventID = thisEvent->GetEventID();
213 static G4int lastEventID = 0;
214 if (thisEventID != lastEventID) {
215 static G4int eventsWaitingToBeFlushed = 0;
216 eventsWaitingToBeFlushed++;
217 if (eventsWaitingToBeFlushed < fEntitiesFlushInterval) return;
218 glFlush();
219 eventsWaitingToBeFlushed = 0;
220 lastEventID = thisEventID;
221 }
222 }
223 break;
224 case never:
225 break;
226 default:
227 break;
228 }
229
230 }
231
232 else
233
234 {
235
236 // For run duration model drawing (detector drawing):
237 // Immediate mode: a huge speed up is obtained if flushes are scaled.
238 // Stored mode: no discernable difference since drawing is done to the
239 // back buffer and then swapped.
240 // So eachPrimitive and NthPrimitive make sense. But endOfEvent and
241 // endOfRun are treated as "no action", i.e., a flush will only be issued,
242 // as happens anyway, when drawing is complete.
243
244 switch (fFlushAction) {
245 case endOfEvent:
246 break;
247 case endOfRun:
248 break;
249 case eachPrimitive:
250 // This is equivalent to NthPrimitive with fEntitiesFlushInterval == 1.
252 [[fallthrough]]; // Fall through to NthPrimitive.
253 case NthPrimitive:
254 { // Encapsulate in scope {} brackets to satisfy Windows.
255 static G4int primitivesWaitingToBeFlushed = 0;
256 primitivesWaitingToBeFlushed++;
257 if (primitivesWaitingToBeFlushed < fEntitiesFlushInterval) return;
258 glFlush();
259 primitivesWaitingToBeFlushed = 0;
260 break;
261 }
262 case NthEvent:
263 break;
264 case never:
265 break;
266 default:
267 break;
268 }
269
270 }
271}
G4int GetEventID() const
Definition: G4Event.hh:118
const G4Event * GetEvent() const
static G4RunManager * GetMasterRunManager()
const G4Run * GetCurrentRun() const
Definition: G4Run.hh:49
G4int GetRunID() const
Definition: G4Run.hh:78
G4bool GetRefreshAtEndOfEvent() const
G4bool GetRefreshAtEndOfRun() const
const G4ModelingParameters * GetModelingParameters() const

Referenced by G4OpenGLImmediateSceneHandler::EndPrimitives(), G4OpenGLStoredSceneHandler::EndPrimitives(), G4OpenGLImmediateSceneHandler::EndPrimitives2D(), and G4OpenGLStoredSceneHandler::EndPrimitives2D().

◆ SetEntitiesFlushInterval()

static void G4OpenGLSceneHandler::SetEntitiesFlushInterval ( G4int  interval)
inlinestatic

Definition at line 101 of file G4OpenGLSceneHandler.hh.

102 {fEntitiesFlushInterval = interval;}

Referenced by G4OpenGLViewerMessenger::SetNewValue().

◆ SetFlushAction()

static void G4OpenGLSceneHandler::SetFlushAction ( FlushAction  action)
inlinestatic

Definition at line 103 of file G4OpenGLSceneHandler.hh.

104 {fFlushAction = action;}

Referenced by G4OpenGLViewerMessenger::SetNewValue().

Friends And Related Function Documentation

◆ G4OpenGLViewer

friend class G4OpenGLViewer
friend

Definition at line 48 of file G4OpenGLSceneHandler.hh.

Member Data Documentation

◆ fEdgeFlag

bool G4OpenGLSceneHandler::fEdgeFlag
protected

Definition at line 177 of file G4OpenGLSceneHandler.hh.

Referenced by AddPrimitive().

◆ fEntitiesFlushInterval

G4int G4OpenGLSceneHandler::fEntitiesFlushInterval = 100
staticprotected

◆ fFlushAction

G4OpenGLSceneHandler::FlushAction G4OpenGLSceneHandler::fFlushAction = G4OpenGLSceneHandler::NthEvent
staticprotected

Definition at line 163 of file G4OpenGLSceneHandler.hh.

Referenced by GetFlushAction(), ScaledFlush(), and SetFlushAction().

◆ fPickMap

std::map<GLuint, G4AttHolder*> G4OpenGLSceneHandler::fPickMap
protected

Definition at line 158 of file G4OpenGLSceneHandler.hh.

Referenced by ClearAndDestroyAtts(), and G4OpenGLViewer::GetPickDetails().

◆ fPickName

GLuint G4OpenGLSceneHandler::fPickName
protected

◆ fSecondPassForTransparency

G4bool G4OpenGLSceneHandler::fSecondPassForTransparency
protected

Definition at line 171 of file G4OpenGLSceneHandler.hh.

Referenced by ProcessScene().

◆ fSecondPassForTransparencyRequested

G4bool G4OpenGLSceneHandler::fSecondPassForTransparencyRequested
protected

Definition at line 170 of file G4OpenGLSceneHandler.hh.

Referenced by ProcessScene().

◆ fStippleMaskHashed

const GLubyte G4OpenGLSceneHandler::fStippleMaskHashed
staticprotected
Initial value:
= {
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55
}

Definition at line 176 of file G4OpenGLSceneHandler.hh.

◆ fThirdPassForNonHiddenMarkers

G4bool G4OpenGLSceneHandler::fThirdPassForNonHiddenMarkers
protected

Definition at line 174 of file G4OpenGLSceneHandler.hh.

Referenced by ProcessScene().

◆ fThirdPassForNonHiddenMarkersRequested

G4bool G4OpenGLSceneHandler::fThirdPassForNonHiddenMarkersRequested
protected

Definition at line 173 of file G4OpenGLSceneHandler.hh.

Referenced by ProcessScene().

◆ fThreePassCapable

G4bool G4OpenGLSceneHandler::fThreePassCapable
protected

Definition at line 168 of file G4OpenGLSceneHandler.hh.

Referenced by ProcessScene().


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