1 // Created on: 2011-08-01
2 // Created by: Sergey ZERCHANINOV
3 // Copyright (c) 2011-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <OpenGl_CappingAlgo.hxx>
17 #include <OpenGl_Context.hxx>
18 #include <OpenGl_GlCore11.hxx>
19 #include <OpenGl_GraphicDriver.hxx>
20 #include <OpenGl_ShaderManager.hxx>
21 #include <OpenGl_ShaderProgram.hxx>
22 #include <OpenGl_Structure.hxx>
23 #include <OpenGl_telem_util.hxx>
24 #include <OpenGl_Vec.hxx>
25 #include <OpenGl_View.hxx>
26 #include <OpenGl_Workspace.hxx>
28 #include <Graphic3d_SequenceOfHClipPlane_Handle.hxx>
30 IMPLEMENT_STANDARD_HANDLE (OpenGl_Structure, Graphic3d_CStructure)
31 IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Structure, Graphic3d_CStructure)
33 //! Auxiliary class for bounding box presentation
34 class OpenGl_BndBoxPrs : public OpenGl_Element
40 OpenGl_BndBoxPrs (const Graphic3d_BndBox4f& theBndBox)
42 const float Xm = theBndBox.CornerMin().x();
43 const float Ym = theBndBox.CornerMin().y();
44 const float Zm = theBndBox.CornerMin().z();
45 const float XM = theBndBox.CornerMax().x();
46 const float YM = theBndBox.CornerMax().y();
47 const float ZM = theBndBox.CornerMax().z();
49 myVerts[0] = OpenGl_Vec3 (Xm, Ym, Zm);
50 myVerts[1] = OpenGl_Vec3 (Xm, Ym, ZM);
51 myVerts[2] = OpenGl_Vec3 (Xm, YM, ZM);
52 myVerts[3] = OpenGl_Vec3 (Xm, YM, Zm);
53 myVerts[4] = OpenGl_Vec3 (Xm, Ym, Zm);
54 myVerts[5] = OpenGl_Vec3 (XM, Ym, Zm);
55 myVerts[6] = OpenGl_Vec3 (XM, Ym, ZM);
56 myVerts[7] = OpenGl_Vec3 (XM, YM, ZM);
57 myVerts[8] = OpenGl_Vec3 (XM, YM, Zm);
58 myVerts[9] = OpenGl_Vec3 (XM, Ym, Zm);
59 myVerts[10] = OpenGl_Vec3 (XM, YM, Zm);
60 myVerts[11] = OpenGl_Vec3 (Xm, YM, Zm);
61 myVerts[12] = OpenGl_Vec3 (Xm, YM, ZM);
62 myVerts[13] = OpenGl_Vec3 (XM, YM, ZM);
63 myVerts[14] = OpenGl_Vec3 (XM, Ym, ZM);
64 myVerts[15] = OpenGl_Vec3 (Xm, Ym, ZM);
67 //! Render presentation
68 virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const
71 const OpenGl_AspectLine* anAspectLine = theWorkspace->AspectLine (Standard_True);
72 const Handle(OpenGl_Texture) aPrevTexture = theWorkspace->DisableTexture();
74 glDisable (GL_LIGHTING);
75 if ((theWorkspace->NamedStatus & OPENGL_NS_IMMEDIATE) != 0)
77 glDepthMask (GL_FALSE);
80 // Use highlight colors
81 glColor3fv ((theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT) ? theWorkspace->HighlightColor->rgb : anAspectLine->Color().rgb);
83 glEnableClientState (GL_VERTEX_ARRAY);
84 glVertexPointer (3, GL_FLOAT, 0, (GLfloat* )&myVerts);
85 glDrawArrays (GL_LINE_STRIP, 0, 16);
86 glDisableClientState (GL_VERTEX_ARRAY);
89 if (!aPrevTexture.IsNull())
91 theWorkspace->EnableTexture (aPrevTexture);
95 //! Release graphical resources
96 virtual void Release (const Handle(OpenGl_Context)& )
103 //! Protected destructor
104 virtual ~OpenGl_BndBoxPrs() {}
108 OpenGl_Vec3 myVerts[16]; //!< vertices array
112 DEFINE_STANDARD_ALLOC
116 /*----------------------------------------------------------------------*/
118 // =======================================================================
119 // function : call_util_transpose_mat
121 // =======================================================================
122 static void call_util_transpose_mat (float tmat[16], float mat[4][4])
128 tmat[j*4+i] = mat[i][j];
131 // =======================================================================
132 // function : OpenGl_Structure
134 // =======================================================================
135 OpenGl_Structure::OpenGl_Structure (const Handle(Graphic3d_StructureManager)& theManager)
136 : Graphic3d_CStructure (theManager),
137 myTransformation(NULL),
141 myAspectMarker(NULL),
143 myHighlightColor(NULL),
146 myIsRaytracable (Standard_False),
147 myModificationState (0),
148 myIsCulled (Standard_True)
153 // =======================================================================
154 // function : ~OpenGl_Structure
156 // =======================================================================
157 OpenGl_Structure::~OpenGl_Structure()
159 Release (Handle(OpenGl_Context)());
160 delete myTransformation; myTransformation = NULL;
161 delete myTransPers; myTransPers = NULL;
164 // =======================================================================
165 // function : UpdateAspects
167 // =======================================================================
168 void OpenGl_Structure::UpdateAspects()
170 SetTransformPersistence (TransformPersistence);
172 if (ContextLine.IsDef)
173 SetAspectLine (ContextLine);
175 if (ContextFillArea.IsDef)
176 SetAspectFace (ContextFillArea);
178 if (ContextMarker.IsDef)
179 SetAspectMarker (ContextMarker);
181 if (ContextText.IsDef)
182 SetAspectText (ContextText);
185 // =======================================================================
186 // function : UpdateTransformation
188 // =======================================================================
189 void OpenGl_Structure::UpdateTransformation()
191 if (myTransformation == NULL)
193 myTransformation = new OpenGl_Matrix();
196 matcpy (myTransformation->mat, &Graphic3d_CStructure::Transformation[0][0]);
200 UpdateStateWithAncestorStructures();
204 // =======================================================================
205 // function : SetTransformPersistence
207 // =======================================================================
208 void OpenGl_Structure::SetTransformPersistence(const CALL_DEF_TRANSFORM_PERSISTENCE &ATransPers)
211 myTransPers = new TEL_TRANSFORM_PERSISTENCE;
213 myTransPers->mode = ATransPers.Flag;
214 myTransPers->pointX = ATransPers.Point.x;
215 myTransPers->pointY = ATransPers.Point.y;
216 myTransPers->pointZ = ATransPers.Point.z;
220 // =======================================================================
221 // function : SetAspectLine
223 // =======================================================================
224 void OpenGl_Structure::SetAspectLine (const CALL_DEF_CONTEXTLINE &theAspect)
228 myAspectLine = new OpenGl_AspectLine();
230 myAspectLine->SetAspect (theAspect);
233 // =======================================================================
234 // function : SetAspectFace
236 // =======================================================================
237 void OpenGl_Structure::SetAspectFace (const CALL_DEF_CONTEXTFILLAREA& theAspect)
241 myAspectFace = new OpenGl_AspectFace();
243 myAspectFace->SetAspect (theAspect);
247 UpdateStateWithAncestorStructures();
251 // =======================================================================
252 // function : SetAspectMarker
254 // =======================================================================
255 void OpenGl_Structure::SetAspectMarker (const CALL_DEF_CONTEXTMARKER& theAspect)
259 myAspectMarker = new OpenGl_AspectMarker();
261 myAspectMarker->SetAspect (theAspect);
264 // =======================================================================
265 // function : SetAspectText
267 // =======================================================================
268 void OpenGl_Structure::SetAspectText (const CALL_DEF_CONTEXTTEXT &theAspect)
272 myAspectText = new OpenGl_AspectText();
274 myAspectText->SetAspect (theAspect);
277 // =======================================================================
278 // function : clearHighlightBox
280 // =======================================================================
281 void OpenGl_Structure::clearHighlightBox (const Handle(OpenGl_Context)& theGlCtx)
283 if (!myHighlightBox.IsNull())
285 myHighlightBox->Release (theGlCtx);
286 myHighlightBox.Nullify();
290 // =======================================================================
291 // function : HighlightWithColor
293 // =======================================================================
294 void OpenGl_Structure::HighlightWithColor (const Graphic3d_Vec3& theColor,
295 const Standard_Boolean theToCreate)
297 const Handle(OpenGl_Context)& aCtx = GlDriver()->GetSharedContext();
299 setHighlightColor (aCtx, theColor);
301 clearHighlightColor (aCtx);
304 // =======================================================================
305 // function : HighlightWithBndBox
307 // =======================================================================
308 void OpenGl_Structure::HighlightWithBndBox (const Handle(Graphic3d_Structure)& theStruct,
309 const Standard_Boolean theToCreate)
311 const Handle(OpenGl_Context)& aCtx = GlDriver()->GetSharedContext();
314 clearHighlightBox (aCtx);
318 if (!myHighlightBox.IsNull())
320 myHighlightBox->Release (aCtx);
324 myHighlightBox = new OpenGl_Group (theStruct);
327 CALL_DEF_CONTEXTLINE& aContextLine = myHighlightBox->ChangeContextLine();
328 aContextLine.IsDef = 1;
329 aContextLine.Color = HighlightColor;
330 aContextLine.LineType = Aspect_TOL_SOLID;
331 aContextLine.Width = 1.0f;
332 myHighlightBox->UpdateAspectLine (Standard_True);
334 OpenGl_BndBoxPrs* aBndBoxPrs = new OpenGl_BndBoxPrs (myBndBox);
335 myHighlightBox->AddElement (aBndBoxPrs);
338 // =======================================================================
339 // function : setHighlightColor
341 // =======================================================================
342 void OpenGl_Structure::setHighlightColor (const Handle(OpenGl_Context)& theGlCtx,
343 const Graphic3d_Vec3& theColor)
345 clearHighlightBox (theGlCtx);
346 if (myHighlightColor == NULL)
348 myHighlightColor = new TEL_COLOUR();
351 myHighlightColor->rgb[0] = theColor.r();
352 myHighlightColor->rgb[1] = theColor.g();
353 myHighlightColor->rgb[2] = theColor.b();
354 myHighlightColor->rgb[3] = 1.F;
357 // =======================================================================
358 // function : clearHighlightColor
360 // =======================================================================
361 void OpenGl_Structure::clearHighlightColor (const Handle(OpenGl_Context)& theGlCtx)
363 clearHighlightBox(theGlCtx);
364 delete myHighlightColor;
365 myHighlightColor = NULL;
368 // =======================================================================
369 // function : UpdateNamedStatus
371 // =======================================================================
372 void OpenGl_Structure::UpdateNamedStatus()
375 if (highlight) myNamedStatus |= OPENGL_NS_HIGHLIGHT;
376 if (!visible) myNamedStatus |= OPENGL_NS_HIDE;
380 UpdateStateWithAncestorStructures();
384 // =======================================================================
385 // function : RegisterAncestorStructure
387 // =======================================================================
388 void OpenGl_Structure::RegisterAncestorStructure (const OpenGl_Structure* theStructure) const
390 for (OpenGl_ListOfStructure::Iterator anIt (myAncestorStructures); anIt.More(); anIt.Next())
392 if (anIt.Value() == theStructure)
398 myAncestorStructures.Append (theStructure);
401 // =======================================================================
402 // function : UnregisterAncestorStructure
404 // =======================================================================
405 void OpenGl_Structure::UnregisterAncestorStructure (const OpenGl_Structure* theStructure) const
407 for (OpenGl_ListOfStructure::Iterator anIt (myAncestorStructures); anIt.More(); anIt.Next())
409 if (anIt.Value() == theStructure)
411 myAncestorStructures.Remove (anIt);
417 // =======================================================================
418 // function : UnregisterFromAncestorStructure
420 // =======================================================================
421 void OpenGl_Structure::UnregisterFromAncestorStructure() const
423 for (OpenGl_ListOfStructure::Iterator anIta (myAncestorStructures); anIta.More(); anIta.Next())
425 OpenGl_Structure* anAncestor = const_cast<OpenGl_Structure*> (anIta.ChangeValue());
427 for (OpenGl_ListOfStructure::Iterator anIts (anAncestor->myConnected); anIts.More(); anIts.Next())
429 if (anIts.Value() == this)
431 anAncestor->myConnected.Remove (anIts);
438 // =======================================================================
439 // function : UpdateStateWithAncestorStructures
441 // =======================================================================
442 void OpenGl_Structure::UpdateStateWithAncestorStructures() const
444 myModificationState++;
446 for (OpenGl_ListOfStructure::Iterator anIt (myAncestorStructures); anIt.More(); anIt.Next())
448 anIt.Value()->UpdateStateWithAncestorStructures();
452 // =======================================================================
453 // function : UpdateRaytracableWithAncestorStructures
455 // =======================================================================
456 void OpenGl_Structure::UpdateRaytracableWithAncestorStructures() const
458 myIsRaytracable = OpenGl_Raytrace::IsRaytracedStructure (this);
460 if (!myIsRaytracable)
462 for (OpenGl_ListOfStructure::Iterator anIt (myAncestorStructures); anIt.More(); anIt.Next())
464 anIt.Value()->UpdateRaytracableWithAncestorStructures();
469 // =======================================================================
470 // function : SetRaytracableWithAncestorStructures
472 // =======================================================================
473 void OpenGl_Structure::SetRaytracableWithAncestorStructures() const
475 myIsRaytracable = Standard_True;
477 for (OpenGl_ListOfStructure::Iterator anIt (myAncestorStructures); anIt.More(); anIt.Next())
479 if (!anIt.Value()->IsRaytracable())
481 anIt.Value()->SetRaytracableWithAncestorStructures();
486 // =======================================================================
487 // function : Connect
489 // =======================================================================
490 void OpenGl_Structure::Connect (Graphic3d_CStructure& theStructure)
492 OpenGl_Structure* aStruct = (OpenGl_Structure* )&theStructure;
493 Disconnect (theStructure);
494 myConnected.Append (aStruct);
496 if (aStruct->IsRaytracable())
498 UpdateStateWithAncestorStructures();
499 SetRaytracableWithAncestorStructures();
502 aStruct->RegisterAncestorStructure (this);
505 // =======================================================================
506 // function : Disconnect
508 // =======================================================================
509 void OpenGl_Structure::Disconnect (Graphic3d_CStructure& theStructure)
511 OpenGl_Structure* aStruct = (OpenGl_Structure* )&theStructure;
512 for (OpenGl_ListOfStructure::Iterator anIter (myConnected); anIter.More(); anIter.Next())
514 // Check for the given structure
515 if (anIter.Value() == aStruct)
517 myConnected.Remove (anIter);
519 if (aStruct->IsRaytracable())
521 UpdateStateWithAncestorStructures();
522 UpdateRaytracableWithAncestorStructures();
525 aStruct->UnregisterAncestorStructure (this);
531 // =======================================================================
532 // function : NewGroup
534 // =======================================================================
535 Handle(Graphic3d_Group) OpenGl_Structure::NewGroup (const Handle(Graphic3d_Structure)& theStruct)
537 Handle(OpenGl_Group) aGroup = new OpenGl_Group (theStruct);
538 myGroups.Append (aGroup);
542 // =======================================================================
543 // function : RemoveGroup
545 // =======================================================================
546 void OpenGl_Structure::RemoveGroup (const Handle(Graphic3d_Group)& theGroup)
548 if (theGroup.IsNull())
553 for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myGroups); aGroupIter.More(); aGroupIter.Next())
555 // Check for the given group
556 if (aGroupIter.Value() == theGroup)
558 theGroup->Clear (Standard_False);
560 if (((OpenGl_Group* )theGroup.operator->())->IsRaytracable())
562 UpdateStateWithAncestorStructures();
563 UpdateRaytracableWithAncestorStructures();
566 myGroups.Remove (aGroupIter);
572 // =======================================================================
575 // =======================================================================
576 void OpenGl_Structure::Clear()
578 Clear (GlDriver()->GetSharedContext());
581 // =======================================================================
584 // =======================================================================
585 void OpenGl_Structure::Clear (const Handle(OpenGl_Context)& theGlCtx)
587 Standard_Boolean aRaytracableGroupDeleted (Standard_False);
590 for (OpenGl_Structure::GroupIterator aGroupIter (myGroups); aGroupIter.More(); aGroupIter.Next())
592 aRaytracableGroupDeleted |= aGroupIter.Value()->IsRaytracable();
595 aGroupIter.ChangeValue()->Release (theGlCtx);
599 if (aRaytracableGroupDeleted)
601 UpdateStateWithAncestorStructures();
602 UpdateRaytracableWithAncestorStructures();
605 Is2dText = Standard_False;
606 IsForHighlight = Standard_False;
609 // =======================================================================
612 // =======================================================================
613 void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
615 // Process the structure only if visible
616 if ( myNamedStatus & OPENGL_NS_HIDE )
619 const Handle(OpenGl_Context)& aCtx = AWorkspace->GetGlContext();
621 // Render named status
622 const Standard_Integer named_status = AWorkspace->NamedStatus;
623 AWorkspace->NamedStatus |= myNamedStatus;
625 // Is rendering in ADD or IMMEDIATE mode?
626 const Standard_Boolean isImmediate = (AWorkspace->NamedStatus & OPENGL_NS_IMMEDIATE) != 0;
628 // Apply local transformation
629 GLint matrix_mode = 0;
630 const OpenGl_Matrix *local_trsf = NULL;
631 if (myTransformation)
635 Tmatrix3 aModelWorld;
636 call_util_transpose_mat (*aModelWorld, myTransformation->mat);
637 glGetIntegerv (GL_MATRIX_MODE, &matrix_mode);
639 if (!aCtx->ShaderManager()->IsEmpty())
642 glGetFloatv (GL_MODELVIEW_MATRIX, *aWorldView);
644 Tmatrix3 aProjection;
645 glGetFloatv (GL_PROJECTION_MATRIX, *aProjection);
647 aCtx->ShaderManager()->UpdateModelWorldStateTo (&aModelWorld);
648 aCtx->ShaderManager()->UpdateWorldViewStateTo (&aWorldView);
649 aCtx->ShaderManager()->UpdateProjectionStateTo (&aProjection);
652 glMatrixMode (GL_MODELVIEW);
654 glScalef (1.F, 1.F, 1.F);
655 glMultMatrixf (*aModelWorld);
659 glMatrixMode (GL_MODELVIEW);
662 local_trsf = AWorkspace->SetStructureMatrix (myTransformation);
666 // Apply transform persistence
667 const TEL_TRANSFORM_PERSISTENCE *trans_pers = NULL;
668 if ( myTransPers && myTransPers->mode != 0 )
670 trans_pers = AWorkspace->ActiveView()->BeginTransformPersistence (aCtx, myTransPers);
674 const OpenGl_AspectLine *aspect_line = AWorkspace->AspectLine(Standard_False);
675 const OpenGl_AspectFace *aspect_face = AWorkspace->AspectFace(Standard_False);
676 const OpenGl_AspectMarker *aspect_marker = AWorkspace->AspectMarker(Standard_False);
677 const OpenGl_AspectText *aspect_text = AWorkspace->AspectText(Standard_False);
679 AWorkspace->SetAspectLine(myAspectLine);
681 AWorkspace->SetAspectFace(myAspectFace);
683 AWorkspace->SetAspectMarker(myAspectMarker);
685 AWorkspace->SetAspectText(myAspectText);
687 // Apply highlight color
688 const TEL_COLOUR *highlight_color = AWorkspace->HighlightColor;
689 if (myHighlightColor)
690 AWorkspace->HighlightColor = myHighlightColor;
692 // Render connected structures
693 OpenGl_ListOfStructure::Iterator its(myConnected);
696 its.Value()->Render(AWorkspace);
700 // Set up plane equations for non-structure transformed global model-view matrix
701 const Handle(OpenGl_Context)& aContext = AWorkspace->GetGlContext();
703 // List of planes to be applied to context state
704 Handle(Graphic3d_SequenceOfHClipPlane) aUserPlanes;
706 // Collect clipping planes of structure scope
707 if (!myClipPlanes.IsEmpty())
709 Graphic3d_SequenceOfHClipPlane::Iterator aClippingIt (myClipPlanes);
710 for (; aClippingIt.More(); aClippingIt.Next())
712 const Handle(Graphic3d_ClipPlane)& aClipPlane = aClippingIt.Value();
713 if (!aClipPlane->IsOn())
718 if (aUserPlanes.IsNull())
720 aUserPlanes = new Graphic3d_SequenceOfHClipPlane();
723 aUserPlanes->Append (aClipPlane);
727 if (!aUserPlanes.IsNull() && !aUserPlanes->IsEmpty())
729 // add planes at loaded view matrix state
730 aContext->ChangeClipping().AddWorld (*aUserPlanes, AWorkspace);
732 // Set OCCT state uniform variables
733 if (!aContext->ShaderManager()->IsEmpty())
735 aContext->ShaderManager()->UpdateClippingState();
740 const Graphic3d_SequenceOfGroup& aGroups = DrawGroups();
741 for (OpenGl_Structure::GroupIterator aGroupIter (aGroups); aGroupIter.More(); aGroupIter.Next())
743 aGroupIter.Value()->Render (AWorkspace);
746 // Render capping for structure groups
747 if (!aContext->Clipping().Planes().IsEmpty())
749 OpenGl_CappingAlgo::RenderCapping (AWorkspace, aGroups);
752 // Revert structure clippings
753 if (!aUserPlanes.IsNull() && !aUserPlanes->IsEmpty())
755 aContext->ChangeClipping().Remove (*aUserPlanes);
757 // Set OCCT state uniform variables
758 if (!aContext->ShaderManager()->IsEmpty())
760 aContext->ShaderManager()->RevertClippingState();
764 // Restore highlight color
765 AWorkspace->HighlightColor = highlight_color;
768 AWorkspace->SetAspectLine(aspect_line);
769 AWorkspace->SetAspectFace(aspect_face);
770 AWorkspace->SetAspectMarker(aspect_marker);
771 AWorkspace->SetAspectText(aspect_text);
773 // Restore transform persistence
774 if ( myTransPers && myTransPers->mode != 0 )
776 AWorkspace->ActiveView()->BeginTransformPersistence (aContext, trans_pers);
779 // Restore local transformation
780 if (myTransformation)
785 glMatrixMode (matrix_mode);
787 Tmatrix3 aModelWorldState = { { 1.f, 0.f, 0.f, 0.f },
788 { 0.f, 1.f, 0.f, 0.f },
789 { 0.f, 0.f, 1.f, 0.f },
790 { 0.f, 0.f, 0.f, 1.f } };
792 aContext->ShaderManager()->RevertModelWorldStateTo (&aModelWorldState);
796 AWorkspace->SetStructureMatrix (local_trsf, true);
798 glMatrixMode (GL_MODELVIEW);
803 // Apply highlight box
804 if (!myHighlightBox.IsNull())
806 myHighlightBox->Render (AWorkspace);
809 // Restore named status
810 AWorkspace->NamedStatus = named_status;
813 // =======================================================================
814 // function : Release
816 // =======================================================================
817 void OpenGl_Structure::Release (const Handle(OpenGl_Context)& theGlCtx)
821 OpenGl_Element::Destroy (theGlCtx, myAspectLine);
822 OpenGl_Element::Destroy (theGlCtx, myAspectFace);
823 OpenGl_Element::Destroy (theGlCtx, myAspectMarker);
824 OpenGl_Element::Destroy (theGlCtx, myAspectText);
825 clearHighlightColor (theGlCtx);
827 // Remove from connected list of ancestor
828 UnregisterFromAncestorStructure();
831 // =======================================================================
832 // function : ReleaseGlResources
834 // =======================================================================
835 void OpenGl_Structure::ReleaseGlResources (const Handle(OpenGl_Context)& theGlCtx)
837 for (OpenGl_Structure::GroupIterator aGroupIter (myGroups); aGroupIter.More(); aGroupIter.Next())
839 aGroupIter.ChangeValue()->Release (theGlCtx);
841 if (myAspectLine != NULL)
843 myAspectLine->Release (theGlCtx);
845 if (myAspectFace != NULL)
847 myAspectFace->Release (theGlCtx);
849 if (myAspectMarker != NULL)
851 myAspectMarker->Release (theGlCtx);
853 if (myAspectText != NULL)
855 myAspectText->Release (theGlCtx);
857 if (!myHighlightBox.IsNull())
859 myHighlightBox->Release (theGlCtx);
863 //=======================================================================
864 //function : SetZLayer
866 //=======================================================================
867 void OpenGl_Structure::SetZLayer (const Standard_Integer theLayerIndex)
869 myZLayer = theLayerIndex;
872 //=======================================================================
873 //function : GetZLayer
875 //=======================================================================
876 Standard_Integer OpenGl_Structure::GetZLayer () const
881 //! Dummy structure which just redirects to groups of another structure.
882 class OpenGl_StructureShadow : public OpenGl_Structure
887 //! Create empty structure
888 OpenGl_StructureShadow (const Handle(Graphic3d_StructureManager)& theManager,
889 const Handle(OpenGl_Structure)& theStructure);
891 virtual const Graphic3d_SequenceOfGroup& DrawGroups() const { return myParent->DrawGroups(); }
895 Handle(OpenGl_Structure) myParent;
899 DEFINE_STANDARD_RTTI(OpenGl_Structure) // Type definition
903 DEFINE_STANDARD_HANDLE(OpenGl_StructureShadow, OpenGl_Structure)
905 IMPLEMENT_STANDARD_HANDLE (OpenGl_StructureShadow, OpenGl_Structure)
906 IMPLEMENT_STANDARD_RTTIEXT(OpenGl_StructureShadow, OpenGl_Structure)
908 //=======================================================================
909 //function : OpenGl_StructureShadow
911 //=======================================================================
912 OpenGl_StructureShadow::OpenGl_StructureShadow (const Handle(Graphic3d_StructureManager)& theManager,
913 const Handle(OpenGl_Structure)& theStructure)
914 : OpenGl_Structure (theManager)
916 Handle(OpenGl_StructureShadow) aShadow = Handle(OpenGl_StructureShadow)::DownCast (theStructure);
917 myParent = aShadow.IsNull() ? theStructure : aShadow->myParent;
920 Composition = myParent->Composition;
921 ContainsFacet = myParent->ContainsFacet;
922 IsInfinite = myParent->IsInfinite;
923 for (Standard_Integer i = 0; i <= 3; ++i)
925 for (Standard_Integer j = 0; j <= 3; ++j)
927 Graphic3d_CStructure::Transformation[i][j] = myParent->Graphic3d_CStructure::Transformation[i][j];
931 TransformPersistence.IsSet = myParent->TransformPersistence.IsSet;
932 TransformPersistence.Flag = myParent->TransformPersistence.Flag;
933 TransformPersistence.Point = myParent->TransformPersistence.Point;
936 //=======================================================================
937 //function : ShadowLink
939 //=======================================================================
940 Handle(Graphic3d_CStructure) OpenGl_Structure::ShadowLink (const Handle(Graphic3d_StructureManager)& theManager) const
942 return new OpenGl_StructureShadow (theManager, this);