0031459: Visualization, AIS_TextLabel - add missing getters
[occt.git] / src / AIS / AIS_LengthDimension.hxx
CommitLineData
a6eb515f 1// Copyright (c) 1999-2013 OPEN CASCADE SAS
2//
973c2be1 3// This file is part of Open CASCADE Technology software library.
a6eb515f 4//
d5f74e42 5// This library is free software; you can redistribute it and/or modify it under
6// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 7// by the Free Software Foundation, with special exception defined in the file
8// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9// distribution for complete text of the license and disclaimer of any warranty.
a6eb515f 10//
973c2be1 11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
a6eb515f 13
14#ifndef _AIS_LengthDimension_HeaderFile
15#define _AIS_LengthDimension_HeaderFile
16
17#include <AIS.hxx>
18#include <AIS_Dimension.hxx>
a6eb515f 19#include <AIS_KindOfDimension.hxx>
20#include <Geom_Plane.hxx>
a6eb515f 21#include <gp_Pnt.hxx>
22#include <gp_Dir.hxx>
23#include <Prs3d_DimensionAspect.hxx>
6262338c 24#include <Prs3d_Drawer.hxx>
a6eb515f 25#include <TopoDS.hxx>
26#include <TopoDS_Vertex.hxx>
a6eb515f 27
60bf98ae 28DEFINE_STANDARD_HANDLE (AIS_LengthDimension, AIS_Dimension)
a6eb515f 29
60bf98ae 30//! Length dimension. Can be constructued:
31//! - Between two generic points.
32//! - Between two vertices.
33//! - Between two faces.
34//! - Between two parallel edges.
35//! - Between face and edge.
36//!
37//! In case of two points (vertices) or one linear edge the user-defined plane
38//! that includes this geometry is necessary to be set.
39//!
40//! In case of face-edge, edge-vertex or face-face lengthes the automatic plane
41//! computing is allowed. For this plane the third point is found on the
42//! edge or on the face.
1c078d3b 43//!
60bf98ae 44//! Please note that if the inappropriate geometry is defined
45//! or the distance between measured points is less than
46//! Precision::Confusion(), the dimension is invalid and its
47//! presentation can not be computed.
a6eb515f 48class AIS_LengthDimension : public AIS_Dimension
49{
50public:
51
60bf98ae 52 //! Construct length dimension between face and edge.
53 //! Here dimension can be built without user-defined plane.
54 //! @param theFace [in] the face (first shape).
55 //! @param theEdge [in] the edge (second shape).
56 Standard_EXPORT AIS_LengthDimension (const TopoDS_Face& theFace,
57 const TopoDS_Edge& theEdge);
a6eb515f 58
60bf98ae 59 //! Construct length dimension between two faces.
60 //! @param theFirstFace [in] the first face (first shape).
61 //! @param theSecondFace [in] the second face (second shape).
62 Standard_EXPORT AIS_LengthDimension (const TopoDS_Face& theFirstFace,
63 const TopoDS_Face& theSecondFace);
64
65 //! Construct length dimension between two points in
66 //! the specified plane.
67 //! @param theFirstPoint [in] the first point.
68 //! @param theSecondPoint [in] the second point.
69 //! @param thePlane [in] the plane to orient dimension.
70 Standard_EXPORT AIS_LengthDimension (const gp_Pnt& theFirstPoint,
71 const gp_Pnt& theSecondPoint,
72 const gp_Pln& thePlane);
73
74 //! Construct length dimension between two arbitrary shapes in
75 //! the specified plane.
76 //! @param theFirstShape [in] the first shape.
77 //! @param theSecondShape [in] the second shape.
78 //! @param thePlane [in] the plane to orient dimension.
a6eb515f 79 Standard_EXPORT AIS_LengthDimension (const TopoDS_Shape& theFirstShape,
80 const TopoDS_Shape& theSecondShape,
60bf98ae 81 const gp_Pln& thePlane);
a6eb515f 82
60bf98ae 83 //! Construct length dimension of linear edge.
84 //! @param theEdge [in] the edge to measure.
85 //! @param thePlane [in] the plane to orient dimension.
86 Standard_EXPORT AIS_LengthDimension (const TopoDS_Edge& theEdge,
87 const gp_Pln& thePlane);
a6eb515f 88
60bf98ae 89public:
a6eb515f 90
60bf98ae 91 //! @return first attachement point.
92 const gp_Pnt& FirstPoint() const
93 {
94 return myFirstPoint;
95 }
96
97 //! @return second attachement point.
98 const gp_Pnt& SecondPoint() const
99 {
100 return mySecondPoint;
101 }
102
103 //! @return first attachement shape.
104 const TopoDS_Shape& FirstShape() const
105 {
106 return myFirstShape;
107 }
108
109 //! @return second attachement shape.
110 const TopoDS_Shape& SecondShape() const
111 {
112 return mySecondShape;
113 }
114
115public:
116
117 //! Measure distance between two points.
118 //! The dimension will become invalid if the new distance between
119 //! attachement points is less than Precision::Confusion().
120 //! @param theFirstPoint [in] the first point.
121 //! @param theSecondPoint [in] the second point.
122 //! @param thePlane [in] the user-defined plane
123 Standard_EXPORT void SetMeasuredGeometry (const gp_Pnt& theFirstPoint,
124 const gp_Pnt& theSecondPoint,
125 const gp_Pln& thePlane);
126
127 //! Measure length of edge.
128 //! The dimension will become invalid if the new length of edge
129 //! is less than Precision::Confusion().
130 //! @param theEdge [in] the edge to measure.
131 //! @param thePlane [in] the user-defined plane
132 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Edge& theEdge,
133 const gp_Pln& thePlane);
134
135 //! Measure distance between two faces.
136 //! The dimension will become invalid if the distance can not
137 //! be measured or it is less than Precision::Confusion().
138 //! @param theFirstFace [in] the first face (first shape).
139 //! @param theSecondFace [in] the second face (second shape).
140 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Face& theFirstFace,
141 const TopoDS_Face& theSecondFace);
142
143 //! Measure distance between face and edge.
144 //! The dimension will become invalid if the distance can not
145 //! be measured or it is less than Precision::Confusion().
146 //! @param theFace [in] the face (first shape).
147 //! @param theEdge [in] the edge (second shape).
148 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Face& theFace,
149 const TopoDS_Edge& theEdge);
150
151 //! Measure distance between generic pair of shapes (edges, vertices, length),
152 //! where measuring is applicable.
153 //! @param theFirstShape [in] the first shape.
154 //! @param theSecondShape [in] the second shape.
155 Standard_EXPORT void SetMeasuredShapes (const TopoDS_Shape& theFirstShape,
156 const TopoDS_Shape& theSecondShape);
157
158 //! @return the display units string.
79104795 159 Standard_EXPORT virtual const TCollection_AsciiString& GetDisplayUnits() const Standard_OVERRIDE;
af203d54 160
60bf98ae 161 //! @return the model units string.
79104795 162 Standard_EXPORT virtual const TCollection_AsciiString& GetModelUnits() const Standard_OVERRIDE;
60bf98ae 163
79104795 164 Standard_EXPORT virtual void SetDisplayUnits (const TCollection_AsciiString& theUnits) Standard_OVERRIDE;
60bf98ae 165
79104795 166 Standard_EXPORT virtual void SetModelUnits (const TCollection_AsciiString& theUnits) Standard_OVERRIDE;
a6eb515f 167
79104795 168 Standard_EXPORT virtual void SetTextPosition (const gp_Pnt& theTextPos) Standard_OVERRIDE;
af203d54 169
79104795 170 Standard_EXPORT virtual const gp_Pnt GetTextPosition() const Standard_OVERRIDE;
af203d54 171
948c552a 172 //! Set custom direction for dimension. If it is not set, the direction is obtained
173 //! from the measured geometry (e.g. line between points of dimension)
174 //! The direction does not change flyout direction of dimension.
175 //! @param theDirection [in] the dimension direction.
176 //! @param theUseDirection [in] boolean value if custom direction should be used.
177 Standard_EXPORT void SetDirection (const gp_Dir& theDirection, const Standard_Boolean theUseDirection = Standard_True);
178
d7bffd44 179public:
180
92efcf78 181 DEFINE_STANDARD_RTTIEXT(AIS_LengthDimension,AIS_Dimension)
d7bffd44 182
60bf98ae 183protected:
d7bffd44 184
60bf98ae 185 //! Checks if the plane includes first and second points to build dimension.
79104795 186 Standard_EXPORT virtual Standard_Boolean CheckPlane (const gp_Pln& thePlane) const Standard_OVERRIDE;
d7bffd44 187
60bf98ae 188 Standard_EXPORT virtual gp_Pln ComputePlane(const gp_Dir& theAttachDir) const;
d7bffd44 189
948c552a 190 //! Computes distance between dimension points. If custom direction is defined, the distance
191 //! is a projection value of the distance between points to this direction
192 //! @return dimension value
79104795 193 Standard_EXPORT Standard_Real ComputeValue() const Standard_OVERRIDE;
d7bffd44 194
60bf98ae 195 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
196 const Handle(Prs3d_Presentation)& thePresentation,
79104795 197 const Standard_Integer theMode = 0) Standard_OVERRIDE;
d7bffd44 198
948c552a 199 //! Computes points bounded the flyout line for linear dimension.
200 //! Direction of flyout line equal to the custom direction of dimension if defined or
201 //! parallel to the main direction line
202 //! @param theFirstPoint [in] the first attach point of linear dimension.
203 //! @param theSecondPoint [in] the second attach point of linear dimension.
204 //! @param theLineBegPoint [out] the first attach point of linear dimension.
205 //! @param theLineEndPoint [out] the second attach point of linear dimension.
206 Standard_EXPORT virtual void ComputeFlyoutLinePoints (const gp_Pnt& theFirstPoint, const gp_Pnt& theSecondPoint,
207 gp_Pnt& theLineBegPoint, gp_Pnt& theLineEndPoint) Standard_OVERRIDE;
208
60bf98ae 209 Standard_EXPORT virtual void ComputeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
79104795 210 const Handle(SelectMgr_EntityOwner)& theEntityOwner) Standard_OVERRIDE;
a6eb515f 211
60bf98ae 212protected:
213
214 //! Checks that distance between two points is valid.
215 //! @param theFirstPoint [in] the first point.
216 //! @param theSecondPoint [in] the second point.
217 Standard_EXPORT Standard_Boolean IsValidPoints (const gp_Pnt& theFirstPoint,
218 const gp_Pnt& theSecondPoint) const;
219
220 Standard_EXPORT Standard_Boolean InitTwoEdgesLength (const TopoDS_Edge & theFirstEdge,
221 const TopoDS_Edge& theSecondEdge,
222 gp_Dir& theEdgeDir);
223
224 //! Auxiliary method for InitTwoShapesPoints()
225 //! in case of the distance between edge and vertex.
226 //! Finds the point on the edge that is the closest one to <theVertex>.
227 //! @param theEdgeDir [out] is the direction on the edge to build
228 //! automatical plane.
229 Standard_EXPORT Standard_Boolean InitEdgeVertexLength (const TopoDS_Edge& theEdge,
230 const TopoDS_Vertex& theVertex,
231 gp_Dir& theEdgeDir,
232 Standard_Boolean isInfinite);
233
234 //! Auxiliary method for InitTwoShapesPoints()
235 //! in case of the distance between face and edge.
236 //! The first attachment point is first parameter point from <theEdge>.
237 //! Find the second attachment point which belongs to <theFace>
238 //! Iterate over the edges of the face and find the closest point according
239 //! to finded point on edge.
240 //! @param theEdgeDir [out] is the direction on the edge to build
241 //! automatical plane.
242 Standard_EXPORT Standard_Boolean InitEdgeFaceLength (const TopoDS_Edge& theEdge,
243 const TopoDS_Face& theFace,
244 gp_Dir& theEdgeDir);
245
246 //! Initialization of two attach points in case of two owner shapes.
247 Standard_EXPORT Standard_Boolean InitTwoShapesPoints (const TopoDS_Shape& theFirstShape,
248 const TopoDS_Shape& theSecondShape,
249 gp_Pln& theComputedPlane,
250 Standard_Boolean& theIsPlaneComputed);
251
252 //! Initialization of two attach points in case of one owner shape.
253 Standard_EXPORT Standard_Boolean InitOneShapePoints (const TopoDS_Shape& theShape);
254
255private:
a6eb515f 256
60bf98ae 257 gp_Pnt myFirstPoint;
258 gp_Pnt mySecondPoint;
259 TopoDS_Shape myFirstShape;
260 TopoDS_Shape mySecondShape;
948c552a 261 gp_Dir myDirection;
262 Standard_Boolean myHasCustomDirection;
a6eb515f 263};
264
60bf98ae 265#endif // _AIS_LengthDimension_HeaderFile