//
// This file is part of Open CASCADE Technology software library.
//
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
#ifndef OpenGl_Structure_Header
#define OpenGl_Structure_Header
-#include <NCollection_List.hxx>
-#include <InterfaceGraphic_Graphic3d.hxx>
+#include <Graphic3d_CStructure.hxx>
+#include <Graphic3d_SequenceOfHClipPlane.hxx>
-#include <OpenGl_AspectLine.hxx>
-#include <OpenGl_AspectFace.hxx>
-#include <OpenGl_AspectMarker.hxx>
-#include <OpenGl_AspectText.hxx>
+#include <OpenGl_Aspects.hxx>
+#include <OpenGl_GraphicDriver.hxx>
#include <OpenGl_Group.hxx>
#include <OpenGl_Matrix.hxx>
-#include <OpenGl_NamedStatus.hxx>
+#include <OpenGl_Vec.hxx>
+#include <OpenGl_Workspace.hxx>
-#include <Graphic3d_SequenceOfHClipPlane.hxx>
+#include <NCollection_List.hxx>
-class OpenGl_Structure;
+class OpenGl_GraphicDriver;
+DEFINE_STANDARD_HANDLE(OpenGl_Structure, Graphic3d_CStructure)
typedef NCollection_List<const OpenGl_Structure* > OpenGl_ListOfStructure;
-class OpenGl_Structure : public OpenGl_Element
+//! Implementation of low-level graphic structure.
+class OpenGl_Structure : public Graphic3d_CStructure
{
friend class OpenGl_Group;
+ DEFINE_STANDARD_RTTIEXT(OpenGl_Structure, Graphic3d_CStructure)
+public:
+
+ //! Auxiliary wrapper to iterate OpenGl_Structure sequence.
+ typedef SubclassStructIterator<OpenGl_Structure> StructIterator;
+
+ //! Auxiliary wrapper to iterate OpenGl_Group sequence.
+ typedef SubclassGroupIterator<OpenGl_Group> GroupIterator;
public:
- OpenGl_Structure();
+ //! Create empty structure
+ Standard_EXPORT OpenGl_Structure (const Handle(Graphic3d_StructureManager)& theManager);
- void SetTransformation (const float *AMatrix);
+ //! Setup structure graphic state
+ Standard_EXPORT virtual void OnVisibilityChanged() Standard_OVERRIDE;
- void SetTransformPersistence (const CALL_DEF_TRANSFORM_PERSISTENCE &ATransPers);
+ //! Clear graphic data
+ Standard_EXPORT virtual void Clear() Standard_OVERRIDE;
- void SetAspectLine (const CALL_DEF_CONTEXTLINE &theAspect);
- void SetAspectFace (const CALL_DEF_CONTEXTFILLAREA& theAspect);
- void SetAspectMarker (const CALL_DEF_CONTEXTMARKER& theAspect);
- void SetAspectText (const CALL_DEF_CONTEXTTEXT &theAspect);
+ //! Connect other structure to this one
+ Standard_EXPORT virtual void Connect (Graphic3d_CStructure& theStructure) Standard_OVERRIDE;
- void SetHighlightBox (const Handle(OpenGl_Context)& theGlCtx,
- const CALL_DEF_BOUNDBOX& theBoundBox);
+ //! Disconnect other structure to this one
+ Standard_EXPORT virtual void Disconnect (Graphic3d_CStructure& theStructure) Standard_OVERRIDE;
- void ClearHighlightBox (const Handle(OpenGl_Context)& theGlCtx);
+ //! Synchronize structure transformation
+ Standard_EXPORT virtual void SetTransformation (const Handle(Geom_Transformation)& theTrsf) Standard_OVERRIDE;
- void SetHighlightColor (const Handle(OpenGl_Context)& theGlCtx,
- const Standard_ShortReal R,
- const Standard_ShortReal G,
- const Standard_ShortReal B);
+ //! Set transformation persistence.
+ Standard_EXPORT virtual void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers) Standard_OVERRIDE;
- void ClearHighlightColor (const Handle(OpenGl_Context)& theGlCtx);
+ //! Set z layer ID to display the structure in specified layer
+ Standard_EXPORT virtual void SetZLayer(const Graphic3d_ZLayerId theLayerIndex) Standard_OVERRIDE;
- void SetNamedStatus (const Standard_Integer aStatus);
+ //! Highlights structure according to the given style and updates corresponding class fields
+ //! (highlight status and style)
+ Standard_EXPORT virtual void GraphicHighlight (const Handle(Graphic3d_PresentationAttributes)& theStyle) Standard_OVERRIDE;
- Standard_Boolean IsVisible() const { return !(myNamedStatus & OPENGL_NS_HIDE); }
+ //! Unighlights structure and updates corresponding class fields (highlight status and style)
+ Standard_EXPORT virtual void GraphicUnhighlight() Standard_OVERRIDE;
- void SetClipPlanes (const Graphic3d_SequenceOfHClipPlane& thePlanes) { myClipPlanes = thePlanes; }
+ //! Create shadow link to this structure
+ Standard_EXPORT virtual Handle(Graphic3d_CStructure) ShadowLink (const Handle(Graphic3d_StructureManager)& theManager) const Standard_OVERRIDE;
- void Connect (const OpenGl_Structure *astructure);
- void Disconnect (const OpenGl_Structure *astructure);
+ //! Create new group within this structure
+ Standard_EXPORT virtual Handle(Graphic3d_Group) NewGroup (const Handle(Graphic3d_Structure)& theStruct) Standard_OVERRIDE;
- OpenGl_Group* AddGroup();
- void RemoveGroup (const Handle(OpenGl_Context)& theGlCtx,
- const OpenGl_Group* theGroup);
- void Clear (const Handle(OpenGl_Context)& theGlCtx);
+ //! Remove group from this structure
+ Standard_EXPORT virtual void RemoveGroup (const Handle(Graphic3d_Group)& theGroup) Standard_OVERRIDE;
- //! Set z layer ID to display the structure in specified layer
- void SetZLayer (const Standard_Integer theLayerIndex);
+public:
+
+ //! Access graphic driver
+ OpenGl_GraphicDriver* GlDriver() const
+ {
+ return (OpenGl_GraphicDriver* )myGraphicDriver.operator->();
+ }
- //! Get z layer ID
- Standard_Integer GetZLayer () const;
+ Standard_EXPORT void Clear (const Handle(OpenGl_Context)& theGlCtx);
+ //! Renders the structure.
virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
- virtual void Release (const Handle(OpenGl_Context)& theGlCtx);
+
+ //! Releases structure resources.
+ virtual void Release (const Handle(OpenGl_Context)& theGlCtx);
//! This method releases GL resources without actual elements destruction.
//! As result structure could be correctly destroyed layer without GL context
//!
//! Notice however that reusage of this structure after calling this method is incorrect
//! and will lead to broken visualization due to loosed data.
- void ReleaseGlResources (const Handle(OpenGl_Context)& theGlCtx);
-
- //! Returns list of OpenGL groups.
- const OpenGl_ListOfGroup& Groups() const { return myGroups; }
-
- //! Returns list of connected OpenGL structures.
- const OpenGl_ListOfStructure& ConnectedStructures() const { return myConnected; }
+ Standard_EXPORT void ReleaseGlResources (const Handle(OpenGl_Context)& theGlCtx);
- //! Returns OpenGL face aspect.
- const OpenGl_AspectFace* AspectFace() const { return myAspectFace; }
-
- //! Returns OpenGL transformation matrix.
- const OpenGl_Matrix* Transformation() const { return myTransformation; }
-
- //! Returns OpenGL persistent translation.
- const TEL_TRANSFORM_PERSISTENCE* PersistentTranslation() const { return myTransPers; }
-
-#ifdef HAVE_OPENCL
+ //! Returns instanced OpenGL structure.
+ const OpenGl_Structure* InstancedStructure() const { return myInstancedStructure; }
//! Returns structure modification state (for ray-tracing).
Standard_Size ModificationState() const { return myModificationState; }
- //! Resets structure modification state (for ray-tracing)
+ //! Resets structure modification state (for ray-tracing).
void ResetModificationState() const { myModificationState = 0; }
//! Is the structure ray-tracable (contains ray-tracable elements)?
- Standard_Boolean IsRaytracable() const { return myIsRaytracable; }
+ Standard_Boolean IsRaytracable() const;
-#endif
+ //! Update render transformation matrix.
+ Standard_EXPORT virtual void updateLayerTransformation() Standard_OVERRIDE;
protected:
- virtual ~OpenGl_Structure();
-
-#ifdef HAVE_OPENCL
-
- //! Registers ancestor connected structure (for updating ray-tracing state).
- void RegisterAncestorStructure (const OpenGl_Structure* theStructure) const;
-
- //! Unregisters ancestor connected structure (for updating ray-tracing state).
- void UnregisterAncestorStructure (const OpenGl_Structure* theStructure) const;
-
- //! Unregisters structure from ancestor structure (for updating ray-tracing state).
- void UnregisterFromAncestorStructure() const;
-
- //! Updates modification state for structure and its parents.
- void UpdateStateWithAncestorStructures() const;
+ Standard_EXPORT virtual ~OpenGl_Structure();
//! Updates ray-tracable status for structure and its parents.
- void UpdateRaytracableWithAncestorStructures() const;
+ void UpdateStateIfRaytracable (const Standard_Boolean toCheck = Standard_True) const;
- //! Sets ray-tracable status for structure and its parents.
- void SetRaytracableWithAncestorStructures() const;
+ //! Renders groups of structure without applying any attributes (i.e. transform, material etc).
+ //! @param theWorkspace current workspace
+ //! @param theHasClosed flag will be set to TRUE if structure contains at least one group of closed primitives
+ Standard_EXPORT void renderGeometry (const Handle(OpenGl_Workspace)& theWorkspace,
+ bool& theHasClosed) const;
-#endif
+ //! Render the bounding box.
+ Standard_EXPORT void renderBoundingBox(const Handle(OpenGl_Workspace)& theWorkspace) const;
protected:
- //Structure_LABBegin
- OpenGl_Matrix* myTransformation;
- TEL_TRANSFORM_PERSISTENCE* myTransPers;
- OpenGl_AspectLine* myAspectLine;
- OpenGl_AspectFace* myAspectFace;
- OpenGl_AspectMarker* myAspectMarker;
- OpenGl_AspectText* myAspectText;
- //Structure_LABHighlight
- OpenGl_Group* myHighlightBox;
- TEL_COLOUR* myHighlightColor;
- //Structure_LABVisibility
- //Structure_LABPick
- int myNamedStatus; //Structure_LABNameSet
- int myZLayer;
-
- OpenGl_ListOfStructure myConnected;
- OpenGl_ListOfGroup myGroups;
- Graphic3d_SequenceOfHClipPlane myClipPlanes;
-
-#ifdef HAVE_OPENCL
- mutable OpenGl_ListOfStructure myAncestorStructures;
- mutable Standard_Boolean myIsRaytracable;
- mutable Standard_Size myModificationState;
-#endif
+ OpenGl_Structure* myInstancedStructure;
+ Graphic3d_Mat4 myRenderTrsf; //!< transformation, actually used for rendering (includes Local Origin shift)
-public:
+ mutable Standard_Boolean myIsRaytracable;
+ mutable Standard_Size myModificationState;
- DEFINE_STANDARD_ALLOC
+ Standard_Boolean myIsMirrored; //!< Used to tell OpenGl to interpret polygons in clockwise order.
};
-#endif //OpenGl_Structure_Header
+#endif // OpenGl_Structure_Header