1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2013 OPEN CASCADE SAS
4 // The content of this file is subject to the Open CASCADE Technology Public
5 // License Version 6.5 (the "License"). You may not use the content of this file
6 // except in compliance with the License. Please obtain a copy of the License
7 // at http://www.opencascade.org and read it completely before using this file.
9 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 // The Original Code and all software distributed under the License is
13 // distributed on an "AS IS" basis, without warranty of any kind, and the
14 // Initial Developer hereby disclaims all such warranties, including without
15 // limitation, any warranties of merchantability, fitness for a particular
16 // purpose or non-infringement. Please see the License for the specific terms
17 // and conditions governing the rights and limitations under the License.
19 //! A framework to define display of angles. <br>
20 //! These displays are particularly useful in viewing draft prisms. <br>
21 //! The angle displayed may define an intersection <br>
22 //! can be between two edges or two faces of a shape <br>
23 //! or a plane. The display consists of arrows and text. <br>
25 #ifndef _AIS_AngleDimension_HeaderFile
26 #define _AIS_AngleDimension_HeaderFile
28 #include <AIS_Dimension.hxx>
29 #include <Geom_Plane.hxx>
30 #include <Geom_Line.hxx>
31 #include <Geom_Transformation.hxx>
36 #include <Prs3d_DimensionAspect.hxx>
37 #include <Prs3d_Projector.hxx>
38 #include <Prs3d_Presentation.hxx>
39 #include <Standard.hxx>
40 #include <Standard_Macro.hxx>
41 #include <Standard_DefineHandle.hxx>
43 #include <TopoDS_Edge.hxx>
44 #include <TopoDS_Face.hxx>
46 DEFINE_STANDARD_HANDLE (AIS_AngleDimension, AIS_Dimension)
48 class AIS_AngleDimension : public AIS_Dimension
52 //! Constructs angle dimension between two edges
53 //! with automatic working plane computing
54 //! if it is possible. In case of PI angle please
55 //! set custom working plane or use constructor with 3 parameters.
56 Standard_EXPORT AIS_AngleDimension (const TopoDS_Edge& theFirstEdge,
57 const TopoDS_Edge& theSecondEdge);
58 //! Constructs the angle display object defined by the <br>
59 //! two edges and custom working plane.
60 //! ATTENTION :In case if the working plane is custom and one edge is out of the
61 //! working plane it tries to project this edge line on the plane.
62 //! To avoid this case you can reset the working plane
63 //! using <ResetWorkingPlane ()> method.
64 Standard_EXPORT AIS_AngleDimension (const TopoDS_Edge& theFirstEdge,
65 const TopoDS_Edge& theSecondEdge,
66 const gp_Pln& thePlane);
68 //! Constructs the angle display object defined by three points.
69 Standard_EXPORT AIS_AngleDimension (const gp_Pnt& theFirstPoint,
70 const gp_Pnt& theSecondPoint,
71 const gp_Pnt& theThirdPoint);
74 Standard_EXPORT AIS_AngleDimension (const TopoDS_Face& theCone);
76 //! TwoPlanarFaceAngle dimension
77 Standard_EXPORT AIS_AngleDimension (const TopoDS_Face& theFirstFace,
78 const TopoDS_Face& theSecondFace,
79 const gp_Ax1& theAxis);
82 Standard_EXPORT void SetFirstShape (const TopoDS_Shape& theShape,
83 const Standard_Boolean isSingleShape = Standard_False);
87 DEFINE_STANDARD_RTTI (AIS_AngleDimension)
91 //! Computes dimension value in display units
92 Standard_EXPORT virtual void computeValue();
94 Standard_EXPORT void init();
96 Standard_EXPORT gp_Pnt getCenterOnArc (const gp_Pnt& theFirstAttach,
97 const gp_Pnt& theSecondAttach);
99 Standard_EXPORT void drawArc (const Handle(Prs3d_Presentation)& thePresentation,
100 const gp_Pnt& theFirstAttach,
101 const gp_Pnt& theSecondAttach,
102 const gp_Pnt& theCenter,
103 const Standard_Real theRadius,
104 const AIS_DimensionDisplayMode theMode);
106 Standard_EXPORT void drawArcWithText (const Handle(Prs3d_Presentation)& thePresentation,
107 const gp_Pnt& theFirstAttach,
108 const gp_Pnt& theSecondAttach,
109 const TCollection_ExtendedString& theText,
110 const AIS_DimensionDisplayMode theMode,
111 const Standard_Integer theLabelPosition);
113 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePM,
114 const Handle(Prs3d_Presentation)& thePresentation,
115 const Standard_Integer theMode = 0);
117 Standard_EXPORT Standard_Boolean initConeAngle (const TopoDS_Face& theCone);
119 Standard_EXPORT Standard_Boolean initTwoFacesAngle();
121 Standard_EXPORT Standard_Boolean initTwoEdgesAngle();
123 //! Auxiliary method to get position of the angle dimension
124 //! if the cone is trimmed
125 //! Returns 1 if <theC> center is above of <theCMin> center;
126 //! 0 if <theC> center is between <theCMin> and <theCMax> centers;
127 //! -1 if <theC> center is below <theCMax> center.
128 Standard_EXPORT Standard_Integer aboveInBelowCone (const gp_Circ &theCMax,
129 const gp_Circ &theCMin,
130 const gp_Circ &theC);
132 //! Fills default plane object if it is possible to count plane automatically.
133 Standard_EXPORT virtual void countDefaultPlane ();
135 //! Fills sensitive entity for flyouts and adds it to the selection
136 Standard_EXPORT virtual void computeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
137 const Handle(AIS_DimensionOwner)& theOwner);
141 //! Shows if there is necessarily to draw extensions on angle dimension
142 //! It is set to the true value if the attachment point are out of the edges.
143 Standard_Boolean myIsFlyoutLines;
145 //! The center of dimension arc