0027862: Exception in BRepOffsetAPI_MakePipeShell
[occt.git] / src / PrsMgr / PrsMgr_PresentableObject.hxx
CommitLineData
42cf5bc1 1// Created on: 1995-01-25
2// Created by: Jean-Louis Frenkel
3// Copyright (c) 1995-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 _PrsMgr_PresentableObject_HeaderFile
18#define _PrsMgr_PresentableObject_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_Type.hxx>
22
23#include <PrsMgr_Presentations.hxx>
24#include <PrsMgr_TypeOfPresentation3d.hxx>
25#include <Graphic3d_SequenceOfHClipPlane.hxx>
42cf5bc1 26#include <Standard_Boolean.hxx>
27#include <Graphic3d_ZLayerId.hxx>
28#include <PrsMgr_PresentableObjectPointer.hxx>
91d96372 29#include <gp_GTrsf.hxx>
42cf5bc1 30#include <gp_Trsf.hxx>
31#include <PrsMgr_ListOfPresentableObjects.hxx>
32#include <MMgt_TShared.hxx>
33#include <PrsMgr_Presentation.hxx>
34#include <PrsMgr_PresentationManager3d.hxx>
35#include <Standard_Integer.hxx>
825aa485 36#include <Graphic3d_TransformPers.hxx>
42cf5bc1 37#include <Graphic3d_TransModeFlags.hxx>
38#include <TColStd_ListOfInteger.hxx>
39#include <Graphic3d_ClipPlane.hxx>
40class Standard_NotImplemented;
41class PrsMgr_Presentation;
42class PrsMgr_PresentationManager;
43class Graphic3d_Structure;
44class Graphic3d_DataStructureManager;
45class Geom_Transformation;
46class Prs3d_Presentation;
47class Prs3d_Projector;
48class gp_Pnt;
49class gp_Trsf;
50
51
52class PrsMgr_PresentableObject;
53DEFINE_STANDARD_HANDLE(PrsMgr_PresentableObject, MMgt_TShared)
54
55//! A framework to supply the Graphic3d
56//! structure of the object to be presented. On the first
57//! display request, this structure is created by calling the
58//! appropriate algorithm and retaining this frameworkfor
59//! further display.
60//! This abstract framework is inherited in Application
61//! Interactive Services (AIS), notably in:
62//! - AIS_InteractiveObject
63//! - AIS_ConnectedInteractive
64//! - AIS_MultipleConnectedInteractive
65//! - AIS_Shape
66//! Consequently, 3D presentation should be handled by
67//! the relevant daughter classes and their member
68//! functions in AIS. This is particularly true in the
69//! creation of new interactive objects.
70class PrsMgr_PresentableObject : public MMgt_TShared
71{
72
73public:
74
75
76 Standard_EXPORT PrsMgr_Presentations& Presentations();
be5c3602 77
42cf5bc1 78 //! Returns information on whether the object accepts display in HLR mode or not.
be5c3602 79 PrsMgr_TypeOfPresentation3d TypeOfPresentation3d() const;
80
42cf5bc1 81 //! Sets up Transform Persistence Mode for this object.
82 //! This function used to lock in object position, rotation and / or zooming relative to camera position.
83 //! Object will be drawn in the origin setted by APoint parameter (except Graphic3d_TMF_TriedronPers flag
84 //! - see description later). aFlag should be:
85 //! - Graphic3d_TMF_None - no persistence attributes (reset);
86 //! - Graphic3d_TMF_PanPers - object doesn't move;
87 //! - Graphic3d_TMF_ZoomPers - object doesn't resize;
88 //! - Graphic3d_TMF_RotatePers - object doesn't rotate;
89 //! - Graphic3d_TMF_FullPers - pan, zoom and rotate transform persistence;
90 //! - Graphic3d_TMF_TriedronPers - object behaves like trihedron;
91 //! - combination (Graphic3d_TMF_PanPers | Graphic3d_TMF_ZoomPers);
92 //! - combination (Graphic3d_TMF_PanPers | Graphic3d_TMF_RotatePers);
93 //! - combination (Graphic3d_TMF_ZoomPers | Graphic3d_TMF_RotatePers).
94 //! If Graphic3d_TMF_TriedronPers or Graphic3d_TMF_2d persistence mode selected APoint coordinates X and Y means:
95 //! - X = 0.0, Y = 0.0 - center of view window;
96 //! - X > 0.0, Y > 0.0 - right upper corner of view window;
97 //! - X > 0.0, Y < 0.0 - right lower corner of view window;
98 //! - X < 0.0, Y > 0.0 - left upper corner of view window;
99 //! - X < 0.0, Y < 0.0 - left lower corner of view window.
100 //! And Z coordinate defines the gap from border of view window (except center position).
1d92133e 101 Standard_EXPORT virtual void SetTransformPersistence (const Graphic3d_TransModeFlags& aFlag, const gp_Pnt& APoint = gp_Pnt (0.0, 0.0, 0.0));
102
42cf5bc1 103 //! Gets Transform Persistence Mode for this object
104 Standard_EXPORT Graphic3d_TransModeFlags GetTransformPersistenceMode() const;
105
106 //! Gets point of transform persistence for this object
107 Standard_EXPORT gp_Pnt GetTransformPersistencePoint() const;
825aa485 108
109 //! @return transform persistence of the presentable object.
110 const Graphic3d_TransformPers& TransformPersistence() const;
111
42cf5bc1 112 Standard_EXPORT void SetTypeOfPresentation (const PrsMgr_TypeOfPresentation3d aType);
113
114 //! flags the Prs of mode <AMode> to be Updated.
115 //! the Update will be done when needed.
116 Standard_EXPORT void SetToUpdate (const Standard_Integer aMode);
117
118 //! flags all the Presentations to be Updated.
119 Standard_EXPORT void SetToUpdate();
120
121 //! gives the list of modes which are flagged "to be updated".
122 Standard_EXPORT void ToBeUpdated (TColStd_ListOfInteger& ListOfMode) const;
123
124 //! Sets local transformation to theTransformation.
125 Standard_EXPORT virtual void SetLocalTransformation (const gp_Trsf& theTransformation);
126
127 //! Returns true if object has a transformation that is different from the identity.
128 Standard_EXPORT Standard_Boolean HasTransformation() const;
129
130 const gp_Trsf& LocalTransformation() const;
131
132 const gp_Trsf& Transformation() const;
133
91d96372 134 const gp_GTrsf& InversedTransformation() const;
42cf5bc1 135
136 //! resets local transformation to identity.
137 Standard_EXPORT virtual void ResetTransformation();
138
139 Standard_EXPORT virtual void UpdateTransformation();
140
141 Standard_EXPORT virtual void UpdateTransformation (const Handle(Prs3d_Presentation)& P);
142
143 //! Set Z layer ID and update all presentations of the presentable object.
144 //! The layers mechanism allows drawing objects in higher layers in overlay of objects in lower layers.
145 Standard_EXPORT virtual void SetZLayer (const Graphic3d_ZLayerId theLayerId);
146
147 //! Get ID of Z layer.
148 Standard_EXPORT Graphic3d_ZLayerId ZLayer() const;
149
150 //! Adds clip plane for graphical clipping for all display mode
151 //! presentations. The composition of clip planes truncates the rendering
152 //! space to convex volume. Please be aware that number of supported
153 //! clip plane is limited. The planes which exceed the limit are ignored.
154 //! Besides of this, some planes can be already set in view where the object
155 //! is shown: the number of these planes should be substracted from limit
156 //! to predict the maximum possible number of object clipping planes.
157 //! @param thePlane [in] the clip plane to be appended to map of clip planes.
158 Standard_EXPORT virtual void AddClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane);
159
160 //! Removes previously added clip plane.
161 //! @param thePlane [in] the clip plane to be removed from map of clip planes.
162 Standard_EXPORT virtual void RemoveClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane);
163
164 //! Set clip planes for graphical clipping for all display mode presentations.
165 //! The composition of clip planes truncates the rendering space to convex
166 //! volume. Please be aware that number of supported clip plane is limited.
167 //! The planes which exceed the limit are ignored. Besides of this, some
168 //! planes can be already set in view where the object is shown: the number
169 //! of these planes should be substracted from limit to predict the maximum
170 //! possible number of object clipping planes.
171 Standard_EXPORT virtual void SetClipPlanes (const Graphic3d_SequenceOfHClipPlane& thePlanes);
172
173 //! Get clip planes.
174 //! @return set of previously added clip planes for all display mode presentations.
175 const Graphic3d_SequenceOfHClipPlane& GetClipPlanes() const;
176
177 //! Sets if the object has mutable nature (content or location will be changed regularly).
178 //! This method should be called before object displaying to take effect.
179 Standard_EXPORT virtual void SetMutable (const Standard_Boolean theIsMutable);
180
181 //! Returns true if object has mutable nature (content or location are be changed regularly).
182 //! Mutable object will be managed in different way than static onces (another optimizations).
487bf1ce 183 Standard_EXPORT Standard_Boolean IsMutable() const;
42cf5bc1 184
185 //! Makes theObject child of current object in scene hierarchy.
186 Standard_EXPORT virtual void AddChild (const Handle(PrsMgr_PresentableObject)& theObject);
187
188 //! Removes theObject from children of current object in scene hierarchy.
189 Standard_EXPORT virtual void RemoveChild (const Handle(PrsMgr_PresentableObject)& theObject);
190
191 //! Returns children of the current object.
be5c3602 192 const PrsMgr_ListOfPresentableObjects& Children() const;
193
42cf5bc1 194 //! Returns true if object should have own presentations.
be5c3602 195 Standard_Boolean HasOwnPresentations() const;
196
42cf5bc1 197 //! Returns parent of current object in scene hierarchy.
be5c3602 198 PrsMgr_PresentableObjectPointer Parent() const;
42cf5bc1 199
200
201friend class PrsMgr_Presentation;
202friend class PrsMgr_PresentationManager;
203friend
204 Standard_EXPORT Handle(Graphic3d_Structure) PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector);
205friend
206 Standard_EXPORT void PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector, const Handle(Graphic3d_Structure)& theGivenStruct);
207friend
208 Standard_EXPORT Handle(Graphic3d_Structure) PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector, const Handle(Geom_Transformation)& theTrsf);
209friend
210 Standard_EXPORT void PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector, const Handle(Geom_Transformation)& theTrsf, const Handle(Graphic3d_Structure)& theGivenStruct);
211
212
92efcf78 213 DEFINE_STANDARD_RTTIEXT(PrsMgr_PresentableObject,MMgt_TShared)
42cf5bc1 214
215protected:
216
217
218 Standard_EXPORT PrsMgr_PresentableObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
219Standard_EXPORT virtual ~PrsMgr_PresentableObject();
220
221 //! Calculates the 3D view aPresentation and its
222 //! updates. The latter are managed by aPresentationManager.
223 //! aPresentableObject has the display mode aMode;
224 //! this has the default value of 0, that is, the wireframe display mode.
8b9a309b 225 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode);
42cf5bc1 226
227 //! Calculates the 3D view aPresentation and its
228 //! updates. The latter are managed by
229 //! aPresentationManager. Each of the views in the
230 //! viewer and every modification such as rotation, for
231 //! example, entails recalculation.
232 //! It must be redefined to implement hidden line removal
233 //! for the object. The user never calls this method
234 //! himself. This is done via the InteractiveContext object
235 //! and is dependent on the point of view from which the
236 //! object is displayed.
237 Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Prs3d_Presentation)& aPresentation);
238
239 //! Calculates the 3D view aPresentation and its
240 //! updates. The latter are managed by
241 //! aPresentationManager. A point of view is provided
242 //! by the projector aProjector, and the geometric
243 //! transformation which has transformed associated
244 //! presentable objects is specified by aTrsf.
245 //! This function is to be used in case where a hidden
246 //! line removal display cannot be calculated
247 //! automatically. This occurs when associated
248 //! presentable objects have been transformed
249 //! geometrically, but not translated.
250 //! Warning
251 //! The transformation aTrsf must be applied to the
252 //! object before computation.
253 Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Geom_Transformation)& aTrsf, const Handle(Prs3d_Presentation)& aPresentation);
254
255 //! recomputes all presentations of the object.
256 Standard_EXPORT void Update (const Standard_Boolean AllModes = Standard_False);
257
258 //! Recomputes the presentation in the given mode.
259 //! If ClearOther is true, other presentation will be cleared.
260 Standard_EXPORT void Update (const Standard_Integer aMode, const Standard_Boolean ClearOther);
261
262 //! High-level interface for controlling polygon offsets
8b9a309b 263 Standard_EXPORT virtual void Fill (const Handle(PrsMgr_PresentationManager)& aPresentationManager, const Handle(PrsMgr_Presentation)& aPresentation, const Standard_Integer aMode);
42cf5bc1 264
265 //! Sets myCombinedParentTransform to theTransformation. Thus object receives transformation
266 //! from parent node and able to derive its own.
267 Standard_EXPORT virtual void SetCombinedParentTransform (const gp_Trsf& theTransformation);
268
269 //! General virtual method for internal update of presentation state
270 //! when some modifications on list of clip planes occurs. Base
271 //! implementation propagate clip planes to every presentation.
272 Standard_EXPORT virtual void UpdateClipping();
273
274 PrsMgr_Presentations myPresentations;
275 PrsMgr_TypeOfPresentation3d myTypeOfPresentation3d;
276 Graphic3d_SequenceOfHClipPlane myClipPlanes;
277 Standard_Boolean myIsMutable;
278 Graphic3d_ZLayerId myZLayer;
279 Standard_Boolean myHasOwnPresentations;
280
281
282private:
283
284
825aa485 285 Graphic3d_TransformPers myTransformPersistence;
42cf5bc1 286 PrsMgr_PresentableObjectPointer myParent;
287 gp_Trsf myLocalTransformation;
288 gp_Trsf myTransformation;
91d96372 289 gp_GTrsf myInvTransformation;
42cf5bc1 290 gp_Trsf myCombinedParentTransform;
291 PrsMgr_ListOfPresentableObjects myChildren;
292
293
294};
295
296
297#include <PrsMgr_PresentableObject.lxx>
298
299
300
301
302
303#endif // _PrsMgr_PresentableObject_HeaderFile