42cf5bc1 |
1 | // Created on: 1991-09-06 |
2 | // Created by: NW,JPB,CAL |
3 | // Copyright (c) 1991-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _Graphic3d_Group_HeaderFile |
18 | #define _Graphic3d_Group_HeaderFile |
19 | |
42cf5bc1 |
20 | #include <Graphic3d_BndBox4f.hxx> |
5b111128 |
21 | #include <Graphic3d_AspectFillArea3d.hxx> |
bf5f0ca2 |
22 | #include <Graphic3d_MapOfAspectsToAspects.hxx> |
42cf5bc1 |
23 | #include <Standard_CString.hxx> |
24 | #include <Graphic3d_Vertex.hxx> |
42cf5bc1 |
25 | #include <Graphic3d_TextPath.hxx> |
26 | #include <Graphic3d_HorizontalTextAlignment.hxx> |
27 | #include <Graphic3d_VerticalTextAlignment.hxx> |
28 | #include <Graphic3d_TypeOfPrimitiveArray.hxx> |
29 | #include <Graphic3d_IndexBuffer.hxx> |
30 | #include <Graphic3d_Buffer.hxx> |
31 | #include <Graphic3d_BoundBuffer.hxx> |
ce01ec26 |
32 | #include <gp_Ax2.hxx> |
33 | #include <TCollection_ExtendedString.hxx> |
5b111128 |
34 | |
35 | class Graphic3d_Structure; |
42cf5bc1 |
36 | class Graphic3d_ArrayOfPrimitives; |
8ed07085 |
37 | class Graphic3d_Text; |
4e993e4d |
38 | class Graphic3d_TransformPers; |
42cf5bc1 |
39 | |
42cf5bc1 |
40 | //! This class allows the definition of groups |
41 | //! of primitives inside of graphic objects (presentations). |
42 | //! A group contains the primitives and attributes |
43 | //! for which the range is limited to this group. |
44 | //! The primitives of a group can be globally suppressed. |
45 | //! |
46 | //! There are two main group usage models: |
47 | //! |
48 | //! 1) Non-modifiable, or unbounded, group ('black box'). |
49 | //! Developers can repeat a sequence of |
50 | //! SetPrimitivesAspect() with AddPrimitiveArray() methods arbitrary number of times |
51 | //! to define arbitrary number of primitive "blocks" each having individual apect values. |
52 | //! Any modification of such a group is forbidden, as aspects and primitives are mixed |
53 | //! in memory without any high-level logical structure, and any modification is very likely to result |
54 | //! in corruption of the group internal data. |
55 | //! It is necessary to recreate such a group as a whole when some attribute should be changed. |
56 | //! (for example, in terms of AIS it is necessary to re-Compute() the whole presentation each time). |
57 | //! 2) Bounded group. Developers should specify the necessary group aspects with help of |
58 | //! SetGroupPrimitivesAspect() and then add primitives to the group. |
59 | //! Such a group have simplified organization in memory (a single block of attributes |
60 | //! followed by a block of primitives) and therefore it can be modified, if it is necessary to |
61 | //! change parameters of some aspect that has already been set, using methods: |
62 | //! IsGroupPrimitivesAspectSet() to detect which aspect was set for primitives; |
63 | //! GroupPrimitivesAspect() to read current aspect values |
64 | //! and SetGroupPrimitivesAspect() to set new values. |
65 | //! |
66 | //! Developers are strongly recommended to take all the above into account when filling Graphic3d_Group |
67 | //! with aspects and primitives and choose the group usage model beforehand out of application needs. |
ce01ec26 |
68 | //! Note that some Graphic3d_Group class virtual methods contain only base implementation |
69 | //! that is extended by the descendant class in OpenGl package. |
25e59720 |
70 | class Graphic3d_Group : public Standard_Transient |
42cf5bc1 |
71 | { |
59ec40f8 |
72 | friend class Graphic3d_Structure; |
25e59720 |
73 | DEFINE_STANDARD_RTTIEXT(Graphic3d_Group,Standard_Transient) |
42cf5bc1 |
74 | |
75 | public: |
76 | |
54adc5e9 |
77 | //! Suppress all primitives and attributes of <me>. |
42cf5bc1 |
78 | //! To clear group without update in Graphic3d_StructureManager |
79 | //! pass Standard_False as <theUpdateStructureMgr>. This |
80 | //! used on context and viewer destruction, when the pointer |
81 | //! to structure manager in Graphic3d_Structure could be |
82 | //! already released (pointers are used here to avoid handle |
83 | //! cross-reference); |
84 | Standard_EXPORT virtual void Clear (const Standard_Boolean theUpdateStructureMgr = Standard_True); |
5b111128 |
85 | |
54adc5e9 |
86 | //! Suppress the group <me> in the structure. |
59ec40f8 |
87 | Standard_EXPORT virtual ~Graphic3d_Group(); |
5b111128 |
88 | |
54adc5e9 |
89 | //! Suppress the group <me> in the structure. |
42cf5bc1 |
90 | //! Warning: No more graphic operations in <me> after this call. |
91 | //! Modifies the current modelling transform persistence (pan, zoom or rotate) |
92 | //! Get the current modelling transform persistence (pan, zoom or rotate) |
93 | Standard_EXPORT void Remove(); |
5b111128 |
94 | |
59ec40f8 |
95 | public: |
96 | |
b6472664 |
97 | //! Return fill area aspect. |
bf5f0ca2 |
98 | virtual Handle(Graphic3d_Aspects) Aspects() const = 0; |
5b111128 |
99 | |
b6472664 |
100 | //! Modifies the context for all the face primitives of the group. |
bf5f0ca2 |
101 | virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_Aspects)& theAspect) = 0; |
5b111128 |
102 | |
bf5f0ca2 |
103 | //! Modifies the current context of the group to give another aspect for all the primitives created after this call in the group. |
104 | virtual void SetPrimitivesAspect (const Handle(Graphic3d_Aspects)& theAspect) = 0; |
5b111128 |
105 | |
eaac0866 |
106 | //! Update presentation aspects after their modification. |
107 | virtual void SynchronizeAspects() = 0; |
108 | |
bf5f0ca2 |
109 | //! Replace aspects specified in the replacement map. |
110 | virtual void ReplaceAspects (const Graphic3d_MapOfAspectsToAspects& theMap) = 0; |
59ec40f8 |
111 | |
8ed07085 |
112 | //! Adds a text for display |
113 | Standard_EXPORT virtual void AddText (const Handle(Graphic3d_Text)& theTextParams, |
114 | const Standard_Boolean theToEvalMinMax = Standard_True); |
115 | |
116 | //! Adds an array of primitives for display |
117 | Standard_EXPORT virtual void AddPrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theType, |
118 | const Handle(Graphic3d_IndexBuffer)& theIndices, |
119 | const Handle(Graphic3d_Buffer)& theAttribs, |
120 | const Handle(Graphic3d_BoundBuffer)& theBounds, |
121 | const Standard_Boolean theToEvalMinMax = Standard_True); |
122 | |
123 | //! Adds an array of primitives for display |
124 | Standard_EXPORT void AddPrimitiveArray (const Handle(Graphic3d_ArrayOfPrimitives)& thePrim, const Standard_Boolean theToEvalMinMax = Standard_True); |
125 | |
8ed07085 |
126 | public: |
127 | |
128 | //! sets the stencil test to theIsEnabled state; |
129 | Standard_EXPORT virtual void SetStencilTestOptions (const Standard_Boolean theIsEnabled) = 0; |
130 | |
131 | //! sets the flipping to theIsEnabled state. |
132 | Standard_EXPORT virtual void SetFlippingOptions (const Standard_Boolean theIsEnabled, const gp_Ax2& theRefPlane) = 0; |
133 | |
4e993e4d |
134 | //! Return transformation persistence. |
135 | const Handle(Graphic3d_TransformPers)& TransformPersistence() const { return myTrsfPers; } |
136 | |
137 | //! Set transformation persistence. |
138 | Standard_EXPORT virtual void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers); |
139 | |
8ed07085 |
140 | //! Returns Standard_True if the group <me> is deleted. |
141 | //! <me> is deleted after the call Remove (me) or the |
142 | //! associated structure is deleted. |
143 | Standard_EXPORT Standard_Boolean IsDeleted() const; |
144 | |
145 | //! Returns Standard_True if the group <me> is empty. |
146 | Standard_EXPORT Standard_Boolean IsEmpty() const; |
147 | |
148 | //! Returns the coordinates of the boundary box of the group. |
149 | Standard_EXPORT void MinMaxValues (Standard_Real& theXMin, Standard_Real& theYMin, Standard_Real& theZMin, |
150 | Standard_Real& theXMax, Standard_Real& theYMax, Standard_Real& theZMax) const; |
151 | |
152 | //! Sets the coordinates of the boundary box of the group. |
153 | Standard_EXPORT void SetMinMaxValues (const Standard_Real theXMin, const Standard_Real theYMin, const Standard_Real theZMin, |
154 | const Standard_Real theXMax, const Standard_Real theYMax, const Standard_Real theZMax); |
155 | |
156 | //! Returns boundary box of the group <me> without transformation applied, |
157 | const Graphic3d_BndBox4f& BoundingBox() const { return myBounds; } |
158 | |
159 | //! Returns non-const boundary box of the group <me> without transformation applied, |
160 | Graphic3d_BndBox4f& ChangeBoundingBox() { return myBounds; } |
161 | |
162 | //! Returns the structure containing the group <me>. |
163 | Standard_EXPORT Handle(Graphic3d_Structure) Structure() const; |
164 | |
165 | //! Changes property shown that primitive arrays within this group form closed volume (do no contain open shells). |
166 | void SetClosed (const bool theIsClosed) { myIsClosed = theIsClosed; } |
167 | |
168 | //! Return true if primitive arrays within this graphic group form closed volume (do no contain open shells). |
169 | bool IsClosed() const { return myIsClosed; } |
170 | |
171 | //! @name obsolete methods |
59ec40f8 |
172 | public: |
5b111128 |
173 | |
bbd92927 |
174 | Standard_DEPRECATED("Deprecated method Marker(), pass Graphic3d_ArrayOfPoints to AddPrimitiveArray() instead") |
175 | Standard_EXPORT void Marker (const Graphic3d_Vertex& thePoint, const Standard_Boolean theToEvalMinMax = Standard_True); |
176 | |
42cf5bc1 |
177 | //! Creates the string <AText> at position <APoint>. |
178 | //! The 3D point of attachment is projected. The text is |
179 | //! written in the plane of projection. |
180 | //! The attributes are given with respect to the plane of |
181 | //! projection. |
182 | //! AHeight : Height of text. |
183 | //! (Relative to the Normalized Projection |
184 | //! Coordinates (NPC) Space). |
185 | //! AAngle : Orientation of the text |
186 | //! (with respect to the horizontal). |
8ed07085 |
187 | Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it") |
188 | Standard_EXPORT virtual void Text (const Standard_CString AText, |
189 | const Graphic3d_Vertex& APoint, |
190 | const Standard_Real AHeight, |
191 | const Standard_Real AAngle, |
192 | const Graphic3d_TextPath ATp, |
193 | const Graphic3d_HorizontalTextAlignment AHta, |
194 | const Graphic3d_VerticalTextAlignment AVta, |
195 | const Standard_Boolean EvalMinMax = Standard_True); |
5b111128 |
196 | |
42cf5bc1 |
197 | //! Creates the string <AText> at position <APoint>. |
198 | //! The 3D point of attachment is projected. The text is |
199 | //! written in the plane of projection. |
200 | //! The attributes are given with respect to the plane of |
201 | //! projection. |
202 | //! AHeight : Height of text. |
203 | //! (Relative to the Normalized Projection |
204 | //! Coordinates (NPC) Space). |
205 | //! The other attributes have the following default values: |
206 | //! AAngle : PI / 2. |
207 | //! ATp : TP_RIGHT |
208 | //! AHta : HTA_LEFT |
209 | //! AVta : VTA_BOTTOM |
8ed07085 |
210 | Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it") |
211 | Standard_EXPORT void Text (const Standard_CString AText, |
212 | const Graphic3d_Vertex& APoint, |
213 | const Standard_Real AHeight, |
214 | const Standard_Boolean EvalMinMax = Standard_True); |
5b111128 |
215 | |
42cf5bc1 |
216 | //! Creates the string <AText> at position <APoint>. |
217 | //! The 3D point of attachment is projected. The text is |
218 | //! written in the plane of projection. |
219 | //! The attributes are given with respect to the plane of |
220 | //! projection. |
221 | //! AHeight : Height of text. |
222 | //! (Relative to the Normalized Projection |
223 | //! Coordinates (NPC) Space). |
224 | //! AAngle : Orientation of the text |
225 | //! (with respect to the horizontal). |
8ed07085 |
226 | Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it") |
227 | Standard_EXPORT void Text (const TCollection_ExtendedString& AText, |
228 | const Graphic3d_Vertex& APoint, |
229 | const Standard_Real AHeight, |
230 | const Standard_Real AAngle, |
231 | const Graphic3d_TextPath ATp, |
232 | const Graphic3d_HorizontalTextAlignment AHta, |
233 | const Graphic3d_VerticalTextAlignment AVta, |
234 | const Standard_Boolean EvalMinMax = Standard_True); |
5b111128 |
235 | |
42cf5bc1 |
236 | //! Creates the string <AText> at position <APoint>. |
237 | //! The 3D point of attachment is projected. The text is |
238 | //! written in the plane of projection. |
239 | //! The attributes are given with respect to the plane of |
240 | //! projection. |
241 | //! AHeight : Height of text. |
242 | //! (Relative to the Normalized Projection |
243 | //! Coordinates (NPC) Space). |
244 | //! The other attributes have the following default values: |
245 | //! AAngle : PI / 2. |
246 | //! ATp : TP_RIGHT |
247 | //! AHta : HTA_LEFT |
248 | //! AVta : VTA_BOTTOM |
8ed07085 |
249 | Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it") |
250 | Standard_EXPORT void Text (const TCollection_ExtendedString& AText, |
251 | const Graphic3d_Vertex& APoint, |
252 | const Standard_Real AHeight, |
253 | const Standard_Boolean EvalMinMax = Standard_True); |
5b111128 |
254 | |
ce01ec26 |
255 | //! Creates the string <theText> at orientation <theOrientation> in 3D space. |
8ed07085 |
256 | Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it") |
ce01ec26 |
257 | Standard_EXPORT virtual void Text (const Standard_CString theTextUtf, |
258 | const gp_Ax2& theOrientation, |
259 | const Standard_Real theHeight, |
ee2be2a8 |
260 | const Standard_Real theAngle, |
ce01ec26 |
261 | const Graphic3d_TextPath theTp, |
262 | const Graphic3d_HorizontalTextAlignment theHTA, |
263 | const Graphic3d_VerticalTextAlignment theVTA, |
3f1eb0ab |
264 | const Standard_Boolean theToEvalMinMax = Standard_True, |
265 | const Standard_Boolean theHasOwnAnchor = Standard_True); |
ce01ec26 |
266 | |
267 | //! Creates the string <theText> at orientation <theOrientation> in 3D space. |
8ed07085 |
268 | Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it") |
ce01ec26 |
269 | Standard_EXPORT virtual void Text (const TCollection_ExtendedString& theText, |
270 | const gp_Ax2& theOrientation, |
271 | const Standard_Real theHeight, |
ee2be2a8 |
272 | const Standard_Real theAngle, |
ce01ec26 |
273 | const Graphic3d_TextPath theTp, |
274 | const Graphic3d_HorizontalTextAlignment theHTA, |
275 | const Graphic3d_VerticalTextAlignment theVTA, |
3f1eb0ab |
276 | const Standard_Boolean theToEvalMinMax = Standard_True, |
277 | const Standard_Boolean theHasOwnAnchor = Standard_True); |
ce01ec26 |
278 | |
279 | |
0904aa63 |
280 | //! Dumps the content of me into the stream |
bc73b006 |
281 | Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const; |
0904aa63 |
282 | |
42cf5bc1 |
283 | protected: |
284 | |
42cf5bc1 |
285 | //! Creates a group in the structure <AStructure>. |
286 | Standard_EXPORT Graphic3d_Group(const Handle(Graphic3d_Structure)& theStructure); |
287 | |
42cf5bc1 |
288 | //! Calls the Update method of the StructureManager which |
289 | //! contains the associated Structure of the Group <me>. |
290 | Standard_EXPORT void Update() const; |
291 | |
59ec40f8 |
292 | protected: |
42cf5bc1 |
293 | |
4e993e4d |
294 | Handle(Graphic3d_TransformPers) myTrsfPers; //!< current transform persistence |
59ec40f8 |
295 | Graphic3d_Structure* myStructure; //!< pointer to the parent structure |
296 | Graphic3d_BndBox4f myBounds; //!< bounding box |
297 | bool myIsClosed; //!< flag indicating closed volume |
42cf5bc1 |
298 | |
299 | }; |
300 | |
25e59720 |
301 | DEFINE_STANDARD_HANDLE(Graphic3d_Group, Standard_Transient) |
42cf5bc1 |
302 | |
303 | #endif // _Graphic3d_Group_HeaderFile |