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_StructureShadow.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
70 #if !defined(GL_ES_VERSION_2_0)
72 const OpenGl_AspectLine* anAspectLine = theWorkspace->AspectLine (Standard_True);
73 const Handle(OpenGl_Texture) aPrevTexture = theWorkspace->DisableTexture();
75 glDisable (GL_LIGHTING);
76 if ((theWorkspace->NamedStatus & OPENGL_NS_IMMEDIATE) != 0)
78 glDepthMask (GL_FALSE);
81 // Use highlight colors
82 theWorkspace->GetGlContext()->core11->glColor3fv ((theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT) ? theWorkspace->HighlightColor->rgb : anAspectLine->Color().rgb);
84 glEnableClientState (GL_VERTEX_ARRAY);
85 glVertexPointer (3, GL_FLOAT, 0, (GLfloat* )&myVerts);
86 glDrawArrays (GL_LINE_STRIP, 0, 16);
87 glDisableClientState (GL_VERTEX_ARRAY);
90 if (!aPrevTexture.IsNull())
92 theWorkspace->EnableTexture (aPrevTexture);
97 //! Release graphical resources
98 virtual void Release (OpenGl_Context*)
105 //! Protected destructor
106 virtual ~OpenGl_BndBoxPrs() {}
110 OpenGl_Vec3 myVerts[16]; //!< vertices array
114 DEFINE_STANDARD_ALLOC
118 /*----------------------------------------------------------------------*/
120 // =======================================================================
121 // function : call_util_transpose_mat
123 // =======================================================================
124 static void call_util_transpose_mat (float tmat[16], float mat[4][4])
130 tmat[j*4+i] = mat[i][j];
133 // =======================================================================
134 // function : OpenGl_Structure
136 // =======================================================================
137 OpenGl_Structure::OpenGl_Structure (const Handle(Graphic3d_StructureManager)& theManager)
138 : Graphic3d_CStructure (theManager),
139 myTransformation(NULL),
143 myAspectMarker(NULL),
145 myHighlightColor(NULL),
148 myIsRaytracable (Standard_False),
149 myModificationState (0),
150 myIsCulled (Standard_True)
155 // =======================================================================
156 // function : ~OpenGl_Structure
158 // =======================================================================
159 OpenGl_Structure::~OpenGl_Structure()
161 Release (Handle(OpenGl_Context)());
162 delete myTransformation; myTransformation = NULL;
163 delete myTransPers; myTransPers = NULL;
166 // =======================================================================
167 // function : UpdateAspects
169 // =======================================================================
170 void OpenGl_Structure::UpdateAspects()
172 SetTransformPersistence (TransformPersistence);
174 if (ContextLine.IsDef)
175 SetAspectLine (ContextLine);
177 if (ContextFillArea.IsDef)
178 SetAspectFace (ContextFillArea);
180 if (ContextMarker.IsDef)
181 SetAspectMarker (ContextMarker);
183 if (ContextText.IsDef)
184 SetAspectText (ContextText);
187 // =======================================================================
188 // function : UpdateTransformation
190 // =======================================================================
191 void OpenGl_Structure::UpdateTransformation()
193 if (myTransformation == NULL)
195 myTransformation = new OpenGl_Matrix();
198 matcpy (myTransformation->mat, &Graphic3d_CStructure::Transformation[0][0]);
202 UpdateStateWithAncestorStructures();
206 // =======================================================================
207 // function : SetTransformPersistence
209 // =======================================================================
210 void OpenGl_Structure::SetTransformPersistence(const CALL_DEF_TRANSFORM_PERSISTENCE &ATransPers)
213 myTransPers = new TEL_TRANSFORM_PERSISTENCE;
215 myTransPers->mode = ATransPers.Flag;
216 myTransPers->pointX = ATransPers.Point.x;
217 myTransPers->pointY = ATransPers.Point.y;
218 myTransPers->pointZ = ATransPers.Point.z;
222 // =======================================================================
223 // function : SetAspectLine
225 // =======================================================================
226 void OpenGl_Structure::SetAspectLine (const CALL_DEF_CONTEXTLINE &theAspect)
230 myAspectLine = new OpenGl_AspectLine();
232 myAspectLine->SetAspect (theAspect);
235 // =======================================================================
236 // function : SetAspectFace
238 // =======================================================================
239 void OpenGl_Structure::SetAspectFace (const CALL_DEF_CONTEXTFILLAREA& theAspect)
243 myAspectFace = new OpenGl_AspectFace();
245 myAspectFace->SetAspect (theAspect);
249 UpdateStateWithAncestorStructures();
253 // =======================================================================
254 // function : SetAspectMarker
256 // =======================================================================
257 void OpenGl_Structure::SetAspectMarker (const CALL_DEF_CONTEXTMARKER& theAspect)
261 myAspectMarker = new OpenGl_AspectMarker();
263 myAspectMarker->SetAspect (theAspect);
266 // =======================================================================
267 // function : SetAspectText
269 // =======================================================================
270 void OpenGl_Structure::SetAspectText (const CALL_DEF_CONTEXTTEXT &theAspect)
274 myAspectText = new OpenGl_AspectText();
276 myAspectText->SetAspect (theAspect);
279 // =======================================================================
280 // function : clearHighlightBox
282 // =======================================================================
283 void OpenGl_Structure::clearHighlightBox (const Handle(OpenGl_Context)& theGlCtx)
285 if (!myHighlightBox.IsNull())
287 myHighlightBox->Release (theGlCtx);
288 myHighlightBox.Nullify();
292 // =======================================================================
293 // function : HighlightWithColor
295 // =======================================================================
296 void OpenGl_Structure::HighlightWithColor (const Graphic3d_Vec3& theColor,
297 const Standard_Boolean theToCreate)
299 const Handle(OpenGl_Context)& aCtx = GlDriver()->GetSharedContext();
301 setHighlightColor (aCtx, theColor);
303 clearHighlightColor (aCtx);
306 // =======================================================================
307 // function : HighlightWithBndBox
309 // =======================================================================
310 void OpenGl_Structure::HighlightWithBndBox (const Handle(Graphic3d_Structure)& theStruct,
311 const Standard_Boolean theToCreate)
313 const Handle(OpenGl_Context)& aCtx = GlDriver()->GetSharedContext();
316 clearHighlightBox (aCtx);
320 if (!myHighlightBox.IsNull())
322 myHighlightBox->Release (aCtx);
326 myHighlightBox = new OpenGl_Group (theStruct);
329 CALL_DEF_CONTEXTLINE& aContextLine = myHighlightBox->ChangeContextLine();
330 aContextLine.IsDef = 1;
331 aContextLine.Color = HighlightColor;
332 aContextLine.LineType = Aspect_TOL_SOLID;
333 aContextLine.Width = 1.0f;
334 myHighlightBox->UpdateAspectLine (Standard_True);
336 OpenGl_BndBoxPrs* aBndBoxPrs = new OpenGl_BndBoxPrs (myBndBox);
337 myHighlightBox->AddElement (aBndBoxPrs);
340 // =======================================================================
341 // function : setHighlightColor
343 // =======================================================================
344 void OpenGl_Structure::setHighlightColor (const Handle(OpenGl_Context)& theGlCtx,
345 const Graphic3d_Vec3& theColor)
347 clearHighlightBox (theGlCtx);
348 if (myHighlightColor == NULL)
350 myHighlightColor = new TEL_COLOUR();
353 myHighlightColor->rgb[0] = theColor.r();
354 myHighlightColor->rgb[1] = theColor.g();
355 myHighlightColor->rgb[2] = theColor.b();
356 myHighlightColor->rgb[3] = 1.F;
359 // =======================================================================
360 // function : clearHighlightColor
362 // =======================================================================
363 void OpenGl_Structure::clearHighlightColor (const Handle(OpenGl_Context)& theGlCtx)
365 clearHighlightBox(theGlCtx);
366 delete myHighlightColor;
367 myHighlightColor = NULL;
370 // =======================================================================
371 // function : UpdateNamedStatus
373 // =======================================================================
374 void OpenGl_Structure::UpdateNamedStatus()
377 if (highlight) myNamedStatus |= OPENGL_NS_HIGHLIGHT;
378 if (!visible) myNamedStatus |= OPENGL_NS_HIDE;
382 UpdateStateWithAncestorStructures();
386 // =======================================================================
387 // function : RegisterAncestorStructure
389 // =======================================================================
390 void OpenGl_Structure::RegisterAncestorStructure (const OpenGl_Structure* theStructure) const
392 for (OpenGl_ListOfStructure::Iterator anIt (myAncestorStructures); anIt.More(); anIt.Next())
394 if (anIt.Value() == theStructure)
400 myAncestorStructures.Append (theStructure);
403 // =======================================================================
404 // function : UnregisterAncestorStructure
406 // =======================================================================
407 void OpenGl_Structure::UnregisterAncestorStructure (const OpenGl_Structure* theStructure) const
409 for (OpenGl_ListOfStructure::Iterator anIt (myAncestorStructures); anIt.More(); anIt.Next())
411 if (anIt.Value() == theStructure)
413 myAncestorStructures.Remove (anIt);
419 // =======================================================================
420 // function : UnregisterFromAncestorStructure
422 // =======================================================================
423 void OpenGl_Structure::UnregisterFromAncestorStructure() const
425 for (OpenGl_ListOfStructure::Iterator anIta (myAncestorStructures); anIta.More(); anIta.Next())
427 OpenGl_Structure* anAncestor = const_cast<OpenGl_Structure*> (anIta.ChangeValue());
429 for (OpenGl_ListOfStructure::Iterator anIts (anAncestor->myConnected); anIts.More(); anIts.Next())
431 if (anIts.Value() == this)
433 anAncestor->myConnected.Remove (anIts);
440 // =======================================================================
441 // function : UpdateStateWithAncestorStructures
443 // =======================================================================
444 void OpenGl_Structure::UpdateStateWithAncestorStructures() const
446 myModificationState++;
448 for (OpenGl_ListOfStructure::Iterator anIt (myAncestorStructures); anIt.More(); anIt.Next())
450 anIt.Value()->UpdateStateWithAncestorStructures();
454 // =======================================================================
455 // function : UpdateRaytracableWithAncestorStructures
457 // =======================================================================
458 void OpenGl_Structure::UpdateRaytracableWithAncestorStructures() const
460 myIsRaytracable = OpenGl_Raytrace::IsRaytracedStructure (this);
462 if (!myIsRaytracable)
464 for (OpenGl_ListOfStructure::Iterator anIt (myAncestorStructures); anIt.More(); anIt.Next())
466 anIt.Value()->UpdateRaytracableWithAncestorStructures();
471 // =======================================================================
472 // function : SetRaytracableWithAncestorStructures
474 // =======================================================================
475 void OpenGl_Structure::SetRaytracableWithAncestorStructures() const
477 myIsRaytracable = Standard_True;
479 for (OpenGl_ListOfStructure::Iterator anIt (myAncestorStructures); anIt.More(); anIt.Next())
481 if (!anIt.Value()->IsRaytracable())
483 anIt.Value()->SetRaytracableWithAncestorStructures();
488 // =======================================================================
489 // function : Connect
491 // =======================================================================
492 void OpenGl_Structure::Connect (Graphic3d_CStructure& theStructure)
494 OpenGl_Structure* aStruct = (OpenGl_Structure* )&theStructure;
495 Disconnect (theStructure);
496 myConnected.Append (aStruct);
498 if (aStruct->IsRaytracable())
500 UpdateStateWithAncestorStructures();
501 SetRaytracableWithAncestorStructures();
504 aStruct->RegisterAncestorStructure (this);
507 // =======================================================================
508 // function : Disconnect
510 // =======================================================================
511 void OpenGl_Structure::Disconnect (Graphic3d_CStructure& theStructure)
513 OpenGl_Structure* aStruct = (OpenGl_Structure* )&theStructure;
514 for (OpenGl_ListOfStructure::Iterator anIter (myConnected); anIter.More(); anIter.Next())
516 // Check for the given structure
517 if (anIter.Value() == aStruct)
519 myConnected.Remove (anIter);
521 if (aStruct->IsRaytracable())
523 UpdateStateWithAncestorStructures();
524 UpdateRaytracableWithAncestorStructures();
527 aStruct->UnregisterAncestorStructure (this);
533 // =======================================================================
534 // function : NewGroup
536 // =======================================================================
537 Handle(Graphic3d_Group) OpenGl_Structure::NewGroup (const Handle(Graphic3d_Structure)& theStruct)
539 Handle(OpenGl_Group) aGroup = new OpenGl_Group (theStruct);
540 myGroups.Append (aGroup);
544 // =======================================================================
545 // function : RemoveGroup
547 // =======================================================================
548 void OpenGl_Structure::RemoveGroup (const Handle(Graphic3d_Group)& theGroup)
550 if (theGroup.IsNull())
555 for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myGroups); aGroupIter.More(); aGroupIter.Next())
557 // Check for the given group
558 if (aGroupIter.Value() == theGroup)
560 theGroup->Clear (Standard_False);
562 if (((OpenGl_Group* )theGroup.operator->())->IsRaytracable())
564 UpdateStateWithAncestorStructures();
565 UpdateRaytracableWithAncestorStructures();
568 myGroups.Remove (aGroupIter);
574 // =======================================================================
577 // =======================================================================
578 void OpenGl_Structure::Clear()
580 Clear (GlDriver()->GetSharedContext());
583 // =======================================================================
586 // =======================================================================
587 void OpenGl_Structure::Clear (const Handle(OpenGl_Context)& theGlCtx)
589 Standard_Boolean aRaytracableGroupDeleted (Standard_False);
592 for (OpenGl_Structure::GroupIterator aGroupIter (myGroups); aGroupIter.More(); aGroupIter.Next())
594 aRaytracableGroupDeleted |= aGroupIter.Value()->IsRaytracable();
597 aGroupIter.ChangeValue()->Release (theGlCtx);
601 if (aRaytracableGroupDeleted)
603 UpdateStateWithAncestorStructures();
604 UpdateRaytracableWithAncestorStructures();
607 Is2dText = Standard_False;
608 IsForHighlight = Standard_False;
611 // =======================================================================
612 // function : RenderGeometry
614 // =======================================================================
615 void OpenGl_Structure::RenderGeometry (const Handle(OpenGl_Workspace) &AWorkspace) const
618 const Graphic3d_SequenceOfGroup& aGroups = DrawGroups();
619 for (OpenGl_Structure::GroupIterator aGroupIter (aGroups); aGroupIter.More(); aGroupIter.Next())
621 aGroupIter.Value()->Render (AWorkspace);
625 // =======================================================================
628 // =======================================================================
629 void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
631 // Process the structure only if visible
632 if ( myNamedStatus & OPENGL_NS_HIDE )
635 const Handle(OpenGl_Context)& aCtx = AWorkspace->GetGlContext();
637 // Render named status
638 const Standard_Integer named_status = AWorkspace->NamedStatus;
639 AWorkspace->NamedStatus |= myNamedStatus;
641 // Is rendering in ADD or IMMEDIATE mode?
642 const Standard_Boolean isImmediate = (AWorkspace->NamedStatus & OPENGL_NS_IMMEDIATE) != 0;
644 // Apply local transformation
645 GLint matrix_mode = 0;
646 const OpenGl_Matrix *local_trsf = NULL;
647 if (myTransformation)
649 #if !defined(GL_ES_VERSION_2_0)
652 Tmatrix3 aModelWorld;
653 call_util_transpose_mat (*aModelWorld, myTransformation->mat);
655 glGetIntegerv (GL_MATRIX_MODE, &matrix_mode);
657 if (!aCtx->ShaderManager()->IsEmpty())
660 glGetFloatv (GL_MODELVIEW_MATRIX, *aWorldView);
662 Tmatrix3 aProjection;
663 glGetFloatv (GL_PROJECTION_MATRIX, *aProjection);
665 aCtx->ShaderManager()->UpdateModelWorldStateTo (&aModelWorld);
666 aCtx->ShaderManager()->UpdateWorldViewStateTo (&aWorldView);
667 aCtx->ShaderManager()->UpdateProjectionStateTo (&aProjection);
670 glMatrixMode (GL_MODELVIEW);
672 glScalef (1.F, 1.F, 1.F);
673 glMultMatrixf (*aModelWorld);
677 glMatrixMode (GL_MODELVIEW);
680 local_trsf = AWorkspace->SetStructureMatrix (myTransformation);
685 // Apply transform persistence
686 const TEL_TRANSFORM_PERSISTENCE *trans_pers = NULL;
687 if ( myTransPers && myTransPers->mode != 0 )
689 trans_pers = AWorkspace->ActiveView()->BeginTransformPersistence (aCtx, myTransPers);
693 const OpenGl_AspectLine *aspect_line = AWorkspace->AspectLine(Standard_False);
694 const OpenGl_AspectFace *aspect_face = AWorkspace->AspectFace(Standard_False);
695 const OpenGl_AspectMarker *aspect_marker = AWorkspace->AspectMarker(Standard_False);
696 const OpenGl_AspectText *aspect_text = AWorkspace->AspectText(Standard_False);
698 AWorkspace->SetAspectLine(myAspectLine);
700 AWorkspace->SetAspectFace(myAspectFace);
702 AWorkspace->SetAspectMarker(myAspectMarker);
704 AWorkspace->SetAspectText(myAspectText);
706 // Apply highlight color
707 const TEL_COLOUR *highlight_color = AWorkspace->HighlightColor;
708 if (myHighlightColor)
709 AWorkspace->HighlightColor = myHighlightColor;
711 // Render connected structures
712 OpenGl_ListOfStructure::Iterator its(myConnected);
715 its.Value()->RenderGeometry (AWorkspace);
719 // Set up plane equations for non-structure transformed global model-view matrix
720 const Handle(OpenGl_Context)& aContext = AWorkspace->GetGlContext();
722 // List of planes to be applied to context state
723 Handle(Graphic3d_SequenceOfHClipPlane) aUserPlanes;
725 // Collect clipping planes of structure scope
726 if (!myClipPlanes.IsEmpty())
728 Graphic3d_SequenceOfHClipPlane::Iterator aClippingIt (myClipPlanes);
729 for (; aClippingIt.More(); aClippingIt.Next())
731 const Handle(Graphic3d_ClipPlane)& aClipPlane = aClippingIt.Value();
732 if (!aClipPlane->IsOn())
737 if (aUserPlanes.IsNull())
739 aUserPlanes = new Graphic3d_SequenceOfHClipPlane();
742 aUserPlanes->Append (aClipPlane);
746 if (!aUserPlanes.IsNull() && !aUserPlanes->IsEmpty())
748 // add planes at loaded view matrix state
749 aContext->ChangeClipping().AddWorld (*aUserPlanes, AWorkspace);
751 // Set OCCT state uniform variables
752 if (!aContext->ShaderManager()->IsEmpty())
754 aContext->ShaderManager()->UpdateClippingState();
759 const Graphic3d_SequenceOfGroup& aGroups = DrawGroups();
760 for (OpenGl_Structure::GroupIterator aGroupIter (aGroups); aGroupIter.More(); aGroupIter.Next())
762 aGroupIter.Value()->Render (AWorkspace);
765 // Render capping for structure groups
766 if (!aContext->Clipping().Planes().IsEmpty())
768 OpenGl_CappingAlgo::RenderCapping (AWorkspace, aGroups);
771 // Revert structure clippings
772 if (!aUserPlanes.IsNull() && !aUserPlanes->IsEmpty())
774 aContext->ChangeClipping().Remove (*aUserPlanes);
776 // Set OCCT state uniform variables
777 if (!aContext->ShaderManager()->IsEmpty())
779 aContext->ShaderManager()->RevertClippingState();
783 // Restore highlight color
784 AWorkspace->HighlightColor = highlight_color;
787 AWorkspace->SetAspectLine(aspect_line);
788 AWorkspace->SetAspectFace(aspect_face);
789 AWorkspace->SetAspectMarker(aspect_marker);
790 AWorkspace->SetAspectText(aspect_text);
792 // Restore transform persistence
793 if ( myTransPers && myTransPers->mode != 0 )
795 AWorkspace->ActiveView()->BeginTransformPersistence (aContext, trans_pers);
798 // Restore local transformation
799 if (myTransformation)
801 #if !defined(GL_ES_VERSION_2_0)
805 glMatrixMode (matrix_mode);
807 Tmatrix3 aModelWorldState = { { 1.f, 0.f, 0.f, 0.f },
808 { 0.f, 1.f, 0.f, 0.f },
809 { 0.f, 0.f, 1.f, 0.f },
810 { 0.f, 0.f, 0.f, 1.f } };
812 aContext->ShaderManager()->RevertModelWorldStateTo (&aModelWorldState);
816 AWorkspace->SetStructureMatrix (local_trsf, true);
818 glMatrixMode (GL_MODELVIEW);
824 // Apply highlight box
825 if (!myHighlightBox.IsNull())
827 myHighlightBox->Render (AWorkspace);
830 // Restore named status
831 AWorkspace->NamedStatus = named_status;
834 // =======================================================================
835 // function : Release
837 // =======================================================================
838 void OpenGl_Structure::Release (const Handle(OpenGl_Context)& theGlCtx)
842 OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectLine);
843 OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectFace);
844 OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectMarker);
845 OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectText);
846 clearHighlightColor (theGlCtx);
848 // Remove from connected list of ancestor
849 UnregisterFromAncestorStructure();
852 // =======================================================================
853 // function : ReleaseGlResources
855 // =======================================================================
856 void OpenGl_Structure::ReleaseGlResources (const Handle(OpenGl_Context)& theGlCtx)
858 for (OpenGl_Structure::GroupIterator aGroupIter (myGroups); aGroupIter.More(); aGroupIter.Next())
860 aGroupIter.ChangeValue()->Release (theGlCtx);
862 if (myAspectLine != NULL)
864 myAspectLine->Release (theGlCtx.operator->());
866 if (myAspectFace != NULL)
868 myAspectFace->Release (theGlCtx.operator->());
870 if (myAspectMarker != NULL)
872 myAspectMarker->Release (theGlCtx.operator->());
874 if (myAspectText != NULL)
876 myAspectText->Release (theGlCtx.operator->());
878 if (!myHighlightBox.IsNull())
880 myHighlightBox->Release (theGlCtx.operator->());
884 //=======================================================================
885 //function : SetZLayer
887 //=======================================================================
888 void OpenGl_Structure::SetZLayer (const Standard_Integer theLayerIndex)
890 myZLayer = theLayerIndex;
893 //=======================================================================
894 //function : GetZLayer
896 //=======================================================================
897 Standard_Integer OpenGl_Structure::GetZLayer () const
902 //=======================================================================
903 //function : ShadowLink
905 //=======================================================================
906 Handle(Graphic3d_CStructure) OpenGl_Structure::ShadowLink (const Handle(Graphic3d_StructureManager)& theManager) const
908 return new OpenGl_StructureShadow (theManager, this);