0024288: Provide flipping text for AIS_Dimensions
[occt.git] / src / OpenGl / OpenGl_Structure.hxx
CommitLineData
b311480e 1// Created on: 2011-08-01
2// Created by: Sergey ZERCHANINOV
3// Copyright (c) 2011-2012 OPEN CASCADE SAS
4//
5// The content of this file is subject to the Open CASCADE Technology Public
6// License Version 6.5 (the "License"). You may not use the content of this file
7// except in compliance with the License. Please obtain a copy of the License
8// at http://www.opencascade.org and read it completely before using this file.
9//
10// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12//
13// The Original Code and all software distributed under the License is
14// distributed on an "AS IS" basis, without warranty of any kind, and the
15// Initial Developer hereby disclaims all such warranties, including without
16// limitation, any warranties of merchantability, fitness for a particular
17// purpose or non-infringement. Please see the License for the specific terms
18// and conditions governing the rights and limitations under the License.
19
2166f0fa
SK
20#ifndef OpenGl_Structure_Header
21#define OpenGl_Structure_Header
22
23#include <NCollection_List.hxx>
24#include <InterfaceGraphic_Graphic3d.hxx>
25
26#include <OpenGl_AspectLine.hxx>
27#include <OpenGl_AspectFace.hxx>
28#include <OpenGl_AspectMarker.hxx>
29#include <OpenGl_AspectText.hxx>
30
31#include <OpenGl_Group.hxx>
32#include <OpenGl_Matrix.hxx>
e276548b 33#include <OpenGl_NamedStatus.hxx>
2166f0fa 34
51b10cd4 35#include <Graphic3d_SequenceOfHClipPlane.hxx>
4269bd1b 36
bf75be98 37class OpenGl_Structure;
38
39typedef NCollection_List<const OpenGl_Structure* > OpenGl_ListOfStructure;
2166f0fa
SK
40
41class OpenGl_Structure : public OpenGl_Element
42{
e276548b 43 friend class OpenGl_Group;
5e27df78 44
45public:
46
47 OpenGl_Structure();
2166f0fa
SK
48
49 void SetTransformation (const float *AMatrix);
50
51 void SetTransformPersistence (const CALL_DEF_TRANSFORM_PERSISTENCE &ATransPers);
52
fd4a6963 53 void SetAspectLine (const CALL_DEF_CONTEXTLINE &theAspect);
54 void SetAspectFace (const CALL_DEF_CONTEXTFILLAREA& theAspect);
55 void SetAspectMarker (const CALL_DEF_CONTEXTMARKER& theAspect);
56 void SetAspectText (const CALL_DEF_CONTEXTTEXT &theAspect);
2166f0fa 57
5e27df78 58 void SetHighlightBox (const Handle(OpenGl_Context)& theGlCtx,
30f0ad28 59 const CALL_DEF_BOUNDBOX& theBoundBox);
5e27df78 60
61 void ClearHighlightBox (const Handle(OpenGl_Context)& theGlCtx);
62
63 void SetHighlightColor (const Handle(OpenGl_Context)& theGlCtx,
64 const Standard_ShortReal R,
65 const Standard_ShortReal G,
66 const Standard_ShortReal B);
2166f0fa 67
5e27df78 68 void ClearHighlightColor (const Handle(OpenGl_Context)& theGlCtx);
2166f0fa 69
e276548b 70 void SetNamedStatus (const Standard_Integer aStatus);
71
72 Standard_Boolean IsVisible() const { return !(myNamedStatus & OPENGL_NS_HIDE); }
2166f0fa 73
51b10cd4 74 void SetClipPlanes (const Graphic3d_SequenceOfHClipPlane& thePlanes) { myClipPlanes = thePlanes; }
4269bd1b 75
2166f0fa
SK
76 void Connect (const OpenGl_Structure *astructure);
77 void Disconnect (const OpenGl_Structure *astructure);
78
5e27df78 79 OpenGl_Group* AddGroup();
80 void RemoveGroup (const Handle(OpenGl_Context)& theGlCtx,
81 const OpenGl_Group* theGroup);
82 void Clear (const Handle(OpenGl_Context)& theGlCtx);
2166f0fa 83
59f45b7c 84 //! Set z layer ID to display the structure in specified layer
85 void SetZLayer (const Standard_Integer theLayerIndex);
86
87 //! Get z layer ID
88 Standard_Integer GetZLayer () const;
2166f0fa 89
5e27df78 90 virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
91 virtual void Release (const Handle(OpenGl_Context)& theGlCtx);
92
dd8a4ce9 93 //! This method releases GL resources without actual elements destruction.
e276548b 94 //! As result structure could be correctly destroyed layer without GL context
dd8a4ce9 95 //! (after last window was closed for example).
96 //!
97 //! Notice however that reusage of this structure after calling this method is incorrect
98 //! and will lead to broken visualization due to loosed data.
99 void ReleaseGlResources (const Handle(OpenGl_Context)& theGlCtx);
100
e276548b 101 //! Returns list of OpenGL groups.
102 const OpenGl_ListOfGroup& Groups() const { return myGroups; }
103
104 //! Returns list of connected OpenGL structures.
105 const OpenGl_ListOfStructure& ConnectedStructures() const { return myConnected; }
106
107 //! Returns OpenGL face aspect.
108 const OpenGl_AspectFace* AspectFace() const { return myAspectFace; }
109
110 //! Returns OpenGL transformation matrix.
111 const OpenGl_Matrix* Transformation() const { return myTransformation; }
112
113 //! Returns OpenGL persistent translation.
114 const TEL_TRANSFORM_PERSISTENCE* PersistentTranslation() const { return myTransPers; }
115
116#ifdef HAVE_OPENCL
117
118 //! Returns structure modification state (for ray-tracing).
119 Standard_Size ModificationState() const { return myModificationState; }
120
121 //! Resets structure modification state (for ray-tracing)
122 void ResetModificationState() const { myModificationState = 0; }
123
124 //! Is the structure ray-tracable (contains ray-tracable elements)?
125 Standard_Boolean IsRaytracable() const { return myIsRaytracable; }
126
127#endif
128
5e27df78 129protected:
130
131 virtual ~OpenGl_Structure();
132
e276548b 133#ifdef HAVE_OPENCL
134
135 //! Registers ancestor connected structure (for updating ray-tracing state).
136 void RegisterAncestorStructure (const OpenGl_Structure* theStructure) const;
137
138 //! Unregisters ancestor connected structure (for updating ray-tracing state).
139 void UnregisterAncestorStructure (const OpenGl_Structure* theStructure) const;
140
d5af8626 141 //! Unregisters structure from ancestor structure (for updating ray-tracing state).
142 void UnregisterFromAncestorStructure() const;
143
e276548b 144 //! Updates modification state for structure and its parents.
145 void UpdateStateWithAncestorStructures() const;
146
147 //! Updates ray-tracable status for structure and its parents.
148 void UpdateRaytracableWithAncestorStructures() const;
149
150 //! Sets ray-tracable status for structure and its parents.
151 void SetRaytracableWithAncestorStructures() const;
152
153#endif
154
5e27df78 155protected:
2166f0fa
SK
156
157 //Structure_LABBegin
5e27df78 158 OpenGl_Matrix* myTransformation;
159 TEL_TRANSFORM_PERSISTENCE* myTransPers;
5e27df78 160 OpenGl_AspectLine* myAspectLine;
161 OpenGl_AspectFace* myAspectFace;
162 OpenGl_AspectMarker* myAspectMarker;
163 OpenGl_AspectText* myAspectText;
2166f0fa 164 //Structure_LABHighlight
5e27df78 165 OpenGl_Group* myHighlightBox;
166 TEL_COLOUR* myHighlightColor;
2166f0fa
SK
167 //Structure_LABVisibility
168 //Structure_LABPick
5e27df78 169 int myNamedStatus; //Structure_LABNameSet
170 int myZLayer;
2166f0fa 171
51b10cd4 172 OpenGl_ListOfStructure myConnected;
173 OpenGl_ListOfGroup myGroups;
174 Graphic3d_SequenceOfHClipPlane myClipPlanes;
2166f0fa 175
e276548b 176#ifdef HAVE_OPENCL
177 mutable OpenGl_ListOfStructure myAncestorStructures;
178 mutable Standard_Boolean myIsRaytracable;
179 mutable Standard_Size myModificationState;
180#endif
181
5e27df78 182public:
2166f0fa 183
1c35b92f 184 DEFINE_STANDARD_ALLOC
5e27df78 185
2166f0fa
SK
186};
187
188#endif //OpenGl_Structure_Header