65 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
66 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
67 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
68 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
69 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
70 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
71 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
72 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
73 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
74 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
75 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
76 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
77 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
78 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
79 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
80 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55
88fThreePassCapable(false),
89fSecondPassForTransparencyRequested(false),
90fSecondPassForTransparency(false),
91fThirdPassForNonHiddenMarkersRequested(false),
92fThirdPassForNonHiddenMarkers(false),
104 std::map<GLuint, G4AttHolder*>::iterator i;
132 if (!modelingParameters) {
171 static G4int lastEventID = 0;
172 if (thisEventID != lastEventID) {
174 lastEventID = thisEventID;
185 static G4int lastRunID = 0;
186 if (thisRunID != lastRunID) {
188 lastRunID = thisRunID;
198 static G4int primitivesWaitingToBeFlushed = 0;
199 primitivesWaitingToBeFlushed++;
202 primitivesWaitingToBeFlushed = 0;
210 static G4int lastEventID = 0;
211 if (thisEventID != lastEventID) {
212 static G4int eventsWaitingToBeFlushed = 0;
213 eventsWaitingToBeFlushed++;
216 eventsWaitingToBeFlushed = 0;
217 lastEventID = thisEventID;
252 static G4int primitivesWaitingToBeFlushed = 0;
253 primitivesWaitingToBeFlushed++;
256 primitivesWaitingToBeFlushed = 0;
344 std::size_t nPoints = line.size ();
345 if (nPoints <= 0)
return;
349 glDisable (GL_LIGHTING);
360 glBegin (GL_LINE_STRIP);
365 for (std::size_t iPoint = 0; iPoint < nPoints; ++iPoint) {
367 x = line[iPoint].x();
368 y = line[iPoint].y();
369 z = line[iPoint].z();
370 glVertex3d (x, y, z);
377 if (polymarker.size() == 0) {
383 glDisable (GL_LIGHTING);
393 if (!pGLViewer)
return;
395 if (sizeType ==
world) {
402 static G4bool hashedWarned =
false;
406 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
407 glEdgeFlag (GL_TRUE);
412 G4cout <<
"Hashed fill style in G4OpenGLSceneHandler."
413 <<
"\n Not implemented. Using G4VMarker::filled."
421 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
428 if (sizeType ==
world) {
448 fpViewer -> GetViewParameters().GetViewpointDirection();
450 const G4double dPhi = twopi / nSides;
455 for (
size_t iPoint = 0; iPoint < polymarker.size (); iPoint++) {
457 glBegin (GL_POLYGON);
458 for (i = 0, phi = startPhi; i < nSides; i++, phi += dPhi) {
461 glVertex3d (p.
x(), p.
y(), p.
z());
475 glEnable (GL_POINT_SMOOTH);
break;
477 glDisable (GL_POINT_SMOOTH);
break;
480 for (
size_t iPoint = 0; iPoint < polymarker.size (); iPoint++) {
482 glVertex3d(centre.
x(),centre.
y(),centre.
z());
491 if (pGLViewer) pGLViewer->
DrawText(text);
521 if (!pGLViewer)
return;
531 GLfloat* painting_colour;
532 GLfloat clear_colour[4];
533 GLfloat current_colour[4];
534 glGetFloatv (GL_CURRENT_COLOR, current_colour);
536 G4bool isTransparent =
false;
537 if (current_colour[3] < 1.) {
538 isTransparent =
true;
543 glGetFloatv (GL_COLOR_CLEAR_VALUE, clear_colour);
544 painting_colour = clear_colour;
546 painting_colour = current_colour;
557 glDisable (GL_LIGHTING);
559 switch (drawing_style) {
563 glEnable (GL_STENCIL_TEST);
566 glStencilFunc (GL_ALWAYS, 0, 1);
567 glStencilOp (GL_INVERT, GL_INVERT, GL_INVERT);
568 glEnable (GL_DEPTH_TEST);
569 glDepthFunc (GL_LEQUAL);
572 glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
573 glEnable(GL_COLOR_MATERIAL);
575 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
579 glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
580 glEnable(GL_COLOR_MATERIAL);
582 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
584 glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
585 glEnable(GL_COLOR_MATERIAL);
588 glPolygonMode (GL_FRONT, GL_LINE);
593 glEnable (GL_DEPTH_TEST);
594 glDepthFunc (GL_LEQUAL);
597 glDepthMask (GL_FALSE);
598 glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
599 glEnable(GL_COLOR_MATERIAL);
601 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
604 glDepthMask (GL_TRUE);
606 glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
607 glEnable(GL_COLOR_MATERIAL);
609 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
611 glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
612 glEnable(GL_COLOR_MATERIAL);
615 glPolygonMode (GL_FRONT, GL_FILL);
622 glEnable (GL_DEPTH_TEST);
623 glDepthFunc (GL_LEQUAL);
625 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
632 glEdgeFlag (GL_TRUE);
641 notLastFace = polyhedron.
GetNextFacet(nEdges, vertex, edgeFlag, normals);
644 for(
G4int edgeCount = 0; edgeCount < nEdges; ++edgeCount) {
646 if (isAuxEdgeVisible) {
647 edgeFlag[edgeCount] = 1;
649 if (edgeFlag[edgeCount] > 0) {
651 glEdgeFlag (GL_TRUE);
656 glEdgeFlag (GL_FALSE);
660 glNormal3d (normals[edgeCount].x(),
661 normals[edgeCount].y(),
662 normals[edgeCount].z());
663 glVertex3d (vertex[edgeCount].x(),
664 vertex[edgeCount].y(),
665 vertex[edgeCount].z());
672 normals[edgeCount] = normals[0];
673 vertex[edgeCount] = vertex[0];
674 edgeFlag[edgeCount] = -1;
676 glEdgeFlag (GL_FALSE);
680 glNormal3d (normals[edgeCount].x(),
681 normals[edgeCount].y(),
682 normals[edgeCount].z());
683 glVertex3d (vertex[edgeCount].x(),
684 vertex[edgeCount].y(),
685 vertex[edgeCount].z());
690 "G4OpenGLSceneHandler::AddPrimitive(G4Polyhedron): WARNING"
691 "\n G4Polyhedron facet with " << nEdges <<
" edges" <<
G4endl;
699 glDisable(GL_COLOR_MATERIAL);
707 glDisable (GL_LIGHTING);
710 glStencilFunc (GL_EQUAL, 0, 1);
711 glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP);
715 glEnable (GL_DEPTH_TEST);
716 glDepthFunc (GL_LEQUAL);
719 glDepthMask (GL_FALSE);
721 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
724 glDepthMask (GL_TRUE);
727 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
731 glPolygonMode (GL_FRONT, GL_FILL);
737 goto end_of_drawing_through_stencil;
742 glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, painting_colour);
745 glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, painting_colour);
747 glColor4fv (painting_colour);
749 glEdgeFlag (GL_TRUE);
752 for (
int edgeCount = 0; edgeCount < 4; ++edgeCount) {
753 if (edgeFlag[edgeCount] > 0) {
755 glEdgeFlag (GL_TRUE);
760 glEdgeFlag (GL_FALSE);
764 glNormal3d (normals[edgeCount].x(),
765 normals[edgeCount].y(),
766 normals[edgeCount].z());
767 glVertex3d (vertex[edgeCount].x(),
768 vertex[edgeCount].y(),
769 vertex[edgeCount].z());
772 end_of_drawing_through_stencil:
775 glStencilFunc (GL_ALWAYS, 0, 1);
776 glStencilOp (GL_INVERT, GL_INVERT, GL_INVERT);
777 glDepthFunc (GL_LEQUAL);
781 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
786 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
790 glPolygonMode (GL_FRONT, GL_LINE);
793 glDisable (GL_LIGHTING);
794 glColor4fv (current_colour);
797 glEdgeFlag (GL_TRUE);
799 for (
int edgeCount = 0; edgeCount < 4; ++edgeCount) {
800 if (edgeFlag[edgeCount] > 0) {
802 glEdgeFlag (GL_TRUE);
807 glEdgeFlag (GL_FALSE);
811 glNormal3d (normals[edgeCount].x(),
812 normals[edgeCount].y(),
813 normals[edgeCount].z());
814 glVertex3d (vertex[edgeCount].x(),
815 vertex[edgeCount].y(),
816 vertex[edgeCount].z());
820 glDepthFunc (GL_LEQUAL);
823 glEdgeFlag (GL_TRUE);
829 }
while (notLastFace);
832 glDisable (GL_STENCIL_TEST);
833 glDepthMask (GL_TRUE);
834 glDisable (GL_LIGHTING);
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
const G4Event * GetEvent() const
G4DisplacedSolid * CreateCutawaySolid()
virtual void EndPrimitives()
G4bool fThirdPassForNonHiddenMarkersRequested
void ClearAndDestroyAtts()
virtual void BeginPrimitives2D(const G4Transform3D &objectTransformation)
G4bool fThirdPassForNonHiddenMarkers
static FlushAction fFlushAction
static G4int fEntitiesFlushInterval
void PreAddSolid(const G4Transform3D &objectTransformation, const G4VisAttributes &)
void AddPrimitive(const G4Polyline &)
void AddCompound(const G4VTrajectory &)
virtual void EndPrimitives2D()
virtual void BeginPrimitives(const G4Transform3D &objectTransformation)
static const GLubyte fStippleMaskHashed[128]
G4bool fSecondPassForTransparency
virtual ~G4OpenGLSceneHandler()
G4DisplacedSolid * CreateSectionSolid()
G4OpenGLSceneHandler(G4VGraphicsSystem &system, G4int id, const G4String &name="")
std::map< GLuint, G4AttHolder * > fPickMap
G4bool fSecondPassForTransparencyRequested
void ChangeLineWidth(G4double width)
virtual void DrawText(const G4Text &)
void ChangePointSize(G4double size)
void SetMarkerType(MarkerType)
MarkerType GetMarkerType() const
static G4RunManager * GetMasterRunManager()
const G4Run * GetCurrentRun() const
G4bool GetRefreshAtEndOfEvent() const
G4bool GetRefreshAtEndOfRun() const
FillStyle GetFillStyle() const
G4Point3D GetPosition() const
const G4ModelingParameters * GetModelingParameters() const
G4int GetNoOfSides(const G4VisAttributes *)
virtual void EndPrimitives()
virtual G4DisplacedSolid * CreateSectionSolid()
virtual void ProcessScene()
G4double GetMarkerSize(const G4VMarker &, MarkerSizeType &)
virtual void PreAddSolid(const G4Transform3D &objectTransformation, const G4VisAttributes &)
virtual void EndPrimitives2D()
const G4VisAttributes * fpVisAttribs
virtual void BeginPrimitives2D(const G4Transform3D &objectTransformation=G4Transform3D())
G4bool fReadyForTransients
G4ViewParameters::DrawingStyle GetDrawingStyle(const G4VisAttributes *)
virtual void BeginPrimitives(const G4Transform3D &objectTransformation=G4Transform3D())
G4double GetLineWidth(const G4VisAttributes *)
virtual void ClearStore()
virtual void AddCompound(const G4VTrajectory &)
G4bool GetAuxEdgeVisible(const G4VisAttributes *)
void StandardSpecialMeshRendering(const G4Mesh &)
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)
BasicVector3D< T > unit() const
G4int GetNoFacets() const
G4bool GetNextFacet(G4int &n, G4Point3D *nodes, G4int *edgeFlags=nullptr, G4Normal3D *normals=nullptr) const