0024752: Visualization - inherit OpenGl_Group from Graphic3d_Group
[occt.git] / src / OpenGl / OpenGl_Group.hxx
index de1d00c..bc942c4 100644 (file)
 #ifndef _OpenGl_Group_Header
 #define _OpenGl_Group_Header
 
-#include <NCollection_List.hxx>
 #include <InterfaceGraphic_Graphic3d.hxx>
+#include <Graphic3d_Group.hxx>
+#include <Graphic3d_Structure.hxx>
 
-#include <OpenGl_Element.hxx>
-
+#include <NCollection_List.hxx>
 #include <OpenGl_AspectLine.hxx>
 #include <OpenGl_AspectFace.hxx>
 #include <OpenGl_AspectMarker.hxx>
 #include <OpenGl_AspectText.hxx>
+#include <OpenGl_Element.hxx>
 
 class OpenGl_Group;
 class OpenGl_Structure;
 
-typedef NCollection_List<const OpenGl_Group* > OpenGl_ListOfGroup;
-
 struct OpenGl_ElementNode
 {
   OpenGl_Element*     elem;
@@ -38,25 +37,63 @@ struct OpenGl_ElementNode
   DEFINE_STANDARD_ALLOC
 };
 
-class OpenGl_Group : public OpenGl_Element
+//! Implementation of low-level graphic group.
+class OpenGl_Group : public Graphic3d_Group
 {
 public:
 
-#ifndef HAVE_OPENCL
-  OpenGl_Group();
-#else
-  OpenGl_Group (const OpenGl_Structure* theAncestorStructure);
-#endif
+  //! Create empty group.
+  //! Will throw exception if not created by OpenGl_Structure.
+  Standard_EXPORT OpenGl_Group (const Handle(Graphic3d_Structure)& theStruct);
+
+  Standard_EXPORT virtual void Clear (const Standard_Boolean theToUpdateStructureMgr);
+
+  //! Update line aspect
+  Standard_EXPORT virtual void UpdateAspectLine   (const Standard_Boolean theIsGlobal);
+
+  //! Update fill aspect
+  Standard_EXPORT virtual void UpdateAspectFace   (const Standard_Boolean theIsGlobal);
+
+  //! Update marker aspect
+  Standard_EXPORT virtual void UpdateAspectMarker (const Standard_Boolean theIsGlobal);
+
+  //! Update text aspect
+  Standard_EXPORT virtual void UpdateAspectText   (const Standard_Boolean theIsGlobal);
 
-  void SetAspectLine   (const CALL_DEF_CONTEXTLINE&     theAspect, const Standard_Boolean IsGlobal = Standard_True);
-  void SetAspectFace   (const CALL_DEF_CONTEXTFILLAREA& theAspect, const Standard_Boolean IsGlobal = Standard_True);
-  void SetAspectMarker (const CALL_DEF_CONTEXTMARKER&   theAspect, const Standard_Boolean IsGlobal = Standard_True);
-  void SetAspectText   (const CALL_DEF_CONTEXTTEXT&     theAspect, const Standard_Boolean IsGlobal = Standard_True);
+  //! Add primitive array element
+  Standard_EXPORT virtual void AddPrimitiveArray (const Handle(Graphic3d_ArrayOfPrimitives)& thePrim,
+                                                  const Standard_Boolean                     theToEvalMinMax);
 
-  void AddElement (OpenGl_Element* theElem);
+  //! Add text element
+  Standard_EXPORT virtual void Text (const Standard_CString                  theTextUtf,
+                                     const Graphic3d_Vertex&                 thePoint,
+                                     const Standard_Real                     theHeight,
+                                     const Quantity_PlaneAngle               theAngle,
+                                     const Graphic3d_TextPath                theTp,
+                                     const Graphic3d_HorizontalTextAlignment theHta,
+                                     const Graphic3d_VerticalTextAlignment   theVta,
+                                     const Standard_Boolean                  theToEvalMinMax);
 
-  virtual void Render  (const Handle(OpenGl_Workspace)& theWorkspace) const;
-  virtual void Release (const Handle(OpenGl_Context)&   theGlCtx);
+  //! Add UserDraw element using obsolete API
+  Standard_EXPORT virtual void UserDraw (const Standard_Address theObject,
+                                         const Standard_Boolean theToEvalMinMax,
+                                         const Standard_Boolean theContainsFacet);
+
+  //! Add flipping element
+  Standard_EXPORT virtual void SetFlippingOptions (const Standard_Boolean theIsEnabled,
+                                                   const gp_Ax2&          theRefPlane);
+
+  //! Add stencil test element
+  Standard_EXPORT virtual void SetStencilTestOptions (const Standard_Boolean theIsEnabled);
+
+public:
+
+  OpenGl_Structure* GlStruct() const { return (OpenGl_Structure* )(myStructure->CStructure().operator->()); }
+
+  Standard_EXPORT void AddElement (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; }
@@ -64,19 +101,18 @@ public:
   //! Returns OpenGL face aspect.
   const OpenGl_AspectFace* AspectFace() const { return myAspectFace; }
 
-#ifdef HAVE_OPENCL
-
   //! Returns modification state for ray-tracing.
   Standard_Size ModificationState() const { return myModificationState; }
 
   //! Is the group ray-tracable (contains ray-tracable elements)?
   Standard_Boolean IsRaytracable() const { return myIsRaytracable; }
 
-#endif
+  //! Accessor to line aspect (to be removed)
+  CALL_DEF_CONTEXTLINE& ChangeContextLine() { return ContextLine; }
 
 protected:
 
-  virtual ~OpenGl_Group();
+  Standard_EXPORT virtual ~OpenGl_Group();
 
 protected:
 
@@ -88,16 +124,15 @@ protected:
   OpenGl_ElementNode*    myFirst;
   OpenGl_ElementNode*    myLast;
 
-#ifdef HAVE_OPENCL
-  const OpenGl_Structure*  myAncestorStructure;
-  Standard_Boolean         myIsRaytracable;
-  Standard_Size            myModificationState;
-#endif
+  Standard_Boolean       myIsRaytracable;
+  Standard_Size          myModificationState;
 
 public:
 
-  DEFINE_STANDARD_ALLOC
+  DEFINE_STANDARD_RTTI(OpenGl_Group) // Type definition
 
 };
 
-#endif //_OpenGl_Group_Header
+DEFINE_STANDARD_HANDLE(OpenGl_Group, Graphic3d_Group)
+
+#endif // _OpenGl_Group_Header