0027696: Return max distance in xdistcs Draw command
[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.
3202bf1e 79 PrsMgr_TypeOfPresentation3d TypeOfPresentation3d() const { return myTypeOfPresentation3d; }
be5c3602 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.
3202bf1e 110 const Graphic3d_TransformPers& TransformPersistence() const { return myTransformPersistence; }
825aa485 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;
3202bf1e 129
130 const gp_Trsf& LocalTransformation() const { return myLocalTransformation; }
131
132 const gp_Trsf& Transformation() const { return myTransformation; }
133
134 const gp_GTrsf& InversedTransformation() const { return myInvTransformation; }
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.
3202bf1e 165 //! The composition of clip planes truncates the rendering space to convex volume.
166 //! Please be aware that number of supported clip plane is limited.
167 //! The planes which exceed the limit are ignored.
168 //! Besides of this, some planes can be already set in view where the object is shown:
169 //! the number of these planes should be subtracted from limit to predict the maximum
42cf5bc1 170 //! possible number of object clipping planes.
3202bf1e 171 Standard_EXPORT virtual void SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes);
172
173 Standard_DEPRECATED("This method is deprecated - overload taking Handle should be used instead")
174 void SetClipPlanes (const Graphic3d_SequenceOfHClipPlane& thePlanes)
175 {
176 Handle(Graphic3d_SequenceOfHClipPlane) aPlanes = new Graphic3d_SequenceOfHClipPlane (thePlanes);
177 SetClipPlanes (aPlanes);
178 }
179
42cf5bc1 180 //! Get clip planes.
181 //! @return set of previously added clip planes for all display mode presentations.
3202bf1e 182 const Handle(Graphic3d_SequenceOfHClipPlane)& ClipPlanes() const { return myClipPlanes; }
183
42cf5bc1 184 //! Sets if the object has mutable nature (content or location will be changed regularly).
185 //! This method should be called before object displaying to take effect.
186 Standard_EXPORT virtual void SetMutable (const Standard_Boolean theIsMutable);
187
188 //! Returns true if object has mutable nature (content or location are be changed regularly).
189 //! Mutable object will be managed in different way than static onces (another optimizations).
3202bf1e 190 Standard_Boolean IsMutable() const { return myIsMutable; }
42cf5bc1 191
192 //! Makes theObject child of current object in scene hierarchy.
193 Standard_EXPORT virtual void AddChild (const Handle(PrsMgr_PresentableObject)& theObject);
194
195 //! Removes theObject from children of current object in scene hierarchy.
196 Standard_EXPORT virtual void RemoveChild (const Handle(PrsMgr_PresentableObject)& theObject);
197
198 //! Returns children of the current object.
3202bf1e 199 const PrsMgr_ListOfPresentableObjects& Children() const { return myChildren; }
be5c3602 200
42cf5bc1 201 //! Returns true if object should have own presentations.
3202bf1e 202 Standard_Boolean HasOwnPresentations() const { return myHasOwnPresentations; }
be5c3602 203
42cf5bc1 204 //! Returns parent of current object in scene hierarchy.
3202bf1e 205 PrsMgr_PresentableObjectPointer Parent() const { return myParent; }
42cf5bc1 206
207
208friend class PrsMgr_Presentation;
209friend class PrsMgr_PresentationManager;
210friend
211 Standard_EXPORT Handle(Graphic3d_Structure) PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector);
212friend
213 Standard_EXPORT void PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector, const Handle(Graphic3d_Structure)& theGivenStruct);
214friend
215 Standard_EXPORT Handle(Graphic3d_Structure) PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector, const Handle(Geom_Transformation)& theTrsf);
216friend
217 Standard_EXPORT void PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector, const Handle(Geom_Transformation)& theTrsf, const Handle(Graphic3d_Structure)& theGivenStruct);
218
219
92efcf78 220 DEFINE_STANDARD_RTTIEXT(PrsMgr_PresentableObject,MMgt_TShared)
42cf5bc1 221
222protected:
223
224
225 Standard_EXPORT PrsMgr_PresentableObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
226Standard_EXPORT virtual ~PrsMgr_PresentableObject();
227
228 //! Calculates the 3D view aPresentation and its
229 //! updates. The latter are managed by aPresentationManager.
230 //! aPresentableObject has the display mode aMode;
231 //! this has the default value of 0, that is, the wireframe display mode.
8b9a309b 232 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode);
42cf5bc1 233
234 //! Calculates the 3D view aPresentation and its
235 //! updates. The latter are managed by
236 //! aPresentationManager. Each of the views in the
237 //! viewer and every modification such as rotation, for
238 //! example, entails recalculation.
239 //! It must be redefined to implement hidden line removal
240 //! for the object. The user never calls this method
241 //! himself. This is done via the InteractiveContext object
242 //! and is dependent on the point of view from which the
243 //! object is displayed.
244 Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Prs3d_Presentation)& aPresentation);
245
246 //! Calculates the 3D view aPresentation and its
247 //! updates. The latter are managed by
248 //! aPresentationManager. A point of view is provided
249 //! by the projector aProjector, and the geometric
250 //! transformation which has transformed associated
251 //! presentable objects is specified by aTrsf.
252 //! This function is to be used in case where a hidden
253 //! line removal display cannot be calculated
254 //! automatically. This occurs when associated
255 //! presentable objects have been transformed
256 //! geometrically, but not translated.
257 //! Warning
258 //! The transformation aTrsf must be applied to the
259 //! object before computation.
260 Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Geom_Transformation)& aTrsf, const Handle(Prs3d_Presentation)& aPresentation);
261
262 //! recomputes all presentations of the object.
263 Standard_EXPORT void Update (const Standard_Boolean AllModes = Standard_False);
264
265 //! Recomputes the presentation in the given mode.
266 //! If ClearOther is true, other presentation will be cleared.
267 Standard_EXPORT void Update (const Standard_Integer aMode, const Standard_Boolean ClearOther);
268
269 //! High-level interface for controlling polygon offsets
8b9a309b 270 Standard_EXPORT virtual void Fill (const Handle(PrsMgr_PresentationManager)& aPresentationManager, const Handle(PrsMgr_Presentation)& aPresentation, const Standard_Integer aMode);
42cf5bc1 271
272 //! Sets myCombinedParentTransform to theTransformation. Thus object receives transformation
273 //! from parent node and able to derive its own.
274 Standard_EXPORT virtual void SetCombinedParentTransform (const gp_Trsf& theTransformation);
275
276 //! General virtual method for internal update of presentation state
277 //! when some modifications on list of clip planes occurs. Base
278 //! implementation propagate clip planes to every presentation.
279 Standard_EXPORT virtual void UpdateClipping();
280
3202bf1e 281protected:
282
42cf5bc1 283 PrsMgr_Presentations myPresentations;
284 PrsMgr_TypeOfPresentation3d myTypeOfPresentation3d;
3202bf1e 285 Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes;
42cf5bc1 286 Standard_Boolean myIsMutable;
287 Graphic3d_ZLayerId myZLayer;
288 Standard_Boolean myHasOwnPresentations;
289
42cf5bc1 290private:
291
825aa485 292 Graphic3d_TransformPers myTransformPersistence;
42cf5bc1 293 PrsMgr_PresentableObjectPointer myParent;
294 gp_Trsf myLocalTransformation;
295 gp_Trsf myTransformation;
91d96372 296 gp_GTrsf myInvTransformation;
42cf5bc1 297 gp_Trsf myCombinedParentTransform;
298 PrsMgr_ListOfPresentableObjects myChildren;
299
42cf5bc1 300};
301
42cf5bc1 302#endif // _PrsMgr_PresentableObject_HeaderFile