X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=blobdiff_plain;f=src%2FOpenGl%2FOpenGl_Structure.hxx;h=efac3ace6d3efc70d8eed9e1e1d358c9a3dbf65d;hp=24ce51603d1c3e80ad3865683f6aa082b7bb4f19;hb=1be4179947116e54658924f0149d3f35743a899a;hpb=7d9e854bdc7a70e1c2fc02b759256966da61a5cc diff --git a/src/OpenGl/OpenGl_Structure.hxx b/src/OpenGl/OpenGl_Structure.hxx index 24ce51603d..efac3ace6d 100644 --- a/src/OpenGl/OpenGl_Structure.hxx +++ b/src/OpenGl/OpenGl_Structure.hxx @@ -24,14 +24,13 @@ #include #include +#include #include #include -#include #include #include #include -#include class OpenGl_Structure; class OpenGl_GraphicDriver; @@ -67,81 +66,47 @@ public: Standard_EXPORT OpenGl_Structure (const Handle(Graphic3d_StructureManager)& theManager); //! Setup structure graphic state - Standard_EXPORT virtual void UpdateNamedStatus(); + Standard_EXPORT virtual void OnVisibilityChanged() Standard_OVERRIDE; //! Clear graphic data - Standard_EXPORT virtual void Clear(); + Standard_EXPORT virtual void Clear() Standard_OVERRIDE; //! Connect other structure to this one - Standard_EXPORT virtual void Connect (Graphic3d_CStructure& theStructure); + Standard_EXPORT virtual void Connect (Graphic3d_CStructure& theStructure) Standard_OVERRIDE; //! Disconnect other structure to this one - Standard_EXPORT virtual void Disconnect (Graphic3d_CStructure& theStructure); - - //! Synchronize structure aspects - Standard_EXPORT virtual void UpdateAspects(); + Standard_EXPORT virtual void Disconnect (Graphic3d_CStructure& theStructure) Standard_OVERRIDE; //! Synchronize structure transformation - Standard_EXPORT virtual void UpdateTransformation(); + Standard_EXPORT virtual void SetTransformation (const Handle(Geom_Transformation)& theTrsf) Standard_OVERRIDE; - //! Highlight entire structure with color - Standard_EXPORT virtual void HighlightWithColor (const Graphic3d_Vec3& theColor, - const Standard_Boolean theToCreate); + //! Highlights structure according to the given style and updates corresponding class fields + //! (highlight status and style) + Standard_EXPORT virtual void GraphicHighlight (const Handle(Graphic3d_HighlightStyle)& theStyle, + const Handle(Graphic3d_Structure)& theStruct) Standard_OVERRIDE; - //! Highlight structure using boundary box - Standard_EXPORT virtual void HighlightWithBndBox (const Handle(Graphic3d_Structure)& theStruct, - const Standard_Boolean theToCreate); + //! Unighlights structure and updates corresponding class fields (highlight status and style) + Standard_EXPORT virtual void GraphicUnhighlight() Standard_OVERRIDE; //! Create shadow link to this structure - Standard_EXPORT virtual Handle(Graphic3d_CStructure) ShadowLink (const Handle(Graphic3d_StructureManager)& theManager) const; + Standard_EXPORT virtual Handle(Graphic3d_CStructure) ShadowLink (const Handle(Graphic3d_StructureManager)& theManager) const Standard_OVERRIDE; //! Create new group within this structure - Standard_EXPORT virtual Handle(Graphic3d_Group) NewGroup (const Handle(Graphic3d_Structure)& theStruct); + Standard_EXPORT virtual Handle(Graphic3d_Group) NewGroup (const Handle(Graphic3d_Structure)& theStruct) Standard_OVERRIDE; //! Remove group from this structure - Standard_EXPORT virtual void RemoveGroup (const Handle(Graphic3d_Group)& theGroup); + Standard_EXPORT virtual void RemoveGroup (const Handle(Graphic3d_Group)& theGroup) Standard_OVERRIDE; public: - //! @return graphic groups - virtual const Graphic3d_SequenceOfGroup& DrawGroups() const - { - return myGroups; - } - //! Access graphic driver OpenGl_GraphicDriver* GlDriver() const { return (OpenGl_GraphicDriver* )myGraphicDriver.operator->(); } - void SetTransformPersistence (const CALL_DEF_TRANSFORM_PERSISTENCE &ATransPers); - - 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); - - void clearHighlightBox (const Handle(OpenGl_Context)& theGlCtx); - - void setHighlightColor (const Handle(OpenGl_Context)& theGlCtx, - const Graphic3d_Vec3& theColor); - - void clearHighlightColor (const Handle(OpenGl_Context)& theGlCtx); - - Standard_Boolean IsVisible() const { return !(myNamedStatus & OPENGL_NS_HIDE); } - Standard_EXPORT void Clear (const Handle(OpenGl_Context)& theGlCtx); - //! Set z layer ID to display the structure in specified layer - Standard_EXPORT void SetZLayer (const Standard_Integer theLayerIndex); - - //! Get z layer ID - Standard_EXPORT Standard_Integer GetZLayer() const; - - //! Renders groups of structure without applying any attributes (i.e. transform, material etc). - virtual void RenderGeometry (const Handle(OpenGl_Workspace)& theWorkspace) const; - //! Renders the structure. virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const; @@ -167,13 +132,13 @@ public: Standard_Boolean IsCulled() const { return myIsCulled; } //! Checks if the structure should be included into BVH tree or not. - const Standard_Boolean IsAlwaysRendered() const + Standard_Boolean IsAlwaysRendered() const { return IsInfinite || IsForHighlight || IsMutable || Is2dText - || TransformPersistence.Flag != 0; + || (!myTrsfPers.IsNull() && myTrsfPers->IsTrihedronOr2d()); } //! This method releases GL resources without actual elements destruction. @@ -184,77 +149,53 @@ public: //! and will lead to broken visualization due to loosed data. Standard_EXPORT void ReleaseGlResources (const Handle(OpenGl_Context)& theGlCtx); - //! Returns list of connected OpenGL structures. - const OpenGl_ListOfStructure& ConnectedStructures() const { return myConnected; } - - //! 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; } + //! 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; protected: Standard_EXPORT virtual ~OpenGl_Structure(); - //! 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 ray-tracable status for structure and its parents. + void UpdateStateIfRaytracable (const Standard_Boolean toCheck = Standard_True) const; - //! Updates modification state for structure and its parents. - void UpdateStateWithAncestorStructures() 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; - //! Updates ray-tracable status for structure and its parents. - void UpdateRaytracableWithAncestorStructures() const; + //! Highlight structure using boundary box + Standard_EXPORT void highlightWithBndBox (const Handle(Graphic3d_Structure)& theStruct); - //! Sets ray-tracable status for structure and its parents. - void SetRaytracableWithAncestorStructures() const; + //! Invalidates highlight box and releases graphic resources it uses + Standard_EXPORT void clearHighlightBox (const Handle(OpenGl_Context)& theGlCtx); protected: - OpenGl_Matrix* myTransformation; - TEL_TRANSFORM_PERSISTENCE* myTransPers; - OpenGl_AspectLine* myAspectLine; - OpenGl_AspectFace* myAspectFace; - OpenGl_AspectMarker* myAspectMarker; - OpenGl_AspectText* myAspectText; - Handle(OpenGl_Group) myHighlightBox; - TEL_COLOUR* myHighlightColor; - - int myNamedStatus; - int myZLayer; - OpenGl_ListOfStructure myConnected; + OpenGl_Structure* myInstancedStructure; - mutable OpenGl_ListOfStructure myAncestorStructures; - mutable Standard_Boolean myIsRaytracable; - mutable Standard_Size myModificationState; + mutable Standard_Boolean myIsRaytracable; + mutable Standard_Size myModificationState; - mutable Standard_Boolean myIsCulled; //!< A status specifying is structure needs to be rendered after BVH tree traverse. + mutable Standard_Boolean myIsCulled; //!< A status specifying is structure needs to be rendered after BVH tree traverse. - Standard_Boolean myIsMirrored; //!< Used to tell OpenGl to interpret polygons in clockwise order. + Standard_Boolean myIsMirrored; //!< Used to tell OpenGl to interpret polygons in clockwise order. public: - DEFINE_STANDARD_RTTI(OpenGl_Structure) // Type definition + DEFINE_STANDARD_RTTIEXT(OpenGl_Structure,Graphic3d_CStructure) // Type definition };