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