Commit | Line | Data |
---|---|---|
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 | // |
973c2be1 | 7 | // This library is free software; you can redistribute it and / or modify it |
8 | // under the terms of the GNU Lesser General Public version 2.1 as published | |
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_Structure_Header |
17 | #define OpenGl_Structure_Header | |
18 | ||
19 | #include <NCollection_List.hxx> | |
20 | #include <InterfaceGraphic_Graphic3d.hxx> | |
21 | ||
22 | #include <OpenGl_AspectLine.hxx> | |
23 | #include <OpenGl_AspectFace.hxx> | |
24 | #include <OpenGl_AspectMarker.hxx> | |
25 | #include <OpenGl_AspectText.hxx> | |
26 | ||
27 | #include <OpenGl_Group.hxx> | |
28 | #include <OpenGl_Matrix.hxx> | |
e276548b | 29 | #include <OpenGl_NamedStatus.hxx> |
2166f0fa | 30 | |
51b10cd4 | 31 | #include <Graphic3d_SequenceOfHClipPlane.hxx> |
4269bd1b | 32 | |
bf75be98 | 33 | class OpenGl_Structure; |
34 | ||
35 | typedef NCollection_List<const OpenGl_Structure* > OpenGl_ListOfStructure; | |
2166f0fa SK |
36 | |
37 | class OpenGl_Structure : public OpenGl_Element | |
38 | { | |
e276548b | 39 | friend class OpenGl_Group; |
5e27df78 | 40 | |
41 | public: | |
42 | ||
43 | OpenGl_Structure(); | |
2166f0fa SK |
44 | |
45 | void SetTransformation (const float *AMatrix); | |
46 | ||
47 | void SetTransformPersistence (const CALL_DEF_TRANSFORM_PERSISTENCE &ATransPers); | |
48 | ||
fd4a6963 | 49 | void SetAspectLine (const CALL_DEF_CONTEXTLINE &theAspect); |
50 | void SetAspectFace (const CALL_DEF_CONTEXTFILLAREA& theAspect); | |
51 | void SetAspectMarker (const CALL_DEF_CONTEXTMARKER& theAspect); | |
52 | void SetAspectText (const CALL_DEF_CONTEXTTEXT &theAspect); | |
2166f0fa | 53 | |
5e27df78 | 54 | void SetHighlightBox (const Handle(OpenGl_Context)& theGlCtx, |
30f0ad28 | 55 | const CALL_DEF_BOUNDBOX& theBoundBox); |
5e27df78 | 56 | |
57 | void ClearHighlightBox (const Handle(OpenGl_Context)& theGlCtx); | |
58 | ||
59 | void SetHighlightColor (const Handle(OpenGl_Context)& theGlCtx, | |
60 | const Standard_ShortReal R, | |
61 | const Standard_ShortReal G, | |
62 | const Standard_ShortReal B); | |
2166f0fa | 63 | |
5e27df78 | 64 | void ClearHighlightColor (const Handle(OpenGl_Context)& theGlCtx); |
2166f0fa | 65 | |
e276548b | 66 | void SetNamedStatus (const Standard_Integer aStatus); |
67 | ||
68 | Standard_Boolean IsVisible() const { return !(myNamedStatus & OPENGL_NS_HIDE); } | |
2166f0fa | 69 | |
51b10cd4 | 70 | void SetClipPlanes (const Graphic3d_SequenceOfHClipPlane& thePlanes) { myClipPlanes = thePlanes; } |
4269bd1b | 71 | |
2166f0fa SK |
72 | void Connect (const OpenGl_Structure *astructure); |
73 | void Disconnect (const OpenGl_Structure *astructure); | |
74 | ||
5e27df78 | 75 | OpenGl_Group* AddGroup(); |
76 | void RemoveGroup (const Handle(OpenGl_Context)& theGlCtx, | |
77 | const OpenGl_Group* theGroup); | |
78 | void Clear (const Handle(OpenGl_Context)& theGlCtx); | |
2166f0fa | 79 | |
59f45b7c | 80 | //! Set z layer ID to display the structure in specified layer |
81 | void SetZLayer (const Standard_Integer theLayerIndex); | |
82 | ||
83 | //! Get z layer ID | |
84 | Standard_Integer GetZLayer () const; | |
2166f0fa | 85 | |
5e27df78 | 86 | virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const; |
87 | virtual void Release (const Handle(OpenGl_Context)& theGlCtx); | |
88 | ||
dd8a4ce9 | 89 | //! This method releases GL resources without actual elements destruction. |
e276548b | 90 | //! As result structure could be correctly destroyed layer without GL context |
dd8a4ce9 | 91 | //! (after last window was closed for example). |
92 | //! | |
93 | //! Notice however that reusage of this structure after calling this method is incorrect | |
94 | //! and will lead to broken visualization due to loosed data. | |
95 | void ReleaseGlResources (const Handle(OpenGl_Context)& theGlCtx); | |
96 | ||
e276548b | 97 | //! Returns list of OpenGL groups. |
98 | const OpenGl_ListOfGroup& Groups() const { return myGroups; } | |
99 | ||
100 | //! Returns list of connected OpenGL structures. | |
101 | const OpenGl_ListOfStructure& ConnectedStructures() const { return myConnected; } | |
102 | ||
103 | //! Returns OpenGL face aspect. | |
104 | const OpenGl_AspectFace* AspectFace() const { return myAspectFace; } | |
105 | ||
106 | //! Returns OpenGL transformation matrix. | |
107 | const OpenGl_Matrix* Transformation() const { return myTransformation; } | |
108 | ||
109 | //! Returns OpenGL persistent translation. | |
110 | const TEL_TRANSFORM_PERSISTENCE* PersistentTranslation() const { return myTransPers; } | |
111 | ||
112 | #ifdef HAVE_OPENCL | |
113 | ||
114 | //! Returns structure modification state (for ray-tracing). | |
115 | Standard_Size ModificationState() const { return myModificationState; } | |
116 | ||
117 | //! Resets structure modification state (for ray-tracing) | |
118 | void ResetModificationState() const { myModificationState = 0; } | |
119 | ||
120 | //! Is the structure ray-tracable (contains ray-tracable elements)? | |
121 | Standard_Boolean IsRaytracable() const { return myIsRaytracable; } | |
122 | ||
123 | #endif | |
124 | ||
5e27df78 | 125 | protected: |
126 | ||
127 | virtual ~OpenGl_Structure(); | |
128 | ||
e276548b | 129 | #ifdef HAVE_OPENCL |
130 | ||
131 | //! Registers ancestor connected structure (for updating ray-tracing state). | |
132 | void RegisterAncestorStructure (const OpenGl_Structure* theStructure) const; | |
133 | ||
134 | //! Unregisters ancestor connected structure (for updating ray-tracing state). | |
135 | void UnregisterAncestorStructure (const OpenGl_Structure* theStructure) const; | |
136 | ||
d5af8626 | 137 | //! Unregisters structure from ancestor structure (for updating ray-tracing state). |
138 | void UnregisterFromAncestorStructure() const; | |
139 | ||
e276548b | 140 | //! Updates modification state for structure and its parents. |
141 | void UpdateStateWithAncestorStructures() const; | |
142 | ||
143 | //! Updates ray-tracable status for structure and its parents. | |
144 | void UpdateRaytracableWithAncestorStructures() const; | |
145 | ||
146 | //! Sets ray-tracable status for structure and its parents. | |
147 | void SetRaytracableWithAncestorStructures() const; | |
148 | ||
149 | #endif | |
150 | ||
5e27df78 | 151 | protected: |
2166f0fa SK |
152 | |
153 | //Structure_LABBegin | |
5e27df78 | 154 | OpenGl_Matrix* myTransformation; |
155 | TEL_TRANSFORM_PERSISTENCE* myTransPers; | |
5e27df78 | 156 | OpenGl_AspectLine* myAspectLine; |
157 | OpenGl_AspectFace* myAspectFace; | |
158 | OpenGl_AspectMarker* myAspectMarker; | |
159 | OpenGl_AspectText* myAspectText; | |
2166f0fa | 160 | //Structure_LABHighlight |
5e27df78 | 161 | OpenGl_Group* myHighlightBox; |
162 | TEL_COLOUR* myHighlightColor; | |
2166f0fa SK |
163 | //Structure_LABVisibility |
164 | //Structure_LABPick | |
5e27df78 | 165 | int myNamedStatus; //Structure_LABNameSet |
166 | int myZLayer; | |
2166f0fa | 167 | |
51b10cd4 | 168 | OpenGl_ListOfStructure myConnected; |
169 | OpenGl_ListOfGroup myGroups; | |
170 | Graphic3d_SequenceOfHClipPlane myClipPlanes; | |
2166f0fa | 171 | |
e276548b | 172 | #ifdef HAVE_OPENCL |
173 | mutable OpenGl_ListOfStructure myAncestorStructures; | |
174 | mutable Standard_Boolean myIsRaytracable; | |
175 | mutable Standard_Size myModificationState; | |
176 | #endif | |
177 | ||
5e27df78 | 178 | public: |
2166f0fa | 179 | |
1c35b92f | 180 | DEFINE_STANDARD_ALLOC |
5e27df78 | 181 | |
2166f0fa SK |
182 | }; |
183 | ||
184 | #endif //OpenGl_Structure_Header |