]> OCCT Git - occt-copy.git/commitdiff
0030491: Visualization - OpenGl_Element inherits Standard_Transient
authornds <nds@opencascade.com>
Fri, 22 Feb 2019 17:26:18 +0000 (20:26 +0300)
committernds <nds@opencascade.com>
Thu, 7 Mar 2019 13:15:12 +0000 (16:15 +0300)
(cherry picked from commit b293d433fbdf97edeb5ea3eab30701c0ceab77ed)

Conflicts:
src/OpenGl/OpenGl_CappingAlgo.cxx
src/OpenGl/OpenGl_CappingPlaneResource.cxx
src/OpenGl/OpenGl_CappingPlaneResource.hxx
src/OpenGl/OpenGl_Group.cxx
src/OpenGl/OpenGl_Group.hxx
src/OpenGl/OpenGl_Text.cxx

Additionally changed classes of VInspector package that uses OpenGl_Element instance (Handle instead of direct pointer).

(cherry picked from commit 62c1e07ce3ff867ce15d4f21c9da44f709845dfa)

51 files changed:
src/OpenGl/OpenGl_AspectFace.cxx
src/OpenGl/OpenGl_AspectFace.hxx
src/OpenGl/OpenGl_AspectLine.cxx
src/OpenGl/OpenGl_AspectLine.hxx
src/OpenGl/OpenGl_AspectMarker.cxx
src/OpenGl/OpenGl_AspectMarker.hxx
src/OpenGl/OpenGl_AspectText.cxx
src/OpenGl/OpenGl_AspectText.hxx
src/OpenGl/OpenGl_BackgroundArray.cxx
src/OpenGl/OpenGl_BackgroundArray.hxx
src/OpenGl/OpenGl_CappingAlgo.cxx
src/OpenGl/OpenGl_CappingPlaneResource.cxx
src/OpenGl/OpenGl_CappingPlaneResource.hxx
src/OpenGl/OpenGl_Context.cxx
src/OpenGl/OpenGl_Context.hxx
src/OpenGl/OpenGl_Element.cxx
src/OpenGl/OpenGl_Element.hxx
src/OpenGl/OpenGl_Flipper.cxx
src/OpenGl/OpenGl_Flipper.hxx
src/OpenGl/OpenGl_FrameStats.cxx
src/OpenGl/OpenGl_FrameStatsPrs.cxx
src/OpenGl/OpenGl_FrameStatsPrs.hxx
src/OpenGl/OpenGl_GraduatedTrihedron.cxx
src/OpenGl/OpenGl_GraduatedTrihedron.hxx
src/OpenGl/OpenGl_GraphicDriver.cxx
src/OpenGl/OpenGl_Group.cxx
src/OpenGl/OpenGl_Group.hxx
src/OpenGl/OpenGl_PrimitiveArray.cxx
src/OpenGl/OpenGl_PrimitiveArray.hxx
src/OpenGl/OpenGl_SceneGeometry.cxx
src/OpenGl/OpenGl_SceneGeometry.hxx
src/OpenGl/OpenGl_StencilTest.cxx
src/OpenGl/OpenGl_StencilTest.hxx
src/OpenGl/OpenGl_Structure.cxx
src/OpenGl/OpenGl_Text.cxx
src/OpenGl/OpenGl_Text.hxx
src/OpenGl/OpenGl_View.cxx
src/OpenGl/OpenGl_View.hxx
src/OpenGl/OpenGl_View_Raytrace.cxx
src/OpenGl/OpenGl_View_Redraw.cxx
src/OpenGl/OpenGl_Workspace.cxx
src/OpenGl/OpenGl_Workspace.hxx
src/ViewerTest/ViewerTest_OpenGlCommands.cxx
tools/VInspector/VInspector_ItemGraphic3dGroup.cxx
tools/VInspector/VInspector_ItemGraphic3dGroup.hxx
tools/VInspector/VInspector_ItemOpenGlElement.cxx
tools/VInspector/VInspector_ItemOpenGlElement.hxx
tools/VInspector/VInspector_PrsOpenGlElement.cxx
tools/VInspector/VInspector_PrsOpenGlElement.hxx
tools/VInspector/VInspector_Window.cxx
tools/VInspector/VInspector_Window.hxx

index dcd13a210016589b25e52b9eaaf8396520a2efcf..a967d4cb81947b1e2b66f7c6dc42f387ebe3c245 100644 (file)
@@ -32,6 +32,8 @@
 
 #include <Image_PixMap.hxx>
 
+IMPLEMENT_STANDARD_RTTIEXT(OpenGl_AspectFace, OpenGl_Element)
+
 namespace
 {
   //! Initialize default material in this way for backward compatibility.
@@ -66,6 +68,7 @@ OpenGl_AspectFace::OpenGl_AspectFace()
                                             THE_DEFAULT_MATERIAL, THE_DEFAULT_MATERIAL)),
   myShadingModel (Graphic3d_TOSM_UNLIT)
 {
+  myAspectEdge = new OpenGl_AspectLine();
   myAspect->SetShadingModel (myShadingModel);
   myAspect->SetHatchStyle (Handle(Graphic3d_HatchStyle)());
 }
@@ -77,6 +80,8 @@ OpenGl_AspectFace::OpenGl_AspectFace()
 OpenGl_AspectFace::OpenGl_AspectFace (const Handle(Graphic3d_AspectFillArea3d)& theAspect)
 : myShadingModel (Graphic3d_TOSM_DEFAULT)
 {
+  myAspectEdge = new OpenGl_AspectLine();
+
   SetAspect (theAspect);
 }
 
@@ -97,9 +102,9 @@ void OpenGl_AspectFace::SetAspect (const Handle(Graphic3d_AspectFillArea3d)& the
                  ? theAspect->ShadingModel()
                  : Graphic3d_TOSM_UNLIT;
 
-  myAspectEdge.Aspect()->SetColor (theAspect->EdgeColor());
-  myAspectEdge.Aspect()->SetType  (theAspect->EdgeLineType());
-  myAspectEdge.Aspect()->SetWidth (theAspect->EdgeWidth());
+  myAspectEdge->Aspect()->SetColor (theAspect->EdgeColor());
+  myAspectEdge->Aspect()->SetType  (theAspect->EdgeLineType());
+  myAspectEdge->Aspect()->SetWidth (theAspect->EdgeWidth());
 
   // update texture binding
   myResources.UpdateTexturesRediness (myAspect->TextureSet());
index 8d93a114d68c1e7bf6e49a3ae98c2633873d4a5e..ee32e54510a40166fffba60781375a344449b96e 100644 (file)
@@ -28,7 +28,7 @@ class OpenGl_Texture;
 //! The element holding Graphic3d_AspectFillArea3d.
 class OpenGl_AspectFace : public OpenGl_Element
 {
-
+  DEFINE_STANDARD_RTTIEXT(OpenGl_AspectFace, OpenGl_Element)
 public:
 
   //! Empty constructor.
@@ -44,10 +44,10 @@ public:
   Standard_EXPORT void SetAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect);
 
   //! Set edge aspect.
-  void SetAspectEdge (const OpenGl_AspectLine* theAspectEdge) { myAspectEdge = *theAspectEdge; }
+  void SetAspectEdge (const Handle(OpenGl_AspectLine)& theAspectEdge) { myAspectEdge = theAspectEdge; }
 
   //! @return edge aspect.
-  const OpenGl_AspectLine* AspectEdge() const  { return &myAspectEdge; }
+  const Handle(OpenGl_AspectLine)& AspectEdge() const  { return myAspectEdge; }
 
   //! Returns Shading Model.
   Graphic3d_TypeOfShadingModel ShadingModel() const { return myShadingModel; }
@@ -140,7 +140,7 @@ protected:
   } myResources;
 
   Handle(Graphic3d_AspectFillArea3d) myAspect;
-  OpenGl_AspectLine                  myAspectEdge;
+  Handle(OpenGl_AspectLine)          myAspectEdge;
   Graphic3d_TypeOfShadingModel       myShadingModel;
 
 public:
index 31fbe7d7e76b3d8d88df89e5cbd6d0155cbf090f..d2b06e86c52bad46adfb634ae6fda5b7bfa86a4e 100644 (file)
@@ -21,6 +21,8 @@
 #include <OpenGl_ShaderProgram.hxx>
 #include <OpenGl_Workspace.hxx>
 
+IMPLEMENT_STANDARD_RTTIEXT(OpenGl_AspectLine, OpenGl_Element)
+
 namespace
 {
   static const TCollection_AsciiString THE_EMPTY_KEY;
index a44bd54671e8de6f9c338f6e87f4b81345e90745..2fd70fd20ec6f0d668a1d2fafaf5e245719931e8 100644 (file)
@@ -26,6 +26,7 @@ class OpenGl_ShaderProgram;
 //! The element holding Graphic3d_AspectLine3d.
 class OpenGl_AspectLine : public OpenGl_Element
 {
+  DEFINE_STANDARD_RTTIEXT(OpenGl_AspectLine, OpenGl_Element)
 public:
 
   //! Empty constructor.
index d12df9a0cb59879685c37070aa423f9eecdbde01..20157e072b519bd48f4575131a714921932833a0 100644 (file)
@@ -27,6 +27,8 @@
 #include <NCollection_Vec4.hxx>
 #include <TColStd_HArray1OfByte.hxx>
 
+IMPLEMENT_STANDARD_RTTIEXT(OpenGl_AspectMarker, OpenGl_Element)
+
 namespace
 {
   static const TCollection_AsciiString THE_EMPTY_KEY;
index c4178aa4b4db9bb27f08a6a8ad591178d4f62e32..7eb39550548839c773543b2e595482b4b7b8492c 100644 (file)
@@ -29,6 +29,7 @@ class OpenGl_ShaderProgram;
 //! The element holding Graphic3d_AspectMarker3d.
 class OpenGl_AspectMarker : public OpenGl_Element
 {
+  DEFINE_STANDARD_RTTIEXT(OpenGl_AspectMarker, OpenGl_Element)
 public:
 
   //! Empty constructor.
index 540c6ac97d554d925f2b7c48e2ff899fac633ebe..ab7c9d7ccd2bbbbcf66cc07f823dd486c971a82a 100755 (executable)
@@ -21,6 +21,8 @@
 #include <OpenGl_ShaderManager.hxx>
 #include <OpenGl_ShaderProgram.hxx>
 
+IMPLEMENT_STANDARD_RTTIEXT(OpenGl_AspectText, OpenGl_Element)
+
 namespace
 {
   static const TCollection_AsciiString THE_EMPTY_KEY;
index 2596b878a86673afe3f3b89f4e8b9ee26eb6df17..d41596d8707717003d30b1799f36d020278909bd 100755 (executable)
@@ -28,7 +28,7 @@ class OpenGl_ShaderProgram;
 //! Text representation parameters
 class OpenGl_AspectText : public OpenGl_Element
 {
-
+  DEFINE_STANDARD_RTTIEXT(OpenGl_AspectText, OpenGl_Element)
 public:
 
   //! Empty constructor.
index f760dcfc9820b102d204d6118db1cb7c11e2d609..17e5611692f08042d51509005a6154e312ef54bd 100644 (file)
@@ -21,6 +21,8 @@
 #include <OpenGl_View.hxx>
 #include <Graphic3d_TextureParams.hxx>
 
+IMPLEMENT_STANDARD_RTTIEXT(OpenGl_BackgroundArray, OpenGl_PrimitiveArray)
+
 // =======================================================================
 // method  : Constructor
 // purpose :
@@ -337,7 +339,7 @@ Standard_Boolean OpenGl_BackgroundArray::createTextureArray (const Handle(OpenGl
 
   // Get texture parameters
   const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
-  const OpenGl_AspectFace* anAspectFace = theWorkspace->AspectFace();
+  const Handle(OpenGl_AspectFace)& anAspectFace = theWorkspace->AspectFace();
   GLfloat aTextureWidth  = (GLfloat )anAspectFace->TextureSet (aCtx)->First()->SizeX();
   GLfloat aTextureHeight = (GLfloat )anAspectFace->TextureSet (aCtx)->First()->SizeY();
 
index 845873641523d893e36cf5046061c5f94d19ccc4..1f01b74c014926827569564eec706ad0c0564f8d 100644 (file)
@@ -28,6 +28,7 @@
 //! gradient or texture background rendering.
 class OpenGl_BackgroundArray : public OpenGl_PrimitiveArray
 {
+  DEFINE_STANDARD_RTTIEXT(OpenGl_BackgroundArray, OpenGl_PrimitiveArray)
 public:
 
   //! Main constructor.
index c13cf3d86982986338eb63ce56ac7707059d54c0..b5d8e28dfe88eb46af72ff9b3de84d232696c40f 100755 (executable)
@@ -66,18 +66,18 @@ namespace
   class OpenGl_SharedElement : public OpenGl_Resource
   {
     public:
-      OpenGl_SharedElement (OpenGl_Element* theGlElement) : myGlElement (theGlElement) {}
+      OpenGl_SharedElement (Handle(OpenGl_Element) theGlElement) : myGlElement (theGlElement) {}
       virtual void Release (OpenGl_Context* theGlCtx) Standard_OVERRIDE
       {
         OpenGl_Element::Destroy (theGlCtx, myGlElement);
       }
-      OpenGl_Element* GlElement() const { return myGlElement; }
+      Handle(OpenGl_Element) GlElement() const { return myGlElement; }
 
       //! Returns estimated GPU memory usage for holding data without considering overheads and allocation alignment rules.
       Standard_Size EstimatedDataSize() const Standard_OVERRIDE { return 0; }
 
     private:
-      OpenGl_Element* myGlElement;
+      Handle(OpenGl_Element) myGlElement;
 
     public:
 
@@ -85,7 +85,7 @@ namespace
   };
 
   //! Iitializes and returns vertex buffer for plane section
-  OpenGl_PrimitiveArray* initQuad (const Handle(OpenGl_Context)& theContext)
+  Handle(OpenGl_PrimitiveArray) initQuad (const Handle(OpenGl_Context)& theContext)
   {
     Handle(OpenGl_SharedElement) aSharedResource;
 
@@ -95,14 +95,14 @@ namespace
       theContext->ShareResource (THE_QUAD_PARRAY, aSharedResource);
     }
 
-    return dynamic_cast<OpenGl_PrimitiveArray*> (aSharedResource->GlElement());
+    return Handle(OpenGl_PrimitiveArray)::DownCast (aSharedResource->GlElement());
   }
 
   //! Render section plane using the given aspects.
   void renderSection (const Handle(OpenGl_Workspace)& theWorkspace,
-                      const OpenGl_PrimitiveArray*    theQuad,
-                      const OpenGl_AspectFace*        theCappingAspect,
-                      const OpenGl_AspectFace*        theHatchAspect,
+                      const Handle(OpenGl_PrimitiveArray)& theQuad,
+                      const Handle(OpenGl_AspectFace)& theCappingAspect,
+                      const Handle(OpenGl_AspectFace)& theHatchAspect,
                       const OpenGl_Mat4&              theCappingMatrix,
                       const Standard_ShortReal        theHatchScale,
                       const Standard_ShortReal        theHatchRotate)
@@ -111,7 +111,7 @@ namespace
     const bool wasCullAllowed = theWorkspace->SetAllowFaceCulling (true);
 
     const Standard_Boolean isTextureHatch =
-        theHatchAspect != NULL
+        !theHatchAspect.IsNull()
     &&  theHatchAspect->Aspect()->TextureMapState();
 
     aContext->ModelWorldState.Push();
@@ -123,7 +123,7 @@ namespace
 
     theQuad->Render (theWorkspace);
 
-    if (theHatchAspect != NULL)
+    if (!theHatchAspect.IsNull())
     {
       Graphic3d_Vec2     aPrevScale;
       Standard_ShortReal aPrevRotate = 0.0;
@@ -184,7 +184,7 @@ namespace
                                          const Handle(Graphic3d_ClipPlane)& theClipChain,
                                          const Standard_Integer          theSubPlaneIndex,
                                          const Handle(OpenGl_CappingPlaneResource)& thePlane,
-                                         const OpenGl_PrimitiveArray*    theQuad)
+                                         const Handle(OpenGl_PrimitiveArray) theQuad)
   {
     const Standard_Integer aPrevFilter = theWorkspace->RenderFilter();
     const Standard_Integer anAnyFilter = aPrevFilter & ~(Standard_Integer )(OpenGl_RenderFilter_OpaqueOnly | OpenGl_RenderFilter_TransparentOnly);
@@ -221,7 +221,7 @@ namespace
       glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
 
       // override aspects, disable culling
-      theWorkspace->SetAspectFace (&theWorkspace->NoneCulling());
+      theWorkspace->SetAspectFace (theWorkspace->NoneCulling());
       theWorkspace->ApplyAspectFace();
 
       // evaluate number of pair faces
@@ -240,7 +240,7 @@ namespace
       aGroupIter.Value()->Render (theWorkspace);
 
       // override material, cull back faces
-      theWorkspace->SetAspectFace (&theWorkspace->FrontCulling());
+      theWorkspace->SetAspectFace (theWorkspace->FrontCulling());
       theWorkspace->ApplyAspectFace();
 
       // enable all clip plane except the rendered one
@@ -260,7 +260,7 @@ namespace
         glEnable (GL_DEPTH_TEST);
       }
 
-      const OpenGl_AspectFace*        aGroupAspectFace    = aGroupIter.Value()->AspectFace();
+      const Handle(OpenGl_AspectFace)& aGroupAspectFace = aGroupIter.Value()->AspectFace();
       const OpenGl_CappingPlaneResource* aGroupAspectCapping = aGroupIter.Value()->AspectFillCapping();
       const OpenGl_CappingPlaneResource* anAspectCapping =
           thePlane && (!aGroupAspectCapping || aGroupAspectCapping->Aspect().IsNull() || aPlane->ToOverrideCappingAspect())
@@ -272,9 +272,9 @@ namespace
         anAspectCapping = &THE_DEFAULT_ASPECT;
       }
 
-      const OpenGl_AspectFace* anAspectFace     = anAspectCapping->CappingFaceAspect (aGroupAspectFace);
+      Handle(OpenGl_AspectFace) anAspectFace    = anAspectCapping->CappingFaceAspect (aGroupAspectFace);
       const Standard_Boolean   hasHatch         = anAspectCapping->Aspect()->ToDrawHatch();
-      const OpenGl_AspectFace* anAspectHatching = hasHatch ? anAspectCapping->HatchingFaceAspect() : NULL;
+      const Handle(OpenGl_AspectFace)& anAspectHatching = hasHatch ? anAspectCapping->HatchingFaceAspect() : NULL;
       const Standard_Boolean   hasTextureHatch  = hasHatch && !anAspectCapping->Aspect()->TextureHatch().IsNull();
       const Standard_Boolean   isRotatePers     = hasTextureHatch && !aCamera.IsNull() && anAspectCapping->Aspect()->IsHatchRotationPersistent();
       const Standard_Boolean   isZoomPers       = hasTextureHatch && !aCamera.IsNull() && anAspectCapping->Aspect()->IsHatchZoomPersistent();
@@ -348,14 +348,14 @@ void OpenGl_CappingAlgo::RenderCapping (const Handle(OpenGl_Workspace)& theWorks
     return;
   }
 
-  const OpenGl_PrimitiveArray* aCappingQuad = initQuad (aContext);
-  if (!aCappingQuad)
+  Handle(OpenGl_PrimitiveArray) aCappingQuad = initQuad (aContext);
+  if (aCappingQuad.IsNull())
   {
     return;
   }
 
   // remember current aspect face defined in workspace
-  const OpenGl_AspectFace* aFaceAsp = theWorkspace->AspectFace();
+  const Handle(OpenGl_AspectFace)& aFaceAsp = theWorkspace->AspectFace();
 
   // only filled primitives should be rendered
   const Standard_Integer aPrevFilter = theWorkspace->RenderFilter();
index 9b6678b87575c45fe1ac0ec1e102562f928fa614..51d3e2a9ff92530358d8f5fd53f431a9a434be09 100755 (executable)
@@ -74,9 +74,9 @@ namespace
 // function : BuildInfinitPlaneVertices
 // purpose  :
 // =======================================================================
-OpenGl_PrimitiveArray* OpenGl_CappingPlaneResource::BuildInfinitPlaneVertices()
+Handle(OpenGl_PrimitiveArray) OpenGl_CappingPlaneResource::BuildInfinitPlaneVertices()
 {
-  OpenGl_PrimitiveArray* aPrimitives = NULL;
+  Handle(OpenGl_PrimitiveArray) aPrimitives;
   // Fill primitive array
   Handle(NCollection_AlignedAllocator) anAlloc = new NCollection_AlignedAllocator (16);
   Handle(Graphic3d_Buffer) anAttribs = new Graphic3d_Buffer (anAlloc);
@@ -101,8 +101,8 @@ OpenGl_PrimitiveArray* OpenGl_CappingPlaneResource::BuildInfinitPlaneVertices()
 // purpose  :
 // =======================================================================
 OpenGl_CappingPlaneResource::OpenGl_CappingPlaneResource (const Handle(Graphic3d_AspectFillCapping)& theAspect)
-: myCappingAspect  (defaultMaterial()),
-  myHatchingAspect (defaultMaterial()),
+: myCappingAspect  (new OpenGl_AspectFace (defaultMaterial())),
+  myHatchingAspect (new OpenGl_AspectFace (defaultMaterial())),
   myHatchingState (0)
 {
   SetAspect (theAspect);
@@ -133,7 +133,7 @@ void OpenGl_CappingPlaneResource::SetAspect (const Handle(Graphic3d_AspectFillCa
    || !theAspect->ToUseObjectTexture()
    || !theAspect->ToUseObjectShader())
   {
-    Handle(Graphic3d_AspectFillArea3d) aFillAspect = myCappingAspect.Aspect();
+    Handle(Graphic3d_AspectFillArea3d) aFillAspect = myCappingAspect->Aspect();
 
     if (!theAspect->ToUseObjectMaterial())
     {
@@ -165,14 +165,14 @@ void OpenGl_CappingPlaneResource::SetAspect (const Handle(Graphic3d_AspectFillCa
       aFillAspect->SetShaderProgram (theAspect->Shader());
     }
 
-    myCappingAspect.SetAspect (aFillAspect);
+    myCappingAspect->SetAspect (aFillAspect);
   }
 
   if (theAspect->ToDrawHatch()
     && (theAspect->IsTextureHatch()
      || theAspect->IsStippleHatch()))
   {
-    Handle(Graphic3d_AspectFillArea3d) aFillAspect = myHatchingAspect.Aspect();
+    Handle(Graphic3d_AspectFillArea3d) aFillAspect = myHatchingAspect->Aspect();
 
     aFillAspect->SetInteriorStyle (theAspect->IsStippleHatch() ? Aspect_IS_HATCH : Aspect_IS_SOLID);
     aFillAspect->SetHatchStyle    (theAspect->IsStippleHatch() ? theAspect->StippleHatch() : Handle(Graphic3d_HatchStyle)());
@@ -188,7 +188,7 @@ void OpenGl_CappingPlaneResource::SetAspect (const Handle(Graphic3d_AspectFillCa
       aFillAspect->SetTextureMapOff();
     }
 
-    myHatchingAspect.SetAspect (aFillAspect);
+    myHatchingAspect->SetAspect (aFillAspect);
     myHatchingState = theAspect->HatchingState();
   }
 }
@@ -199,24 +199,24 @@ void OpenGl_CappingPlaneResource::SetAspect (const Handle(Graphic3d_AspectFillCa
 // =======================================================================
 void OpenGl_CappingPlaneResource::Release (OpenGl_Context* theContext)
 {
-  myCappingAspect .Release (theContext);
-  myHatchingAspect.Release (theContext);
+  myCappingAspect->Release (theContext);
+  myHatchingAspect->Release (theContext);
 }
 
 // =======================================================================
 // function : CappingFaceAspect
 // purpose  :
 // =======================================================================
-const OpenGl_AspectFace* OpenGl_CappingPlaneResource::CappingFaceAspect (const OpenGl_AspectFace* theObjectAspect) const
+Handle(OpenGl_AspectFace) OpenGl_CappingPlaneResource::CappingFaceAspect (const Handle(OpenGl_AspectFace)& theObjectAspect) const
 {
   if (myAspect.IsNull())
   {
     return NULL;
   }
 
-  Handle(Graphic3d_AspectFillArea3d) aFillAspect = myCappingAspect.Aspect();
+  Handle(Graphic3d_AspectFillArea3d) aFillAspect = myCappingAspect->Aspect();
 
-  if (myAspect->ToUseObjectMaterial() && theObjectAspect != NULL)
+  if (myAspect->ToUseObjectMaterial() && !theObjectAspect.IsNull())
   {
     // only front material currently supported by capping rendering
     aFillAspect->SetFrontMaterial (theObjectAspect->Aspect()->FrontMaterial());
@@ -228,7 +228,7 @@ const OpenGl_AspectFace* OpenGl_CappingPlaneResource::CappingFaceAspect (const O
     aFillAspect->SetInteriorColor (myAspect->Material().Color());
   }
 
-  if (myAspect->ToUseObjectTexture() && theObjectAspect != NULL)
+  if (myAspect->ToUseObjectTexture() && !theObjectAspect.IsNull())
   {
     if (theObjectAspect->Aspect()->ToMapTexture())
     {
@@ -253,7 +253,7 @@ const OpenGl_AspectFace* OpenGl_CappingPlaneResource::CappingFaceAspect (const O
     }
   }
 
-  if (myAspect->ToUseObjectShader() && theObjectAspect != NULL)
+  if (myAspect->ToUseObjectShader() && !theObjectAspect.IsNull())
   {
     aFillAspect->SetShaderProgram (theObjectAspect->Aspect()->ShaderProgram());
   }
@@ -262,16 +262,16 @@ const OpenGl_AspectFace* OpenGl_CappingPlaneResource::CappingFaceAspect (const O
     aFillAspect->SetShaderProgram (myAspect->Shader());
   }
 
-  myCappingAspect.SetAspect (aFillAspect);
+  myCappingAspect->SetAspect (aFillAspect);
 
-  return &myCappingAspect;
+  return myCappingAspect;
 }
 
 // =======================================================================
 // function : HatchingFaceAspect
 // purpose  :
 // =======================================================================
-const OpenGl_AspectFace* OpenGl_CappingPlaneResource::HatchingFaceAspect() const
+Handle(OpenGl_AspectFace) OpenGl_CappingPlaneResource::HatchingFaceAspect() const
 {
   if (myAspect.IsNull())
   {
@@ -283,7 +283,7 @@ const OpenGl_AspectFace* OpenGl_CappingPlaneResource::HatchingFaceAspect() const
   {
     if (myAspect->ToDrawHatch())
     {
-      Handle(Graphic3d_AspectFillArea3d) aFillAspect = myHatchingAspect.Aspect();
+      Handle(Graphic3d_AspectFillArea3d) aFillAspect = myHatchingAspect->Aspect();
 
       aFillAspect->SetInteriorStyle (myAspect->IsStippleHatch() ? Aspect_IS_HATCH : Aspect_IS_SOLID);
       aFillAspect->SetHatchStyle    (myAspect->IsStippleHatch() ? myAspect->StippleHatch() : Handle(Graphic3d_HatchStyle)());
@@ -299,10 +299,10 @@ const OpenGl_AspectFace* OpenGl_CappingPlaneResource::HatchingFaceAspect() const
         aFillAspect->SetTextureMapOff();
       }
 
-      myHatchingAspect.SetAspect (aFillAspect);
+      myHatchingAspect->SetAspect (aFillAspect);
       myHatchingState = aHatchingState;
     }
   }
 
-  return &myHatchingAspect;
+  return myHatchingAspect;
 }
index 8c1b8b8b7325a21dfa6256e6ad611ca526d2e1fe..c71c1e71155dd2c4dd12588dc838f11c30ce1d83 100755 (executable)
@@ -56,7 +56,7 @@ public:
   virtual Standard_Size EstimatedDataSize() const Standard_OVERRIDE { return 0; }
 
   //! @return primitive array of vertices to render infinite plane.
-  static OpenGl_PrimitiveArray* BuildInfinitPlaneVertices();
+  static Handle(OpenGl_PrimitiveArray) BuildInfinitPlaneVertices();
 
   //! Returns true if capping should draw hatch layer.
   Standard_Boolean ToDrawHatch() const 
@@ -68,10 +68,10 @@ public:
 
   //! Returns the shading aspect for drawing face of a clipping section itself.
   //! @param theObjectAspect [in] the aspect of an object if it requires combining.
-  Standard_EXPORT  const OpenGl_AspectFace* CappingFaceAspect (const OpenGl_AspectFace* theObjectAspect) const;
+  Standard_EXPORT  Handle(OpenGl_AspectFace) CappingFaceAspect (const Handle(OpenGl_AspectFace)& theObjectAspect) const;
 
   //! Returns the shading aspect for drawing hatch layer of a section.
-  Standard_EXPORT const OpenGl_AspectFace* HatchingFaceAspect() const;
+  Standard_EXPORT Handle(OpenGl_AspectFace) HatchingFaceAspect() const;
 
 private:
 
@@ -84,8 +84,8 @@ private:
 private:
 
   Handle(Graphic3d_AspectFillCapping) myAspect;         //!< Section style settings from application's level.
-  mutable OpenGl_AspectFace           myCappingAspect;  //!< GL aspect for shading base layer of a capping section.
-  mutable OpenGl_AspectFace           myHatchingAspect; //!< GL aspect for shading hatching layer (additional to base) of a capping section.
+  mutable Handle(OpenGl_AspectFace)   myCappingAspect;  //!< GL aspect for shading base layer of a capping section.
+  mutable Handle(OpenGl_AspectFace)   myHatchingAspect; //!< GL aspect for shading hatching layer (additional to base) of a capping section.
   mutable Standard_Size               myHatchingState;
 
 public:
index 125102fe7582c58ccaf67bbf9da5ea4d6121d95d..c3d7516c602ad053fc1fb8453abb6630dda08d55 100644 (file)
@@ -3167,7 +3167,7 @@ Handle(OpenGl_FrameBuffer) OpenGl_Context::SetDefaultFrameBuffer (const Handle(O
 // function : SetShadingMaterial
 // purpose  :
 // =======================================================================
-void OpenGl_Context::SetShadingMaterial (const OpenGl_AspectFace* theAspect,
+void OpenGl_Context::SetShadingMaterial (const Handle(OpenGl_AspectFace)& theAspect,
                                          const Handle(Graphic3d_PresentationAttributes)& theHighlight)
 {
   const Handle(Graphic3d_AspectFillArea3d)& anAspect = (!theHighlight.IsNull() && !theHighlight->BasicFillAreaAspect().IsNull())
@@ -3239,7 +3239,7 @@ void OpenGl_Context::SetShadingMaterial (const OpenGl_AspectFace* theAspect,
 // function : CheckIsTransparent
 // purpose  :
 // =======================================================================
-Standard_Boolean OpenGl_Context::CheckIsTransparent (const OpenGl_AspectFace* theAspect,
+Standard_Boolean OpenGl_Context::CheckIsTransparent (const Handle(OpenGl_AspectFace)& theAspect,
                                                      const Handle(Graphic3d_PresentationAttributes)& theHighlight,
                                                      Standard_ShortReal& theAlphaFront,
                                                      Standard_ShortReal& theAlphaBack)
index 13bf652ba2d1db3ce3306261981269b9e508d57a..8ba7a9a88d2bfe2d9c5992e79f711ad0c5bb643a 100644 (file)
@@ -696,17 +696,17 @@ public: //! @name methods to alter or retrieve current state
   Standard_EXPORT Standard_Boolean BindProgram (const Handle(OpenGl_ShaderProgram)& theProgram);
 
   //! Setup current shading material.
-  Standard_EXPORT void SetShadingMaterial (const OpenGl_AspectFace* theAspect,
+  Standard_EXPORT void SetShadingMaterial (const Handle(OpenGl_AspectFace)& theAspect,
                                            const Handle(Graphic3d_PresentationAttributes)& theHighlight);
 
   //! Checks if transparency is required for the given aspect and highlight style.
-  Standard_EXPORT static Standard_Boolean CheckIsTransparent (const OpenGl_AspectFace* theAspect,
+  Standard_EXPORT static Standard_Boolean CheckIsTransparent (const Handle(OpenGl_AspectFace)& theAspect,
                                                               const Handle(Graphic3d_PresentationAttributes)& theHighlight,
                                                               Standard_ShortReal& theAlphaFront,
                                                               Standard_ShortReal& theAlphaBack);
 
   //! Checks if transparency is required for the given aspect and highlight style.
-  static Standard_Boolean CheckIsTransparent (const OpenGl_AspectFace* theAspect,
+  static Standard_Boolean CheckIsTransparent (const Handle(OpenGl_AspectFace)& theAspect,
                                               const Handle(Graphic3d_PresentationAttributes)& theHighlight)
   {
     Standard_ShortReal anAlphaFront = 1.0f, anAlphaBack = 1.0f;
index 0d5c53f5d5b868386a95753c9fbf7fa9d35b2660..9ffd180a7f1603a86759fb43c242a10ee2c80065 100755 (executable)
@@ -15,6 +15,8 @@
 
 #include <OpenGl_Element.hxx>
 
+IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Element, Standard_Transient)
+
 // =======================================================================
 // function : OpenGl_Element
 // purpose  :
index 8a14275a1ab8811341fcd781e2c38729cbe7a964..4d23ded0512826e1044279ad46029456d4438e80 100644 (file)
@@ -23,8 +23,9 @@ class OpenGl_Workspace;
 class OpenGl_Context;
 
 //! Base interface for drawable elements.
-class OpenGl_Element
+class OpenGl_Element : public Standard_Transient
 {
+  DEFINE_STANDARD_RTTIEXT(OpenGl_Element, Standard_Transient)
 public:
 
   Standard_EXPORT OpenGl_Element();
@@ -40,18 +41,14 @@ public:
   //! Pointer to the context is used because this method might be called
   //! when the context is already being destroyed and usage of a handle
   //! would be unsafe
-  template <typename theResource_t>
   static void Destroy (OpenGl_Context* theContext,
-                       theResource_t*& theElement)
+                       Handle(OpenGl_Element)& theElement)
   {
-    if (theElement == NULL)
+    if (theElement.IsNull())
     {
       return;
     }
-
     theElement->Release (theContext);
-    OpenGl_Element* anElement = theElement;
-    delete anElement;
     theElement = NULL;
   }
 
index 3a5a0673b152c465aa382a126830f9bfe01d2d07..c8797f56ebbddddd06a96307473cd7943979545d 100755 (executable)
@@ -22,6 +22,8 @@
 
 #include <gp_Ax2.hxx>
 
+IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Flipper, OpenGl_Element)
+
 // =======================================================================
 // function : Constructor
 // purpose  :
index 7f159c5db97e9230b3f96f00fcff1b2911247c90..14d92ca80bbf074d977d1655aff1bb46ed1ce9ab 100755 (executable)
@@ -27,6 +27,7 @@ class gp_Ax2;
 //! Originally, this element serves for need of flipping the 3D text of dimension presentations.
 class OpenGl_Flipper : public OpenGl_Element
 {
+  DEFINE_STANDARD_RTTIEXT(OpenGl_Flipper, OpenGl_Element)
 public:
 
   //! Construct rendering element to flip model-view matrix
index cb64c5a186005e6031962ff3209453283eec5a1e..4fda2dfb9c7d795452f3e3ce57a6eb8993755a74 100644 (file)
@@ -203,9 +203,10 @@ void OpenGl_FrameStats::updateStructures (Standard_Integer theViewId,
           for (OpenGl_Structure::GroupIterator aGroupIter (aStruct->Groups()); aGroupIter.More(); aGroupIter.Next())
           {
             const OpenGl_Group* aGroup = aGroupIter.Value();
-            for (const OpenGl_ElementNode* aNodeIter = aGroup->FirstNode(); aNodeIter != NULL; aNodeIter = aNodeIter->next)
+            for (OpenGl_ElementNodes::Iterator anElemIterator (aGroup->GetElements()); anElemIterator.More(); anElemIterator.Next())
             {
-              if (const OpenGl_PrimitiveArray* aPrim = dynamic_cast<const OpenGl_PrimitiveArray*> (aNodeIter->elem))
+              Handle(OpenGl_PrimitiveArray) aPrim = Handle(OpenGl_PrimitiveArray)::DownCast (anElemIterator.Value());
+              if (!aPrim.IsNull())
               {
                 myCountersTmp[Graphic3d_FrameStatsCounter_EstimatedBytesGeom] += estimatedDataSize (aPrim->AttributesVbo());
                 myCountersTmp[Graphic3d_FrameStatsCounter_EstimatedBytesGeom] += estimatedDataSize (aPrim->IndexVbo());
@@ -225,9 +226,10 @@ void OpenGl_FrameStats::updateStructures (Standard_Integer theViewId,
       for (OpenGl_Structure::GroupIterator aGroupIter (aStruct->Groups()); aGroupIter.More(); aGroupIter.Next())
       {
         const OpenGl_Group* aGroup = aGroupIter.Value();
-        for (const OpenGl_ElementNode* aNodeIter = aGroup->FirstNode(); aNodeIter != NULL; aNodeIter = aNodeIter->next)
+        for (OpenGl_ElementNodes::Iterator anElemIterator (aGroup->GetElements()); anElemIterator.More(); anElemIterator.Next())
         {
-          if (const OpenGl_PrimitiveArray* aPrim = dynamic_cast<const OpenGl_PrimitiveArray*> (aNodeIter->elem))
+          Handle(OpenGl_PrimitiveArray) aPrim = Handle(OpenGl_PrimitiveArray)::DownCast (anElemIterator.Value());
+          if (!aPrim.IsNull())
           {
             ++myCountersTmp[Graphic3d_FrameStatsCounter_NbElemsNotCulled];
             if (theToCountMem)
@@ -311,9 +313,8 @@ void OpenGl_FrameStats::updateStructures (Standard_Integer theViewId,
               ++myCountersTmp[Graphic3d_FrameStatsCounter_NbElemsLineNotCulled];
             }
           }
-          else if (const OpenGl_Text* aText = dynamic_cast<const OpenGl_Text*> (aNodeIter->elem))
+          else if (!Handle(OpenGl_Text)::DownCast(anElemIterator.Value()).IsNull())
           {
-            (void )aText;
             ++myCountersTmp[Graphic3d_FrameStatsCounter_NbElemsNotCulled];
             ++myCountersTmp[Graphic3d_FrameStatsCounter_NbElemsTextNotCulled];
           }
index b4ddc3193254ee3284685adfe7afe64144652742..849873ec105c8f94c211d3edfb6c9e518c36ff5a 100644 (file)
@@ -19,6 +19,8 @@
 
 #include <Graphic3d_ArrayOfTriangles.hxx>
 
+IMPLEMENT_STANDARD_RTTIEXT(OpenGl_FrameStatsPrs, OpenGl_Element)
+
 namespace
 {
   //! Auxiliary structure defining vertex with two attributes.
@@ -50,7 +52,11 @@ OpenGl_FrameStatsPrs::OpenGl_FrameStatsPrs()
   myChartIndices (new OpenGl_IndexBuffer()),
   myChartLines (new OpenGl_VertexBuffer())
 {
-  //
+  myCountersText = new OpenGl_Text();
+  myTextAspect = new OpenGl_AspectText();
+  myChartLabels[0] = new OpenGl_Text();
+  myChartLabels[1] = new OpenGl_Text();
+  myChartLabels[2] = new OpenGl_Text();
 }
 
 // =======================================================================
@@ -68,10 +74,10 @@ OpenGl_FrameStatsPrs::~OpenGl_FrameStatsPrs()
 // =======================================================================
 void OpenGl_FrameStatsPrs::Release (OpenGl_Context* theCtx)
 {
-  myCountersText.Release (theCtx);
-  myChartLabels[0].Release (theCtx);
-  myChartLabels[1].Release (theCtx);
-  myChartLabels[2].Release (theCtx);
+  myCountersText->Release (theCtx);
+  myChartLabels[0]->Release (theCtx);
+  myChartLabels[1]->Release (theCtx);
+  myChartLabels[2]->Release (theCtx);
   myChartVertices->Release (theCtx);
   myChartIndices->Release (theCtx);
   myChartLines->Release (theCtx);
@@ -88,7 +94,7 @@ void OpenGl_FrameStatsPrs::Update (const Handle(OpenGl_Workspace)& theWorkspace)
   const Graphic3d_RenderingParams& aRendParams = theWorkspace->View()->RenderingParams();
   myCountersTrsfPers = theWorkspace->View()->RenderingParams().StatsPosition;
   myChartTrsfPers    = theWorkspace->View()->RenderingParams().ChartPosition;
-  myTextAspect.SetAspect (aRendParams.StatsTextAspect);
+  myTextAspect->SetAspect (aRendParams.StatsTextAspect);
 
   // adjust text alignment depending on corner
   OpenGl_TextParam aParams;
@@ -111,21 +117,21 @@ void OpenGl_FrameStatsPrs::Update (const Handle(OpenGl_Workspace)& theWorkspace)
   {
     aParams.VAlign = Graphic3d_VTA_BOTTOM;
   }
-  if (aParams.Height != myCountersText.FormatParams().Height
-   || aParams.HAlign != myCountersText.FormatParams().HAlign
-   || aParams.VAlign != myCountersText.FormatParams().VAlign)
+  if (aParams.Height != myCountersText->FormatParams().Height
+   || aParams.HAlign != myCountersText->FormatParams().HAlign
+   || aParams.VAlign != myCountersText->FormatParams().VAlign)
   {
-    myCountersText.Release (aCtx.operator->());
+    myCountersText->Release (aCtx.operator->());
   }
 
   if (!aStats->IsFrameUpdated (myStatsPrev)
-   && !myCountersText.Text().IsEmpty())
+   && !myCountersText->Text().IsEmpty())
   {
     return;
   }
 
   TCollection_AsciiString aText = aStats->FormatStats (aRendParams.CollectedStats);
-  myCountersText.Init (aCtx, aText.ToCString(), OpenGl_Vec3 (0.0f, 0.0f, 0.0f), aParams);
+  myCountersText->Init (aCtx, aText.ToCString(), OpenGl_Vec3 (0.0f, 0.0f, 0.0f), aParams);
 
   updateChart (theWorkspace);
 }
@@ -341,9 +347,9 @@ void OpenGl_FrameStatsPrs::updateChart (const Handle(OpenGl_Workspace)& theWorks
     const float aLabX = aParams.HAlign == Graphic3d_HTA_RIGHT
                       ? float(anOffset.x())
                       : float(anOffset.x() + aCharSize.x());
-    myChartLabels[0].Init (aCtx, aLabels[isTopDown ? 0 : 2].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y()),                    0.0f), aParams);
-    myChartLabels[1].Init (aCtx, aLabels[isTopDown ? 1 : 1].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y() - aBinSize.y() / 2), 0.0f), aParams);
-    myChartLabels[2].Init (aCtx, aLabels[isTopDown ? 2 : 0].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y() - aBinSize.y()),     0.0f), aParams);
+    myChartLabels[0]->Init (aCtx, aLabels[isTopDown ? 0 : 2].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y()),                    0.0f), aParams);
+    myChartLabels[1]->Init (aCtx, aLabels[isTopDown ? 1 : 1].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y() - aBinSize.y() / 2), 0.0f), aParams);
+    myChartLabels[2]->Init (aCtx, aLabels[isTopDown ? 2 : 0].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y() - aBinSize.y()),     0.0f), aParams);
   }
 }
 
@@ -361,7 +367,8 @@ void OpenGl_FrameStatsPrs::Render (const Handle(OpenGl_Workspace)& theWorkspace)
     glDepthMask (GL_FALSE);
   }
 
-  const OpenGl_AspectText* aTextAspectBack = theWorkspace->SetAspectText (&myTextAspect);
+  const Handle(OpenGl_AspectText)& aTextAspectBack = theWorkspace->AspectText();
+  theWorkspace->SetAspectText (myTextAspect);
 
   aCtx->ModelWorldState.Push();
   aCtx->ModelWorldState.ChangeCurrent().InitIdentity();
@@ -376,7 +383,7 @@ void OpenGl_FrameStatsPrs::Render (const Handle(OpenGl_Workspace)& theWorkspace)
                                  aCtx->VirtualViewport()[2], aCtx->VirtualViewport()[3]);
     }
     aCtx->ApplyModelViewMatrix();
-    myCountersText.Render (theWorkspace);
+    myCountersText->Render (theWorkspace);
     aCtx->WorldViewState.Pop();
   }
 
@@ -419,9 +426,9 @@ void OpenGl_FrameStatsPrs::Render (const Handle(OpenGl_Workspace)& theWorkspace)
     myChartLines->unbindAttribute (aCtx, Graphic3d_TOA_COLOR);
     myChartLines->unbindAttribute (aCtx, Graphic3d_TOA_POS);
 
-    myChartLabels[0].Render (theWorkspace);
-    myChartLabels[1].Render (theWorkspace);
-    myChartLabels[2].Render (theWorkspace);
+    myChartLabels[0]->Render (theWorkspace);
+    myChartLabels[1]->Render (theWorkspace);
+    myChartLabels[2]->Render (theWorkspace);
 
     aCtx->WorldViewState.Pop();
   }
index 35231640c1216bc9195b6d7cd51a9e53fbb01e2b..16508b4e4a5bf6d50e2d82d513de7984cefefda8 100644 (file)
@@ -25,6 +25,7 @@ class OpenGl_VertexBuffer;
 //! Element rendering frame statistics.
 class OpenGl_FrameStatsPrs : public OpenGl_Element
 {
+  DEFINE_STANDARD_RTTIEXT(OpenGl_FrameStatsPrs, OpenGl_Element)
 public:
 
   //! Default constructor.
@@ -43,7 +44,7 @@ public:
   Standard_EXPORT void Update (const Handle(OpenGl_Workspace)& theWorkspace);
 
   //! Assign text aspect.
-  void SetTextAspect (const Handle(Graphic3d_AspectText3d)& theAspect) { myTextAspect.SetAspect (theAspect); }
+  void SetTextAspect (const Handle(Graphic3d_AspectText3d)& theAspect) { myTextAspect->SetAspect (theAspect); }
 
 protected:
 
@@ -54,14 +55,14 @@ protected:
 
   Handle(OpenGl_FrameStats)          myStatsPrev;         //!< currently displayed stats
   Handle(Graphic3d_TransformPers)    myCountersTrsfPers;  //!< transformation persistence for counters presentation
-  OpenGl_Text                        myCountersText;      //!< counters presentation
-  OpenGl_AspectText                  myTextAspect;        //!< text aspect
+  Handle(OpenGl_Text)                myCountersText;      //!< counters presentation
+  Handle(OpenGl_AspectText)          myTextAspect;        //!< text aspect
   Handle(Graphic3d_TransformPers)    myChartTrsfPers;     //!< transformation persistence for chart presentation
   Handle(Graphic3d_ArrayOfTriangles) myChartArray;        //!< array of chart triangles
   Handle(OpenGl_VertexBuffer)        myChartVertices;     //!< VBO with chart triangles
   Handle(OpenGl_IndexBuffer)         myChartIndices;      //!< VBO with chart triangle indexes
   Handle(OpenGl_VertexBuffer)        myChartLines;        //!< array of chart lines
-  OpenGl_Text                        myChartLabels[3];    //!< chart labels
+  Handle(OpenGl_Text)                myChartLabels[3];    //!< chart labels
 
 };
 
index ecb35c61bc8bbb67a6bc3754a2dacee9394e9dcb..6f290f514540404facfd0a0ff356c841e87b00db 100755 (executable)
@@ -32,6 +32,8 @@
   #include <string.h>
 #endif
 
+IMPLEMENT_STANDARD_RTTIEXT(OpenGl_GraduatedTrihedron, OpenGl_Element)
+
 namespace
 {
   static const OpenGl_TextParam THE_LABEL_PARAMS =
@@ -49,7 +51,11 @@ OpenGl_GraduatedTrihedron::OpenGl_GraduatedTrihedron()
   myMax (100.0f, 100.0f, 100.0f),
   myIsInitialized (Standard_False)
 {
-  //
+  myGridLineAspect = new OpenGl_AspectLine();
+
+  myLabelValues = new OpenGl_Text();
+  myAspectLabels = new OpenGl_AspectText();
+  myAspectValues = new OpenGl_AspectText();
 }
 
 // =======================================================================
@@ -80,7 +86,7 @@ void OpenGl_GraduatedTrihedron::Release (OpenGl_Context* theCtx)
   myAxes[0].Release (theCtx);
   myAxes[1].Release (theCtx);
   myAxes[2].Release (theCtx);
-  myLabelValues.Release (theCtx);
+  myLabelValues->Release (theCtx);
 }
 
 // =======================================================================
@@ -92,7 +98,7 @@ void OpenGl_GraduatedTrihedron::initGlResources (const Handle(OpenGl_Context)& t
   myAxes[0].Release     (theCtx.operator->());
   myAxes[1].Release     (theCtx.operator->());
   myAxes[2].Release     (theCtx.operator->());
-  myLabelValues.Release (theCtx.operator->());
+  myLabelValues->Release (theCtx.operator->());
 
   // Initialize text label parameters for x, y, and z axes
   myAxes[0] = Axis (myData.XAxisAspect(), OpenGl_Vec3 (1.0f, 0.0f, 0.0f));
@@ -105,19 +111,19 @@ void OpenGl_GraduatedTrihedron::initGlResources (const Handle(OpenGl_Context)& t
   myAxes[2].InitArrow (theCtx, myData.ArrowsLength(), OpenGl_Vec3 (1.0f, 0.0f, 0.0f));
   for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
   {
-    myAxes[anIt].Label.SetFontSize (theCtx, myData.NamesSize());
+    myAxes[anIt].Label->SetFontSize (theCtx, myData.NamesSize());
   }
 
-  myLabelValues.SetFontSize (theCtx, myData.ValuesSize());
+  myLabelValues->SetFontSize (theCtx, myData.ValuesSize());
 
-  myAspectLabels.Aspect()->SetTextFontAspect (myData.NamesFontAspect());
-  myAspectLabels.Aspect()->SetFont (myData.NamesFont());
+  myAspectLabels->Aspect()->SetTextFontAspect (myData.NamesFontAspect());
+  myAspectLabels->Aspect()->SetFont (myData.NamesFont());
 
-  myAspectValues.Aspect()->SetTextFontAspect (myData.ValuesFontAspect());
-  myAspectValues.Aspect()->SetFont (myData.ValuesFont());
+  myAspectValues->Aspect()->SetTextFontAspect (myData.ValuesFontAspect());
+  myAspectValues->Aspect()->SetFont (myData.ValuesFont());
 
   // Grid aspect
-  myGridLineAspect.Aspect()->SetColor (myData.GridColor());
+  myGridLineAspect->Aspect()->SetColor (myData.GridColor());
 }
 
 // =======================================================================
@@ -326,7 +332,7 @@ Standard_ExtCharacter OpenGl_GraduatedTrihedron::getGridAxes (const Standard_Sho
 // function : renderLine
 // purpose  :
 // =======================================================================
-void OpenGl_GraduatedTrihedron::renderLine (const OpenGl_PrimitiveArray&    theLine,
+void OpenGl_GraduatedTrihedron::renderLine (const Handle(OpenGl_PrimitiveArray)& theLine,
                                             const Handle(OpenGl_Workspace)& theWorkspace,
                                             const OpenGl_Mat4& theMat,
                                             const Standard_ShortReal theXt,
@@ -338,7 +344,7 @@ void OpenGl_GraduatedTrihedron::renderLine (const OpenGl_PrimitiveArray&    theL
   Graphic3d_TransformUtils::Translate (aMat, theXt, theYt, theZt);
   aContext->WorldViewState.SetCurrent (aMat);
   aContext->ApplyWorldViewMatrix();
-  theLine.Render (theWorkspace);
+  theLine->Render (theWorkspace);
 }
 
 // =======================================================================
@@ -385,7 +391,7 @@ void OpenGl_GraduatedTrihedron::renderGridPlane (const Handle(OpenGl_Workspace)&
       Graphic3d_TransformUtils::Translate (aMat, aStepVec.x(), aStepVec.y(), aStepVec.z());
       aContext->WorldViewState.SetCurrent (aMat);
       aContext->ApplyWorldViewMatrix();
-      anAxis.Line.Render (theWorkspace);
+      anAxis.Line->Render (theWorkspace);
     }
   }
 }
@@ -400,7 +406,7 @@ void OpenGl_GraduatedTrihedron::renderAxis (const Handle(OpenGl_Workspace)& theW
 {
   const Axis& anAxis = myAxes[theIndex];
 
-  theWorkspace->SetAspectLine (&anAxis.LineAspect);
+  theWorkspace->SetAspectLine (anAxis.LineAspect);
   const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
 
   // Reset transformations
@@ -422,7 +428,7 @@ void OpenGl_GraduatedTrihedron::renderAxis (const Handle(OpenGl_Workspace)& theW
   aContext->ModelWorldState.SetCurrent (aTransMode.Compute (theWorkspace->View()->Camera(), aProjection, aWorldView, aWidth, aHeight));
   aContext->ApplyModelViewMatrix();
 
-  anAxis.Arrow.Render (theWorkspace);
+  anAxis.Arrow->Render (theWorkspace);
 
   // Get current Model-View and Projection states
   OpenGl_Mat4 aModelMat;
@@ -457,7 +463,7 @@ void OpenGl_GraduatedTrihedron::renderAxis (const Handle(OpenGl_Workspace)& theW
 
   aContext->WorldViewState.SetCurrent (aModelMat);
   aContext->ApplyWorldViewMatrix();
-  anAxis.Line.Render (theWorkspace);
+  anAxis.Line->Render (theWorkspace);
 }
 
 // =======================================================================
@@ -487,7 +493,7 @@ void OpenGl_GraduatedTrihedron::renderTickmarkLabels (const Handle(OpenGl_Worksp
 
   if (aCurAspect.ToDrawTickmarks() && aCurAspect.TickmarksNumber() > 0)
   {
-    theWorkspace->SetAspectLine (&myGridLineAspect);
+    theWorkspace->SetAspectLine (myGridLineAspect);
 
     OpenGl_Mat4 aModelMat (theMat);
 
@@ -500,7 +506,7 @@ void OpenGl_GraduatedTrihedron::renderTickmarkLabels (const Handle(OpenGl_Worksp
     OpenGl_Vec3 aStepVec = anAxis.Direction * aStep;
     for (Standard_Integer anIter = 0; anIter <= aCurAspect.TickmarksNumber(); ++anIter)
     {
-      anAxis.Tickmark.Render (theWorkspace);
+      anAxis.Tickmark->Render (theWorkspace);
       Graphic3d_TransformUtils::Translate (aModelMat, aStepVec.x(), aStepVec.y(), aStepVec.z());
       aContext->WorldViewState.SetCurrent (aModelMat);
       aContext->ApplyWorldViewMatrix();
@@ -517,24 +523,24 @@ void OpenGl_GraduatedTrihedron::renderTickmarkLabels (const Handle(OpenGl_Worksp
 
     OpenGl_Vec3 aMiddle (theGridAxes.Ticks[theIndex] + aSizeVec * theGridAxes.Axes[theIndex] * 0.5f + aDir * (Standard_ShortReal)(theDpix * anOffset));
 
-    myAspectLabels.Aspect()->SetColor (anAxis.NameColor);
-    theWorkspace->SetAspectText (&myAspectLabels);
-    anAxis.Label.SetPosition (aMiddle);
-    anAxis.Label.Render (theWorkspace);
+    myAspectLabels->Aspect()->SetColor (anAxis.NameColor);
+    theWorkspace->SetAspectText (myAspectLabels);
+    anAxis.Label->SetPosition (aMiddle);
+    anAxis.Label->Render (theWorkspace);
   }
 
   if (aCurAspect.ToDrawValues() && aCurAspect.TickmarksNumber() > 0)
   {
-    myAspectValues.Aspect()->SetColor (anAxis.LineAspect.Aspect()->Color());
-    theWorkspace->SetAspectText (&myAspectValues);
+    myAspectValues->Aspect()->SetColor (anAxis.LineAspect->Aspect()->Color());
+    theWorkspace->SetAspectText (myAspectValues);
     Standard_Real anOffset = aCurAspect.ValuesOffset() + aCurAspect.TickmarksLength();
 
     for (Standard_Integer anIt = 0; anIt <= aCurAspect.TickmarksNumber(); ++anIt)
     {
       sprintf (aTextValue, "%g", theGridAxes.Ticks[theIndex].GetData()[theIndex] + anIt * aStep);
       OpenGl_Vec3 aPos (theGridAxes.Ticks[theIndex] + anAxis.Direction* (Standard_ShortReal) (anIt * aStep) + aDir * (Standard_ShortReal) (theDpix * anOffset));
-      myLabelValues.Init (theWorkspace->GetGlContext(), aTextValue, aPos);
-      myLabelValues.Render (theWorkspace);
+      myLabelValues->Init (theWorkspace->GetGlContext(), aTextValue, aPos);
+      myLabelValues->Render (theWorkspace);
     }
   }
 }
@@ -559,9 +565,9 @@ void OpenGl_GraduatedTrihedron::Render (const Handle(OpenGl_Workspace)& theWorks
   if (myData.CubicAxesCallback)
   {
     myData.CubicAxesCallback (myData.PtrView);
-    if (!myAxes[0].Line.IsInitialized()
-     || !myAxes[1].Line.IsInitialized()
-     || !myAxes[2].Line.IsInitialized()
+    if (!myAxes[0].Line->IsInitialized()
+     || !myAxes[1].Line->IsInitialized()
+     || !myAxes[2].Line->IsInitialized()
      ||  OpenGl_Vec3 (anOldMin - myMin).Modulus() > Precision::Confusion()
      ||  OpenGl_Vec3 (anOldMax - myMax).Modulus() > Precision::Confusion())
     {
@@ -605,8 +611,8 @@ void OpenGl_GraduatedTrihedron::Render (const Handle(OpenGl_Workspace)& theWorks
   Standard_ExtCharacter anAxesState = getGridAxes (aCorners, aGridAxes);
 
   // Remember current aspects
-  const OpenGl_AspectLine* anOldAspectLine = theWorkspace->AspectLine();
-  const OpenGl_AspectText* anOldAspectText = theWorkspace->AspectText();
+  const Handle(OpenGl_AspectLine)& anOldAspectLine = theWorkspace->AspectLine();
+  const Handle(OpenGl_AspectText)& anOldAspectText = theWorkspace->AspectText();
 
   OpenGl_Mat4 aModelMatrix;
   aModelMatrix.Convert (aContext->WorldViewState.Current());
@@ -618,7 +624,7 @@ void OpenGl_GraduatedTrihedron::Render (const Handle(OpenGl_Workspace)& theWorks
 
   if (myData.ToDrawGrid())
   {
-    theWorkspace->SetAspectLine (&myGridLineAspect);
+    theWorkspace->SetAspectLine (myGridLineAspect);
 
     // render grid edges
     if (anAxesState & XOO_XYO)
@@ -714,13 +720,14 @@ void OpenGl_GraduatedTrihedron::SetMinMax (const OpenGl_Vec3& theMin, const Open
 OpenGl_GraduatedTrihedron::Axis::Axis (const Graphic3d_AxisAspect& theAspect,
                                        const OpenGl_Vec3&          theDirection)
 : Direction (theDirection),
-  Label     (NCollection_String ((Standard_Utf16Char* )theAspect.Name().ToExtString()).ToCString(), theDirection, THE_LABEL_PARAMS),
-  Tickmark  (NULL),
-  Line      (NULL),
-  Arrow     (NULL)
+  Label     (new OpenGl_Text(NCollection_String ((Standard_Utf16Char* )theAspect.Name().ToExtString()).ToCString(), theDirection, THE_LABEL_PARAMS)),
+  Tickmark  (new OpenGl_PrimitiveArray (NULL)),
+  Line      (new OpenGl_PrimitiveArray (NULL)),
+  Arrow     (new OpenGl_PrimitiveArray (NULL))
 {
   NameColor = theAspect.NameColor();
-  LineAspect.Aspect()->SetColor (theAspect.Color());
+  LineAspect = new OpenGl_AspectLine();
+  LineAspect->Aspect()->SetColor (theAspect.Color());
 }
 
 // =======================================================================
@@ -743,9 +750,9 @@ OpenGl_GraduatedTrihedron::Axis& OpenGl_GraduatedTrihedron::Axis::operator= (con
   LineAspect = theOther.LineAspect;
   Label      = theOther.Label;
 
-  Line    .InitBuffers (NULL, Graphic3d_TOPA_SEGMENTS,  theOther.Line.Indices(),     theOther.Line.Attributes(),     theOther.Line.Bounds());
-  Tickmark.InitBuffers (NULL, Graphic3d_TOPA_SEGMENTS,  theOther.Tickmark.Indices(), theOther.Tickmark.Attributes(), theOther.Tickmark.Bounds());
-  Arrow   .InitBuffers (NULL, Graphic3d_TOPA_POLYLINES, theOther.Arrow.Indices(),    theOther.Arrow.Attributes(),    theOther.Arrow.Bounds());
+  Line    ->InitBuffers (NULL, Graphic3d_TOPA_SEGMENTS,  theOther.Line->Indices(),     theOther.Line->Attributes(),     theOther.Line->Bounds());
+  Tickmark->InitBuffers (NULL, Graphic3d_TOPA_SEGMENTS,  theOther.Tickmark->Indices(), theOther.Tickmark->Attributes(), theOther.Tickmark->Bounds());
+  Arrow   ->InitBuffers (NULL, Graphic3d_TOPA_POLYLINES, theOther.Arrow->Indices(),    theOther.Arrow->Attributes(),    theOther.Arrow->Bounds());
   return *this;
 }
 
@@ -780,8 +787,8 @@ void OpenGl_GraduatedTrihedron::Axis::InitArrow (const Handle(OpenGl_Context)& t
   anArray->AddVertex (aPoint3);
   anArray->AddVertex (aPoint1);
 
-  Arrow.InitBuffers (theContext, Graphic3d_TOPA_POLYLINES,
-                     anArray->Indices(), anArray->Attributes(), anArray->Bounds());
+  Arrow->InitBuffers (theContext, Graphic3d_TOPA_POLYLINES,
+                      anArray->Indices(), anArray->Attributes(), anArray->Bounds());
 }
 
 // =======================================================================
@@ -795,8 +802,8 @@ void OpenGl_GraduatedTrihedron::Axis::InitTickmark (const Handle(OpenGl_Context)
   Handle(Graphic3d_ArrayOfSegments) anArray = new Graphic3d_ArrayOfSegments (2);
   anArray->AddVertex (0.0f, 0.0f, 0.0f);
   anArray->AddVertex (theDir);
-  Tickmark.InitBuffers (theContext, Graphic3d_TOPA_SEGMENTS,
-                        anArray->Indices(), anArray->Attributes(), anArray->Bounds());
+  Tickmark->InitBuffers (theContext, Graphic3d_TOPA_SEGMENTS,
+                         anArray->Indices(), anArray->Attributes(), anArray->Bounds());
 
 }
 
@@ -812,8 +819,8 @@ void OpenGl_GraduatedTrihedron::Axis::InitLine (const Handle(OpenGl_Context)& th
   anArray->AddVertex (0.0f, 0.0f, 0.0f);
   anArray->AddVertex (theDir);
 
-  Line.InitBuffers (theContext, Graphic3d_TOPA_SEGMENTS,
-                    anArray->Indices(), anArray->Attributes(), anArray->Bounds());
+  Line->InitBuffers (theContext, Graphic3d_TOPA_SEGMENTS,
+                     anArray->Indices(), anArray->Attributes(), anArray->Bounds());
 }
 
 // =======================================================================
@@ -822,8 +829,8 @@ void OpenGl_GraduatedTrihedron::Axis::InitLine (const Handle(OpenGl_Context)& th
 // =======================================================================
 void OpenGl_GraduatedTrihedron::Axis::Release (OpenGl_Context* theCtx)
 {
-  Label   .Release (theCtx);
-  Tickmark.Release (theCtx);
-  Line    .Release (theCtx);
-  Arrow   .Release (theCtx);
+  Label   ->Release (theCtx);
+  Tickmark->Release (theCtx);
+  Line    ->Release (theCtx);
+  Arrow   ->Release (theCtx);
 }
index ac1da0f960fb298ce6d9ffa25c5b0936ff034edf..cf33b3f76d78b420de91fa77cdf2091332a3d412 100755 (executable)
@@ -34,6 +34,7 @@ class OpenGl_View;
 //! @sa Graphic3d_GraduatedTrihedron
 class OpenGl_GraduatedTrihedron : public OpenGl_Element
 {
+  DEFINE_STANDARD_RTTIEXT(OpenGl_GraduatedTrihedron, OpenGl_Element)
 public:
 
   DEFINE_STANDARD_ALLOC
@@ -70,11 +71,11 @@ private:
 
     OpenGl_Vec3         Direction;
     Quantity_Color      NameColor;
-    OpenGl_AspectLine   LineAspect;
-    mutable OpenGl_Text Label;
-    mutable OpenGl_PrimitiveArray Tickmark;
-    mutable OpenGl_PrimitiveArray Line;
-    mutable OpenGl_PrimitiveArray Arrow;
+    Handle(OpenGl_AspectLine) LineAspect;
+    mutable Handle(OpenGl_Text) Label;
+    mutable Handle(OpenGl_PrimitiveArray) Tickmark;
+    mutable Handle(OpenGl_PrimitiveArray) Line;
+    mutable Handle(OpenGl_PrimitiveArray) Arrow;
 
   public:
 
@@ -165,7 +166,7 @@ private:
   //! @param thaTx the X for vector of translation
   //! @param thaTy the Y for vector of translation
   //! @param thaTz the Z for vector of translation
-  void renderLine (const OpenGl_PrimitiveArray&    theLine,
+  void renderLine (const Handle(OpenGl_PrimitiveArray)& theLine,
                    const Handle(OpenGl_Workspace)& theWorkspace,
                    const OpenGl_Mat4&              theMat,
                    const Standard_ShortReal        theXt,
@@ -215,13 +216,13 @@ protected:
 
   mutable Axis myAxes[3]; //!< Axes for trihedron
   mutable Graphic3d_GraduatedTrihedron myData;
-  mutable OpenGl_AspectLine myGridLineAspect; //!< Color grid properties
+  mutable Handle(OpenGl_AspectLine) myGridLineAspect; //!< Color grid properties
 
 protected: //! @name Labels properties
 
-  mutable OpenGl_Text       myLabelValues;
-  mutable OpenGl_AspectText myAspectLabels;
-  mutable OpenGl_AspectText myAspectValues;
+  mutable Handle(OpenGl_Text)       myLabelValues;
+  mutable Handle(OpenGl_AspectText) myAspectLabels;
+  mutable Handle(OpenGl_AspectText) myAspectValues;
 
 private:
 
index 23cba938f593648f3bb68ebd73b2d1e4ab13a55a..b3ce7b6404dac44d6fdae6829bb1b2eee062b976 100644 (file)
@@ -536,8 +536,8 @@ void OpenGl_GraphicDriver::TextSize (const Handle(Graphic3d_CView)& theView,
   const Standard_ShortReal aHeight = (theHeight < 2.0f) ? DefaultTextHeight() : theHeight;
   OpenGl_TextParam aTextParam;
   aTextParam.Height = (int )aHeight;
-  OpenGl_AspectText aTextAspect;
-  aTextAspect.Aspect()->SetSpace (0.3);
+  Handle(OpenGl_AspectText) aTextAspect = new OpenGl_AspectText();
+  aTextAspect->Aspect()->SetSpace (0.3);
   TCollection_ExtendedString anExtText = theText;
   NCollection_String aText (anExtText.ToExtString());
   OpenGl_Text::StringSize(aCtx, aText, aTextAspect, aTextParam, theView->RenderingParams().Resolution, theWidth, theAscent, theDescent);
index a4de0f6e746aa60b7ea1ec0f0d42a124be1423db..701a9f05c415a782f72b78b915c18a433f964fce 100644 (file)
@@ -40,7 +40,7 @@ namespace
   //! should be rendered or not.
   //! @return True if element passes the check and renders,
   static bool renderFiltered (const Handle(OpenGl_Workspace)& theWorkspace,
-                              OpenGl_Element* theElement)
+                              const Handle(OpenGl_Element)& theElement)
   {
     if (!theWorkspace->ShouldRender (theElement))
     {
@@ -58,12 +58,6 @@ namespace
 // =======================================================================
 OpenGl_Group::OpenGl_Group (const Handle(Graphic3d_Structure)& theStruct)
 : Graphic3d_Group (theStruct),
-  myAspectLine(NULL),
-  myAspectFace(NULL),
-  myAspectMarker(NULL),
-  myAspectText(NULL),
-  myFirst(NULL),
-  myLast(NULL),
   myIsRaytracable (Standard_False),
   myIsDestroyElements (Standard_True)
 {
@@ -94,7 +88,7 @@ void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d
     return;
   }
 
-  if (myAspectLine == NULL)
+  if (myAspectLine.IsNull())
   {
     myAspectLine = new OpenGl_AspectLine (theAspect);
   }
@@ -111,7 +105,7 @@ void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d
 // =======================================================================
 void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspect)
 {
-  if (myAspectLine == NULL)
+  if (myAspectLine.IsNull())
   {
     SetGroupPrimitivesAspect (theAspect);
     return;
@@ -121,7 +115,7 @@ void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& th
     return;
   }
 
-  OpenGl_AspectLine* anAspectLine = new OpenGl_AspectLine (theAspect);
+  Handle(OpenGl_AspectLine) anAspectLine = new OpenGl_AspectLine (theAspect);
   AddElement (anAspectLine);
   Update();
 }
@@ -137,7 +131,7 @@ void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFillAr
     return;
   }
 
-  if (myAspectFace == NULL)
+  if (myAspectFace.IsNull())
   {
     myAspectFace = new OpenGl_AspectFace (theAspect);
   }
@@ -164,7 +158,7 @@ void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFillAr
 // =======================================================================
 void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect)
 {
-  if (myAspectFace == NULL)
+  if (myAspectFace.IsNull())
   {
     SetGroupPrimitivesAspect (theAspect);
     return;
@@ -174,7 +168,7 @@ void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)
     return;
   }
 
-  OpenGl_AspectFace* anAspectFace = new OpenGl_AspectFace (theAspect);
+  Handle(OpenGl_AspectFace) anAspectFace = new OpenGl_AspectFace (theAspect);
   AddElement (anAspectFace);
   Update();
 }
@@ -190,7 +184,7 @@ void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectMarker
     return;
   }
 
-  if (myAspectMarker == NULL)
+  if (myAspectMarker.IsNull())
   {
     myAspectMarker = new OpenGl_AspectMarker (theAspMarker);
   }
@@ -207,7 +201,7 @@ void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectMarker
 // =======================================================================
 void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspMarker)
 {
-  if (myAspectMarker == NULL)
+  if (myAspectMarker.IsNull())
   {
     SetGroupPrimitivesAspect (theAspMarker);
     return;
@@ -217,7 +211,7 @@ void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)&
     return;
   }
 
-  OpenGl_AspectMarker* anAspectMarker = new OpenGl_AspectMarker (theAspMarker);
+  Handle(OpenGl_AspectMarker) anAspectMarker = new OpenGl_AspectMarker (theAspMarker);
   AddElement (anAspectMarker);
   Update();
 }
@@ -233,7 +227,7 @@ void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectText3d
     return;
   }
 
-  if (myAspectText == NULL)
+  if (myAspectText.IsNull())
   {
     myAspectText = new OpenGl_AspectText (theAspText);
   }
@@ -250,7 +244,7 @@ void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectText3d
 // =======================================================================
 void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspText)
 {
-  if (myAspectText == NULL)
+  if (myAspectText.IsNull())
   {
     SetGroupPrimitivesAspect (theAspText);
     return;
@@ -260,7 +254,7 @@ void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& th
     return;
   }
 
-  OpenGl_AspectText* anAspectText = new OpenGl_AspectText (theAspText);
+  Handle(OpenGl_AspectText) anAspectText = new OpenGl_AspectText (theAspText);
   AddElement (anAspectText);
   Update();
 }
@@ -271,25 +265,25 @@ void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& th
 // =======================================================================
 void OpenGl_Group::SynchronizeAspects()
 {
-  if (myAspectFace != NULL)
+  if (!myAspectFace.IsNull())
   {
     myAspectFace->SynchronizeAspects();
   }
-  if (myAspectLine != NULL)
+  if (!myAspectLine.IsNull())
   {
     myAspectLine->SynchronizeAspects();
   }
-  if (myAspectMarker != NULL)
+  if (!myAspectMarker.IsNull())
   {
     myAspectMarker->SynchronizeAspects();
   }
-  if (myAspectText != NULL)
+  if (!myAspectText.IsNull())
   {
     myAspectText->SynchronizeAspects();
   }
-  for (OpenGl_ElementNode* aNode = myFirst; aNode != NULL; aNode = aNode->next)
+  for (OpenGl_ElementNodes::Iterator anElemIterator(myElements); anElemIterator.More(); anElemIterator.Next())
   {
-    aNode->elem->SynchronizeAspects();
+    anElemIterator.ChangeValue()->SynchronizeAspects();
   }
 }
 
@@ -335,7 +329,7 @@ void OpenGl_Group::AddPrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theTy
   OpenGl_Structure* aStruct = GlStruct();
   const OpenGl_GraphicDriver* aDriver = aStruct->GlDriver();
 
-  OpenGl_PrimitiveArray* anArray = new OpenGl_PrimitiveArray (aDriver, theType, theIndices, theAttribs, theBounds);
+  Handle(OpenGl_PrimitiveArray) anArray = new OpenGl_PrimitiveArray (aDriver, theType, theIndices, theAttribs, theBounds);
   AddElement (anArray);
 
   Graphic3d_Group::AddPrimitiveArray (theType, theIndices, theAttribs, theBounds, theToEvalMinMax);
@@ -365,7 +359,7 @@ void OpenGl_Group::Text (const Standard_CString                  theTextUtf,
   aParams.HAlign = theHta;
   aParams.VAlign = theVta;
   const OpenGl_Vec3 aPoint (thePoint.X(), thePoint.Y(), thePoint.Z());
-  OpenGl_Text* aText = new OpenGl_Text (theTextUtf, aPoint, aParams);
+  Handle(OpenGl_Text) aText = new OpenGl_Text (theTextUtf, aPoint, aParams);
   AddElement (aText);
   Graphic3d_Group::Text (theTextUtf, thePoint, theHeight, theAngle,
                          theTp, theHta, theVta, theToEvalMinMax);
@@ -397,7 +391,7 @@ void OpenGl_Group::Text (const Standard_CString                  theTextUtf,
   aParams.HAlign      = theHTA;
   aParams.VAlign      = theVTA;
 
-  OpenGl_Text* aText = new OpenGl_Text (theTextUtf, theOrientation, aParams, theHasOwnAnchor != Standard_False);
+  Handle(OpenGl_Text) aText = new OpenGl_Text (theTextUtf, theOrientation, aParams, theHasOwnAnchor != Standard_False);
 
   AddElement (aText);
 
@@ -420,7 +414,7 @@ void OpenGl_Group::Text (const Standard_CString                  theTextUtf,
 void OpenGl_Group::SetFlippingOptions (const Standard_Boolean theIsEnabled,
                                        const gp_Ax2&          theRefPlane)
 {
-  OpenGl_Flipper* aFlipper = new OpenGl_Flipper (theRefPlane);
+  Handle(OpenGl_Flipper) aFlipper = new OpenGl_Flipper (theRefPlane);
   aFlipper->SetOptions (theIsEnabled);
   AddElement (aFlipper);
 }
@@ -431,7 +425,7 @@ void OpenGl_Group::SetFlippingOptions (const Standard_Boolean theIsEnabled,
 // =======================================================================
 void OpenGl_Group::SetStencilTestOptions (const Standard_Boolean theIsEnabled)
 {
-  OpenGl_StencilTest* aStencilTest = new OpenGl_StencilTest();
+  Handle(OpenGl_StencilTest) aStencilTest = new OpenGl_StencilTest();
   aStencilTest->SetOptions (theIsEnabled);
   AddElement (aStencilTest);
 }
@@ -440,16 +434,11 @@ void OpenGl_Group::SetStencilTestOptions (const Standard_Boolean theIsEnabled)
 // function : AddElement
 // purpose  :
 // =======================================================================
-void OpenGl_Group::AddElement (OpenGl_Element* theElem)
+void OpenGl_Group::AddElement (Handle(OpenGl_Element) theElem)
 {
-  OpenGl_ElementNode *aNode = new OpenGl_ElementNode();
+  myElements.Append (theElem);
 
-  aNode->elem = theElem;
-  aNode->next = NULL;
-  (myLast? myLast->next : myFirst) = aNode;
-  myLast = aNode;
-
-  if (OpenGl_Raytrace::IsRaytracedElement (aNode))
+  if (OpenGl_Raytrace::IsRaytracedElement (theElem))
   {
     myIsRaytracable = Standard_True;
 
@@ -470,19 +459,19 @@ void OpenGl_Group::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
   // Setup aspects
   theWorkspace->SetAllowFaceCulling (myIsClosed
                                  && !theWorkspace->GetGlContext()->Clipping().IsClippingOrCappingOn());
-  const OpenGl_AspectLine*   aBackAspectLine   = theWorkspace->AspectLine();
-  const OpenGl_AspectFace*   aBackAspectFace   = theWorkspace->AspectFace();
-  const OpenGl_AspectMarker* aBackAspectMarker = theWorkspace->AspectMarker();
-  const OpenGl_AspectText*   aBackAspectText   = theWorkspace->AspectText();
-  const bool isLineSet   = myAspectLine   && renderFiltered (theWorkspace, myAspectLine);
-  const bool isFaceSet   = myAspectFace   && renderFiltered (theWorkspace, myAspectFace);
-  const bool isMarkerSet = myAspectMarker && renderFiltered (theWorkspace, myAspectMarker);
-  const bool isTextSet   = myAspectText   && renderFiltered (theWorkspace, myAspectText);
+  const Handle(OpenGl_AspectLine)& aBackAspectLine   = theWorkspace->AspectLine();
+  const Handle(OpenGl_AspectFace)& aBackAspectFace   = theWorkspace->AspectFace();
+  const Handle(OpenGl_AspectMarker)& aBackAspectMarker = theWorkspace->AspectMarker();
+  const Handle(OpenGl_AspectText)& aBackAspectText   = theWorkspace->AspectText();
+  const bool isLineSet   = !myAspectLine.IsNull()   && renderFiltered (theWorkspace, myAspectLine);
+  const bool isFaceSet   = !myAspectFace.IsNull()   && renderFiltered (theWorkspace, myAspectFace);
+  const bool isMarkerSet = !myAspectMarker.IsNull() && renderFiltered (theWorkspace, myAspectMarker);
+  const bool isTextSet   = !myAspectText.IsNull()   && renderFiltered (theWorkspace, myAspectText);
 
   // Render group elements
-  for (OpenGl_ElementNode* aNodeIter = myFirst; aNodeIter != NULL; aNodeIter = aNodeIter->next)
+  for (OpenGl_ElementNodes::Iterator anElemIterator(myElements); anElemIterator.More(); anElemIterator.Next())
   {
-    renderFiltered (theWorkspace, aNodeIter->elem);
+    renderFiltered (theWorkspace, anElemIterator.Value());
   }
 
   // Restore aspects
@@ -525,15 +514,12 @@ void OpenGl_Group::Release (const Handle(OpenGl_Context)& theGlCtx)
   // Delete elements
   if (myIsDestroyElements)
   {
-    while (myFirst != NULL)
+    for (OpenGl_ElementNodes::Iterator anElemIterator(myElements); anElemIterator.More(); anElemIterator.Next())
     {
-      OpenGl_ElementNode* aNext = myFirst->next;
-      OpenGl_Element::Destroy (theGlCtx.operator->(), myFirst->elem);
-      delete myFirst;
-      myFirst = aNext;
+      OpenGl_Element::Destroy (theGlCtx.operator->(), anElemIterator.ChangeValue());
     }
   }
-  myLast = NULL;
+  myElements.Clear();
 
   OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectLine);
   OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectFace);
index da9b76988fc50107ed60e9126d12598c85e6998a..a1b548372fd0880bebbd56f1b06a2fb061607399 100644 (file)
@@ -31,12 +31,7 @@ class OpenGl_Group;
 class OpenGl_CappingPlaneResource;
 class OpenGl_Structure;
 
-struct OpenGl_ElementNode
-{
-  OpenGl_Element*     elem;
-  OpenGl_ElementNode* next;
-  DEFINE_STANDARD_ALLOC
-};
+typedef NCollection_List<Handle(OpenGl_Element)> OpenGl_ElementNodes;
 
 //! Implementation of low-level graphic group.
 class OpenGl_Group : public Graphic3d_Group
@@ -52,9 +47,9 @@ public:
   //! Return line aspect.
   virtual Handle(Graphic3d_AspectLine3d) LineAspect() const Standard_OVERRIDE
   {
-    return myAspectLine != NULL
-         ? myAspectLine->Aspect()
-         : Handle(Graphic3d_AspectLine3d)();
+    return !myAspectLine.IsNull()
+           ? myAspectLine->Aspect()
+           : Handle(Graphic3d_AspectLine3d)();
   }
 
   //! Update line aspect.
@@ -66,9 +61,9 @@ public:
   //! Return marker aspect.
   virtual Handle(Graphic3d_AspectMarker3d) MarkerAspect() const Standard_OVERRIDE
   {
-    return myAspectMarker != NULL
-         ? myAspectMarker->Aspect()
-         : Handle(Graphic3d_AspectMarker3d)();
+    return !myAspectMarker.IsNull()
+          ? myAspectMarker->Aspect()
+          : Handle(Graphic3d_AspectMarker3d)();
   }
 
   //! Update marker aspect.
@@ -80,7 +75,7 @@ public:
   //! Return fill area aspect.
   virtual Handle(Graphic3d_AspectFillArea3d) FillAreaAspect() const Standard_OVERRIDE
   {
-    return myAspectFace != NULL
+    return !myAspectFace.IsNull()
          ? myAspectFace->Aspect()
          : Handle(Graphic3d_AspectFillArea3d)();
   }
@@ -94,7 +89,7 @@ public:
   //! Return marker aspect.
   virtual Handle(Graphic3d_AspectText3d) TextAspect() const Standard_OVERRIDE
   {
-    return myAspectText != NULL
+    return !myAspectText.IsNull()
          ? myAspectText->Aspect()
          : Handle(Graphic3d_AspectText3d)();
   }
@@ -166,16 +161,16 @@ public:
 
   OpenGl_Structure* GlStruct() const { return (OpenGl_Structure* )(myStructure->CStructure().operator->()); }
 
-  Standard_EXPORT void AddElement (OpenGl_Element* theElem);
+  Standard_EXPORT void AddElement (Handle(OpenGl_Element) theElem);
 
   Standard_EXPORT virtual void Render  (const Handle(OpenGl_Workspace)& theWorkspace) const;
   Standard_EXPORT virtual void Release (const Handle(OpenGl_Context)&   theGlCtx);
 
-  //! Returns first OpenGL element node of the group.
-  const OpenGl_ElementNode* FirstNode() const { return myFirst; }
+  //! Returns OpenGl elements of the group
+  const OpenGl_ElementNodes& GetElements() const { return myElements; }
 
   //! Returns OpenGL face aspect.
-  const OpenGl_AspectFace* AspectFace() const { return myAspectFace; }
+  const Handle(OpenGl_AspectFace)& AspectFace() const { return myAspectFace; }
 
   //! Returns OpenGL capping filling aspect.
   const OpenGl_CappingPlaneResource* AspectFillCapping() const { return myAspectFillCapping; }
@@ -189,14 +184,13 @@ protected:
 
 protected:
 
-  OpenGl_AspectLine*     myAspectLine;
-  OpenGl_AspectFace*     myAspectFace;
-  OpenGl_AspectMarker*   myAspectMarker;
-  OpenGl_AspectText*     myAspectText;
+  Handle(OpenGl_AspectLine) myAspectLine;
+  Handle(OpenGl_AspectFace) myAspectFace;
+  Handle(OpenGl_AspectMarker) myAspectMarker;
+  Handle(OpenGl_AspectText) myAspectText;
   OpenGl_CappingPlaneResource* myAspectFillCapping;
 
-  OpenGl_ElementNode*    myFirst;
-  OpenGl_ElementNode*    myLast;
+  OpenGl_ElementNodes    myElements;
 
   Standard_Boolean       myIsRaytracable;
   Standard_Boolean       myIsDestroyElements;
index 8986de7bb62d54e8fd92c4dab644c4136671f455..c759c7703fcdeb7bf5bca79bc6eee13a09b36e18 100644 (file)
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
+#include <OpenGl_PrimitiveArray.hxx>
+
 #include <OpenGl_AspectFace.hxx>
 #include <OpenGl_Context.hxx>
 #include <OpenGl_GraphicDriver.hxx>
 #include <OpenGl_IndexBuffer.hxx>
 #include <OpenGl_PointSprite.hxx>
-#include <OpenGl_PrimitiveArray.hxx>
 #include <OpenGl_Sampler.hxx>
 #include <OpenGl_ShaderManager.hxx>
 #include <OpenGl_ShaderProgram.hxx>
@@ -28,6 +29,8 @@
 #include <Graphic3d_TextureParams.hxx>
 #include <NCollection_AlignedAllocator.hxx>
 
+IMPLEMENT_STANDARD_RTTIEXT(OpenGl_PrimitiveArray, OpenGl_Element)
+
 namespace
 {
   //! Convert data type to GL info
@@ -502,8 +505,10 @@ void OpenGl_PrimitiveArray::drawEdges (const OpenGl_Vec4&              theEdgeCo
     return;
   }
 
-  const OpenGl_AspectLine* anAspectLineOld = theWorkspace->SetAspectLine (theWorkspace->AspectFace()->AspectEdge());
-  const OpenGl_AspectLine* anAspect = theWorkspace->ApplyAspectLine();
+  const Handle(OpenGl_AspectLine) anAspectLineOld = theWorkspace->AspectLine();
+  theWorkspace->SetAspectLine (theWorkspace->AspectFace()->AspectEdge());
+
+  const Handle(OpenGl_AspectLine)& anAspect = theWorkspace->ApplyAspectLine();
 
 #if !defined(GL_ES_VERSION_2_0)
   glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
@@ -588,8 +593,8 @@ void OpenGl_PrimitiveArray::drawEdges (const OpenGl_Vec4&              theEdgeCo
 // =======================================================================
 void OpenGl_PrimitiveArray::drawMarkers (const Handle(OpenGl_Workspace)& theWorkspace) const
 {
-  const OpenGl_AspectMarker* anAspectMarker = theWorkspace->ApplyAspectMarker();
-  const Handle(OpenGl_Context)&     aCtx    = theWorkspace->GetGlContext();
+  const Handle(OpenGl_AspectMarker)& anAspectMarker = theWorkspace->ApplyAspectMarker();
+  const Handle(OpenGl_Context)& aCtx    = theWorkspace->GetGlContext();
   const GLenum aDrawMode = !aCtx->ActiveProgram().IsNull()
                          && aCtx->ActiveProgram()->HasTessellationStage()
                          ? GL_PATCHES
@@ -765,9 +770,9 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
     return;
   }
 
-  const OpenGl_AspectFace*   anAspectFace   = theWorkspace->ApplyAspectFace();
-  const OpenGl_AspectLine*   anAspectLine   = theWorkspace->ApplyAspectLine();
-  const OpenGl_AspectMarker* anAspectMarker = myDrawMode == GL_POINTS
+  const Handle(OpenGl_AspectFace)& anAspectFace = theWorkspace->ApplyAspectFace();
+  const Handle(OpenGl_AspectLine)& anAspectLine = theWorkspace->ApplyAspectLine();
+  const Handle(OpenGl_AspectMarker)& anAspectMarker = myDrawMode == GL_POINTS
                                             ? theWorkspace->ApplyAspectMarker()
                                             : theWorkspace->AspectMarker();
 
@@ -1041,7 +1046,7 @@ Standard_Boolean OpenGl_PrimitiveArray::processIndices (const Handle(OpenGl_Cont
     return Standard_True;
   }
 
-  if (myAttribs->NbElements > std::numeric_limits<GLushort>::max())
+  if (myAttribs->NbElements > IntegerLast()/*std::numeric_limits<GLushort>::max()*/)
   {
     Handle(Graphic3d_Buffer) anAttribs = new Graphic3d_Buffer (new NCollection_AlignedAllocator (16));
     if (!anAttribs->Init (myIndices->NbElements, myAttribs->AttributesArray(), myAttribs->NbAttributes))
index 811b2220711907fbfd52a6468f8cdd9cd22eea50..d10de8c0f130bcd2d015c8bd46cd01002f72201e 100644 (file)
@@ -31,6 +31,7 @@ class OpenGl_GraphicDriver;
 //! Class for rendering of arbitrary primitive array.
 class OpenGl_PrimitiveArray : public OpenGl_Element
 {
+  DEFINE_STANDARD_RTTIEXT(OpenGl_PrimitiveArray, OpenGl_Element)
 public:
   //! OpenGL does not provide a constant for "none" draw mode.
   //! So we define our own one that does not conflict with GL constants and utilizes common GL invalid value.
index 530bf570481d98ebe42eb1ae16cf148df402038d..71dcd2eb6432e27a36861cd647bc732b3f136230 100644 (file)
@@ -593,21 +593,10 @@ namespace OpenGl_Raytrace
   // function : IsRaytracedElement
   // purpose  : Checks to see if the element contains ray-trace geometry
   // =======================================================================
-  Standard_Boolean IsRaytracedElement (const OpenGl_ElementNode* theNode)
+  Standard_Boolean IsRaytracedElement (const Handle(OpenGl_Element) theElement)
   {
-    OpenGl_PrimitiveArray* anArray = dynamic_cast<OpenGl_PrimitiveArray*> (theNode->elem);
-    return anArray != NULL
-        && anArray->DrawMode() >= GL_TRIANGLES;
-  }
-
-  // =======================================================================
-  // function : IsRaytracedElement
-  // purpose  : Checks to see if the element contains ray-trace geometry
-  // =======================================================================
-  Standard_Boolean IsRaytracedElement (const OpenGl_Element* theElement)
-  {
-    const OpenGl_PrimitiveArray* anArray = dynamic_cast<const OpenGl_PrimitiveArray*> (theElement);
-    return anArray != NULL
+    Handle(OpenGl_PrimitiveArray) anArray = Handle(OpenGl_PrimitiveArray)::DownCast (theElement);
+    return !anArray.IsNull()
         && anArray->DrawMode() >= GL_TRIANGLES;
   }
 
@@ -617,9 +606,9 @@ namespace OpenGl_Raytrace
   // =======================================================================
   Standard_Boolean IsRaytracedGroup (const OpenGl_Group* theGroup)
   {
-    for (const OpenGl_ElementNode* aNode = theGroup->FirstNode(); aNode != NULL; aNode = aNode->next)
+    for (OpenGl_ElementNodes::Iterator anElemIterator (theGroup->GetElements()); anElemIterator.More(); anElemIterator.Next())
     {
-      if (IsRaytracedElement (aNode))
+      if (IsRaytracedElement (anElemIterator.Value()))
       {
         return Standard_True;
       }
index 8fa64e2959608aea12e43189bea84682f09c66d4..dc12f204c0b9b4a95408c29d697262006745cdcf 100644 (file)
@@ -36,10 +36,7 @@ namespace OpenGl_Raytrace
   Standard_Boolean IsRaytracedGroup (const OpenGl_Group* theGroup);
 
   //! Checks to see if the element contains ray-trace geometry.
-  Standard_Boolean IsRaytracedElement (const OpenGl_ElementNode* theNode);
-
-  //! Checks to see if the element contains ray-trace geometry.
-  Standard_Boolean IsRaytracedElement (const OpenGl_Element* theElement);
+  Standard_Boolean IsRaytracedElement (const Handle(OpenGl_Element) theElement);
 }
 
 //! Stores properties of surface material.
index ba5dab14a40d15d240914f5a7429562f9704f828..c1240b095099a0ee5a9ab073391078c94a474871 100755 (executable)
@@ -16,6 +16,8 @@
 #include <OpenGl_GlCore11.hxx>
 #include <OpenGl_StencilTest.hxx>
 
+IMPLEMENT_STANDARD_RTTIEXT(OpenGl_StencilTest, OpenGl_Element)
+
 OpenGl_StencilTest::OpenGl_StencilTest()
 {
   //
index f540c199e9007f109c824f909cdef97b5a12d2d6..5771d1086eba02553025a992bd077f3249bd1373 100755 (executable)
@@ -20,6 +20,7 @@
 
 class OpenGl_StencilTest : public OpenGl_Element
 {
+  DEFINE_STANDARD_RTTIEXT(OpenGl_StencilTest, OpenGl_Element)
 public:
 
   //! Default constructor
index c21435cd5dddc36afc8cc727faf933fcee223d79..5a4f2cb42eb299764339ce411956ab0fa0b45969 100644 (file)
@@ -460,10 +460,10 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con
   aCtx->ApplyModelViewMatrix();
 
   // remember aspects
-  const OpenGl_AspectLine*   aPrevAspectLine   = theWorkspace->AspectLine();
-  const OpenGl_AspectFace*   aPrevAspectFace   = theWorkspace->AspectFace();
-  const OpenGl_AspectMarker* aPrevAspectMarker = theWorkspace->AspectMarker();
-  const OpenGl_AspectText*   aPrevAspectText   = theWorkspace->AspectText();
+  const Handle(OpenGl_AspectLine)& aPrevAspectLine   = theWorkspace->AspectLine();
+  const Handle(OpenGl_AspectFace)& aPrevAspectFace   = theWorkspace->AspectFace();
+  const Handle(OpenGl_AspectMarker)& aPrevAspectMarker = theWorkspace->AspectMarker();
+  const Handle(OpenGl_AspectText)& aPrevAspectText   = theWorkspace->AspectText();
 
   // Apply correction for mirror transform
   if (myIsMirrored)
index 70cd2fb3a37a4ca36f7f794dae29ad538d9ef0c7..93d87cf9bb7a2a28e5e2e65d14cde29025610029 100644 (file)
@@ -29,6 +29,8 @@
 #include <Graphic3d_TransformUtils.hxx>
 #include <TCollection_HAsciiString.hxx>
 
+IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Text, OpenGl_Element)
+
 namespace
 {
   static const GLdouble THE_IDENTITY_MATRIX[16] =
@@ -287,7 +289,7 @@ void OpenGl_Text::Release (OpenGl_Context* theCtx)
 // =======================================================================
 void OpenGl_Text::StringSize (const Handle(OpenGl_Context)& theCtx,
                               const NCollection_String&     theText,
-                              const OpenGl_AspectText&      theTextAspect,
+                              const Handle(OpenGl_AspectText)& theTextAspect,
                               const OpenGl_TextParam&       theParams,
                               const unsigned int            theResolution,
                               Standard_ShortReal&           theWidth,
@@ -353,10 +355,10 @@ void OpenGl_Text::StringSize (const Handle(OpenGl_Context)& theCtx,
 // =======================================================================
 void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
 {
-  theWorkspace->SetAspectFace (&theWorkspace->FontFaceAspect());
+  theWorkspace->SetAspectFace (theWorkspace->FontFaceAspect());
   theWorkspace->ApplyAspectFace();
-  const OpenGl_AspectText*      aTextAspect  = theWorkspace->ApplyAspectText();
-  const Handle(OpenGl_Context)& aCtx         = theWorkspace->GetGlContext();
+  const Handle(OpenGl_AspectText)& aTextAspect  = theWorkspace->ApplyAspectText();
+  const Handle(OpenGl_Context)& aCtx           = theWorkspace->GetGlContext();
   const Handle(OpenGl_TextureSet) aPrevTexture = aCtx->BindTextures (Handle(OpenGl_TextureSet)());
 
   // Bind custom shader program or generate default version
@@ -367,7 +369,7 @@ void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
 
   // use highlight color or colors from aspect
   render (aCtx,
-          *aTextAspect,
+          aTextAspect,
           theWorkspace->TextColor(),
           theWorkspace->TextSubtitleColor(),
           aCtx->Resolution());
@@ -390,12 +392,12 @@ void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
 // purpose  :
 // =======================================================================
 void OpenGl_Text::Render (const Handle(OpenGl_Context)& theCtx,
-                          const OpenGl_AspectText&      theTextAspect,
+                          const Handle(OpenGl_AspectText)& theTextAspect,
                           const unsigned int            theResolution) const
 {
   render (theCtx, theTextAspect,
-          theTextAspect.Aspect()->ColorRGBA(),
-          theTextAspect.Aspect()->ColorSubTitleRGBA(),
+          theTextAspect->Aspect()->ColorRGBA(),
+          theTextAspect->Aspect()->ColorSubTitleRGBA(),
           theResolution);
 }
 
@@ -404,7 +406,7 @@ void OpenGl_Text::Render (const Handle(OpenGl_Context)& theCtx,
 // purpose  :
 // =======================================================================
 void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
-                               const OpenGl_AspectText&      theTextAspect,
+                               const Handle(OpenGl_AspectText)& theTextAspect,
                                const OpenGl_Vec3             theDVec) const
 {
   OpenGl_Mat4d aModViewMat;
@@ -422,7 +424,7 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
   {
     Graphic3d_TransformUtils::Translate<GLdouble> (aModViewMat, myPoint.x() + theDVec.x(), myPoint.y() + theDVec.y(), 0.f);
     Graphic3d_TransformUtils::Scale<GLdouble> (aModViewMat, 1.f, -1.f, 1.f);
-    Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect.Aspect()->GetTextAngle(), 0.f, 0.f, 1.f);
+    Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect->Aspect()->GetTextAngle(), 0.f, 0.f, 1.f);
   }
   else
   {
@@ -464,10 +466,10 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
     else
     {
       Graphic3d_TransformUtils::Translate<GLdouble> (aModViewMat, anObjX, anObjY, anObjZ);
-      Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect.Aspect()->GetTextAngle(), 0.0, 0.0, 1.0);
+      Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect->Aspect()->GetTextAngle(), 0.0, 0.0, 1.0);
     }
 
-    if (!theTextAspect.Aspect()->GetTextZoomable())
+    if (!theTextAspect->Aspect()->GetTextZoomable())
     {
       Graphic3d_TransformUtils::Scale<GLdouble> (aModViewMat, myScaleHeight, myScaleHeight, myScaleHeight);
     }
@@ -504,7 +506,7 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
 // purpose  :
 // =======================================================================
 void OpenGl_Text::drawText (const Handle(OpenGl_Context)& theCtx,
-                            const OpenGl_AspectText&      theTextAspect) const
+                            const Handle(OpenGl_AspectText)& theTextAspect) const
 {
   (void )theTextAspect;
   if (myVertsVbo.Length() != myTextures.Length()
@@ -535,14 +537,14 @@ void OpenGl_Text::drawText (const Handle(OpenGl_Context)& theCtx,
 // function : FontKey
 // purpose  :
 // =======================================================================
-TCollection_AsciiString OpenGl_Text::FontKey (const OpenGl_AspectText& theAspect,
+TCollection_AsciiString OpenGl_Text::FontKey (const Handle(OpenGl_AspectText)& theAspect,
                                               const Standard_Integer   theHeight,
                                               const unsigned int       theResolution)
 {
-  const Font_FontAspect anAspect = theAspect.Aspect()->GetTextFontAspect() != Font_FA_Undefined
-                                 ? theAspect.Aspect()->GetTextFontAspect()
+  const Font_FontAspect anAspect = theAspect->Aspect()->GetTextFontAspect() != Font_FA_Undefined
+                                 ? theAspect->Aspect()->GetTextFontAspect()
                                  : Font_FA_Regular;
-  return theAspect.Aspect()->Font()
+  return theAspect->Aspect()->Font()
        + TCollection_AsciiString(":") + Standard_Integer(anAspect)
        + TCollection_AsciiString(":") + Standard_Integer(theResolution)
        + TCollection_AsciiString(":") + theHeight;
@@ -553,7 +555,7 @@ TCollection_AsciiString OpenGl_Text::FontKey (const OpenGl_AspectText& theAspect
 // purpose  :
 // =======================================================================
 Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx,
-                                           const OpenGl_AspectText&      theAspect,
+                                           const Handle(OpenGl_AspectText)& theAspect,
                                            const Standard_Integer        theHeight,
                                            const unsigned int            theResolution,
                                            const TCollection_AsciiString theKey)
@@ -567,9 +569,9 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx,
   if (!theCtx->GetResource (theKey, aFont))
   {
     Handle(Font_FontMgr) aFontMgr = Font_FontMgr::GetInstance();
-    const Handle(TCollection_HAsciiString) aFontName = new TCollection_HAsciiString (theAspect.Aspect()->Font());
-    const Font_FontAspect anAspect = theAspect.Aspect()->GetTextFontAspect() != Font_FA_Undefined
-                                   ? theAspect.Aspect()->GetTextFontAspect()
+    const Handle(TCollection_HAsciiString) aFontName = new TCollection_HAsciiString (theAspect->Aspect()->Font());
+    const Font_FontAspect anAspect = theAspect->Aspect()->GetTextFontAspect() != Font_FA_Undefined
+                                   ? theAspect->Aspect()->GetTextFontAspect()
                                    : Font_FA_Regular;
     Handle(Font_SystemFont) aRequestedFont = aFontMgr->FindFont (aFontName, anAspect, theHeight);
     Handle(Font_FTFont) aFontFt;
@@ -584,7 +586,7 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx,
         {
           TCollection_ExtendedString aMsg;
           aMsg += "Font '";
-          aMsg += theAspect.Aspect()->Font();
+          aMsg += theAspect->Aspect()->Font();
           aMsg += "' - initialization of GL resources has failed!";
           theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aMsg);
           aFontFt.Nullify();
@@ -596,7 +598,7 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx,
       {
         TCollection_ExtendedString aMsg;
         aMsg += "Font '";
-        aMsg += theAspect.Aspect()->Font();
+        aMsg += theAspect->Aspect()->Font();
         aMsg += "' is broken or has incompatible format! File path: ";
         aMsg += aRequestedFont->FontPath()->ToCString();
         theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aMsg);
@@ -608,7 +610,7 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx,
     {
       TCollection_ExtendedString aMsg;
       aMsg += "Font '";
-      aMsg += theAspect.Aspect()->Font();
+      aMsg += theAspect->Aspect()->Font();
       aMsg += "' is not found in the system!";
       theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aMsg);
       aFont = new OpenGl_Font (aFontFt, theKey);
@@ -624,7 +626,7 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx,
 // purpose  :
 // =======================================================================
 void OpenGl_Text::drawRect (const Handle(OpenGl_Context)& theCtx,
-                            const OpenGl_AspectText&      theTextAspect,
+                            const Handle(OpenGl_AspectText)& theTextAspect,
                             const OpenGl_Vec4&            theColorSubs) const
 {
   Handle(OpenGl_ShaderProgram) aPrevProgram = theCtx->ActiveProgram();
@@ -675,7 +677,7 @@ void OpenGl_Text::drawRect (const Handle(OpenGl_Context)& theCtx,
 // purpose  :
 // =======================================================================
 void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
-                          const OpenGl_AspectText&      theTextAspect,
+                          const Handle(OpenGl_AspectText)& theTextAspect,
                           const OpenGl_Vec4&            theColorText,
                           const OpenGl_Vec4&            theColorSubs,
                           const unsigned int            theResolution) const
@@ -748,7 +750,7 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
                                                       myWinX, myWinY, myWinZ);
 
     // compute scale factor for constant text height
-    if (theTextAspect.Aspect()->GetTextZoomable())
+    if (theTextAspect->Aspect()->GetTextZoomable())
     {
       myExportHeight = aPointSize;
     }
@@ -779,7 +781,7 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
 
   // setup depth test
   const bool hasDepthTest = !myIs2d
-                         && theTextAspect.Aspect()->Style() != Aspect_TOST_ANNOTATION;
+                         && theTextAspect->Aspect()->Style() != Aspect_TOST_ANNOTATION;
   if (!hasDepthTest)
   {
     glDisable (GL_DEPTH_TEST);
@@ -810,7 +812,7 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
   const bool anAlphaToCoverageOld = theCtx->SetSampleAlphaToCoverage (false);
 
   // extra drawings
-  switch (theTextAspect.Aspect()->DisplayType())
+  switch (theTextAspect->Aspect()->DisplayType())
   {
     case Aspect_TODT_BLEND:
     {
@@ -873,7 +875,7 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
   }
 #endif
 
-  if (theTextAspect.Aspect()->DisplayType() == Aspect_TODT_DIMENSION)
+  if (theTextAspect->Aspect()->DisplayType() == Aspect_TODT_DIMENSION)
   {
     glDisable (GL_BLEND);
     if (!myIs2d)
index e076ae19817ead435d70b6bba8cd224a6c6499c3..0af140c823dafe8e5be5a730fe8141a9e3595ad9 100755 (executable)
@@ -33,7 +33,7 @@
 //! Text rendering
 class OpenGl_Text : public OpenGl_Element
 {
-
+  DEFINE_STANDARD_RTTIEXT(OpenGl_Text, OpenGl_Element)
 public:
 
   //! Main constructor
@@ -83,13 +83,13 @@ public: //! @name methods for compatibility with layers
   Standard_EXPORT OpenGl_Text();
 
   //! Create key for shared resource
-  Standard_EXPORT static TCollection_AsciiString FontKey (const OpenGl_AspectText& theAspect,
+  Standard_EXPORT static TCollection_AsciiString FontKey (const Handle(OpenGl_AspectText)& theAspect,
                                                           const Standard_Integer   theHeight,
                                                           const unsigned int       theResolution);
 
   //! Find shared resource for specified font or initialize new one
   Standard_EXPORT static Handle(OpenGl_Font) FindFont (const Handle(OpenGl_Context)& theCtx,
-                                                       const OpenGl_AspectText&      theAspect,
+                                                       const Handle(OpenGl_AspectText)& theAspect,
                                                        const Standard_Integer        theHeight,
                                                        const unsigned int            theResolution,
                                                        const TCollection_AsciiString theKey);
@@ -97,7 +97,7 @@ public: //! @name methods for compatibility with layers
   //! Compute text width
   Standard_EXPORT static void StringSize (const Handle(OpenGl_Context)& theCtx,
                                           const NCollection_String&     theText,
-                                          const OpenGl_AspectText&      theTextAspect,
+                                          const Handle(OpenGl_AspectText)& theTextAspect,
                                           const OpenGl_TextParam&       theParams,
                                           const unsigned int            theResolution,
                                           Standard_ShortReal&           theWidth,
@@ -112,8 +112,8 @@ public: //! @name methods for compatibility with layers
 
   //! Perform rendering
   Standard_EXPORT void Render (const Handle(OpenGl_Context)& theCtx,
-                               const OpenGl_AspectText&      theTextAspect,
-                               const unsigned int            theResolution = Graphic3d_RenderingParams::THE_DEFAULT_RESOLUTION) const;
+                               const Handle(OpenGl_AspectText)& theTextAspect,
+                               const unsigned int theResolution = Graphic3d_RenderingParams::THE_DEFAULT_RESOLUTION) const;
 
 protected:
 
@@ -127,21 +127,21 @@ private:
 
   //! Setup matrix.
   void setupMatrix (const Handle(OpenGl_Context)& theCtx,
-                    const OpenGl_AspectText&      theTextAspect,
+                    const Handle(OpenGl_AspectText)& theTextAspect,
                     const OpenGl_Vec3             theDVec) const;
 
   //! Draw arrays of vertices.
   void drawText (const Handle(OpenGl_Context)& theCtx,
-                 const OpenGl_AspectText&      theTextAspect) const;
+                 const Handle(OpenGl_AspectText)& theTextAspect) const;
 
   //! Draw rectangle from bounding text box.
   void drawRect (const Handle(OpenGl_Context)& theCtx,
-                 const OpenGl_AspectText&      theTextAspect,
+                 const Handle(OpenGl_AspectText)& theTextAspect,
                  const OpenGl_Vec4&            theColorSubs) const;
 
   //! Main rendering code
   void render (const Handle(OpenGl_Context)& theCtx,
-               const OpenGl_AspectText&      theTextAspect,
+               const Handle(OpenGl_AspectText)& theTextAspect,
                const OpenGl_Vec4&            theColorText,
                const OpenGl_Vec4&            theColorSubs,
                const unsigned int            theResolution) const;
index f6b3fa6c9b7fcf2286967c76984ce1ee86d9d8b5..db417b4b7f93de54ab6623a618a3ac84e8c21b47 100644 (file)
@@ -111,6 +111,9 @@ OpenGl_View::OpenGl_View (const Handle(Graphic3d_StructureManager)& theMgr,
   myRaytraceFBO1[1]          = new OpenGl_FrameBuffer();
   myRaytraceFBO2[0]          = new OpenGl_FrameBuffer();
   myRaytraceFBO2[1]          = new OpenGl_FrameBuffer();
+
+  myGraduatedTrihedron       = new OpenGl_GraduatedTrihedron();
+  myFrameStatsPrs            = new OpenGl_FrameStatsPrs();
 }
 
 // =======================================================================
@@ -131,8 +134,8 @@ OpenGl_View::~OpenGl_View()
 // =======================================================================
 void OpenGl_View::ReleaseGlResources (const Handle(OpenGl_Context)& theCtx)
 {
-  myGraduatedTrihedron.Release (theCtx.operator->());
-  myFrameStatsPrs.Release (theCtx.operator->());
+  myGraduatedTrihedron->Release (theCtx.operator->());
+  myFrameStatsPrs->Release (theCtx.operator->());
 
   if (!myTextureEnv.IsNull())
   {
@@ -144,15 +147,15 @@ void OpenGl_View::ReleaseGlResources (const Handle(OpenGl_Context)& theCtx)
     myTextureEnv.Nullify();
   }
 
-  if (myTextureParams != NULL)
+  if (!myTextureParams.IsNull())
   {
     myTextureParams->Release (theCtx.operator->());
   }
-  if (myBgGradientArray != NULL)
+  if (!myBgGradientArray.IsNull())
   {
     myBgGradientArray->Release (theCtx.operator->());
   }
-  if (myBgTextureArray != NULL)
+  if (!myBgTextureArray.IsNull())
   {
     myBgTextureArray->Release (theCtx.operator->());
   }
@@ -334,7 +337,7 @@ void OpenGl_View::GraduatedTrihedronDisplay (const Graphic3d_GraduatedTrihedron&
   myGTrihedronData = theTrihedronData;
   myGTrihedronData.PtrView = this;
   myGTrihedronData.CubicAxesCallback = SetMinMaxValuesCallback;
-  myGraduatedTrihedron.SetValues (myGTrihedronData);
+  myGraduatedTrihedron->SetValues (myGTrihedronData);
   myToShowGradTrihedron = true;
 }
 
@@ -345,7 +348,7 @@ void OpenGl_View::GraduatedTrihedronDisplay (const Graphic3d_GraduatedTrihedron&
 void OpenGl_View::GraduatedTrihedronErase()
 {
   myGTrihedronData.PtrView = NULL;
-  myGraduatedTrihedron.Release (myWorkspace->GetGlContext().operator->());
+  myGraduatedTrihedron->Release (myWorkspace->GetGlContext().operator->());
   myToShowGradTrihedron = false;
 }
 
@@ -355,7 +358,7 @@ void OpenGl_View::GraduatedTrihedronErase()
 // =======================================================================
 void OpenGl_View::GraduatedTrihedronMinMaxValues (const Graphic3d_Vec3 theMin, const Graphic3d_Vec3 theMax)
 {
-  myGraduatedTrihedron.SetMinMax (theMin, theMax);
+  myGraduatedTrihedron->SetMinMax (theMin, theMax);
 }
 
 // =======================================================================
index c24873b86fd2650e9a5c6f1713fb666808f25902..0b3ffa42395e3ef2a067178892379112aea79034 100644 (file)
@@ -297,7 +297,7 @@ public:
   const Quantity_ColorRGBA& BackgroundColor() const { return myBgColor; }
 
   //! Change graduated trihedron.
-  OpenGl_GraduatedTrihedron& ChangeGraduatedTrihedron() { return myGraduatedTrihedron; }
+  const Handle(OpenGl_GraduatedTrihedron)& ChangeGraduatedTrihedron() { return myGraduatedTrihedron; }
 
   void SetTextureEnv (const Handle(OpenGl_Context)&       theCtx,
                       const Handle(Graphic3d_TextureEnv)& theTexture);
@@ -487,8 +487,8 @@ protected:
   //! Is needed for selection of overlapping objects and storage of the current view volume
   OpenGl_BVHTreeSelector myBVHSelector;
 
-  OpenGl_GraduatedTrihedron myGraduatedTrihedron;
-  OpenGl_FrameStatsPrs      myFrameStatsPrs;
+  Handle(OpenGl_GraduatedTrihedron) myGraduatedTrihedron;
+  Handle(OpenGl_FrameStatsPrs) myFrameStatsPrs;
 
   Handle(OpenGl_TextureSet) myTextureEnv;
 
@@ -521,9 +521,9 @@ protected: //! @name Rendering properties
 
 protected: //! @name Background parameters
 
-  OpenGl_AspectFace*      myTextureParams;   //!< Stores texture and its parameters for textured background
-  OpenGl_BackgroundArray* myBgGradientArray; //!< Primitive array for gradient background
-  OpenGl_BackgroundArray* myBgTextureArray;  //!< Primitive array for texture  background
+  Handle(OpenGl_AspectFace)      myTextureParams;   //!< Stores texture and its parameters for textured background
+  Handle(OpenGl_BackgroundArray) myBgGradientArray; //!< Primitive array for gradient background
+  Handle(OpenGl_BackgroundArray) myBgTextureArray;  //!< Primitive array for texture  background
 
 protected: //! @name data types related to ray-tracing
 
@@ -777,11 +777,11 @@ protected: //! @name methods related to ray-tracing
                                       const Handle(OpenGl_Context)&  theGlContext);
 
   //! Creates ray-tracing material properties.
-  OpenGl_RaytraceMaterial convertMaterial (const OpenGl_AspectFace*      theAspect,
+  OpenGl_RaytraceMaterial convertMaterial (const Handle(OpenGl_AspectFace)& theAspect,
                                            const Handle(OpenGl_Context)& theGlContext);
 
   //! Adds OpenGL primitive array to ray-traced scene geometry.
-  Handle(OpenGl_TriangleSet) addRaytracePrimitiveArray (const OpenGl_PrimitiveArray* theArray,
+  Handle(OpenGl_TriangleSet) addRaytracePrimitiveArray (const Handle(OpenGl_PrimitiveArray)& theArray,
                                                         const Standard_Integer       theMatID,
                                                         const OpenGl_Mat4*           theTrans);
 
@@ -790,7 +790,7 @@ protected: //! @name methods related to ray-tracing
                                              const Standard_Integer               theMatID,
                                              const Standard_Integer               theCount,
                                              const Standard_Integer               theOffset,
-                                             const OpenGl_PrimitiveArray&         theArray);
+                                             const Handle(OpenGl_PrimitiveArray)& theArray);
 
   //! Adds OpenGL triangle array to ray-traced scene geometry.
   Standard_Boolean addRaytraceTriangleArray (OpenGl_TriangleSet&                  theSet,
index 60322e105952f47969cbe50469cc76dc0bf3baf0..242415f2e5d528447c3db2cfc54c7515ab283fc0 100644 (file)
@@ -144,11 +144,10 @@ Standard_Boolean OpenGl_View::updateRaytraceGeometry (const RaytraceUpdateMode
           for (OpenGl_Structure::GroupIterator aGroupIter (aStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
           {
             // Extract OpenGL elements from the group (primitives arrays)
-            for (const OpenGl_ElementNode* aNode = aGroupIter.Value()->FirstNode(); aNode != NULL; aNode = aNode->next)
+            for (OpenGl_ElementNodes::Iterator anElemIterator (aGroupIter.Value()->GetElements()); anElemIterator.More(); anElemIterator.Next())
             {
-              OpenGl_PrimitiveArray* aPrimArray = dynamic_cast<OpenGl_PrimitiveArray*> (aNode->elem);
-
-              if (aPrimArray != NULL)
+              Handle(OpenGl_PrimitiveArray) aPrimArray = Handle(OpenGl_PrimitiveArray)::DownCast (anElemIterator.Value());
+              if (!aPrimArray.IsNull())
               {
                 anArrayIDs.insert (aPrimArray->GetUID());
               }
@@ -344,7 +343,7 @@ void buildTextureTransform (const Handle(Graphic3d_TextureParams)& theParams, BV
 // function : convertMaterial
 // purpose  : Creates ray-tracing material properties
 // =======================================================================
-OpenGl_RaytraceMaterial OpenGl_View::convertMaterial (const OpenGl_AspectFace*      theAspect,
+OpenGl_RaytraceMaterial OpenGl_View::convertMaterial (const Handle(OpenGl_AspectFace)& theAspect,
                                                       const Handle(OpenGl_Context)& theGlContext)
 {
   OpenGl_RaytraceMaterial theMaterial;
@@ -509,7 +508,7 @@ Standard_Boolean OpenGl_View::addRaytraceGroups (const OpenGl_Structure*
   {
     // Get group material
     OpenGl_RaytraceMaterial aGroupMaterial;
-    if (aGroupIter.Value()->AspectFace() != NULL)
+    if (!aGroupIter.Value()->AspectFace().IsNull())
     {
       aGroupMaterial = convertMaterial (
         aGroupIter.Value()->AspectFace(), theGlContext);
@@ -519,14 +518,14 @@ Standard_Boolean OpenGl_View::addRaytraceGroups (const OpenGl_Structure*
 
     // Use group material if available, otherwise use structure material
     myRaytraceGeometry.Materials.push_back (
-      aGroupIter.Value()->AspectFace() != NULL ? aGroupMaterial : theStructMat);
+      !aGroupIter.Value()->AspectFace().IsNull() ? aGroupMaterial : theStructMat);
 
     // Add OpenGL elements from group (extract primitives arrays and aspects)
-    for (const OpenGl_ElementNode* aNode = aGroupIter.Value()->FirstNode(); aNode != NULL; aNode = aNode->next)
+    for (OpenGl_ElementNodes::Iterator anElemIterator (aGroupIter.Value()->GetElements()); anElemIterator.More(); anElemIterator.Next())
     {
-      OpenGl_AspectFace* anAspect = dynamic_cast<OpenGl_AspectFace*> (aNode->elem);
+      Handle(OpenGl_AspectFace) anAspect = Handle(OpenGl_AspectFace)::DownCast (anElemIterator.Value());
 
-      if (anAspect != NULL)
+      if (!anAspect.IsNull())
       {
         aMatID = static_cast<Standard_Integer> (myRaytraceGeometry.Materials.size());
 
@@ -536,9 +535,9 @@ Standard_Boolean OpenGl_View::addRaytraceGroups (const OpenGl_Structure*
       }
       else
       {
-        OpenGl_PrimitiveArray* aPrimArray = dynamic_cast<OpenGl_PrimitiveArray*> (aNode->elem);
+        Handle(OpenGl_PrimitiveArray) aPrimArray = Handle(OpenGl_PrimitiveArray)::DownCast (anElemIterator.Value());
 
-        if (aPrimArray != NULL)
+        if (!aPrimArray.IsNull())
         {
           std::map<Standard_Size, OpenGl_TriangleSet*>::iterator aSetIter = myArrayToTrianglesMap.find (aPrimArray->GetUID());
 
@@ -585,7 +584,7 @@ Standard_Boolean OpenGl_View::addRaytraceGroups (const OpenGl_Structure*
 // function : addRaytracePrimitiveArray
 // purpose  : Adds OpenGL primitive array to ray-traced scene geometry
 // =======================================================================
-Handle(OpenGl_TriangleSet) OpenGl_View::addRaytracePrimitiveArray (const OpenGl_PrimitiveArray* theArray,
+Handle(OpenGl_TriangleSet) OpenGl_View::addRaytracePrimitiveArray (const Handle(OpenGl_PrimitiveArray)& theArray,
                                                                    const Standard_Integer       theMaterial,
                                                                    const OpenGl_Mat4*           theTransform)
 {
@@ -705,7 +704,7 @@ Handle(OpenGl_TriangleSet) OpenGl_View::addRaytracePrimitiveArray (const OpenGl_
       {
         const Standard_Integer aVertNum = aBounds->Bounds[aBound];
 
-        if (!addRaytraceVertexIndices (*aSet, theMaterial, aVertNum, aBoundStart, *theArray))
+        if (!addRaytraceVertexIndices (*aSet, theMaterial, aVertNum, aBoundStart, theArray))
         {
           aSet.Nullify();
           return Handle(OpenGl_TriangleSet)();
@@ -718,7 +717,7 @@ Handle(OpenGl_TriangleSet) OpenGl_View::addRaytracePrimitiveArray (const OpenGl_
     {
       const Standard_Integer aVertNum = !anIndices.IsNull() ? anIndices->NbElements : anAttribs->NbElements;
 
-      if (!addRaytraceVertexIndices (*aSet, theMaterial, aVertNum, 0, *theArray))
+      if (!addRaytraceVertexIndices (*aSet, theMaterial, aVertNum, 0, theArray))
       {
         aSet.Nullify();
         return Handle(OpenGl_TriangleSet)();
@@ -742,17 +741,17 @@ Standard_Boolean OpenGl_View::addRaytraceVertexIndices (OpenGl_TriangleSet&
                                                         const Standard_Integer               theMatID,
                                                         const Standard_Integer               theCount,
                                                         const Standard_Integer               theOffset,
-                                                        const OpenGl_PrimitiveArray&         theArray)
+                                                        const Handle(OpenGl_PrimitiveArray)& theArray)
 {
-  switch (theArray.DrawMode())
+  switch (theArray->DrawMode())
   {
-    case GL_TRIANGLES:      return addRaytraceTriangleArray        (theSet, theMatID, theCount, theOffset, theArray.Indices());
-    case GL_TRIANGLE_FAN:   return addRaytraceTriangleFanArray     (theSet, theMatID, theCount, theOffset, theArray.Indices());
-    case GL_TRIANGLE_STRIP: return addRaytraceTriangleStripArray   (theSet, theMatID, theCount, theOffset, theArray.Indices());
+    case GL_TRIANGLES:      return addRaytraceTriangleArray        (theSet, theMatID, theCount, theOffset, theArray->Indices());
+    case GL_TRIANGLE_FAN:   return addRaytraceTriangleFanArray     (theSet, theMatID, theCount, theOffset, theArray->Indices());
+    case GL_TRIANGLE_STRIP: return addRaytraceTriangleStripArray   (theSet, theMatID, theCount, theOffset, theArray->Indices());
   #if !defined(GL_ES_VERSION_2_0)
-    case GL_QUAD_STRIP:     return addRaytraceQuadrangleStripArray (theSet, theMatID, theCount, theOffset, theArray.Indices());
-    case GL_QUADS:          return addRaytraceQuadrangleArray      (theSet, theMatID, theCount, theOffset, theArray.Indices());
-    case GL_POLYGON:        return addRaytracePolygonArray         (theSet, theMatID, theCount, theOffset, theArray.Indices());
+    case GL_QUAD_STRIP:     return addRaytraceQuadrangleStripArray (theSet, theMatID, theCount, theOffset, theArray->Indices());
+    case GL_QUADS:          return addRaytraceQuadrangleArray      (theSet, theMatID, theCount, theOffset, theArray->Indices());
+    case GL_POLYGON:        return addRaytracePolygonArray         (theSet, theMatID, theCount, theOffset, theArray->Indices());
   #endif
   }
 
@@ -2680,7 +2679,7 @@ Standard_Boolean OpenGl_View::setUniformState (const Standard_Integer        the
   }
 
   // Set background colors (only gradient background supported)
-  if (myBgGradientArray != NULL && myBgGradientArray->IsDefined())
+  if (!myBgGradientArray.IsNull() && myBgGradientArray->IsDefined())
   {
     theProgram->SetUniform (theGlContext,
       myUniformLocations[theProgramId][OpenGl_RT_uBackColorTop], myBgGradientArray->GradientColor (0));
index b88fcd15a449dde4af16a72faf9721528d4bf5ad..4229f435865dbd5d5f469c0aaeb124d0bf6441ab 100644 (file)
@@ -125,7 +125,9 @@ void OpenGl_View::drawBackground (const Handle(OpenGl_Workspace)& theWorkspace)
   {
     aCtx->core11fwd->glDisable (GL_BLEND);
 
-    const OpenGl_AspectFace* anOldAspectFace = theWorkspace->SetAspectFace (myTextureParams);
+    const Handle(OpenGl_AspectFace) anOldAspectFace = theWorkspace->AspectFace();
+    theWorkspace->SetAspectFace (myTextureParams);
+
     myBgTextureArray->Render (theWorkspace);
     theWorkspace->SetAspectFace (anOldAspectFace);
   }
@@ -1161,7 +1163,7 @@ void OpenGl_View::renderTrihedron (const Handle(OpenGl_Workspace) &theWorkspace)
 {
   if (myToShowGradTrihedron)
   {
-    myGraduatedTrihedron.Render (theWorkspace);
+    myGraduatedTrihedron->Render (theWorkspace);
   }
 }
 
@@ -1174,8 +1176,8 @@ void OpenGl_View::renderFrameStats()
   if (myRenderParams.ToShowStats
    && myRenderParams.CollectedStats != Graphic3d_RenderingParams::PerfCounters_NONE)
   {
-    myFrameStatsPrs.Update (myWorkspace);
-    myFrameStatsPrs.Render (myWorkspace);
+    myFrameStatsPrs->Update (myWorkspace);
+    myFrameStatsPrs->Render (myWorkspace);
   }
 }
 
index 8e355a264d7fd2cc9c49d497ae7204359e1a2e5b..b1cd5e924d6a4237a4e800914f71ca57098c8276 100644 (file)
@@ -123,16 +123,25 @@ OpenGl_Workspace::OpenGl_Workspace (OpenGl_View* theView, const Handle(OpenGl_Wi
   myNbSkippedTranspElems (0),
   myRenderFilter (OpenGl_RenderFilter_Empty),
   //
-  myAspectLineSet (&myDefaultAspectLine),
-  myAspectFaceSet (&myDefaultAspectFace),
-  myAspectMarkerSet (&myDefaultAspectMarker),
-  myAspectTextSet (&myDefaultAspectText),
-  //
   ViewMatrix_applied (&myDefaultMatrix),
   StructureMatrix_applied (&myDefaultMatrix),
   myToAllowFaceCulling (false),
   myModelViewMatrix (myDefaultMatrix)
 {
+  myDefaultAspectLine = new OpenGl_AspectLine();
+  myDefaultAspectFace = new OpenGl_AspectFace();
+  myDefaultAspectMarker = new OpenGl_AspectMarker();
+  myDefaultAspectText = new OpenGl_AspectText();
+
+  myNoneCulling = new OpenGl_AspectFace();
+  myFrontCulling = new OpenGl_AspectFace();
+  myFontFaceAspect = new OpenGl_AspectFace();
+
+  myAspectLineSet = myDefaultAspectLine;
+  myAspectFaceSet = myDefaultAspectFace;
+  myAspectMarkerSet = myDefaultAspectMarker;
+  myAspectTextSet = myDefaultAspectText;
+
   if (!myGlContext.IsNull() && myGlContext->MakeCurrent())
   {
     myGlContext->core11fwd->glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
@@ -155,16 +164,16 @@ OpenGl_Workspace::OpenGl_Workspace (OpenGl_View* theView, const Handle(OpenGl_Wi
   #endif
   }
 
-  myFontFaceAspect.Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Mask, 0.285f);
-  myFontFaceAspect.Aspect()->SetShadingModel (Graphic3d_TOSM_UNLIT);
+  myFontFaceAspect->Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Mask, 0.285f);
+  myFontFaceAspect->Aspect()->SetShadingModel (Graphic3d_TOSM_UNLIT);
 
-  myNoneCulling .Aspect()->SetSuppressBackFaces (false);
-  myNoneCulling .Aspect()->SetDrawEdges (false);
-  myNoneCulling .Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Opaque);
+  myNoneCulling->Aspect()->SetSuppressBackFaces (false);
+  myNoneCulling->Aspect()->SetDrawEdges (false);
+  myNoneCulling->Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Opaque);
 
-  myFrontCulling.Aspect()->SetSuppressBackFaces (true);
-  myFrontCulling.Aspect()->SetDrawEdges (false);
-  myFrontCulling.Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Opaque);
+  myFrontCulling->Aspect()->SetSuppressBackFaces (true);
+  myFrontCulling->Aspect()->SetDrawEdges (false);
+  myFrontCulling->Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Opaque);
 }
 
 // =======================================================================
@@ -206,12 +215,12 @@ void OpenGl_Workspace::ResetAppliedAspect()
 
   myHighlightStyle.Nullify();
   myToAllowFaceCulling  = false;
-  myAspectLineSet       = &myDefaultAspectLine;
-  myAspectFaceSet       = &myDefaultAspectFace;
+  myAspectLineSet       = myDefaultAspectLine;
+  myAspectFaceSet       = myDefaultAspectFace;
   myAspectFaceApplied.Nullify();
-  myAspectMarkerSet     = &myDefaultAspectMarker;
+  myAspectMarkerSet     = myDefaultAspectMarker;
   myAspectMarkerApplied.Nullify();
-  myAspectTextSet       = &myDefaultAspectText;
+  myAspectTextSet       = myDefaultAspectText;
   myGlContext->SetPolygonOffset (Graphic3d_PolygonOffset());
 
   ApplyAspectLine();
@@ -219,8 +228,8 @@ void OpenGl_Workspace::ResetAppliedAspect()
   ApplyAspectMarker();
   ApplyAspectText();
 
-  myGlContext->SetTypeOfLine (myDefaultAspectLine.Aspect()->Type());
-  myGlContext->SetLineWidth  (myDefaultAspectLine.Aspect()->Width());
+  myGlContext->SetTypeOfLine (myDefaultAspectLine->Aspect()->Type());
+  myGlContext->SetLineWidth  (myDefaultAspectLine->Aspect()->Width());
 }
 
 // =======================================================================
@@ -229,9 +238,9 @@ void OpenGl_Workspace::ResetAppliedAspect()
 // =======================================================================
 Graphic3d_PolygonOffset OpenGl_Workspace::SetDefaultPolygonOffset (const Graphic3d_PolygonOffset& theOffset)
 {
-  Graphic3d_PolygonOffset aPrev = myDefaultAspectFace.Aspect()->PolygonOffset();
-  myDefaultAspectFace.Aspect()->SetPolygonOffset (theOffset);
-  if (myAspectFaceApplied == myDefaultAspectFace.Aspect()
+  Graphic3d_PolygonOffset aPrev = myDefaultAspectFace->Aspect()->PolygonOffset();
+  myDefaultAspectFace->Aspect()->SetPolygonOffset (theOffset);
+  if (myAspectFaceApplied == myDefaultAspectFace->Aspect()
    || myAspectFaceApplied.IsNull()
    || (myAspectFaceApplied->PolygonOffset().Mode & Aspect_POM_None) == Aspect_POM_None)
   {
@@ -244,51 +253,43 @@ Graphic3d_PolygonOffset OpenGl_Workspace::SetDefaultPolygonOffset (const Graphic
 // function : SetAspectLine
 // purpose  :
 // =======================================================================
-const OpenGl_AspectLine* OpenGl_Workspace::SetAspectLine (const OpenGl_AspectLine* theAspect)
+void OpenGl_Workspace::SetAspectLine (const Handle(OpenGl_AspectLine)& theAspect)
 {
-  const OpenGl_AspectLine* aPrevAspectLine = myAspectLineSet;
   myAspectLineSet = theAspect;
-  return aPrevAspectLine;
 }
 
 // =======================================================================
 // function : SetAspectFace
 // purpose  :
 // =======================================================================
-const OpenGl_AspectFace * OpenGl_Workspace::SetAspectFace (const OpenGl_AspectFace* theAspect)
+void OpenGl_Workspace::SetAspectFace (const Handle(OpenGl_AspectFace)& theAspect)
 {
-  const OpenGl_AspectFace* aPrevAspectFace = myAspectFaceSet;
   myAspectFaceSet = theAspect;
-  return aPrevAspectFace;
 }
 
 // =======================================================================
 // function : SetAspectMarker
 // purpose  :
 // =======================================================================
-const OpenGl_AspectMarker* OpenGl_Workspace::SetAspectMarker (const OpenGl_AspectMarker* theAspect)
+void OpenGl_Workspace::SetAspectMarker (const Handle(OpenGl_AspectMarker)& theAspect)
 {
-  const OpenGl_AspectMarker* aPrevAspectMarker = myAspectMarkerSet;
   myAspectMarkerSet = theAspect;
-  return aPrevAspectMarker;
 }
 
 // =======================================================================
 // function : SetAspectText
 // purpose  :
 // =======================================================================
-const OpenGl_AspectText * OpenGl_Workspace::SetAspectText (const OpenGl_AspectText* theAspect)
+void OpenGl_Workspace::SetAspectText (const Handle(OpenGl_AspectText)& theAspect)
 {
-  const OpenGl_AspectText* aPrevAspectText = myAspectTextSet;
   myAspectTextSet = theAspect;
-  return aPrevAspectText;
 }
 
 // =======================================================================
 // function : ApplyAspectFace
 // purpose  :
 // =======================================================================
-const OpenGl_AspectFace* OpenGl_Workspace::ApplyAspectFace()
+const Handle(OpenGl_AspectFace)& OpenGl_Workspace::ApplyAspectFace()
 {
   if (myView->BackfacingModel() == Graphic3d_TOBM_AUTOMATIC)
   {
@@ -366,12 +367,12 @@ const OpenGl_AspectFace* OpenGl_Workspace::ApplyAspectFace()
   if (myAspectFaceSet->Aspect()->InteriorStyle() == Aspect_IS_HIDDENLINE)
   {
     // copy all values including line edge aspect
-    *myAspectFaceHl.Aspect() = *myAspectFaceSet->Aspect();
-    myAspectFaceHl.SetAspectEdge (myAspectFaceSet->AspectEdge());
-    myAspectFaceHl.Aspect()->SetShadingModel (Graphic3d_TOSM_UNLIT);
-    myAspectFaceHl.Aspect()->SetInteriorColor (myView->BackgroundColor().GetRGB());
-    myAspectFaceHl.SetNoLighting();
-    myAspectFaceSet = &myAspectFaceHl;
+    myAspectFaceHl->SetAspect (myAspectFaceSet->Aspect());
+    myAspectFaceHl->SetAspectEdge (myAspectFaceSet->AspectEdge());
+    myAspectFaceHl->Aspect()->SetShadingModel (Graphic3d_TOSM_UNLIT);
+    myAspectFaceHl->Aspect()->SetInteriorColor (myView->BackgroundColor().GetRGB());
+    myAspectFaceHl->SetNoLighting();
+    myAspectFaceSet = myAspectFaceHl;
   }
   else
   {
@@ -395,7 +396,7 @@ const OpenGl_AspectFace* OpenGl_Workspace::ApplyAspectFace()
 // function : ApplyAspectMarker
 // purpose  :
 // =======================================================================
-const OpenGl_AspectMarker* OpenGl_Workspace::ApplyAspectMarker()
+const Handle(OpenGl_AspectMarker)& OpenGl_Workspace::ApplyAspectMarker()
 {
   if (myAspectMarkerSet->Aspect() != myAspectMarkerApplied)
   {
@@ -495,7 +496,7 @@ Standard_Boolean OpenGl_Workspace::BufferDump (const Handle(OpenGl_FrameBuffer)&
 // function : ShouldRender
 // purpose  :
 // =======================================================================
-bool OpenGl_Workspace::ShouldRender (const OpenGl_Element* theElement)
+bool OpenGl_Workspace::ShouldRender (const Handle(OpenGl_Element)& theElement)
 {
   // render only non-raytracable elements when RayTracing is enabled
   if ((myRenderFilter & OpenGl_RenderFilter_NonRaytraceableOnly) != 0)
@@ -531,7 +532,7 @@ bool OpenGl_Workspace::ShouldRender (const OpenGl_Element* theElement)
   {
     if (!theElement->IsFillDrawMode())
     {
-      if (dynamic_cast<const OpenGl_AspectFace*> (theElement) == NULL)
+      if (Handle(OpenGl_AspectFace)::DownCast(theElement).IsNull())
       {
         return false;
       }
index fad9e8adf638b6f11435a2bc17d0cc482ea3159c..fd40cebd8aa3888944a8fe5b425e807782b3f2bf 100644 (file)
@@ -163,44 +163,44 @@ public:
   }
 
   //! Currently set line aspect (can differ from applied).
-  const OpenGl_AspectLine*   AspectLine()   const { return myAspectLineSet; }
+  const Handle(OpenGl_AspectLine)& AspectLine() const { return myAspectLineSet; }
 
   //! Currently set face aspect (can differ from applied).
-  const OpenGl_AspectFace*   AspectFace()   const { return myAspectFaceSet; }
+  const Handle(OpenGl_AspectFace)& AspectFace() const { return myAspectFaceSet; }
 
   //! Currently set marker aspect (can differ from applied).
-  const OpenGl_AspectMarker* AspectMarker() const { return myAspectMarkerSet; }
+  const Handle(OpenGl_AspectMarker)& AspectMarker() const { return myAspectMarkerSet; }
 
   //! Currently set text aspect (can differ from applied).
-  const OpenGl_AspectText*   AspectText()   const { return myAspectTextSet; }
+  const Handle(OpenGl_AspectText)& AspectText() const { return myAspectTextSet; }
 
   //! Assign new line aspect (will be applied within ApplyAspectLine()).
-  Standard_EXPORT const OpenGl_AspectLine*   SetAspectLine   (const OpenGl_AspectLine*   theAspect);
+  Standard_EXPORT void SetAspectLine (const Handle(OpenGl_AspectLine)& theAspect);
 
   //! Assign new face aspect (will be applied within ApplyAspectFace()).
-  Standard_EXPORT const OpenGl_AspectFace*   SetAspectFace   (const OpenGl_AspectFace*   theAspect);
+  Standard_EXPORT void SetAspectFace (const Handle(OpenGl_AspectFace)& theAspect);
 
   //! Assign new marker aspect (will be applied within ApplyAspectMarker()).
-  Standard_EXPORT const OpenGl_AspectMarker* SetAspectMarker (const OpenGl_AspectMarker* theAspect);
+  Standard_EXPORT void SetAspectMarker (const Handle(OpenGl_AspectMarker)& theAspect);
 
   //! Assign new text aspect (will be applied within ApplyAspectText()).
-  Standard_EXPORT const OpenGl_AspectText*   SetAspectText   (const OpenGl_AspectText*   theAspect);
+  Standard_EXPORT void SetAspectText (const Handle(OpenGl_AspectText)& theAspect);
 
   //! Apply line aspect.
   //! @return aspect set by SetAspectLine()
-  const OpenGl_AspectLine* ApplyAspectLine() { return myAspectLineSet; }
+  const Handle(OpenGl_AspectLine)& ApplyAspectLine() { return myAspectLineSet; }
 
   //! Apply face aspect.
   //! @return aspect set by SetAspectFace()
-  Standard_EXPORT const OpenGl_AspectFace*   ApplyAspectFace();
+  Standard_EXPORT const Handle(OpenGl_AspectFace)& ApplyAspectFace();
 
   //! Apply marker aspect.
   //! @return aspect set by SetAspectMarker()
-  Standard_EXPORT const OpenGl_AspectMarker* ApplyAspectMarker();
+  Standard_EXPORT const Handle(OpenGl_AspectMarker)& ApplyAspectMarker();
 
   //! Apply text aspect.
   //! @return aspect set by SetAspectText()
-  const OpenGl_AspectText* ApplyAspectText() { return myAspectTextSet; }
+  const Handle(OpenGl_AspectText)& ApplyAspectText() { return myAspectTextSet; }
 
   //! Clear the applied aspect state to default values.
   void ResetAppliedAspect();
@@ -216,7 +216,7 @@ public:
   //! Checks whether the element can be rendered or not.
   //! @param theElement [in] the element to check
   //! @return True if element can be rendered
-  bool ShouldRender (const OpenGl_Element* theElement);
+  bool ShouldRender (const Handle(OpenGl_Element)& theElement);
 
   //! Return the number of skipped transparent elements within active OpenGl_RenderFilter_OpaqueOnly filter.
   //! @sa OpenGl_LayerList::Render()
@@ -233,13 +233,13 @@ public:
   inline const OpenGl_Matrix* ModelMatrix() const { return StructureMatrix_applied; }
 
   //! Returns face aspect for textured font rendering.
-  const OpenGl_AspectFace& FontFaceAspect() const { return myFontFaceAspect; }
+  const Handle(OpenGl_AspectFace)& FontFaceAspect() const { return myFontFaceAspect; }
 
   //! Returns face aspect for none culling mode.
-  const OpenGl_AspectFace& NoneCulling() const { return myNoneCulling; }
+  const Handle(OpenGl_AspectFace)& NoneCulling() const { return myNoneCulling; }
 
   //! Returns face aspect for front face culling mode.
-  const OpenGl_AspectFace& FrontCulling() const { return myFrontCulling; }
+  const Handle(OpenGl_AspectFace)& FrontCulling() const { return myFrontCulling; }
 
   //! Sets a new environment texture.
   void SetEnvironmentTexture (const Handle(OpenGl_TextureSet)& theTexture) { myEnvironmentTexture = theTexture; }
@@ -254,26 +254,26 @@ protected: //! @name protected fields
   Handle(OpenGl_Context)           myGlContext;
   Standard_Boolean                 myUseZBuffer;
   Standard_Boolean                 myUseDepthWrite;
-  OpenGl_AspectFace                myNoneCulling;
-  OpenGl_AspectFace                myFrontCulling;
-  OpenGl_AspectFace                myFontFaceAspect;
+  Handle(OpenGl_AspectFace)        myNoneCulling;
+  Handle(OpenGl_AspectFace)        myFrontCulling;
+  Handle(OpenGl_AspectFace)        myFontFaceAspect;
 
 protected: //! @name fields related to status
 
   Standard_Integer myNbSkippedTranspElems; //!< counter of skipped transparent elements for OpenGl_LayerList two rendering passes method
   Standard_Integer myRenderFilter;         //!< active filter for skipping rendering of elements by some criteria (multiple render passes)
 
-  OpenGl_AspectLine   myDefaultAspectLine;
-  OpenGl_AspectFace   myDefaultAspectFace;
-  OpenGl_AspectMarker myDefaultAspectMarker;
-  OpenGl_AspectText   myDefaultAspectText;
+  Handle(OpenGl_AspectLine)   myDefaultAspectLine;
+  Handle(OpenGl_AspectFace)   myDefaultAspectFace;
+  Handle(OpenGl_AspectMarker) myDefaultAspectMarker;
+  Handle(OpenGl_AspectText)   myDefaultAspectText;
 
-  const OpenGl_AspectLine*   myAspectLineSet;
-  const OpenGl_AspectFace*   myAspectFaceSet;
+  Handle(OpenGl_AspectLine)   myAspectLineSet;
+  Handle(OpenGl_AspectFace)   myAspectFaceSet;
   Handle(Graphic3d_AspectFillArea3d) myAspectFaceApplied;
-  const OpenGl_AspectMarker* myAspectMarkerSet;
+  Handle(OpenGl_AspectMarker) myAspectMarkerSet;
   Handle(Graphic3d_AspectMarker3d) myAspectMarkerApplied;
-  const OpenGl_AspectText*   myAspectTextSet;
+  Handle(OpenGl_AspectText)   myAspectTextSet;
   Handle(Graphic3d_PresentationAttributes) myAspectFaceAppliedWithHL;
 
   const OpenGl_Matrix* ViewMatrix_applied;
@@ -284,7 +284,7 @@ protected: //! @name fields related to status
 
   OpenGl_Matrix myModelViewMatrix; //!< Model matrix with applied structure transformations
 
-  OpenGl_AspectFace myAspectFaceHl; //!< Hiddenline aspect
+  Handle(OpenGl_AspectFace) myAspectFaceHl; //!< Hiddenline aspect
 
   Handle(OpenGl_TextureSet) myEnvironmentTexture;
 
index 3a614a3e7cb7bccc1d612e449cfdbbd87fa092f4..39e7ab2f3ae1b69b17ac82dc0bd30869c887bb10 100644 (file)
@@ -158,9 +158,9 @@ void VUserDrawObj::Render(const Handle(OpenGl_Workspace)& theWorkspace) const
   const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
 
   // To test linking against OpenGl_Workspace and all aspect classes
-  const OpenGl_AspectMarker* aMA = theWorkspace->AspectMarker();
+  const Handle(OpenGl_AspectMarker)& aMA = theWorkspace->AspectMarker();
   aMA->Aspect()->Type();
-  const OpenGl_AspectText* aTA = theWorkspace->AspectText();
+  const Handle(OpenGl_AspectText)& aTA = theWorkspace->AspectText();
   aTA->Aspect()->Font();
   OpenGl_Vec4 aColor = theWorkspace->LineColor();
 
index 134d387452712f90841ed959329559b6cee8c35d..b841b224ba7e730a44d6c35a65821e59c44905dd 100644 (file)
@@ -75,7 +75,7 @@ int VInspector_ItemGraphic3dGroup::initRowCount() const
     return 0;
 
   int aNbElements = 0;
-  for (const OpenGl_ElementNode* aNodeIter = anOpenGlGroup->FirstNode(); aNodeIter != NULL; aNodeIter = aNodeIter->next)
+  for (OpenGl_ElementNodes::Iterator anElemIter (anOpenGlGroup->GetElements()); anElemIter.More(); anElemIter.Next())
   {
     aNbElements++;
   }
@@ -99,10 +99,6 @@ QVariant VInspector_ItemGraphic3dGroup::initValue (const int theItemRole) const
   {
     case 0: return theItemRole == Qt::DisplayRole ? aGroup->DynamicType()->Name()
                                                   : STANDARD_TYPE (Graphic3d_Group)->Name();
-    case 1:
-      return rowCount();
-    case 2:
-      return ViewControl_Tools::GetPointerInfo (aGroup, true).ToCString();
     default:
       break;
   }
@@ -113,21 +109,21 @@ QVariant VInspector_ItemGraphic3dGroup::initValue (const int theItemRole) const
 // function : GetElementNode
 // purpose :
 // =======================================================================
-OpenGl_Element* VInspector_ItemGraphic3dGroup::GetElementNode (const int theRowId) const
+Handle(OpenGl_Element) VInspector_ItemGraphic3dGroup::GetElementNode (const int theRowId) const
 {
   int aCurrentIndex = 0;
 
   Handle(Graphic3d_Group) aGroup = GetGroup();
   Handle(OpenGl_Group) anOpenGlGroup = Handle(OpenGl_Group)::DownCast(aGroup);
   if (anOpenGlGroup.IsNull())
-    return 0;
-  for (const OpenGl_ElementNode* aNodeIter = anOpenGlGroup->FirstNode(); aNodeIter != NULL; aNodeIter = aNodeIter->next)
+    return NULL;
+  for (OpenGl_ElementNodes::Iterator anElemIter (anOpenGlGroup->GetElements()); anElemIter.More(); anElemIter.Next())
   {
     if (theRowId == aCurrentIndex)
-      return aNodeIter->elem;
+      return anElemIter.Value();
     aCurrentIndex++;
   }
-  return 0;
+  return NULL;
 }
 
 // =======================================================================
index 8b7097b1343ccaf7ec361925e4b766afbc4204f1..3ae98be214fe7b9a6cd4c56327979a1839811c74 100644 (file)
@@ -59,7 +59,7 @@ public:
   //! Returns element node or NULL
   //! \param theRowId row index
   //! \return element node
-  OpenGl_Element* GetElementNode(const int theRowId) const;
+  Standard_EXPORT Handle(OpenGl_Element) GetElementNode(const int theRowId) const;
 
   //! Returns number of table rows
   //! \return an integer value
index 9fca52a31eb9bc09698e2605c657c082b5e3b528..0ed0e648d40e8833180ad28fd74f73cb6cd099a0 100644 (file)
 #include <QStringList>
 #include <Standard_WarningsRestore.hxx>
 
-// =======================================================================
-// function : GetGroup
-// purpose :
-// =======================================================================
-OpenGl_Element* VInspector_ItemOpenGlElement::GetElement() const
-{
-  initItem();
-  return myElement;
-}
-
 // =======================================================================
 // function : Init
 // purpose :
@@ -61,7 +51,7 @@ void VInspector_ItemOpenGlElement::Init()
 void VInspector_ItemOpenGlElement::Reset()
 {
   VInspector_ItemBase::Reset();
-  myElement = 0;
+  myElement = NULL;
 }
 
 // =======================================================================
@@ -96,26 +86,17 @@ QVariant VInspector_ItemOpenGlElement::initValue (const int theItemRole) const
   if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
     return QVariant();
 
-  OpenGl_Element* anElement = GetElement();
-  if (anElement == 0)
+  Handle(OpenGl_Element) anElement = GetElement();
+  if (anElement.IsNull())
     return Column() == 0 ? "Empty element" : "";
 
   switch (Column())
   {
     case 0:
     {
-      if (theItemRole != Qt::ToolTipRole)
-        return "OpenGl_Element";
-
-      VInspector_ElementKind aKind = GetElementKind();
-      if (aKind == VInspector_ElementKind_PrimitiveArray) return "OpenGl_PrimitiveArray";
-      else if (aKind == VInspector_ElementKind_Text) return "OpenGl_Text";
-      else return "OpenGl_Element";
+      return theItemRole == Qt::ToolTipRole ? QVariant ("")
+                                            : QVariant (anElement->DynamicType()->Name());
     }
-    case 1:
-      return rowCount();
-    case 2:
-      return ViewControl_Tools::GetPointerInfo (anElement, true).ToCString();
     default:
       break;
   }
@@ -140,16 +121,15 @@ QVariant VInspector_ItemOpenGlElement::GetTableData (const int theRow, const int
   if (theRole != Qt::DisplayRole)
     return QVariant();
 
-  OpenGl_Element* anElement = GetElement();
-  if (anElement == 0)
+  Handle(OpenGl_Element) anElement = GetElement();
+  if (anElement.IsNull())
     return QVariant();
 
   bool isFirstColumn = theColumn == 0;
 
-  VInspector_ElementKind aKind = GetElementKind();
-  if (aKind == VInspector_ElementKind_PrimitiveArray)
+  if (!Handle(OpenGl_PrimitiveArray)::DownCast (anElement).IsNull())
   {
-    OpenGl_PrimitiveArray* aCElement = dynamic_cast<OpenGl_PrimitiveArray*>(anElement);
+    Handle(OpenGl_PrimitiveArray) aCElement = Handle(OpenGl_PrimitiveArray)::DownCast (anElement);
     switch (theRow)
     {
       case 0: return isFirstColumn ? QVariant ("IsInitialized") : QVariant (aCElement->IsInitialized());
@@ -163,18 +143,14 @@ QVariant VInspector_ItemOpenGlElement::GetTableData (const int theRow, const int
         : !aCElement->AttributesVbo().IsNull() ? QVariant (ViewControl_Tools::GetPointerInfo (aCElement->AttributesVbo()).ToCString()) : QVariant();
 
       case 6: return isFirstColumn ? QVariant ("Indices") : VInspector_Tools::ToVariant (aCElement->Indices());
-      case 7:
-      {
-        const Handle(Graphic3d_Buffer)& anAttributes = aCElement->Attributes();
-        return isFirstColumn ? QVariant ("Attributes") : VInspector_Tools::ToVariant (aCElement->Attributes());
-      }
+      case 7: return isFirstColumn ? QVariant ("Attributes") : VInspector_Tools::ToVariant (aCElement->Attributes());
       case 8: return isFirstColumn ? QVariant ("Bounds") : VInspector_Tools::ToVariant (aCElement->Bounds());
       default: return QVariant();
     }
   }
-  else if (aKind == VInspector_ElementKind_Text)
+  else if (!Handle(OpenGl_Text)::DownCast (anElement).IsNull())
   {
-    OpenGl_Text* aCmElement = dynamic_cast<OpenGl_Text*>(anElement);
+    Handle(OpenGl_Text) aCmElement = Handle(OpenGl_Text)::DownCast (anElement);
     switch (theRow)
     {
       case 0:
@@ -196,6 +172,8 @@ QVariant VInspector_ItemOpenGlElement::GetTableData (const int theRow, const int
 // =======================================================================
 TreeModel_ItemBasePtr VInspector_ItemOpenGlElement::createChild (int theRow, int theColumn)
 {
+  (void)theRow;
+  (void)theColumn;
   //if (theRow == 0)
   //  return VInspector_ItemFolderObject::CreateItem (currentItem(), theRow, theColumn);
   //else
@@ -203,21 +181,3 @@ TreeModel_ItemBasePtr VInspector_ItemOpenGlElement::createChild (int theRow, int
 
   return TreeModel_ItemBasePtr();
 }
-
-// =======================================================================
-// function : GetElementKind
-// purpose :
-// =======================================================================
-VInspector_ItemOpenGlElement::VInspector_ElementKind VInspector_ItemOpenGlElement::GetElementKind() const
-{
-  OpenGl_Element* anElement = GetElement();
-  if (anElement == 0)
-    return VInspector_ElementKind_Undefined;
-
-  if (dynamic_cast<OpenGl_PrimitiveArray*>(anElement))
-    return VInspector_ElementKind_PrimitiveArray;
-  else if (dynamic_cast<OpenGl_Text*>(anElement))
-    return VInspector_ElementKind_Text;
-
-  return VInspector_ElementKind_Undefined;
-}
index 3a333cc83359b59b6952870a6b6edd5e136be326..09476d2a1e6252112a9295eacd5ab8f95b9065f7 100644 (file)
@@ -19,8 +19,9 @@
 #include <Standard.hxx>
 #include <inspector/VInspector_ItemBase.hxx>
 
+#include <OpenGl_Element.hxx>
+
 class Graphic3d_Group;
-class OpenGl_Element;
 
 class VInspector_ItemOpenGlElement;
 typedef QExplicitlySharedDataPointer<VInspector_ItemOpenGlElement> VInspector_ItemOpenGlElementPtr;
@@ -41,9 +42,13 @@ public:
   //! Destructor
   virtual ~VInspector_ItemOpenGlElement() Standard_OVERRIDE {};
 
+  //! Returns data object of the item.
+  //! \return object
+  virtual Handle(Standard_Transient) GetObject() const { initItem(); return myElement; }
+
   //! Returns the current graphic3d group, init item if it was not initialized yet
   //! \return graphic group
-  Standard_EXPORT OpenGl_Element* GetElement() const;
+  Handle(OpenGl_Element) GetElement() const { return Handle(OpenGl_Element)::DownCast (GetObject());}
 
   //! Inits the item, fills internal containers
   Standard_EXPORT virtual void Init() Standard_OVERRIDE;
@@ -84,26 +89,16 @@ protected:
   virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
 
 private:
-  enum VInspector_ElementKind
-  {
-    VInspector_ElementKind_PrimitiveArray, //!< OpenGl_PrimitiveArray
-    VInspector_ElementKind_Text, //!< OpenGl_Text
-    VInspector_ElementKind_Undefined //!< another OpenGl_Element kind
-  };
-
-  //! Returns kind of the current element
-  //! \return kind
-  VInspector_ElementKind GetElementKind() const;
 
   //! Constructor
   //! param theParent a parent item
   //! \param theRow the item row positition in the parent item
   //! \param theColumn the item column positition in the parent item
   VInspector_ItemOpenGlElement(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
-    : VInspector_ItemBase(theParent, theRow, theColumn), myElement (0) {}
+    : VInspector_ItemBase(theParent, theRow, theColumn) {}
 
 private:
-  OpenGl_Element* myElement; //! current element
+  Handle(OpenGl_Element) myElement; //! current element
 };
 
 #endif
index cf7f6ad9b03cbfb827993685622c6071b4bc7406..3fbda71833b261058a496107e22d5add469388fc 100644 (file)
@@ -40,9 +40,10 @@ void VInspector_PrsOpenGlElement::Compute (const Handle(PrsMgr_PresentationManag
 
   Handle(OpenGl_Group) aGroup = Handle(OpenGl_Group)::DownCast (thePrs->NewGroup());
   aGroup->SetDestroyElements (Standard_False);
-  for (NCollection_List<OpenGl_Element*>::Iterator anElementsIt (myElements); anElementsIt.More(); anElementsIt.Next())
+
+  for (NCollection_List<Handle(OpenGl_Element)>::Iterator anElementsIt (myElements); anElementsIt.More(); anElementsIt.Next())
   {
-    OpenGl_Element* anElement = anElementsIt.Value();
+    Handle(OpenGl_Element) anElement = anElementsIt.Value();
     aGroup->AddElement (anElement);
   }
   // invalidate bounding box of the scene
index 3fdbdfb0282b7523de49664d41eb63de53deadc4..623e0c507789bba3a586a06e51e481d9a77355a5 100644 (file)
@@ -41,7 +41,7 @@ public:
 
   //! Fills internal container of elements
   //! \param theElements elements to be displayed
-  void Set (const NCollection_List<OpenGl_Element*>& theElements) { myElements = theElements; }
+  void Set (const NCollection_List<Handle(OpenGl_Element)>& theElements) { myElements = theElements; }
 
 private:
   //! Calculates the 3D view aPresentation and its updates.
@@ -62,7 +62,7 @@ private:
   DEFINE_STANDARD_RTTIEXT(VInspector_PrsOpenGlElement, AIS_InteractiveObject)
 
 private:
-  NCollection_List<OpenGl_Element*> myElements;
+  NCollection_List<Handle(OpenGl_Element)> myElements;
 };
 
 #endif
index 36de69592dfd5171f929958b45ed68036fb12dea..4814fa251fe3e29b24194709f6425502713714bc 100644 (file)
@@ -385,9 +385,9 @@ NCollection_List<TopoDS_Shape> VInspector_Window::GetSelectedShapes (const QMode
 // function : GetSelectedElements
 // purpose :
 // =======================================================================
-NCollection_List<OpenGl_Element*> VInspector_Window::GetSelectedElements (QItemSelectionModel* theModel)
+NCollection_List<Handle(OpenGl_Element)> VInspector_Window::GetSelectedElements (QItemSelectionModel* theModel)
 {
-  NCollection_List<OpenGl_Element*> anElements;
+  NCollection_List<Handle(OpenGl_Element)> anElements;
   QList<TreeModel_ItemBasePtr> anItems;
   QModelIndexList anIndices = theModel->selectedIndexes();
   for (QModelIndexList::const_iterator anIndicesIt = anIndices.begin(); anIndicesIt != anIndices.end(); anIndicesIt++)
@@ -410,7 +410,7 @@ NCollection_List<OpenGl_Element*> VInspector_Window::GetSelectedElements (QItemS
     if (!aVItem)
       continue;
 
-    OpenGl_Element* anElement = aVItem->GetElement();
+    Handle(OpenGl_Element) anElement = aVItem->GetElement();
     if (!anElement)
       continue;
 
@@ -681,11 +681,12 @@ void VInspector_Window::onTreeViewSelectionChanged (const QItemSelection&,
   if (myPropertyPanelWidget->toggleViewAction()->isChecked())
     updatePropertyPanelBySelection();
 
+  Handle(Graphic3d_TransformPers) aSelectedPersistent = GetSelectedTransformPers();
   NCollection_List<TopoDS_Shape> aSelectedShapes = GetSelectedShapes (myTreeView->selectionModel()->selectedIndexes());
-  updatePreviewPresentation(aSelectedShapes, GetSelectedTransformPers());
+  updatePreviewPresentation(aSelectedShapes, aSelectedPersistent);
 
-  NCollection_List<OpenGl_Element*> aSelectedElements = GetSelectedElements (myTreeView->selectionModel());
-  updatePreviewPresentation(aSelectedElements);
+  NCollection_List<Handle(OpenGl_Element)> aSelectedElements = GetSelectedElements (myTreeView->selectionModel());
+  updatePreviewPresentation(aSelectedElements, aSelectedPersistent);
 
   QApplication::restoreOverrideCursor();
 }
@@ -1022,7 +1023,8 @@ void VInspector_Window::updatePreviewPresentation (const NCollection_List<TopoDS
 // function : updatePreviewPresentation
 // purpose :
 // =======================================================================
-void VInspector_Window::updatePreviewPresentation (const NCollection_List<OpenGl_Element*>& theElements)
+void VInspector_Window::updatePreviewPresentation (const NCollection_List<Handle(OpenGl_Element)>& theElements,
+                                                   const Handle(Graphic3d_TransformPers)& thePersistent)
 {
   Handle(AIS_InteractiveContext) aContext;
   VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
@@ -1044,12 +1046,14 @@ void VInspector_Window::updatePreviewPresentation (const NCollection_List<OpenGl
 
     myOpenGlPreviewPresentation->SetColor (Quantity_Color (Quantity_NOC_BLUE1));
     myOpenGlPreviewPresentation->SetZLayer (Graphic3d_ZLayerId_Topmost);
+    myOpenGlPreviewPresentation->SetTransformPersistence(thePersistent);
     if (!aContext.IsNull())
       aContext->Display (myOpenGlPreviewPresentation, Standard_True);
   }
   else
   {
     myOpenGlPreviewPresentation->Set (theElements);
+    myOpenGlPreviewPresentation->SetTransformPersistence(thePersistent);
     if (!aContext.IsNull())
       aContext->Redisplay (myOpenGlPreviewPresentation, Standard_True);
   }
index 527785ff26e5341f2a900036ea423888fad0d45d..f82d2f9eb5e9c3b6bb56b3f92250767ead67a779 100644 (file)
@@ -110,7 +110,7 @@ public:
   //! Returns selected elements
   //! \param theModel selection model
   //! \return container of OpenGl elements
-  NCollection_List<OpenGl_Element*> GetSelectedElements (QItemSelectionModel* theModel);
+  NCollection_List<Handle(OpenGl_Element)> GetSelectedElements (QItemSelectionModel* theModel);
 
   //! Returns the first not zero transform persistent of selected elements
   Handle(Graphic3d_TransformPers) GetSelectedTransformPers();
@@ -212,7 +212,8 @@ private:
 
   //!< Updates presentation of preview for OpenGl elements.
   //!< \param theElements container of elements
-  void updatePreviewPresentation (const NCollection_List<OpenGl_Element*>& theElements);
+  void updatePreviewPresentation (const NCollection_List<Handle(OpenGl_Element)>& theElements,
+                                  const Handle(Graphic3d_TransformPers)& thePersistent);
 
 private: