0024547: Convertation of the generic classes to the non-generic (math).
[occt.git] / src / AIS / AIS_AngleDimension.hxx
CommitLineData
a6eb515f 1// Copyright (c) 1995-1999 Matra Datavision
2// Copyright (c) 1999-2013 OPEN CASCADE SAS
3//
973c2be1 4// This file is part of Open CASCADE Technology software library.
a6eb515f 5//
973c2be1 6// This library is free software; you can redistribute it and / or modify it
7// under the terms of the GNU Lesser General Public version 2.1 as published
8// by the Free Software Foundation, with special exception defined in the file
9// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10// distribution for complete text of the license and disclaimer of any warranty.
a6eb515f 11//
973c2be1 12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
a6eb515f 14
a6eb515f 15#ifndef _AIS_AngleDimension_HeaderFile
16#define _AIS_AngleDimension_HeaderFile
17
18#include <AIS_Dimension.hxx>
19#include <Geom_Plane.hxx>
20#include <Geom_Line.hxx>
21#include <Geom_Transformation.hxx>
22#include <gp.hxx>
23#include <gp_Ax1.hxx>
24#include <gp_Dir.hxx>
25#include <gp_Pnt.hxx>
26#include <Prs3d_DimensionAspect.hxx>
27#include <Prs3d_Projector.hxx>
28#include <Prs3d_Presentation.hxx>
29#include <Standard.hxx>
30#include <Standard_Macro.hxx>
31#include <Standard_DefineHandle.hxx>
32#include <TopoDS.hxx>
33#include <TopoDS_Edge.hxx>
34#include <TopoDS_Face.hxx>
60bf98ae 35#include <TopoDS_Vertex.hxx>
a6eb515f 36
37DEFINE_STANDARD_HANDLE (AIS_AngleDimension, AIS_Dimension)
38
60bf98ae 39//! Angle dimension. Can be constructed:
40//! - on two intersected edges.
41//! - on three points or vertices.
42//! - on conical face.
43//! - between two intersected faces.
44//!
45//! In case of three points or two intersected edges the dimension plane
46//! (on which dimension presentation is built) can be computed uniquely
47//! as through three defined points can be built only one plane.
48//! Therefore, if user-defined plane differs from this one, the dimension can't be built.
49//!
50//! In cases of two planes automatical plane by default is built on point of the
51//! origin of parametrical space of the first face (the basis surface) so, that
52//! the working plane and two faces intersection forms minimal angle between the faces.
53//! User can define the other point which the dimension plane should pass through
54//! using the appropriate constructor. This point can lay on the one of the faces or not.
55//! Also user can define his own plane but it should pass through the three points
56//! computed on the geometry initialization step (when the constructor or SetMeasuredGeometry() method
57//! is called).
58//!
59//! In case of the conical face the center point of the angle is the apex of the conical surface.
60//! The attachment points are points of the first and the last parameter of the basis circle of the cone.
61//!
a6eb515f 62class AIS_AngleDimension : public AIS_Dimension
63{
64public:
d7bffd44 65
60bf98ae 66 //! Constructs minimum angle dimension between two linear edges (where possible).
67 //! These two edges should be intersected by each other. Otherwise the geometry is not valid.
68 //! @param theFirstEdge [in] the first edge.
69 //! @param theSecondEdge [in] the second edge.
70 Standard_EXPORT AIS_AngleDimension (const TopoDS_Edge& theFirstEdge,
71 const TopoDS_Edge& theSecondEdge);
a6eb515f 72
73 //! Constructs the angle display object defined by three points.
60bf98ae 74 //! @param theFirstPoint [in] the first point (point on first angle flyout).
75 //! @param theSecondPoint [in] the center point of angle dimension.
76 //! @param theThirdPoint [in] the second point (point on second angle flyout).
77 Standard_EXPORT AIS_AngleDimension (const gp_Pnt& theFirstPoint,
78 const gp_Pnt& theSecondPoint,
79 const gp_Pnt& theThirdPoint);
80
81 //! Constructs the angle display object defined by three vertices.
82 //! @param theFirstVertex [in] the first vertex (vertex for first angle flyout).
83 //! @param theSecondVertex [in] the center vertex of angle dimension.
84 //! @param theThirdPoint [in] the second vertex (vertex for second angle flyout).
85 Standard_EXPORT AIS_AngleDimension (const TopoDS_Vertex& theFirstVertex,
86 const TopoDS_Vertex& theSecondVertex,
87 const TopoDS_Vertex& theThirdVertex);
88
89 //! Constructs angle dimension for the cone face.
90 //! @param theCone [in] the conical face.
91 Standard_EXPORT AIS_AngleDimension (const TopoDS_Face& theCone);
92
93 //! Constructs angle dimension between two planar faces.
94 //! @param theFirstFace [in] the first face.
95 //! @param theSecondFace [in] the second face.
96 Standard_EXPORT AIS_AngleDimension (const TopoDS_Face& theFirstFace,
97 const TopoDS_Face& theSecondFace);
98
99 //! Constructs angle dimension between two planar faces.
100 //! @param theFirstFace [in] the first face.
101 //! @param theSecondFace [in] the second face.
102 //! @param thePoint [in] the point which the dimension plane should pass through.
103 //! This point can lay on the one of the faces or not.
104 Standard_EXPORT AIS_AngleDimension (const TopoDS_Face& theFirstFace,
105 const TopoDS_Face& theSecondFace,
106 const gp_Pnt& thePoint);
107
108public:
109
110 //! @return first point forming the angle.
111 const gp_Pnt& FirstPoint() const
112 {
113 return myFirstPoint;
114 }
115
116 //! @return second point forming the angle.
117 const gp_Pnt& SecondPoint() const
118 {
119 return mySecondPoint;
120 }
121
122 //! @return center point forming the angle.
123 const gp_Pnt& CenterPoint() const
124 {
125 return myCenterPoint;
126 }
127
128 //! @return first argument shape.
129 const TopoDS_Shape& FirstShape() const
130 {
131 return myFirstShape;
132 }
133
134 //! @return second argument shape.
135 const TopoDS_Shape& SecondShape() const
136 {
137 return mySecondShape;
138 }
139
140 //! @return third argument shape.
141 const TopoDS_Shape& ThirdShape() const
142 {
143 return myThirdShape;
144 }
145
146public:
147
148 //! Measures minimum angle dimension between two linear edges.
149 //! These two edges should be intersected by each other. Otherwise the geometry is not valid.
150 //! @param theFirstEdge [in] the first edge.
151 //! @param theSecondEdge [in] the second edge.
152 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Edge& theFirstEdge,
153 const TopoDS_Edge& theSecondEdge);
a6eb515f 154
60bf98ae 155 //! Measures angle defined by three points.
156 //! @param theFirstPoint [in] the first point (point on first angle flyout).
157 //! @param theSecondPoint [in] the center point of angle dimension.
158 //! @param theThirdPoint [in] the second point (point on second angle flyout).
159 Standard_EXPORT void SetMeasuredGeometry (const gp_Pnt& theFirstPoint,
160 const gp_Pnt& theSecondPoint,
161 const gp_Pnt& theThridPoint);
a6eb515f 162
60bf98ae 163 //! Measures angle defined by three vertices.
164 //! @param theFirstVertex [in] the first vertex (vertex for first angle flyout).
165 //! @param theSecondVertex [in] the center vertex of angle dimension.
166 //! @param theThirdPoint [in] the second vertex (vertex for second angle flyout).
167 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Vertex& theFirstVertex,
168 const TopoDS_Vertex& theSecondVertex,
169 const TopoDS_Vertex& theThirdVertex);
a6eb515f 170
60bf98ae 171 //! Measures angle of conical face.
172 //! @param theCone [in] the shape to measure.
173 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Face& theCone);
174
175 //! Measures angle between two planar faces.
176 //! @param theFirstFace [in] the first face.
177 //! @param theSecondFace [in] the second face..
178 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Face& theFirstFace,
179 const TopoDS_Face& theSecondFace);
180
181 //! Measures angle between two planar faces.
182 //! @param theFirstFace [in] the first face.
183 //! @param theSecondFace [in] the second face.
184 //! @param thePoint [in] the point which the dimension plane should pass through.
185 //! This point can lay on the one of the faces or not.
186 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Face& theFirstFace,
187 const TopoDS_Face& theSecondFace,
188 const gp_Pnt& thePoint);
189
190 //! @return the display units string.
191 Standard_EXPORT virtual const TCollection_AsciiString& GetDisplayUnits () const;
192
193 //! @return the model units string.
194 Standard_EXPORT virtual const TCollection_AsciiString& GetModelUnits () const;
195
196 Standard_EXPORT virtual void SetDisplayUnits (const TCollection_AsciiString& theUnits);
197
198 Standard_EXPORT virtual void SetModelUnits (const TCollection_AsciiString& theUnits);
a6eb515f 199
d7bffd44 200public:
201
202 DEFINE_STANDARD_RTTI (AIS_AngleDimension)
a6eb515f 203
204protected:
205
60bf98ae 206 //! Initialization of fields that is common to all constructors.
207 Standard_EXPORT void Init();
a6eb515f 208
60bf98ae 209 //! @param theFirstAttach [in] the first attachment point.
210 //! @param theSecondAttach [in] the second attachment point.
211 //! @param theCenter [in] the center point (center point of the angle).
212 //! @return the center of the dimension arc (the main dimension line in case of angle).
213 Standard_EXPORT gp_Pnt GetCenterOnArc (const gp_Pnt& theFirstAttach,
214 const gp_Pnt& theSecondAttach,
215 const gp_Pnt& theCenter);
a6eb515f 216
60bf98ae 217 //! Draws main dimension line (arc).
218 //! @param thePresentation [in] the dimension presentation.
219 //! @param theFirstAttach [in] the first attachment point.
220 //! @param theSecondAttach [in] the second attachment point.
221 //! @param theCenter [in] the center point (center point of the angle).
222 //! @param theRadius [in] the radius of the dimension arc.
223 //! @param theMode [in] the display mode.
224 Standard_EXPORT void DrawArc (const Handle(Prs3d_Presentation)& thePresentation,
225 const gp_Pnt& theFirstAttach,
226 const gp_Pnt& theSecondAttach,
227 const gp_Pnt& theCenter,
228 const Standard_Real theRadius,
229 const Standard_Integer theMode);
a6eb515f 230
60bf98ae 231 //! Draws main dimension line (arc) with text.
232 //! @param thePresentation [in] the dimension presentation.
233 //! @param theFirstAttach [in] the first attachment point.
234 //! @param theSecondAttach [in] the second attachment point.
235 //! @param theCenter [in] the center point (center point of the angle).
236 //! @param theText [in] the text label string.
237 //! @param theTextWidth [in] the text label width.
238 //! @param theMode [in] the display mode.
239 //! @param theLabelPosition [in] the text label vertical and horizontal positioning option
240 //! respectively to the main dimension line.
241 Standard_EXPORT void DrawArcWithText (const Handle(Prs3d_Presentation)& thePresentation,
242 const gp_Pnt& theFirstAttach,
243 const gp_Pnt& theSecondAttach,
244 const gp_Pnt& theCenter,
245 const TCollection_ExtendedString& theText,
246 const Standard_Real theTextWidth,
247 const Standard_Integer theMode,
248 const Standard_Integer theLabelPosition);
a6eb515f 249
60bf98ae 250protected:
251
252 Standard_EXPORT virtual void ComputePlane();
253
254 //! Checks if the plane includes three angle points to build dimension.
255 Standard_EXPORT virtual Standard_Boolean CheckPlane (const gp_Pln& thePlane) const;
256
257 Standard_EXPORT virtual Standard_Real ComputeValue() const;
a6eb515f 258
259 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePM,
260 const Handle(Prs3d_Presentation)& thePresentation,
261 const Standard_Integer theMode = 0);
262
60bf98ae 263 Standard_EXPORT virtual void ComputeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
264 const Handle(SelectMgr_EntityOwner)& theOwner);
a6eb515f 265
60bf98ae 266protected:
a6eb515f 267
60bf98ae 268 //! Init angular dimension to measure angle between two linear edges.
269 //! @return TRUE if the angular dimension can be constructured
270 //! for the passed edges.
271 Standard_EXPORT Standard_Boolean InitTwoEdgesAngle (gp_Pln& theComputedPlane);
a6eb515f 272
60bf98ae 273 //! Init angular dimension to measure angle between two planar faces.
274 //! there is no user-defined poisitoning. So attach points are set
275 //! according to faces geometry (in origin of the first face basis surface).
276 //! @return TRUE if the angular dimension can be constructed
277 //! for the passed faces.
278 Standard_EXPORT Standard_Boolean InitTwoFacesAngle();
a6eb515f 279
60bf98ae 280 //! Init angular dimension to measure angle between two planar faces.
281 //! @param thePointOnFirstFace [in] the point which the dimension plane should pass through.
282 //! This point can lay on the one of the faces or not.
283 //! It will be projected on the first face and this point will be set
284 //! as the first point attach point.
285 //! It defines some kind of dimension positioning over the faces.
286 //! @return TRUE if the angular dimension can be constructed
287 //! for the passed faces.
288 Standard_EXPORT Standard_Boolean InitTwoFacesAngle (const gp_Pnt thePointOnFirstFace);
a6eb515f 289
60bf98ae 290 //! Init angular dimension to measure cone face.
291 //! @return TRUE if the angular dimension can be constructed
292 //! for the passed cone.
293 Standard_EXPORT Standard_Boolean InitConeAngle();
294
295 //! Check that the points forming angle are valid.
296 //! @return TRUE if the points met the following requirements:
297 //! The (P1, Center), (P2, Center) can be built.
298 //! The angle between the vectors > Precision::Angular().
299 Standard_EXPORT Standard_Boolean IsValidPoints (const gp_Pnt& theFirstPoint,
300 const gp_Pnt& theCenterPoint,
301 const gp_Pnt& theSecondPoint) const;
a6eb515f 302
60bf98ae 303private:
a6eb515f 304
60bf98ae 305 gp_Pnt myFirstPoint;
306 gp_Pnt mySecondPoint;
307 gp_Pnt myCenterPoint;
308 TopoDS_Shape myFirstShape;
309 TopoDS_Shape mySecondShape;
310 TopoDS_Shape myThirdShape;
a6eb515f 311};
312
60bf98ae 313#endif // _AIS_AngleDimension_HeaderFile