0025180: Visualization - Homogeneous transformation API in TKV3d
[occt.git] / src / AIS / AIS_Shape.hxx
CommitLineData
42cf5bc1 1// Created on: 1996-12-20
2// Created by: Robert COUBLANC
3// Copyright (c) 1996-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 _AIS_Shape_HeaderFile
18#define _AIS_Shape_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_Type.hxx>
22
23#include <TopoDS_Shape.hxx>
24#include <Bnd_Box.hxx>
25#include <Standard_Boolean.hxx>
26#include <Standard_Real.hxx>
27#include <AIS_InteractiveObject.hxx>
28#include <Standard_Integer.hxx>
29#include <AIS_KindOfInteractive.hxx>
30#include <Prs3d_TypeOfHLR.hxx>
31#include <PrsMgr_PresentationManager3d.hxx>
32#include <SelectMgr_Selection.hxx>
33#include <Quantity_NameOfColor.hxx>
34#include <Graphic3d_NameOfMaterial.hxx>
35#include <TopAbs_ShapeEnum.hxx>
36#include <Prs3d_Drawer.hxx>
37class TopoDS_Shape;
38class Prs3d_Presentation;
39class Prs3d_Projector;
40class Geom_Transformation;
41class Quantity_Color;
42class Graphic3d_MaterialAspect;
43class Bnd_Box;
44
45
46class AIS_Shape;
47DEFINE_STANDARD_HANDLE(AIS_Shape, AIS_InteractiveObject)
48
49//! A framework to manage presentation and selection of shapes.
50//! AIS_Shape is the interactive object which is used the
51//! most by applications. There are standard functions
52//! available which allow you to prepare selection
53//! operations on the constituent elements of shapes -
54//! vertices, edges, faces etc - in an open local context.
55//! The selection modes specific to "Shape" type objects
56//! are referred to as Standard Activation Mode. These
57//! modes are only taken into account in open local
58//! context and only act on Interactive Objects which
59//! have redefined the virtual method
60//! AcceptShapeDecomposition so that it returns true.
61//! Several advanced functions are also available. These
62//! include functions to manage deviation angle and
63//! deviation coefficient - both HLR and non-HLR - of
64//! an inheriting shape class. These services allow you to
65//! select one type of shape interactive object for higher
66//! precision drawing. When you do this, the
67//! Prs3d_Drawer::IsOwn... functions corresponding to the
68//! above deviation angle and coefficient functions return
69//! true indicating that there is a local setting available
70//! for the specific object.
71class AIS_Shape : public AIS_InteractiveObject
72{
73
74public:
75
76
77 //! Initializes construction of the shape shap from wires,
78 //! edges and vertices.
79 Standard_EXPORT AIS_Shape(const TopoDS_Shape& shap);
80
81 //! Returns index 0. This value refers to SHAPE from TopAbs_ShapeEnum
82 Standard_EXPORT virtual Standard_Integer Signature() const Standard_OVERRIDE;
83
84 //! Returns Object as the type of Interactive Object.
85 Standard_EXPORT virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE;
86
87 //! Returns true if the Interactive Object accepts shape decomposition.
88 Standard_EXPORT virtual Standard_Boolean AcceptShapeDecomposition() const Standard_OVERRIDE;
89
90 //! Constructs an instance of the shape object ashape.
91 void Set (const TopoDS_Shape& ashap);
92
93 //! Returns this shape object.
94 const TopoDS_Shape& Shape() const;
95
96 //! Sets a local value for deviation coefficient for this specific shape.
97 Standard_EXPORT Standard_Boolean SetOwnDeviationCoefficient();
98
99 //! Sets a local value for HLR deviation coefficient for this specific shape.
100 Standard_EXPORT Standard_Boolean SetOwnHLRDeviationCoefficient();
101
102 //! Sets a local value for deviation angle for this specific shape.
103 Standard_EXPORT Standard_Boolean SetOwnDeviationAngle();
104
105 //! Sets a local value for HLR deviation angle for this specific shape.
106 Standard_EXPORT Standard_Boolean SetOwnHLRDeviationAngle();
107
108 //! Sets a local value for deviation coefficient for this specific shape.
109 Standard_EXPORT void SetOwnDeviationCoefficient (const Standard_Real aCoefficient);
110
111 //! sets myOwnHLRDeviationCoefficient field in Prs3d_Drawer &
112 //! recomputes presentation
113 Standard_EXPORT void SetOwnHLRDeviationCoefficient (const Standard_Real aCoefficient);
114
115 //! this compute a new angle and Deviation from the value anAngle
116 //! and set the values stored in myDrawer with these that become local to the shape
117 Standard_EXPORT void SetAngleAndDeviation (const Standard_Real anAngle);
118
119 //! gives back the angle initial value put by the User.
120 Standard_EXPORT Standard_Real UserAngle() const;
121
122 //! sets myOwnDeviationAngle field in Prs3d_Drawer & recomputes presentation
123 Standard_EXPORT void SetOwnDeviationAngle (const Standard_Real anAngle);
124
125 //! this compute a new Angle and Deviation from the value anAngle for HLR
126 //! and set the values stored in myDrawer for with these that become local to the shape
127 Standard_EXPORT void SetHLRAngleAndDeviation (const Standard_Real anAngle);
128
129 //! sets myOwnHLRDeviationAngle field in Prs3d_Drawer & recomputes presentation
130 Standard_EXPORT void SetOwnHLRDeviationAngle (const Standard_Real anAngle);
131
132 //! Returns true and the values of the deviation
133 //! coefficient aCoefficient and the previous deviation
134 //! coefficient aPreviousCoefficient. If these values are
135 //! not already set, false is returned.
136 Standard_EXPORT Standard_Boolean OwnDeviationCoefficient (Standard_Real& aCoefficient, Standard_Real& aPreviousCoefficient) const;
137
138 //! Returns true and the values of the HLR deviation
139 //! coefficient aCoefficient and the previous HLR
140 //! deviation coefficient aPreviousCoefficient. If these
141 //! values are not already set, false is returned.
142 Standard_EXPORT Standard_Boolean OwnHLRDeviationCoefficient (Standard_Real& aCoefficient, Standard_Real& aPreviousCoefficient) const;
143
144 //! Returns true and the values of the deviation angle
145 //! anAngle and the previous deviation angle aPreviousAngle.
146 //! If these values are not already set, false is returned.
147 Standard_EXPORT Standard_Boolean OwnDeviationAngle (Standard_Real& anAngle, Standard_Real& aPreviousAngle) const;
148
149 //! Returns true and the values of the HLR deviation
150 //! angle anAngle and of the previous HLR deviation
151 //! angle aPreviousAngle. If these values are not
152 //! already set, false is returned.
153 Standard_EXPORT Standard_Boolean OwnHLRDeviationAngle (Standard_Real& anAngle, Standard_Real& aPreviousAngle) const;
154
155 //! Sets the type of HLR algorithm used by the shape
156 void SetTypeOfHLR (const Prs3d_TypeOfHLR theTypeOfHLR);
157
158 //! Gets the type of HLR algorithm
159 Prs3d_TypeOfHLR TypeOfHLR() const;
160
161 //! Sets the color aColor in the reconstructed
162 //! compound shape. Acts via the Drawer methods below on the appearance of:
163 //! - free boundaries:
164 //! Prs3d_Drawer_FreeBoundaryAspect,
165 //! - isos: Prs3d_Drawer_UIsoAspect,
166 //! Prs3dDrawer_VIsoAspect,
167 //! - shared boundaries:
168 //! Prs3d_Drawer_UnFreeBoundaryAspect,
169 //! - shading: Prs3d_Drawer_ShadingAspect,
170 //! - visible line color in hidden line mode:
171 //! Prs3d_Drawer_SeenLineAspect
172 //! - hidden line color in hidden line mode:
173 //! Prs3d_Drawer_HiddenLineAspect.
174 Standard_EXPORT virtual void SetColor (const Quantity_NameOfColor aColor) Standard_OVERRIDE;
175
176 Standard_EXPORT virtual void SetColor (const Quantity_Color& aColor) Standard_OVERRIDE;
177
178 //! Removes settings for color in the reconstructed compound shape.
179 Standard_EXPORT virtual void UnsetColor() Standard_OVERRIDE;
180
181 //! Sets the value aValue for line width in the reconstructed compound shape.
182 //! Changes line aspects for lines-only presentation modes like Wireframe and Bounding Box.
183 //! Doesn't change face boundary line aspect.
184 Standard_EXPORT virtual void SetWidth (const Standard_Real aValue) Standard_OVERRIDE;
185
186 //! Removes the setting for line width in the reconstructed compound shape.
187 Standard_EXPORT virtual void UnsetWidth() Standard_OVERRIDE;
188
189 Standard_EXPORT virtual void SetMaterial (const Graphic3d_NameOfMaterial aName) Standard_OVERRIDE;
190
191 //! Allows you to provide settings for the material aName
192 //! in the reconstructed compound shape.
193 Standard_EXPORT virtual void SetMaterial (const Graphic3d_MaterialAspect& aName) Standard_OVERRIDE;
194
195 //! Removes settings for material in the reconstructed compound shape.
196 Standard_EXPORT virtual void UnsetMaterial() Standard_OVERRIDE;
197
198 //! Sets the value aValue for transparency in the reconstructed compound shape.
199 Standard_EXPORT virtual void SetTransparency (const Standard_Real aValue = 0.6) Standard_OVERRIDE;
200
201 //! Removes the setting for transparency in the reconstructed compound shape.
202 Standard_EXPORT virtual void UnsetTransparency() Standard_OVERRIDE;
203
204 //! Constructs a bounding box with which to reconstruct
205 //! compound topological shapes for presentation.
206 Standard_EXPORT virtual const Bnd_Box& BoundingBox();
207
201c2208 208 //! AIS_InteractiveObject defines another virtual method BoundingBox,
209 //! which is not the same as above; keep it visible.
210 using AIS_InteractiveObject::BoundingBox;
211
42cf5bc1 212 //! Returns the NameOfColor attributes of the shape accordingly to
213 //! the current facing model;
214 Standard_EXPORT virtual Quantity_NameOfColor Color() const Standard_OVERRIDE;
215
216 //! Returns the Color attributes of the shape accordingly to
217 //! the current facing model;
218 Standard_EXPORT virtual void Color (Quantity_Color& aColor) const Standard_OVERRIDE;
219
220 //! Returns the NameOfMaterial attributes of the shape accordingly to
221 //! the current facing model;
222 Standard_EXPORT virtual Graphic3d_NameOfMaterial Material() const Standard_OVERRIDE;
223
224 //! Returns the transparency attributes of the shape accordingly to
225 //! the current facing model;
226 Standard_EXPORT virtual Standard_Real Transparency() const Standard_OVERRIDE;
227
228 //! Activates the same TopAbs shape enumerations as
229 //! those used by SelectionMode assigning a type to the mode aDecompositionMode.
230 Standard_EXPORT static TopAbs_ShapeEnum SelectionType (const Standard_Integer aDecompositionMode);
231
232 //! Establishes an equivalence between a mode and the
233 //! type, aShapeType, of selection. The correspondences are as follows:
234 //! - mode 0 - Shape
235 //! - mode 1 - Vertex
236 //! - mode 2 - Edge
237 //! - mode 3 - Wire
238 //! - mode 4 - Face
239 //! - mode 5 - Shell
240 //! - mode 6 - Solid
241 //! - mode 7 - Compsolid
242 //! - mode 8 - Compound
243 Standard_EXPORT static Standard_Integer SelectionMode (const TopAbs_ShapeEnum aShapeType);
244
245
246
247
92efcf78 248 DEFINE_STANDARD_RTTIEXT(AIS_Shape,AIS_InteractiveObject)
42cf5bc1 249
250protected:
251
252
253 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
254
255 Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Prs3d_Presentation)& aPresentation) Standard_OVERRIDE;
256
257 Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Geom_Transformation)& aTrsf, const Handle(Prs3d_Presentation)& aPresentation) Standard_OVERRIDE;
258
259 Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
260
261 Standard_EXPORT void LoadRecomputable (const Standard_Integer TheMode);
262
263 Standard_EXPORT void setColor (const Handle(Prs3d_Drawer)& theDrawer, const Quantity_Color& theColor) const;
264
265 Standard_EXPORT void setWidth (const Handle(Prs3d_Drawer)& theDrawer, const Standard_Real theWidth) const;
266
267 Standard_EXPORT void setTransparency (const Handle(Prs3d_Drawer)& theDrawer, const Standard_Real theValue) const;
268
269 Standard_EXPORT void setMaterial (const Handle(Prs3d_Drawer)& theDrawer, const Graphic3d_MaterialAspect& theMaterial, const Standard_Boolean theToKeepColor, const Standard_Boolean theToKeepTransp) const;
270
271 TopoDS_Shape myshape;
272 Bnd_Box myBB;
273 Standard_Boolean myCompBB;
274
275
276private:
277
278
279 Standard_EXPORT void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Prs3d_Presentation)& aPresentation, const TopoDS_Shape& ashape);
280
281 Standard_Real myInitAng;
282
283
284};
285
286
287#include <AIS_Shape.lxx>
288
289
290
291
292
293#endif // _AIS_Shape_HeaderFile