0024386: Provide high-level API to specify font by user-defined path for AIS (Prs3d...
[occt.git] / src / AIS / AIS_AngleDimension.hxx
CommitLineData
a6eb515f 1// Copyright (c) 1995-1999 Matra Datavision
2// Copyright (c) 1999-2013 OPEN CASCADE SAS
3//
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.
8//
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.
11//
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.
18
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>
24
25#ifndef _AIS_AngleDimension_HeaderFile
26#define _AIS_AngleDimension_HeaderFile
27
28#include <AIS_Dimension.hxx>
29#include <Geom_Plane.hxx>
30#include <Geom_Line.hxx>
31#include <Geom_Transformation.hxx>
32#include <gp.hxx>
33#include <gp_Ax1.hxx>
34#include <gp_Dir.hxx>
35#include <gp_Pnt.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>
42#include <TopoDS.hxx>
43#include <TopoDS_Edge.hxx>
44#include <TopoDS_Face.hxx>
45
46DEFINE_STANDARD_HANDLE (AIS_AngleDimension, AIS_Dimension)
47
48class AIS_AngleDimension : public AIS_Dimension
49{
50public:
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);
66
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);
74
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);
79
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);
87
88 //! Angle of cone
89 Standard_EXPORT AIS_AngleDimension (const TopoDS_Face& theCone);
90
91 //! TwoPlanarFaceAngle dimension
92 Standard_EXPORT AIS_AngleDimension (const TopoDS_Face& theFirstFace,
93 const TopoDS_Face& theSecondFace,
94 const gp_Ax1& theAxis);
95
96 //! Sets the flyout.
97 Standard_EXPORT void SetFlyout (const Standard_Real theFlyout);
98
99 //! Returns flyout value. If value > 0 the dimension is to be displayed inside the angle.
100 //! Otherwise it is displayed outside one.
101 Standard_EXPORT Standard_Real GetFlyout() const;
102
103 //! Sets first shape
104 Standard_EXPORT void SetFirstShape (const TopoDS_Shape& theShape,
105 const Standard_Boolean isSingleShape = Standard_False);
106
107 DEFINE_STANDARD_RTTI(AIS_AngleDimension)
108
109protected:
110
111 //! Computes dimension value in display units
112 Standard_EXPORT virtual void computeValue();
113
114 Standard_EXPORT void init();
115
116 Standard_EXPORT gp_Pnt getCenterOnArc (const gp_Pnt& theFirstAttach,
117 const gp_Pnt& theSecondAttach);
118
119 Standard_EXPORT void drawArc (const Handle(Prs3d_Presentation)& thePresentation,
120 const gp_Pnt& theFirstAttach,
121 const gp_Pnt& theSecondAttach,
122 const gp_Pnt& theCenter,
123 const Standard_Real theRadius,
124 const AIS_DimensionDisplayMode theMode);
125
126 Standard_EXPORT void drawArcWithText (const Handle(Prs3d_Presentation)& thePresentation,
127 const gp_Pnt& theFirstAttach,
128 const gp_Pnt& theSecondAttach,
129 const TCollection_ExtendedString& theText,
130 const AIS_DimensionDisplayMode theMode);
131
132 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePM,
133 const Handle(Prs3d_Presentation)& thePresentation,
134 const Standard_Integer theMode = 0);
135
136 Standard_EXPORT Standard_Boolean initConeAngle (const TopoDS_Face& theCone);
137
138 Standard_EXPORT Standard_Boolean initTwoFacesAngle();
139
140 Standard_EXPORT Standard_Boolean initTwoEdgesAngle();
141
142 //! Auxiliary method to get position of the angle dimension
143 //! if the cone is trimmed
144 //! Returns 1 if <theC> center is above of <theCMin> center;
145 //! 0 if <theC> center is between <theCMin> and <theCMax> centers;
146 //! -1 if <theC> center is below <theCMax> center.
147 Standard_EXPORT Standard_Integer aboveInBelowCone (const gp_Circ &theCMax,
148 const gp_Circ &theCMin,
149 const gp_Circ &theC);
150
151 //! Auxiliary method to arrange text and arrows
152 Standard_EXPORT Standard_Boolean canTextBeInCenter (const gp_Pnt& theFirstAttach,
153 const gp_Pnt& theSecondAttach,
154 const Quantity_Length& theTextLength,
155 const Quantity_Length& theArrowLength);
156
157 //! Fills default plane object if it is possible to count plane automatically.
158 Standard_EXPORT virtual void countDefaultPlane ();
159
160protected:
161
162 //! Shows if there is necessarily to draw extensions on angle dimension
163 //! It is set to the true value if the attachment point are out of the edges.
164 Standard_Boolean myIsFlyoutLines;
165
166 //! The center of dimension arc
167 gp_Pnt myCenter;
168
169 //! Defines flyout lines and direction
170 //! Flyout direction in the working plane (stored in the base AIS_Dimension).
171 //! can be negative , or positive and is defined by the sign of <myFlyout> value.
172 //! The direction vector is counting using the working plane.
173 //! <myFlyout> value defined the size of flyout (radius of angle).
174 Standard_Real myFlyout;
175};
176
177#endif