0024624: Lost word in license statement in source files
[occt.git] / src / AIS / AIS_DiameterDimension.hxx
CommitLineData
a6eb515f 1// Copyright (c) 1995-1999 Matra Datavision
973c2be1 2// Copyright (c) 1999-2014 OPEN CASCADE SAS
a6eb515f 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.
14
60bf98ae 15
a6eb515f 16#ifndef _AIS_DiameterDimension_HeaderFile
17#define _AIS_DiameterDimension_HeaderFile
18
19#include <AIS.hxx>
20#include <AIS_Dimension.hxx>
21#include <gp_Pnt.hxx>
22#include <gp_Circ.hxx>
23#include <Standard.hxx>
24#include <Standard_Macro.hxx>
25#include <Standard_DefineHandle.hxx>
26
60bf98ae 27DEFINE_STANDARD_HANDLE (AIS_DiameterDimension, AIS_Dimension)
a6eb515f 28
60bf98ae 29//! Diameter dimension. Can be constructued:
30//! - On generic circle.
31//! - On generic circle with user-defined anchor point on that circle
32//! (dimension plane is oriented to follow the anchor point).
33//! - On generic circle in the specified plane.
34//! - On generic shape containing geometry that can be measured
35//! by diameter dimension: circle wire, circular face, etc.
36//! The anchor point is the location of the left attachement point of
37//! dimension on the circle.
38//! The anchor point computation is processed after dimension plane setting
39//! so that positive flyout direction stands with normal of the circle and
40//! the normal of the plane.
41//! If the plane is user-defined the anchor point was computed as intersection
42//! of the plane and the basis circle. Among two intersection points
43//! the one is selected so that positive flyout direction vector and
44//! the circle normal on the one side form the circle plane.
45//! (corner between positive flyout directio nand the circle normal is acute.)
46//! If the plane is computed automatically (by default it is the circle plane),
47//! the anchor point is the zero parameter point of the circle.
48//!
49//! The dimension is considered as invalid if the user-defined plane
50//! does not include th enachor point and th ecircle center,
51//! if the diameter of the circle is less than Precision::Confusion().
52//! In case if the dimension is built on the arbitrary shape, it can be considered
53//! as invalid if the shape does not contain circle geometry.
54//!
a6eb515f 55class AIS_DiameterDimension : public AIS_Dimension
56{
57public:
fe83e1ea 58
60bf98ae 59 //! Construct diameter dimension for the circle.
60 //! @param theCircle [in] the circle to measure.
61 Standard_EXPORT AIS_DiameterDimension (const gp_Circ& theCircle);
62
63 //! Construct diameter dimension for the circle and orient it correspondingly
64 //! to the passed plane.
65 //! @param theCircle [in] the circle to measure.
66 //! @param thePlane [in] the plane defining preferred orientation
67 //! for dimension.
68 Standard_EXPORT AIS_DiameterDimension (const gp_Circ& theCircle,
69 const gp_Pln& thePlane);
70
71 //! Construct diameter on the passed shape, if applicable.
72 //! @param theShape [in] the shape to measure.
73 Standard_EXPORT AIS_DiameterDimension (const TopoDS_Shape& theShape);
74
75 //! Construct diameter on the passed shape, if applicable - and
76 //! define the preferred plane to orient the dimension.
77 //! @param theShape [in] the shape to measure.
78 //! @param thePlane [in] the plane defining preferred orientation
79 //! for dimension.
80 Standard_EXPORT AIS_DiameterDimension (const TopoDS_Shape& theShape,
81 const gp_Pln& thePlane);
82
83public:
84
85 //! @return measured geometry circle.
86 const gp_Circ& Circle() const
87 {
88 return myCircle;
89 }
90
91 //! @return anchor point on circle for diameter dimension.
92 Standard_EXPORT gp_Pnt AnchorPoint();
93
94 //! @return the measured shape.
95 const TopoDS_Shape& Shape() const
96 {
97 return myShape;
98 }
99
100public:
101
102 //! Measure diameter of the circle.
103 //! The actual dimension plane is used for determining anchor points
104 //! on the circle to attach the dimension lines to.
105 //! The dimension will become invalid if the diameter of the circle
106 //! is less than Precision::Confusion().
107 //! @param theCircle [in] the circle to measure.
108 Standard_EXPORT void SetMeasuredGeometry (const gp_Circ& theCircle);
109
110 //! Measure diameter on the passed shape, if applicable.
111 //! The dimension will become invalid if the passed shape is not
112 //! measurable or if measured diameter value is less than Precision::Confusion().
113 //! @param theShape [in] the shape to measure.
114 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Shape& theShape);
a6eb515f 115
60bf98ae 116 //! @return the display units string.
af203d54 117 Standard_EXPORT virtual const TCollection_AsciiString& GetDisplayUnits() const;
60bf98ae 118
119 //! @return the model units string.
af203d54 120 Standard_EXPORT virtual const TCollection_AsciiString& GetModelUnits() const;
60bf98ae 121
122 Standard_EXPORT virtual void SetDisplayUnits (const TCollection_AsciiString& theUnits);
123
124 Standard_EXPORT virtual void SetModelUnits (const TCollection_AsciiString& theUnits);
125
af203d54 126 Standard_EXPORT virtual void SetTextPosition (const gp_Pnt& theTextPos);
127
128 Standard_EXPORT virtual const gp_Pnt GetTextPosition() const;
129
60bf98ae 130public:
a6eb515f 131
a6eb515f 132 DEFINE_STANDARD_RTTI(AIS_DiameterDimension)
133
134protected:
135
60bf98ae 136 //! Override this method to change logic of anchor point computation.
137 //! Computes anchor point. Its computation is based on the current
138 //! dimension plane. Therfore, anchor point is an intersection of plane
139 //! and circle.
140 //! ATTENTION!
141 //! 1) The plane should be set or computed before.
142 //! 2) The plane should inclide th ecircle center to be valid.
143 Standard_EXPORT virtual void ComputeAnchorPoint();
144
145 Standard_EXPORT virtual void ComputePlane();
146
147 //! Checks if the center of the circle is on the plane.
148 Standard_EXPORT virtual Standard_Boolean CheckPlane (const gp_Pln& thePlane) const;
d7bffd44 149
60bf98ae 150 Standard_EXPORT virtual Standard_Real ComputeValue() const;
a6eb515f 151
60bf98ae 152 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
153 const Handle(Prs3d_Presentation)& thePresentation,
154 const Standard_Integer theMode = 0);
a6eb515f 155
60bf98ae 156 Standard_EXPORT virtual void ComputeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
157 const Handle(SelectMgr_EntityOwner)& theEntityOwner);
158
159protected:
160
af203d54 161 //! Compute points on the circle sides for the dimension plane.
60bf98ae 162 //! Program error exception is raised if the dimension plane "x" direction
163 //! is orthogonal to plane (the "impossible" case). The passed dimension plane
164 //! is the one specially computed to locate dimension presentation in circle.
165 //! @param theCircle [in] the circle.
60bf98ae 166 //! @param theFirstPnt [out] the first point.
167 //! @param theSecondPnt [out] the second point.
168 Standard_EXPORT void ComputeSidePoints (const gp_Circ& theCircle,
60bf98ae 169 gp_Pnt& theFirstPnt,
170 gp_Pnt& theSecondPnt);
171
172 Standard_EXPORT Standard_Boolean IsValidCircle (const gp_Circ& theCircle) const;
173
174 Standard_EXPORT Standard_Boolean IsValidAnchor (const gp_Circ& theCircle,
175 const gp_Pnt& thePnt) const;
a6eb515f 176
d7bffd44 177private:
a6eb515f 178
60bf98ae 179 gp_Circ myCircle;
180 gp_Pnt myAnchorPoint;
181 TopoDS_Shape myShape;
a6eb515f 182};
60bf98ae 183
184#endif // _AIS_DiameterDimension_HeaderFile