1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2012 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 #include <Prs3d_LengthPresentation.ixx>
23 #include <Graphic3d_Group.hxx>
24 #include <Prs3d_Arrow.hxx>
25 #include <Prs3d_ArrowAspect.hxx>
26 #include <Prs3d_LineAspect.hxx>
27 #include <Prs3d_LengthAspect.hxx>
28 #include <TCollection_AsciiString.hxx>
29 #include <Graphic3d_AspectMarker3d.hxx>
30 #include <Graphic3d_AspectLine3d.hxx>
31 #include <Graphic3d_ArrayOfPolylines.hxx>
32 #include <Prs3d_Text.hxx>
34 void Prs3d_LengthPresentation::Draw (
35 const Handle(Prs3d_Presentation)& aPresentation,
36 const Handle(Prs3d_Drawer)& aDrawer,
37 const TCollection_ExtendedString& aText,
38 const gp_Pnt& AttachmentPoint1,
39 const gp_Pnt& AttachmentPoint2,
40 const gp_Pnt& OffsetPoint)
42 Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
43 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
45 gp_Dir D (gp_Vec(AttachmentPoint1,AttachmentPoint2));
46 gp_Lin L (OffsetPoint,D);
47 gp_Pnt Proj1 = ElCLib::Value(ElCLib::Parameter(L,AttachmentPoint1),L);
48 gp_Pnt Proj2 = ElCLib::Value(ElCLib::Parameter(L,AttachmentPoint2),L);
50 Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(4);
51 aPrims->AddVertex(AttachmentPoint1);
52 aPrims->AddVertex(Proj1);
53 aPrims->AddVertex(Proj2);
54 aPrims->AddVertex(AttachmentPoint2);
55 Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
57 Quantity_Length X,Y,Z;
59 if (LA->DrawFirstArrow())
60 Prs3d_Arrow::Draw(aPresentation,Proj1,D.Reversed(),LA->Arrow1Aspect()->Angle(),LA->Arrow1Aspect()->Length());
62 Quantity_Length X2,Y2,Z2;
63 Proj2.Coord(X2,Y2,Z2);
64 if (LA->DrawSecondArrow())
65 Prs3d_Arrow::Draw(aPresentation,Proj2,D,LA->Arrow2Aspect()->Angle(),LA->Arrow2Aspect()->Length());
67 gp_Pnt p( .5*(X+X2), .5*(Y+Y2), .5*(Z+Z2) );
68 Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,p);