0026936: Drawbacks of inlining in new type system in OCCT 7.0 -- automatic
[occt.git] / src / Graphic3d / Graphic3d_Group.hxx
CommitLineData
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
20#include <Standard.hxx>
21#include <Standard_Type.hxx>
22
23#include <Graphic3d_CBitFields4.hxx>
24#include <Graphic3d_StructurePtr.hxx>
25#include <Graphic3d_BndBox4f.hxx>
26#include <Standard_Boolean.hxx>
27#include <Graphic3d_CAspectLine.hxx>
28#include <Graphic3d_CAspectFillArea.hxx>
29#include <Graphic3d_CAspectMarker.hxx>
30#include <Graphic3d_CAspectText.hxx>
5b111128 31#include <Graphic3d_AspectLine3d.hxx>
32#include <Graphic3d_AspectFillArea3d.hxx>
33#include <Graphic3d_AspectText3d.hxx>
34#include <Graphic3d_AspectMarker3d.hxx>
42cf5bc1 35#include <MMgt_TShared.hxx>
36#include <Standard_Real.hxx>
37#include <Standard_CString.hxx>
38#include <Graphic3d_Vertex.hxx>
39#include <Quantity_PlaneAngle.hxx>
40#include <Graphic3d_TextPath.hxx>
41#include <Graphic3d_HorizontalTextAlignment.hxx>
42#include <Graphic3d_VerticalTextAlignment.hxx>
43#include <Graphic3d_TypeOfPrimitiveArray.hxx>
44#include <Graphic3d_IndexBuffer.hxx>
45#include <Graphic3d_Buffer.hxx>
46#include <Graphic3d_BoundBuffer.hxx>
47#include <Standard_Address.hxx>
48#include <Graphic3d_GroupAspect.hxx>
ce01ec26 49#include <gp_Ax2.hxx>
50#include <TCollection_ExtendedString.hxx>
5b111128 51
52class Graphic3d_Structure;
42cf5bc1 53class Graphic3d_GroupDefinitionError;
54class Standard_OutOfRange;
42cf5bc1 55class Graphic3d_ArrayOfPrimitives;
42cf5bc1 56
57
58class Graphic3d_Group;
59DEFINE_STANDARD_HANDLE(Graphic3d_Group, MMgt_TShared)
60
61//! This class allows the definition of groups
62//! of primitives inside of graphic objects (presentations).
63//! A group contains the primitives and attributes
64//! for which the range is limited to this group.
65//! The primitives of a group can be globally suppressed.
66//!
67//! There are two main group usage models:
68//!
69//! 1) Non-modifiable, or unbounded, group ('black box').
70//! Developers can repeat a sequence of
71//! SetPrimitivesAspect() with AddPrimitiveArray() methods arbitrary number of times
72//! to define arbitrary number of primitive "blocks" each having individual apect values.
73//! Any modification of such a group is forbidden, as aspects and primitives are mixed
74//! in memory without any high-level logical structure, and any modification is very likely to result
75//! in corruption of the group internal data.
76//! It is necessary to recreate such a group as a whole when some attribute should be changed.
77//! (for example, in terms of AIS it is necessary to re-Compute() the whole presentation each time).
78//! 2) Bounded group. Developers should specify the necessary group aspects with help of
79//! SetGroupPrimitivesAspect() and then add primitives to the group.
80//! Such a group have simplified organization in memory (a single block of attributes
81//! followed by a block of primitives) and therefore it can be modified, if it is necessary to
82//! change parameters of some aspect that has already been set, using methods:
83//! IsGroupPrimitivesAspectSet() to detect which aspect was set for primitives;
84//! GroupPrimitivesAspect() to read current aspect values
85//! and SetGroupPrimitivesAspect() to set new values.
86//!
87//! Developers are strongly recommended to take all the above into account when filling Graphic3d_Group
88//! with aspects and primitives and choose the group usage model beforehand out of application needs.
ce01ec26 89//! Note that some Graphic3d_Group class virtual methods contain only base implementation
90//! that is extended by the descendant class in OpenGl package.
42cf5bc1 91class Graphic3d_Group : public MMgt_TShared
92{
93
94public:
95
5b111128 96
42cf5bc1 97 //! Supress all primitives and attributes of <me>.
98 //! To clear group without update in Graphic3d_StructureManager
99 //! pass Standard_False as <theUpdateStructureMgr>. This
100 //! used on context and viewer destruction, when the pointer
101 //! to structure manager in Graphic3d_Structure could be
102 //! already released (pointers are used here to avoid handle
103 //! cross-reference);
104 Standard_EXPORT virtual void Clear (const Standard_Boolean theUpdateStructureMgr = Standard_True);
5b111128 105
42cf5bc1 106 Standard_EXPORT virtual void UpdateAspectLine (const Standard_Boolean theIsGlobal) = 0;
5b111128 107
42cf5bc1 108 Standard_EXPORT virtual void UpdateAspectFace (const Standard_Boolean theIsGlobal) = 0;
5b111128 109
42cf5bc1 110 Standard_EXPORT virtual void UpdateAspectMarker (const Standard_Boolean theIsGlobal) = 0;
5b111128 111
42cf5bc1 112 Standard_EXPORT virtual void UpdateAspectText (const Standard_Boolean theIsGlobal) = 0;
5b111128 113
42cf5bc1 114 //! Supress the group <me> in the structure.
115 Standard_EXPORT void Destroy();
116~Graphic3d_Group()
117{
118 Destroy();
119}
5b111128 120
42cf5bc1 121 //! Supress the group <me> in the structure.
122 //! Warning: No more graphic operations in <me> after this call.
123 //! Modifies the current modelling transform persistence (pan, zoom or rotate)
124 //! Get the current modelling transform persistence (pan, zoom or rotate)
125 Standard_EXPORT void Remove();
5b111128 126
42cf5bc1 127 //! Modifies the context for all the line primitives
128 //! of the group.
129 Standard_EXPORT void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& CTX);
5b111128 130
42cf5bc1 131 //! Modifies the context for all the face primitives
132 //! of the group.
133 Standard_EXPORT void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& CTX);
5b111128 134
42cf5bc1 135 //! Modifies the context for all the text primitives
136 //! of the group.
137 Standard_EXPORT void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& CTX);
5b111128 138
42cf5bc1 139 //! Modifies the context for all the marker primitives
140 //! of the group.
141 Standard_EXPORT void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& CTX);
5b111128 142
42cf5bc1 143 //! Modifies the current context of the group to give
144 //! another aspect for all the line primitives created
145 //! after this call in the group.
146 Standard_EXPORT void SetPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& CTX);
5b111128 147
42cf5bc1 148 //! Modifies the current context of the group to give
149 //! another aspect for all the face primitives created
150 //! after this call in the group.
151 Standard_EXPORT void SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& CTX);
5b111128 152
42cf5bc1 153 //! Modifies the current context of the group to give
154 //! another aspect for all the text primitives created
155 //! after this call in the group.
156 Standard_EXPORT void SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& CTX);
5b111128 157
42cf5bc1 158 //! Modifies the current context of the group to give
159 //! another aspect for all the marker primitives created
160 //! after this call in the group.
161 Standard_EXPORT void SetPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& CTX);
5b111128 162
42cf5bc1 163 //! Sets the coordinates of the boundary box of the
164 //! group <me>.
165 Standard_EXPORT void SetMinMaxValues (const Standard_Real XMin, const Standard_Real YMin, const Standard_Real ZMin, const Standard_Real XMax, const Standard_Real YMax, const Standard_Real ZMax);
5b111128 166
42cf5bc1 167 //! Creates the string <AText> at position <APoint>.
168 //! The 3D point of attachment is projected. The text is
169 //! written in the plane of projection.
170 //! The attributes are given with respect to the plane of
171 //! projection.
172 //! AHeight : Height of text.
173 //! (Relative to the Normalized Projection
174 //! Coordinates (NPC) Space).
175 //! AAngle : Orientation of the text
176 //! (with respect to the horizontal).
177 Standard_EXPORT virtual void Text (const Standard_CString AText, const Graphic3d_Vertex& APoint, const Standard_Real AHeight, const Quantity_PlaneAngle AAngle, const Graphic3d_TextPath ATp, const Graphic3d_HorizontalTextAlignment AHta, const Graphic3d_VerticalTextAlignment AVta, const Standard_Boolean EvalMinMax = Standard_True);
5b111128 178
42cf5bc1 179 //! Creates the string <AText> at position <APoint>.
180 //! The 3D point of attachment is projected. The text is
181 //! written in the plane of projection.
182 //! The attributes are given with respect to the plane of
183 //! projection.
184 //! AHeight : Height of text.
185 //! (Relative to the Normalized Projection
186 //! Coordinates (NPC) Space).
187 //! The other attributes have the following default values:
188 //! AAngle : PI / 2.
189 //! ATp : TP_RIGHT
190 //! AHta : HTA_LEFT
191 //! AVta : VTA_BOTTOM
192 Standard_EXPORT void Text (const Standard_CString AText, const Graphic3d_Vertex& APoint, const Standard_Real AHeight, const Standard_Boolean EvalMinMax = Standard_True);
5b111128 193
42cf5bc1 194 //! Creates the string <AText> at position <APoint>.
195 //! The 3D point of attachment is projected. The text is
196 //! written in the plane of projection.
197 //! The attributes are given with respect to the plane of
198 //! projection.
199 //! AHeight : Height of text.
200 //! (Relative to the Normalized Projection
201 //! Coordinates (NPC) Space).
202 //! AAngle : Orientation of the text
203 //! (with respect to the horizontal).
204 Standard_EXPORT void Text (const TCollection_ExtendedString& AText, const Graphic3d_Vertex& APoint, const Standard_Real AHeight, const Quantity_PlaneAngle AAngle, const Graphic3d_TextPath ATp, const Graphic3d_HorizontalTextAlignment AHta, const Graphic3d_VerticalTextAlignment AVta, const Standard_Boolean EvalMinMax = Standard_True);
5b111128 205
42cf5bc1 206 //! Creates the string <AText> at position <APoint>.
207 //! The 3D point of attachment is projected. The text is
208 //! written in the plane of projection.
209 //! The attributes are given with respect to the plane of
210 //! projection.
211 //! AHeight : Height of text.
212 //! (Relative to the Normalized Projection
213 //! Coordinates (NPC) Space).
214 //! The other attributes have the following default values:
215 //! AAngle : PI / 2.
216 //! ATp : TP_RIGHT
217 //! AHta : HTA_LEFT
218 //! AVta : VTA_BOTTOM
219 Standard_EXPORT void Text (const TCollection_ExtendedString& AText, const Graphic3d_Vertex& APoint, const Standard_Real AHeight, const Standard_Boolean EvalMinMax = Standard_True);
5b111128 220
ce01ec26 221 //! Creates the string <theText> at orientation <theOrientation> in 3D space.
222 Standard_EXPORT virtual void Text (const Standard_CString theTextUtf,
223 const gp_Ax2& theOrientation,
224 const Standard_Real theHeight,
225 const Quantity_PlaneAngle theAngle,
226 const Graphic3d_TextPath theTp,
227 const Graphic3d_HorizontalTextAlignment theHTA,
228 const Graphic3d_VerticalTextAlignment theVTA,
229 const Standard_Boolean theToEvalMinMax = Standard_True);
230
231 //! Creates the string <theText> at orientation <theOrientation> in 3D space.
232 Standard_EXPORT virtual void Text (const TCollection_ExtendedString& theText,
233 const gp_Ax2& theOrientation,
234 const Standard_Real theHeight,
235 const Quantity_PlaneAngle theAngle,
236 const Graphic3d_TextPath theTp,
237 const Graphic3d_HorizontalTextAlignment theHTA,
238 const Graphic3d_VerticalTextAlignment theVTA,
239 const Standard_Boolean theToEvalMinMax = Standard_True);
240
241
42cf5bc1 242 //! Adds an array of primitives for display
243 Standard_EXPORT virtual void AddPrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theType, const Handle(Graphic3d_IndexBuffer)& theIndices, const Handle(Graphic3d_Buffer)& theAttribs, const Handle(Graphic3d_BoundBuffer)& theBounds, const Standard_Boolean theToEvalMinMax = Standard_True);
5b111128 244
42cf5bc1 245 //! Adds an array of primitives for display
246 Standard_EXPORT void AddPrimitiveArray (const Handle(Graphic3d_ArrayOfPrimitives)& thePrim, const Standard_Boolean theToEvalMinMax = Standard_True);
5b111128 247
42cf5bc1 248 //! Creates a primitive array with single marker using AddPrimitiveArray().
249 Standard_EXPORT void Marker (const Graphic3d_Vertex& thePoint, const Standard_Boolean theToEvalMinMax = Standard_True);
5b111128 250
42cf5bc1 251 //! sets the stencil test to theIsEnabled state;
252 Standard_EXPORT virtual void SetStencilTestOptions (const Standard_Boolean theIsEnabled) = 0;
5b111128 253
42cf5bc1 254 //! sets the flipping to theIsEnabled state.
255 Standard_EXPORT virtual void SetFlippingOptions (const Standard_Boolean theIsEnabled, const gp_Ax2& theRefPlane) = 0;
5b111128 256
42cf5bc1 257 //! Returns TRUE if aspect is set for the group.
258 Standard_EXPORT Standard_Boolean IsGroupPrimitivesAspectSet (const Graphic3d_GroupAspect theAspect) const;
5b111128 259
42cf5bc1 260 //! Returns the context of all the primitives of the group.
261 Standard_EXPORT void GroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& CTXL, const Handle(Graphic3d_AspectText3d)& CTXT, const Handle(Graphic3d_AspectMarker3d)& CTXM, const Handle(Graphic3d_AspectFillArea3d)& CTXF) const;
5b111128 262
42cf5bc1 263 //! Returns the last inserted context in the group <me>
264 //! foreach kind of primitives.
265 Standard_EXPORT void PrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& CTXL, const Handle(Graphic3d_AspectText3d)& CTXT, const Handle(Graphic3d_AspectMarker3d)& CTXM, const Handle(Graphic3d_AspectFillArea3d)& CTXF) const;
5b111128 266
42cf5bc1 267 //! Returns Standard_True if the group <me> contains
268 //! Polygons, Triangles or Quadrangles.
269 Standard_EXPORT Standard_Boolean ContainsFacet() const;
5b111128 270
42cf5bc1 271 //! Returns Standard_True if the group <me> is deleted.
272 //! <me> is deleted after the call Remove (me) or the
273 //! associated structure is deleted.
274 Standard_EXPORT Standard_Boolean IsDeleted() const;
5b111128 275
42cf5bc1 276 //! Returns Standard_True if the group <me> is empty.
277 Standard_EXPORT Standard_Boolean IsEmpty() const;
5b111128 278
42cf5bc1 279 //! Returns the coordinates of the boundary box of the
280 //! group <me>.
281 Standard_EXPORT void MinMaxValues (Standard_Real& XMin, Standard_Real& YMin, Standard_Real& ZMin, Standard_Real& XMax, Standard_Real& YMax, Standard_Real& ZMax) const;
5b111128 282
42cf5bc1 283 //! Returns boundary box of the group <me> without transformation applied,
284 Standard_EXPORT const Graphic3d_BndBox4f& BoundingBox() const;
5b111128 285
42cf5bc1 286 //! Returns non-const boundary box of the group <me> without transformation applied,
287 Standard_EXPORT Graphic3d_BndBox4f& ChangeBoundingBox();
5b111128 288
42cf5bc1 289 //! Returns the structure containing the group <me>.
290 Standard_EXPORT Handle(Graphic3d_Structure) Structure() const;
5b111128 291
42cf5bc1 292 //! Changes property shown that primitive arrays within this group form closed volume (do no contain open shells).
293 Standard_EXPORT void SetClosed (const Standard_Boolean theIsClosed);
5b111128 294
42cf5bc1 295 //! Return true if primitive arrays within this graphic group form closed volume (do no contain open shells).
296 Standard_EXPORT Standard_Boolean IsClosed() const;
297
298friend class Graphic3d_Structure;
299
300
92efcf78 301 DEFINE_STANDARD_RTTIEXT(Graphic3d_Group,MMgt_TShared)
42cf5bc1 302
303protected:
304
5b111128 305
42cf5bc1 306 //! Creates a group in the structure <AStructure>.
307 Standard_EXPORT Graphic3d_Group(const Handle(Graphic3d_Structure)& theStructure);
308
309 Graphic3d_CBitFields4 myCBitFields;
310 Graphic3d_StructurePtr myStructure;
311 Graphic3d_BndBox4f myBounds;
312 Standard_Boolean myIsClosed;
313 Graphic3d_CAspectLine ContextLine;
314 Graphic3d_CAspectFillArea ContextFillArea;
315 Graphic3d_CAspectMarker ContextMarker;
316 Graphic3d_CAspectText ContextText;
317
318
319private:
320
5b111128 321
42cf5bc1 322 //! Returns the extreme coordinates found in the group.
323 Standard_EXPORT void MinMaxCoord (Standard_Real& XMin, Standard_Real& YMin, Standard_Real& ZMin, Standard_Real& XMax, Standard_Real& YMax, Standard_Real& ZMax) const;
5b111128 324
42cf5bc1 325 //! Calls the Update method of the StructureManager which
326 //! contains the associated Structure of the Group <me>.
327 Standard_EXPORT void Update() const;
328
329
330
331};
332
333
334
335
336
337
338
339#endif // _Graphic3d_Group_HeaderFile