0030523: Visualization - Highlighting does not work anymore
[occt.git] / src / AIS / AIS.hxx
CommitLineData
42cf5bc1 1// Created on: 1996-12-11
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_HeaderFile
18#define _AIS_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_DefineAlloc.hxx>
22#include <Standard_Handle.hxx>
23
24#include <Standard_Boolean.hxx>
25#include <Standard_Integer.hxx>
26#include <Standard_Real.hxx>
27#include <AIS_KindOfSurface.hxx>
28#include <Prs3d_Drawer.hxx>
29#include <Quantity_NameOfColor.hxx>
30#include <Aspect_TypeOfLine.hxx>
31#include <Aspect_TypeOfMarker.hxx>
32class gp_Pnt;
33class TopoDS_Shape;
34class gp_Lin;
35class Geom_Curve;
36class TopoDS_Edge;
37class Geom_Plane;
38class TopoDS_Vertex;
39class TopoDS_Face;
40class gp_Pln;
41class Geom_Surface;
42class gp_Dir;
43class Bnd_Box;
44class gp_Elips;
45class Prs3d_Presentation;
46class AIS_Triangulation;
47class AIS_InteractiveContext;
48class AIS_GraphicTool;
42cf5bc1 49class AIS_GlobalStatus;
50class AIS_InteractiveObject;
51class AIS_Point;
52class AIS_Axis;
53class AIS_Trihedron;
54class AIS_PlaneTrihedron;
55class AIS_Line;
56class AIS_Circle;
57class AIS_Plane;
58class AIS_Shape;
59class AIS_ConnectedInteractive;
60class AIS_MultipleConnectedInteractive;
61class AIS_DimensionOwner;
62class AIS_Relation;
63class AIS_EllipseRadiusDimension;
64class AIS_MaxRadiusDimension;
65class AIS_MinRadiusDimension;
66class AIS_Chamf2dDimension;
67class AIS_Chamf3dDimension;
68class AIS_OffsetDimension;
69class AIS_FixRelation;
70class AIS_PerpendicularRelation;
71class AIS_ParallelRelation;
72class AIS_TangentRelation;
73class AIS_ConcentricRelation;
74class AIS_IdenticRelation;
75class AIS_SymmetricRelation;
76class AIS_MidPointRelation;
77class AIS_EqualRadiusRelation;
78class AIS_EqualDistanceRelation;
79class AIS_TypeFilter;
80class AIS_SignatureFilter;
81class AIS_ExclusionFilter;
82class AIS_AttributeFilter;
83class AIS_C0RegularityFilter;
84class AIS_BadEdgeFilter;
85class AIS_Selection;
86
87
8c088c52 88//! Application Interactive Services provide the means to create links between an application GUI viewer and
89//! the packages which are used to manage selection and presentation.
90//! The tools AIS defined in order to do this include different sorts of entities:
91//! both the selectable viewable objects themselves and the context and attribute managers to define their selection and display.
92//! To orient the user as he works in a modeling environment, views and selections must be comprehensible.
93//! There must be several different sorts of selectable and viewable object defined.
94//! These must also be interactive, that is, connecting graphic representation and the underlying reference geometry.
95//! These entities are called Interactive Objects, and are divided into four types:
42cf5bc1 96//! - the Datum
97//! - the Relation
98//! - the Object
99//! - None.
8c088c52 100//! The Datum groups together the construction elements such as lines, circles, points, trihedra, plane trihedra, planes and axes.
101//! The Relation is made up of constraints on one or more interactive shapes and the corresponding reference geometry.
102//! For example, you might want to constrain two edges in a parallel relation.
103//! This contraint is considered as an object in its own right, and is shown as a sensitive primitive.
104//! This takes the graphic form of a perpendicular arrow marked with the || symbol and lying between the two edges.
105//! The Object type includes topological shapes, and connections between shapes.
106//! None, in order not to eliminate the object, tells the application to look further until it finds an object definition in its generation which is accepted.
107//! Inside these categories, you have the possibility of an additional characterization by means of a signature.
108//! The signature provides an index to the further characterization.
109//! By default, the Interactive Object has a None type and a signature of 0 (equivalent to None.)
110//! If you want to give a particular type and signature to your interactive object, you must redefine the two virtual methods: Type and Signature.
111//! In the C++ inheritance structure of the package, each class representing a specific Interactive Object inherits AIS_InteractiveObject.
112//! Among these inheriting classes, AIS_Relation functions as the abstract mother class for tinheriting classes defining display of specific relational constraints and types of dimension.
113//! Some of these include:
114//! - display of constraints based on relations of symmetry, tangency, parallelism and concentricity
115//! - display of dimensions for angles, offsets, diameters, radii and chamfers.
116//! No viewer can show everything at once with any coherence or clarity.
117//! Views must be managed carefully both sequentially and at any given instant.
118//! Another function of the view is that of a context to carry out design in.
119//! The design changes are applied to the objects in the view and then extended to the underlying reference geometry by a solver.
120//! To make sense of this complicated visual data, several display and selection tools are required.
121//! To facilitate management, each object and each construction element has a selection priority.
122//! There are also means to modify the default priority.
123//! To define an environment of dynamic detection, you can use standard filter classes or create your own.
124//! A filter questions the owner of the sensitive primitive to determine if it has the the desired qualities.
125//! If it answers positively, it is kept. If not, it is rejected.
42cf5bc1 126//! The standard filters supplied in AIS include:
8c088c52 127//! - AIS_AttributeFilter
128//! - AIS_SignatureFilter
129//! - AIS_TypeFilter.
130//! A set of functions allows you to choose the interactive objects which you want to act on, the selection modes which you want to activate.
131//! An interactive object can have a certain number of graphic attributes which are specific to it, such as visualization mode, color, and material.
132//! By the same token, the interactive context has a set of graphic attributes, the Drawer which is valid by default for the objects it controls.
133//! When an interactive object is visualized, the required graphic attributes are first taken from the object's own Drawer if one exists, or from the context drawer for the others.
42cf5bc1 134class AIS
135{
136public:
137
138 DEFINE_STANDARD_ALLOC
139
140
141
142 //! Returns the nearest point in a shape. This is used by
143 //! several classes in calculation of dimensions.
144 Standard_EXPORT static gp_Pnt Nearest (const TopoDS_Shape& aShape, const gp_Pnt& aPoint);
145
146
147 //! @return the nearest point on the line.
148 Standard_EXPORT static gp_Pnt Nearest (const gp_Lin& theLine, const gp_Pnt& thePoint);
149
150
151 //! For the given point finds nearest point on the curve,
152 //! @return TRUE if found point is belongs to the curve
153 //! and FALSE otherwise.
154 Standard_EXPORT static Standard_Boolean Nearest (const Handle(Geom_Curve)& theCurve, const gp_Pnt& thePoint, const gp_Pnt& theFirstPoint, const gp_Pnt& theLastPoint, gp_Pnt& theNearestPoint);
155
156 Standard_EXPORT static gp_Pnt Farest (const TopoDS_Shape& aShape, const gp_Pnt& aPoint);
157
158 //! Used by 2d Relation only
159 //! Computes the 3d geometry of <anEdge> in the current WorkingPlane
160 //! and the extremities if any
161 //! Return TRUE if ok.
162 Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Edge& theEdge, Handle(Geom_Curve)& theCurve, gp_Pnt& theFirstPnt, gp_Pnt& theLastPnt);
163
164 //! Used by dimensions only.
165 //! Computes the 3d geometry of <anEdge>.
166 //! Return TRUE if ok.
167 Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Edge& theEdge, Handle(Geom_Curve)& theCurve, gp_Pnt& theFirstPnt, gp_Pnt& theLastPnt, Standard_Boolean& theIsInfinite);
168
169 //! Used by 2d Relation only
170 //! Computes the 3d geometry of <anEdge> in the current WorkingPlane
171 //! and the extremities if any.
172 //! If <aCurve> is not in the current plane, <extCurve> contains
173 //! the not projected curve associated to <anEdge>.
174 //! If <anEdge> is infinite, <isinfinite> = true and the 2
175 //! parameters <FirstPnt> and <LastPnt> have no signification.
176 //! Return TRUE if ok.
177 Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Edge& theEdge, Handle(Geom_Curve)& theCurve, gp_Pnt& theFirstPnt, gp_Pnt& theLastPnt, Handle(Geom_Curve)& theExtCurve, Standard_Boolean& theIsInfinite, Standard_Boolean& theIsOnPlane, const Handle(Geom_Plane)& thePlane);
178
179 //! Used by 2d Relation only
180 //! Computes the 3d geometry of <anEdge> in the current WorkingPlane
181 //! and the extremities if any
182 //! Return TRUE if ok.
183 Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Edge& theFirstEdge, const TopoDS_Edge& theSecondEdge, Handle(Geom_Curve)& theFirstCurve, Handle(Geom_Curve)& theSecondCurve, gp_Pnt& theFirstPnt1, gp_Pnt& theLastPnt1, gp_Pnt& theFirstPnt2, gp_Pnt& theLastPnt2, const Handle(Geom_Plane)& thePlane);
184
185 //! Used by dimensions only.Computes the 3d geometry
186 //! of<anEdge1> and <anEdge2> and checks if they are infinite.
187 Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Edge& theFirstEdge, const TopoDS_Edge& theSecondEdge, Handle(Geom_Curve)& theFirstCurve, Handle(Geom_Curve)& theSecondCurve, gp_Pnt& theFirstPnt1, gp_Pnt& theLastPnt1, gp_Pnt& theFirstPnt2, gp_Pnt& theLastPnt2, Standard_Boolean& theIsinfinite1, Standard_Boolean& theIsinfinite2);
188
189 //! Used by 2d Relation only Computes the 3d geometry
190 //! of<anEdge1> and <anEdge2> in the current Plane and the
191 //! extremities if any. Return in ExtCurve the 3d curve
192 //! (not projected in the plane) of the first edge if
193 //! <indexExt> =1 or of the 2nd edge if <indexExt> = 2. If
194 //! <indexExt> = 0, ExtCurve is Null. if there is an edge
195 //! external to the plane, <isinfinite> is true if this
196 //! edge is infinite. So, the extremities of it are not
197 //! significant. Return TRUE if ok
198 Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Edge& theFirstEdge, const TopoDS_Edge& theSecondEdge, Standard_Integer& theExtIndex, Handle(Geom_Curve)& theFirstCurve, Handle(Geom_Curve)& theSecondCurve, gp_Pnt& theFirstPnt1, gp_Pnt& theLastPnt1, gp_Pnt& theFirstPnt2, gp_Pnt& theLastPnt2, Handle(Geom_Curve)& theExtCurve, Standard_Boolean& theIsinfinite1, Standard_Boolean& theIsinfinite2, const Handle(Geom_Plane)& thePlane);
199
200 //! Checks if aCurve belongs to aPlane; if not, projects aCurve in aPlane
201 //! and returns aCurve;
202 //! Return TRUE if ok
203 Standard_EXPORT static Standard_Boolean ComputeGeomCurve (Handle(Geom_Curve)& aCurve, const Standard_Real first1, const Standard_Real last1, gp_Pnt& FirstPnt1, gp_Pnt& LastPnt1, const Handle(Geom_Plane)& aPlane, Standard_Boolean& isOnPlane);
204
205 Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Vertex& aVertex, gp_Pnt& point, const Handle(Geom_Plane)& aPlane, Standard_Boolean& isOnPlane);
206
207 //! Tryes to get Plane from Face. Returns Surface of Face
208 //! in aSurf. Returns Standard_True and Plane of Face in
209 //! aPlane in following cases:
210 //! Face is Plane, Offset of Plane,
211 //! Extrusion of Line and Offset of Extrusion of Line
212 //! Returns pure type of Surface which can be:
213 //! Plane, Cylinder, Cone, Sphere, Torus,
214 //! SurfaceOfRevolution, SurfaceOfExtrusion
215 Standard_EXPORT static Standard_Boolean GetPlaneFromFace (const TopoDS_Face& aFace, gp_Pln& aPlane, Handle(Geom_Surface)& aSurf, AIS_KindOfSurface& aSurfType, Standard_Real& Offset);
216
217 Standard_EXPORT static void InitFaceLength (const TopoDS_Face& aFace, gp_Pln& aPlane, Handle(Geom_Surface)& aSurface, AIS_KindOfSurface& aSurfaceType, Standard_Real& anOffset);
218
219 //! Finds attachment points on two curvilinear faces for length dimension.
220 //! @param thePlaneDir [in] the direction on the dimension plane to
221 //! compute the plane automatically. It will not be taken into account if
222 //! plane is defined by user.
223 Standard_EXPORT static void InitLengthBetweenCurvilinearFaces (const TopoDS_Face& theFirstFace, const TopoDS_Face& theSecondFace, Handle(Geom_Surface)& theFirstSurf, Handle(Geom_Surface)& theSecondSurf, gp_Pnt& theFirstAttach, gp_Pnt& theSecondAttach, gp_Dir& theDirOnPlane);
224
225 //! Finds three points for the angle dimension between
226 //! two planes.
227 Standard_EXPORT static Standard_Boolean InitAngleBetweenPlanarFaces (const TopoDS_Face& theFirstFace, const TopoDS_Face& theSecondFace, gp_Pnt& theCenter, gp_Pnt& theFirstAttach, gp_Pnt& theSecondAttach, const Standard_Boolean theIsFirstPointSet = Standard_False);
228
229 //! Finds three points for the angle dimension between
230 //! two curvilinear surfaces.
231 Standard_EXPORT static Standard_Boolean InitAngleBetweenCurvilinearFaces (const TopoDS_Face& theFirstFace, const TopoDS_Face& theSecondFace, const AIS_KindOfSurface theFirstSurfType, const AIS_KindOfSurface theSecondSurfType, gp_Pnt& theCenter, gp_Pnt& theFirstAttach, gp_Pnt& theSecondAttach, const Standard_Boolean theIsFirstPointSet = Standard_False);
232
233 Standard_EXPORT static gp_Pnt ProjectPointOnPlane (const gp_Pnt& aPoint, const gp_Pln& aPlane);
234
235 Standard_EXPORT static gp_Pnt ProjectPointOnLine (const gp_Pnt& aPoint, const gp_Lin& aLine);
236
237 Standard_EXPORT static gp_Pnt TranslatePointToBound (const gp_Pnt& aPoint, const gp_Dir& aDir, const Bnd_Box& aBndBox);
238
239 //! returns True if point with anAttachPar is
240 //! in domain of arc
241 Standard_EXPORT static Standard_Boolean InDomain (const Standard_Real aFirstPar, const Standard_Real aLastPar, const Standard_Real anAttachPar);
242
243 //! computes nearest to ellipse arc apex
244 Standard_EXPORT static gp_Pnt NearestApex (const gp_Elips& elips, const gp_Pnt& pApex, const gp_Pnt& nApex, const Standard_Real fpara, const Standard_Real lpara, Standard_Boolean& IsInDomain);
245
246 //! computes length of ellipse arc in parametric units
247 Standard_EXPORT static Standard_Real DistanceFromApex (const gp_Elips& elips, const gp_Pnt& Apex, const Standard_Real par);
248
249 Standard_EXPORT static void ComputeProjEdgePresentation (const Handle(Prs3d_Presentation)& aPres, const Handle(Prs3d_Drawer)& aDrawer, const TopoDS_Edge& anEdge, const Handle(Geom_Curve)& ProjCurve, const gp_Pnt& FirstP, const gp_Pnt& LastP, const Quantity_NameOfColor aColor = Quantity_NOC_PURPLE, const Standard_Real aWidth = 2, const Aspect_TypeOfLine aProjTOL = Aspect_TOL_DASH, const Aspect_TypeOfLine aCallTOL = Aspect_TOL_DOT);
250
251 Standard_EXPORT static void ComputeProjVertexPresentation (const Handle(Prs3d_Presentation)& aPres, const Handle(Prs3d_Drawer)& aDrawer, const TopoDS_Vertex& aVertex, const gp_Pnt& ProjPoint, const Quantity_NameOfColor aColor = Quantity_NOC_PURPLE, const Standard_Real aWidth = 2, const Aspect_TypeOfMarker aProjTOM = Aspect_TOM_PLUS, const Aspect_TypeOfLine aCallTOL = Aspect_TOL_DOT);
252
42cf5bc1 253};
254
42cf5bc1 255#endif // _AIS_HeaderFile