0026911: Configuration, CMake - strips symbol information from the binary in release...
[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//
d5f74e42 6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 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>
ec357c5c 31#include <Standard_Type.hxx>
a6eb515f 32#include <TopoDS.hxx>
33#include <TopoDS_Edge.hxx>
34#include <TopoDS_Face.hxx>
60bf98ae 35#include <TopoDS_Vertex.hxx>
a6eb515f 36
c04c30b3 37class AIS_AngleDimension;
a6eb515f 38DEFINE_STANDARD_HANDLE (AIS_AngleDimension, AIS_Dimension)
39
60bf98ae 40//! Angle dimension. Can be constructed:
41//! - on two intersected edges.
42//! - on three points or vertices.
43//! - on conical face.
44//! - between two intersected faces.
45//!
46//! In case of three points or two intersected edges the dimension plane
47//! (on which dimension presentation is built) can be computed uniquely
48//! as through three defined points can be built only one plane.
49//! Therefore, if user-defined plane differs from this one, the dimension can't be built.
50//!
af203d54 51//! In cases of two planes automatic plane by default is built on point of the
52//! origin of parametric space of the first face (the basis surface) so, that
60bf98ae 53//! the working plane and two faces intersection forms minimal angle between the faces.
54//! User can define the other point which the dimension plane should pass through
55//! using the appropriate constructor. This point can lay on the one of the faces or not.
56//! Also user can define his own plane but it should pass through the three points
57//! computed on the geometry initialization step (when the constructor or SetMeasuredGeometry() method
58//! is called).
59//!
60//! In case of the conical face the center point of the angle is the apex of the conical surface.
61//! The attachment points are points of the first and the last parameter of the basis circle of the cone.
62//!
a6eb515f 63class AIS_AngleDimension : public AIS_Dimension
64{
65public:
d7bffd44 66
60bf98ae 67 //! Constructs minimum angle dimension between two linear edges (where possible).
68 //! These two edges should be intersected by each other. Otherwise the geometry is not valid.
69 //! @param theFirstEdge [in] the first edge.
70 //! @param theSecondEdge [in] the second edge.
71 Standard_EXPORT AIS_AngleDimension (const TopoDS_Edge& theFirstEdge,
72 const TopoDS_Edge& theSecondEdge);
a6eb515f 73
74 //! Constructs the angle display object defined by three points.
60bf98ae 75 //! @param theFirstPoint [in] the first point (point on first angle flyout).
76 //! @param theSecondPoint [in] the center point of angle dimension.
77 //! @param theThirdPoint [in] the second point (point on second angle flyout).
78 Standard_EXPORT AIS_AngleDimension (const gp_Pnt& theFirstPoint,
79 const gp_Pnt& theSecondPoint,
80 const gp_Pnt& theThirdPoint);
81
82 //! Constructs the angle display object defined by three vertices.
83 //! @param theFirstVertex [in] the first vertex (vertex for first angle flyout).
84 //! @param theSecondVertex [in] the center vertex of angle dimension.
85 //! @param theThirdPoint [in] the second vertex (vertex for second angle flyout).
86 Standard_EXPORT AIS_AngleDimension (const TopoDS_Vertex& theFirstVertex,
87 const TopoDS_Vertex& theSecondVertex,
88 const TopoDS_Vertex& theThirdVertex);
89
90 //! Constructs angle dimension for the cone face.
91 //! @param theCone [in] the conical face.
92 Standard_EXPORT AIS_AngleDimension (const TopoDS_Face& theCone);
93
94 //! Constructs angle dimension between two planar faces.
95 //! @param theFirstFace [in] the first face.
96 //! @param theSecondFace [in] the second face.
97 Standard_EXPORT AIS_AngleDimension (const TopoDS_Face& theFirstFace,
98 const TopoDS_Face& theSecondFace);
99
100 //! Constructs angle dimension between two planar faces.
101 //! @param theFirstFace [in] the first face.
102 //! @param theSecondFace [in] the second face.
103 //! @param thePoint [in] the point which the dimension plane should pass through.
104 //! This point can lay on the one of the faces or not.
105 Standard_EXPORT AIS_AngleDimension (const TopoDS_Face& theFirstFace,
106 const TopoDS_Face& theSecondFace,
107 const gp_Pnt& thePoint);
108
109public:
110
111 //! @return first point forming the angle.
112 const gp_Pnt& FirstPoint() const
113 {
114 return myFirstPoint;
115 }
116
117 //! @return second point forming the angle.
118 const gp_Pnt& SecondPoint() const
119 {
120 return mySecondPoint;
121 }
122
123 //! @return center point forming the angle.
124 const gp_Pnt& CenterPoint() const
125 {
126 return myCenterPoint;
127 }
128
129 //! @return first argument shape.
130 const TopoDS_Shape& FirstShape() const
131 {
132 return myFirstShape;
133 }
134
135 //! @return second argument shape.
136 const TopoDS_Shape& SecondShape() const
137 {
138 return mySecondShape;
139 }
140
141 //! @return third argument shape.
142 const TopoDS_Shape& ThirdShape() const
143 {
144 return myThirdShape;
145 }
146
147public:
148
149 //! Measures minimum angle dimension between two linear edges.
150 //! These two edges should be intersected by each other. Otherwise the geometry is not valid.
151 //! @param theFirstEdge [in] the first edge.
152 //! @param theSecondEdge [in] the second edge.
153 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Edge& theFirstEdge,
154 const TopoDS_Edge& theSecondEdge);
a6eb515f 155
60bf98ae 156 //! Measures angle defined by three points.
157 //! @param theFirstPoint [in] the first point (point on first angle flyout).
158 //! @param theSecondPoint [in] the center point of angle dimension.
159 //! @param theThirdPoint [in] the second point (point on second angle flyout).
160 Standard_EXPORT void SetMeasuredGeometry (const gp_Pnt& theFirstPoint,
161 const gp_Pnt& theSecondPoint,
162 const gp_Pnt& theThridPoint);
a6eb515f 163
60bf98ae 164 //! Measures angle defined by three vertices.
165 //! @param theFirstVertex [in] the first vertex (vertex for first angle flyout).
166 //! @param theSecondVertex [in] the center vertex of angle dimension.
167 //! @param theThirdPoint [in] the second vertex (vertex for second angle flyout).
168 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Vertex& theFirstVertex,
169 const TopoDS_Vertex& theSecondVertex,
170 const TopoDS_Vertex& theThirdVertex);
a6eb515f 171
60bf98ae 172 //! Measures angle of conical face.
173 //! @param theCone [in] the shape to measure.
174 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Face& theCone);
175
176 //! Measures angle between two planar faces.
177 //! @param theFirstFace [in] the first face.
178 //! @param theSecondFace [in] the second face..
179 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Face& theFirstFace,
180 const TopoDS_Face& theSecondFace);
181
182 //! Measures angle between two planar faces.
183 //! @param theFirstFace [in] the first face.
184 //! @param theSecondFace [in] the second face.
185 //! @param thePoint [in] the point which the dimension plane should pass through.
186 //! This point can lay on the one of the faces or not.
187 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Face& theFirstFace,
188 const TopoDS_Face& theSecondFace,
189 const gp_Pnt& thePoint);
190
191 //! @return the display units string.
af203d54 192 Standard_EXPORT virtual const TCollection_AsciiString& GetDisplayUnits() const;
60bf98ae 193
194 //! @return the model units string.
af203d54 195 Standard_EXPORT virtual const TCollection_AsciiString& GetModelUnits() const;
60bf98ae 196
197 Standard_EXPORT virtual void SetDisplayUnits (const TCollection_AsciiString& theUnits);
198
199 Standard_EXPORT virtual void SetModelUnits (const TCollection_AsciiString& theUnits);
a6eb515f 200
af203d54 201 //! Principle of horizontal text alignment settings:
202 //! - divide circle into two halves according to attachment points
203 //! - if aTextPos is between attach points -> Center + positive flyout
204 //! - if aTextPos is not between attach points but in this half -> Left or Right + positive flyout
205 //! - if aTextPos is between reflections of attach points -> Center + negative flyout
206 //! - if aTextPos is not between reflections of attach points -> Left or Right + negative flyout
207 Standard_EXPORT virtual void SetTextPosition (const gp_Pnt& theTextPos);
208
209 Standard_EXPORT virtual const gp_Pnt GetTextPosition () const;
210
d7bffd44 211public:
212
ec357c5c 213 DEFINE_STANDARD_RTTI (AIS_AngleDimension, AIS_Dimension)
a6eb515f 214
215protected:
216
60bf98ae 217 //! Initialization of fields that is common to all constructors.
218 Standard_EXPORT void Init();
a6eb515f 219
60bf98ae 220 //! @param theFirstAttach [in] the first attachment point.
221 //! @param theSecondAttach [in] the second attachment point.
222 //! @param theCenter [in] the center point (center point of the angle).
223 //! @return the center of the dimension arc (the main dimension line in case of angle).
224 Standard_EXPORT gp_Pnt GetCenterOnArc (const gp_Pnt& theFirstAttach,
225 const gp_Pnt& theSecondAttach,
af203d54 226 const gp_Pnt& theCenter) const;
a6eb515f 227
60bf98ae 228 //! Draws main dimension line (arc).
229 //! @param thePresentation [in] the dimension presentation.
230 //! @param theFirstAttach [in] the first attachment point.
231 //! @param theSecondAttach [in] the second attachment point.
232 //! @param theCenter [in] the center point (center point of the angle).
233 //! @param theRadius [in] the radius of the dimension arc.
234 //! @param theMode [in] the display mode.
235 Standard_EXPORT void DrawArc (const Handle(Prs3d_Presentation)& thePresentation,
236 const gp_Pnt& theFirstAttach,
237 const gp_Pnt& theSecondAttach,
238 const gp_Pnt& theCenter,
239 const Standard_Real theRadius,
240 const Standard_Integer theMode);
a6eb515f 241
60bf98ae 242 //! Draws main dimension line (arc) with text.
243 //! @param thePresentation [in] the dimension presentation.
244 //! @param theFirstAttach [in] the first attachment point.
245 //! @param theSecondAttach [in] the second attachment point.
246 //! @param theCenter [in] the center point (center point of the angle).
247 //! @param theText [in] the text label string.
248 //! @param theTextWidth [in] the text label width.
249 //! @param theMode [in] the display mode.
250 //! @param theLabelPosition [in] the text label vertical and horizontal positioning option
251 //! respectively to the main dimension line.
252 Standard_EXPORT void DrawArcWithText (const Handle(Prs3d_Presentation)& thePresentation,
253 const gp_Pnt& theFirstAttach,
254 const gp_Pnt& theSecondAttach,
255 const gp_Pnt& theCenter,
256 const TCollection_ExtendedString& theText,
257 const Standard_Real theTextWidth,
258 const Standard_Integer theMode,
259 const Standard_Integer theLabelPosition);
a6eb515f 260
af203d54 261 //! Fits text alignment relatively to the dimension line;
262 //! it computes the value of label position and arrow orientation
263 //! according set in the aspect and dimension properties.
264 //! @param theHorizontalTextPos [in] the horizontal alignment for text position.
265 //! @param theLabelPosition [out] the label position, contains bits that defines
266 //! vertical and horizontal alignment. (for internal usage in count text position).
267 //! @param theIsArrowExternal [out] is the arrows external,
268 //! if arrow orientation in the dimension aspect is Prs3d_DAO_Fit, it fits arrow
269 //! orientation automatically.
270 Standard_EXPORT void FitTextAlignment (const Prs3d_DimensionTextHorizontalPosition& theHorizontalTextPos,
271 Standard_Integer& theLabelPosition,
272 Standard_Boolean& theIsArrowsExternal) const;
273
274 //! Adjusts aspect parameters according the text position:
275 //! extension size, vertical text alignment and flyout.
af203d54 276 //! @param theTextPos [in] the user defined 3d point of text position.
277 //! @param theExtensionSize [out] the adjusted extension size.
278 //! @param theAlignment [out] the horizontal label alignment.
91b16a64 279 //! @param theFlyout [out] the adjusted value of flyout.
af203d54 280 Standard_EXPORT void AdjustParameters (const gp_Pnt& theTextPos,
281 Standard_Real& theExtensionSize,
91b16a64 282 Prs3d_DimensionTextHorizontalPosition& theAlignment,
283 Standard_Real& theFlyout) const;
af203d54 284
60bf98ae 285protected:
286
287 Standard_EXPORT virtual void ComputePlane();
288
289 //! Checks if the plane includes three angle points to build dimension.
290 Standard_EXPORT virtual Standard_Boolean CheckPlane (const gp_Pln& thePlane) const;
291
292 Standard_EXPORT virtual Standard_Real ComputeValue() const;
a6eb515f 293
294 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePM,
295 const Handle(Prs3d_Presentation)& thePresentation,
296 const Standard_Integer theMode = 0);
297
60bf98ae 298 Standard_EXPORT virtual void ComputeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
299 const Handle(SelectMgr_EntityOwner)& theOwner);
a6eb515f 300
60bf98ae 301protected:
a6eb515f 302
60bf98ae 303 //! Init angular dimension to measure angle between two linear edges.
304 //! @return TRUE if the angular dimension can be constructured
305 //! for the passed edges.
306 Standard_EXPORT Standard_Boolean InitTwoEdgesAngle (gp_Pln& theComputedPlane);
a6eb515f 307
60bf98ae 308 //! Init angular dimension to measure angle between two planar faces.
309 //! there is no user-defined poisitoning. So attach points are set
310 //! according to faces geometry (in origin of the first face basis surface).
311 //! @return TRUE if the angular dimension can be constructed
312 //! for the passed faces.
313 Standard_EXPORT Standard_Boolean InitTwoFacesAngle();
a6eb515f 314
60bf98ae 315 //! Init angular dimension to measure angle between two planar faces.
316 //! @param thePointOnFirstFace [in] the point which the dimension plane should pass through.
317 //! This point can lay on the one of the faces or not.
318 //! It will be projected on the first face and this point will be set
319 //! as the first point attach point.
320 //! It defines some kind of dimension positioning over the faces.
321 //! @return TRUE if the angular dimension can be constructed
322 //! for the passed faces.
323 Standard_EXPORT Standard_Boolean InitTwoFacesAngle (const gp_Pnt thePointOnFirstFace);
a6eb515f 324
60bf98ae 325 //! Init angular dimension to measure cone face.
326 //! @return TRUE if the angular dimension can be constructed
327 //! for the passed cone.
328 Standard_EXPORT Standard_Boolean InitConeAngle();
329
330 //! Check that the points forming angle are valid.
331 //! @return TRUE if the points met the following requirements:
332 //! The (P1, Center), (P2, Center) can be built.
333 //! The angle between the vectors > Precision::Angular().
334 Standard_EXPORT Standard_Boolean IsValidPoints (const gp_Pnt& theFirstPoint,
335 const gp_Pnt& theCenterPoint,
336 const gp_Pnt& theSecondPoint) const;
a6eb515f 337
60bf98ae 338private:
a6eb515f 339
60bf98ae 340 gp_Pnt myFirstPoint;
341 gp_Pnt mySecondPoint;
342 gp_Pnt myCenterPoint;
343 TopoDS_Shape myFirstShape;
344 TopoDS_Shape mySecondShape;
345 TopoDS_Shape myThirdShape;
a6eb515f 346};
347
60bf98ae 348#endif // _AIS_AngleDimension_HeaderFile