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