0032308: Configuration - make Xlib dependency optional
[occt.git] / src / OpenGl / OpenGl_Group.hxx
CommitLineData
b311480e 1// Created on: 2011-08-01
2// Created by: Sergey ZERCHANINOV
973c2be1 3// Copyright (c) 2011-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
b311480e 15
2166f0fa
SK
16#ifndef _OpenGl_Group_Header
17#define _OpenGl_Group_Header
18
b64d84be 19#include <Graphic3d_Group.hxx>
20#include <Graphic3d_Structure.hxx>
2166f0fa 21
b64d84be 22#include <NCollection_List.hxx>
bf5f0ca2 23#include <OpenGl_Aspects.hxx>
b64d84be 24#include <OpenGl_Element.hxx>
2166f0fa 25
4269bd1b 26class OpenGl_Group;
e276548b 27class OpenGl_Structure;
4269bd1b 28
2166f0fa
SK
29struct OpenGl_ElementNode
30{
5322131b 31 OpenGl_Element* elem;
32 OpenGl_ElementNode* next;
1c35b92f 33 DEFINE_STANDARD_ALLOC
2166f0fa
SK
34};
35
b64d84be 36//! Implementation of low-level graphic group.
37class OpenGl_Group : public Graphic3d_Group
2166f0fa 38{
5e27df78 39public:
40
b64d84be 41 //! Create empty group.
42 //! Will throw exception if not created by OpenGl_Structure.
43 Standard_EXPORT OpenGl_Group (const Handle(Graphic3d_Structure)& theStruct);
44
79104795 45 Standard_EXPORT virtual void Clear (const Standard_Boolean theToUpdateStructureMgr) Standard_OVERRIDE;
b64d84be 46
b6472664 47 //! Return line aspect.
bf5f0ca2 48 virtual Handle(Graphic3d_Aspects) Aspects() const Standard_OVERRIDE
b6472664 49 {
bf5f0ca2 50 return myAspects != NULL
51 ? myAspects->Aspect()
52 : Handle(Graphic3d_Aspects)();
b6472664 53 }
54
4552cb85 55 //! Return TRUE if group contains primitives with transform persistence.
56 bool HasPersistence() const { return myStructure != NULL && !myStructure->TransformPersistence().IsNull(); }
57
bf5f0ca2 58 //! Update aspect.
59 Standard_EXPORT virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_Aspects)& theAspect) Standard_OVERRIDE;
b6472664 60
bf5f0ca2 61 //! Append aspect as an element.
62 Standard_EXPORT virtual void SetPrimitivesAspect (const Handle(Graphic3d_Aspects)& theAspect) Standard_OVERRIDE;
2166f0fa 63
eaac0866 64 //! Update presentation aspects after their modification.
65 Standard_EXPORT virtual void SynchronizeAspects() Standard_OVERRIDE;
66
bf5f0ca2 67 //! Replace aspects specified in the replacement map.
68 Standard_EXPORT virtual void ReplaceAspects (const Graphic3d_MapOfAspectsToAspects& theMap) Standard_OVERRIDE;
69
b64d84be 70 //! Add primitive array element
871fa103 71 Standard_EXPORT virtual void AddPrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theType,
72 const Handle(Graphic3d_IndexBuffer)& theIndices,
73 const Handle(Graphic3d_Buffer)& theAttribs,
74 const Handle(Graphic3d_BoundBuffer)& theBounds,
79104795 75 const Standard_Boolean theToEvalMinMax) Standard_OVERRIDE;
2166f0fa 76
8ed07085 77 //! Adds a text for display
78 Standard_EXPORT virtual void AddText (const Handle(Graphic3d_Text)& theTextParams,
79 const Standard_Boolean theToEvalMinMax) Standard_OVERRIDE;
b64d84be 80 //! Add flipping element
81 Standard_EXPORT virtual void SetFlippingOptions (const Standard_Boolean theIsEnabled,
79104795 82 const gp_Ax2& theRefPlane) Standard_OVERRIDE;
b64d84be 83
84 //! Add stencil test element
79104795 85 Standard_EXPORT virtual void SetStencilTestOptions (const Standard_Boolean theIsEnabled) Standard_OVERRIDE;
b64d84be 86
87public:
88
89 OpenGl_Structure* GlStruct() const { return (OpenGl_Structure* )(myStructure->CStructure().operator->()); }
90
91 Standard_EXPORT void AddElement (OpenGl_Element* theElem);
92
93 Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
94 Standard_EXPORT virtual void Release (const Handle(OpenGl_Context)& theGlCtx);
2166f0fa 95
e276548b 96 //! Returns first OpenGL element node of the group.
97 const OpenGl_ElementNode* FirstNode() const { return myFirst; }
98
bf5f0ca2 99 //! Returns OpenGL aspect.
100 const OpenGl_Aspects* GlAspects() const { return myAspects; }
e276548b 101
e276548b 102 //! Is the group ray-tracable (contains ray-tracable elements)?
103 Standard_Boolean IsRaytracable() const { return myIsRaytracable; }
104
0904aa63 105 //! Dumps the content of me into the stream
bc73b006 106 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
0904aa63 107
5e27df78 108protected:
2166f0fa 109
b64d84be 110 Standard_EXPORT virtual ~OpenGl_Group();
5e27df78 111
4552cb85 112private:
113
114 //! Render element if it passes the filtering procedure.
115 //! This method should be used for elements which can be used in scope of rendering algorithms.
116 //! E.g. elements of groups during recursive rendering.
117 //! If render filter is null, pure rendering is performed.
118 //! @param theWorkspace [in] the rendering workspace
119 //! @param theFilter [in] the rendering filter to check whether the element should be rendered or not
120 //! @return True if element passes the check and renders
121 Standard_EXPORT bool renderFiltered (const Handle(OpenGl_Workspace)& theWorkspace,
122 OpenGl_Element* theElement) const;
123
5e27df78 124protected:
2166f0fa 125
bf5f0ca2 126 OpenGl_Aspects* myAspects;
127 OpenGl_ElementNode* myFirst;
128 OpenGl_ElementNode* myLast;
129 Standard_Boolean myIsRaytracable;
5e27df78 130
131public:
2166f0fa 132
92efcf78 133 DEFINE_STANDARD_RTTIEXT(OpenGl_Group,Graphic3d_Group) // Type definition
5e27df78 134
2166f0fa
SK
135};
136
b64d84be 137DEFINE_STANDARD_HANDLE(OpenGl_Group, Graphic3d_Group)
138
139#endif // _OpenGl_Group_Header