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