0031456: Visualization - move out Dimensions and Relations from package AIS to PrsDims
[occt.git] / src / PrsDim / PrsDim_RadiusDimension.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.
a6eb515f 14
787ff240 15#ifndef _PrsDim_RadiusDimension_HeaderFile
16#define _PrsDim_RadiusDimension_HeaderFile
a6eb515f 17
787ff240 18#include <PrsDim_Dimension.hxx>
a6eb515f 19#include <gp_Pnt.hxx>
60bf98ae 20#include <gp_Circ.hxx>
a6eb515f 21#include <Standard.hxx>
22#include <Standard_Macro.hxx>
a6eb515f 23
787ff240 24DEFINE_STANDARD_HANDLE(PrsDim_RadiusDimension, PrsDim_Dimension)
60bf98ae 25
26//! Radius dimension. Can be constructued:
27//! - On generic circle.
28//! - On generic circle with user-defined anchor point on that circle.
29//! - On generic shape containing geometry that can be measured
30//! by diameter dimension: circle wire, arc, circular face, etc.
31//! The anchor point is the location of left attachement point of
32//! dimension on the circle. It can be user-specified, or computed as
33//! middle point on the arc. The radius dimension always lies in the
34//! plane of the measured circle. The dimension is considered as
35//! invalid if the user-specified anchor point is not lying on the circle,
36//! if the radius of the circle is less than Precision::Confusion().
37//! In case if the dimension is built on the arbitrary shape,
38//! it can be considered as invalid if the shape does not contain
39//! circle geometry.
787ff240 40class PrsDim_RadiusDimension : public PrsDim_Dimension
a6eb515f 41{
787ff240 42 DEFINE_STANDARD_RTTIEXT(PrsDim_RadiusDimension, PrsDim_Dimension)
a6eb515f 43public:
a6eb515f 44
60bf98ae 45 //! Create radius dimension for the circle geometry.
46 //! @param theCircle [in] the circle to measure.
787ff240 47 Standard_EXPORT PrsDim_RadiusDimension (const gp_Circ& theCircle);
60bf98ae 48
49 //! Create radius dimension for the circle geometry and define its
50 //! orientation by location of the first point on that circle.
51 //! @param theCircle [in] the circle to measure.
52 //! @param theAnchorPoint [in] the point to define the position
af203d54 53 //! of the dimension attachment on the circle.
787ff240 54 Standard_EXPORT PrsDim_RadiusDimension (const gp_Circ& theCircle,
55 const gp_Pnt& theAnchorPoint);
60bf98ae 56
57 //! Create radius dimension for the arbitrary shape (if possible).
58 //! @param theShape [in] the shape to measure.
787ff240 59 Standard_EXPORT PrsDim_RadiusDimension (const TopoDS_Shape& theShape);
60bf98ae 60
61public:
62
63 //! @return measured geometry circle.
787ff240 64 const gp_Circ& Circle() const { return myCircle; }
60bf98ae 65
66 //! @return anchor point on circle for radius dimension.
787ff240 67 const gp_Pnt& AnchorPoint() const { return myAnchorPoint; }
a6eb515f 68
60bf98ae 69 //! @return the measured shape.
787ff240 70 const TopoDS_Shape& Shape() const { return myShape; }
a6eb515f 71
60bf98ae 72public:
73
74 //! Measure radius of the circle.
75 //! The dimension will become invalid if the radius of the circle
76 //! is less than Precision::Confusion().
77 //! @param theCircle [in] the circle to measure.
d29b2469 78 void SetMeasuredGeometry (const gp_Circ& theCircle) { SetMeasuredGeometry (theCircle, gp_Pnt(), Standard_False); }
60bf98ae 79
80 //! Measure radius of the circle and orient the dimension so
81 //! the dimension lines attaches to anchor point on the circle.
af203d54 82 //! The dimension will become invalid if the radius of the circle
60bf98ae 83 //! is less than Precision::Confusion().
84 //! @param theCircle [in] the circle to measure.
d29b2469 85 //! @param theAnchorPoint [in] the point to attach the dimension lines, should be on the circle
86 //! @param theHasAnchor [in] should be set TRUE if theAnchorPoint should be used
60bf98ae 87 Standard_EXPORT void SetMeasuredGeometry (const gp_Circ& theCircle,
d29b2469 88 const gp_Pnt& theAnchorPoint,
89 const Standard_Boolean theHasAnchor = Standard_True);
60bf98ae 90
91 //! Measure radius on the passed shape, if applicable.
92 //! The dimension will become invalid if the passed shape is not
93 //! measurable or if measured diameter value is less than Precision::Confusion().
94 //! @param theShape [in] the shape to measure.
d29b2469 95 void SetMeasuredGeometry (const TopoDS_Shape& theShape) { SetMeasuredGeometry (theShape, gp_Pnt(), Standard_False); }
96
97 //! Measure radius on the passed shape, if applicable.
98 //! The dimension will become invalid if the passed shape is not
99 //! measurable or if measured diameter value is less than Precision::Confusion().
100 //! @param theShape [in] the shape to measure.
101 //! @param theAnchorPoint [in] the point to attach the dimension lines, should be on the circle
102 //! @param theHasAnchor [in] should be set TRUE if theAnchorPoint should be used
103 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Shape& theShape,
104 const gp_Pnt& theAnchorPoint,
105 const Standard_Boolean theHasAnchor = Standard_True);
60bf98ae 106
107 //! @return the display units string.
79104795 108 Standard_EXPORT virtual const TCollection_AsciiString& GetDisplayUnits() const Standard_OVERRIDE;
60bf98ae 109
110 //! @return the model units string.
79104795 111 Standard_EXPORT virtual const TCollection_AsciiString& GetModelUnits() const Standard_OVERRIDE;
60bf98ae 112
79104795 113 Standard_EXPORT virtual void SetDisplayUnits (const TCollection_AsciiString& theUnits) Standard_OVERRIDE;
60bf98ae 114
79104795 115 Standard_EXPORT virtual void SetModelUnits (const TCollection_AsciiString& theUnits) Standard_OVERRIDE;
a6eb515f 116
79104795 117 Standard_EXPORT virtual void SetTextPosition (const gp_Pnt& theTextPos) Standard_OVERRIDE;
af203d54 118
787ff240 119 Standard_EXPORT virtual gp_Pnt GetTextPosition() const Standard_OVERRIDE;
a6eb515f 120
121protected:
d7bffd44 122
201c2208 123 Standard_EXPORT virtual void ComputePlane();
d7bffd44 124
60bf98ae 125 //! Checks if anchor point and the center of the circle are on the plane.
79104795 126 Standard_EXPORT virtual Standard_Boolean CheckPlane (const gp_Pln& thePlane) const Standard_OVERRIDE;
a6eb515f 127
79104795 128 Standard_EXPORT virtual Standard_Real ComputeValue() const Standard_OVERRIDE;
d7bffd44 129
60bf98ae 130 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
131 const Handle(Prs3d_Presentation)& thePresentation,
79104795 132 const Standard_Integer theMode = 0) Standard_OVERRIDE;
60bf98ae 133
134protected:
135
136 Standard_EXPORT Standard_Boolean IsValidCircle (const gp_Circ& theCircle) const;
137
138 Standard_EXPORT Standard_Boolean IsValidAnchor (const gp_Circ& theCircle,
139 const gp_Pnt& thePnt) const;
a6eb515f 140
d7bffd44 141private:
a6eb515f 142
60bf98ae 143 gp_Circ myCircle;
144 gp_Pnt myAnchorPoint;
145 TopoDS_Shape myShape;
a6eb515f 146};
60bf98ae 147
787ff240 148#endif // _PrsDim_RadiusDimension_HeaderFile