0024428: Implementation of LGPL license
[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//
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.
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.
117 Standard_EXPORT virtual const TCollection_AsciiString& GetDisplayUnits () const;
118
119 //! @return the model units string.
120 Standard_EXPORT virtual const TCollection_AsciiString& GetModelUnits () const;
121
122 Standard_EXPORT virtual void SetDisplayUnits (const TCollection_AsciiString& theUnits);
123
124 Standard_EXPORT virtual void SetModelUnits (const TCollection_AsciiString& theUnits);
125
126public:
a6eb515f 127
a6eb515f 128 DEFINE_STANDARD_RTTI(AIS_DiameterDimension)
129
130protected:
131
60bf98ae 132 //! Override this method to change logic of anchor point computation.
133 //! Computes anchor point. Its computation is based on the current
134 //! dimension plane. Therfore, anchor point is an intersection of plane
135 //! and circle.
136 //! ATTENTION!
137 //! 1) The plane should be set or computed before.
138 //! 2) The plane should inclide th ecircle center to be valid.
139 Standard_EXPORT virtual void ComputeAnchorPoint();
140
141 Standard_EXPORT virtual void ComputePlane();
142
143 //! Checks if the center of the circle is on the plane.
144 Standard_EXPORT virtual Standard_Boolean CheckPlane (const gp_Pln& thePlane) const;
d7bffd44 145
60bf98ae 146 Standard_EXPORT virtual Standard_Real ComputeValue() const;
a6eb515f 147
60bf98ae 148 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
149 const Handle(Prs3d_Presentation)& thePresentation,
150 const Standard_Integer theMode = 0);
a6eb515f 151
60bf98ae 152 Standard_EXPORT virtual void ComputeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
153 const Handle(SelectMgr_EntityOwner)& theEntityOwner);
154
155protected:
156
157 //! Compute points on the circle sides for the specified dimension plane.
158 //! Program error exception is raised if the dimension plane "x" direction
159 //! is orthogonal to plane (the "impossible" case). The passed dimension plane
160 //! is the one specially computed to locate dimension presentation in circle.
161 //! @param theCircle [in] the circle.
162 //! @param thePlane [in] the dimension presentation plane computed.
163 //! @param theFirstPnt [out] the first point.
164 //! @param theSecondPnt [out] the second point.
165 Standard_EXPORT void ComputeSidePoints (const gp_Circ& theCircle,
166 const gp_Pln& thePlane,
167 gp_Pnt& theFirstPnt,
168 gp_Pnt& theSecondPnt);
169
170 Standard_EXPORT Standard_Boolean IsValidCircle (const gp_Circ& theCircle) const;
171
172 Standard_EXPORT Standard_Boolean IsValidAnchor (const gp_Circ& theCircle,
173 const gp_Pnt& thePnt) const;
a6eb515f 174
d7bffd44 175private:
a6eb515f 176
60bf98ae 177 gp_Circ myCircle;
178 gp_Pnt myAnchorPoint;
179 TopoDS_Shape myShape;
a6eb515f 180};
60bf98ae 181
182#endif // _AIS_DiameterDimension_HeaderFile