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
51 //! Constructs angle dimension between two edges
52 //! with automatic working plane computing
53 //! if it is possible. In case of PI angle please
54 //! set custom working plane or use constructor with 3 parameters.
55 Standard_EXPORT AIS_AngleDimension (const TopoDS_Edge& theFirstEdge,
56 const TopoDS_Edge& theSecondEdge);
57 //! Constructs the angle display object defined by the <br>
58 //! two edges and custom working plane.
59 //! ATTENTION :In case if the working plane is custom and one edge is out of the
60 //! working plane it tries to project this edge line on the plane.
61 //! To avoid this case you can reset the working plane
62 //! using <ResetWorkingPlane ()> method.
63 Standard_EXPORT AIS_AngleDimension (const TopoDS_Edge& theFirstEdge,
64 const TopoDS_Edge& theSecondEdge,
65 const gp_Pln& thePlane);
67 //! Constructs the angle display object defined by the <br>
68 //! two edges and custom working plane and dimension aspect.
69 Standard_EXPORT AIS_AngleDimension (const TopoDS_Edge& theFirstEdge,
70 const TopoDS_Edge& theSecondEdge,
71 const gp_Pln& thePlane,
72 const Handle(Prs3d_DimensionAspect)& theDimensionAspect,
73 const Standard_Real theExtensionSize = 1.0);
75 //! Constructs the angle display object defined by three points.
76 Standard_EXPORT AIS_AngleDimension (const gp_Pnt& theFirstPoint,
77 const gp_Pnt& theSecondPoint,
78 const gp_Pnt& theThirdPoint);
80 //! Constructs the angle display object defined by three points
81 //! and dimension aspect that defines line, arrow and text aspect.
82 Standard_EXPORT AIS_AngleDimension (const gp_Pnt& theFirstPoint,
83 const gp_Pnt& theSecondPoint,
84 const gp_Pnt& theThirdPoint,
85 const Handle(Prs3d_DimensionAspect)& theDimensionAspect,
86 const Standard_Real theExtensionSize = 1.0);
89 Standard_EXPORT AIS_AngleDimension (const TopoDS_Face& theCone);
91 //! TwoPlanarFaceAngle dimension
92 Standard_EXPORT AIS_AngleDimension (const TopoDS_Face& theFirstFace,
93 const TopoDS_Face& theSecondFace,
94 const gp_Ax1& theAxis);
97 Standard_EXPORT void SetFirstShape (const TopoDS_Shape& theShape,
98 const Standard_Boolean isSingleShape = Standard_False);
100 DEFINE_STANDARD_RTTI(AIS_AngleDimension)
104 //! Computes dimension value in display units
105 Standard_EXPORT virtual void computeValue();
107 Standard_EXPORT void init();
109 Standard_EXPORT gp_Pnt getCenterOnArc (const gp_Pnt& theFirstAttach,
110 const gp_Pnt& theSecondAttach);
112 Standard_EXPORT void drawArc (const Handle(Prs3d_Presentation)& thePresentation,
113 const gp_Pnt& theFirstAttach,
114 const gp_Pnt& theSecondAttach,
115 const gp_Pnt& theCenter,
116 const Standard_Real theRadius,
117 const AIS_DimensionDisplayMode theMode);
119 Standard_EXPORT void drawArcWithText (const Handle(Prs3d_Presentation)& thePresentation,
120 const gp_Pnt& theFirstAttach,
121 const gp_Pnt& theSecondAttach,
122 const TCollection_ExtendedString& theText,
123 const AIS_DimensionDisplayMode theMode);
125 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePM,
126 const Handle(Prs3d_Presentation)& thePresentation,
127 const Standard_Integer theMode = 0);
129 Standard_EXPORT Standard_Boolean initConeAngle (const TopoDS_Face& theCone);
131 Standard_EXPORT Standard_Boolean initTwoFacesAngle();
133 Standard_EXPORT Standard_Boolean initTwoEdgesAngle();
135 //! Auxiliary method to get position of the angle dimension
136 //! if the cone is trimmed
137 //! Returns 1 if <theC> center is above of <theCMin> center;
138 //! 0 if <theC> center is between <theCMin> and <theCMax> centers;
139 //! -1 if <theC> center is below <theCMax> center.
140 Standard_EXPORT Standard_Integer aboveInBelowCone (const gp_Circ &theCMax,
141 const gp_Circ &theCMin,
142 const gp_Circ &theC);
144 //! Auxiliary method to arrange text and arrows
145 Standard_EXPORT Standard_Boolean canTextBeInCenter (const gp_Pnt& theFirstAttach,
146 const gp_Pnt& theSecondAttach,
147 const Quantity_Length& theTextLength,
148 const Quantity_Length& theArrowLength);
150 //! Fills default plane object if it is possible to count plane automatically.
151 Standard_EXPORT virtual void countDefaultPlane ();
153 //! Fills sensitive entity for flyouts and adds it to the selection
154 Standard_EXPORT virtual void computeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
155 const Handle(AIS_DimensionOwner)& theOwner);
159 //! Shows if there is necessarily to draw extensions on angle dimension
160 //! It is set to the true value if the attachment point are out of the edges.
161 Standard_Boolean myIsFlyoutLines;
163 //! The center of dimension arc