0023634: Eliminate Polyline and Polygon usage in drawers
[occt.git] / src / Prs3d / Prs3d_LengthPresentation.cxx
CommitLineData
b311480e 1// Copyright (c) 1995-1999 Matra Datavision
2// Copyright (c) 1999-2012 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
7fd59977 19#include <Prs3d_LengthPresentation.ixx>
20#include <gp_Lin.hxx>
21#include <gp_Dir.hxx>
22#include <ElCLib.hxx>
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>
b8ddfc2f 31#include <Graphic3d_ArrayOfPolylines.hxx>
7fd59977 32#include <Prs3d_Text.hxx>
33
34void 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,
b8ddfc2f 40 const gp_Pnt& OffsetPoint)
41{
7fd59977 42 Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
b8ddfc2f 43 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
44
7fd59977 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);
7fd59977 49
b8ddfc2f 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);
7fd59977 56
b8ddfc2f 57 Quantity_Length X,Y,Z;
7fd59977 58 Proj1.Coord(X,Y,Z);
b8ddfc2f 59 if (LA->DrawFirstArrow())
60 Prs3d_Arrow::Draw(aPresentation,Proj1,D.Reversed(),LA->Arrow1Aspect()->Angle(),LA->Arrow1Aspect()->Length());
7fd59977 61
7fd59977 62 Quantity_Length X2,Y2,Z2;
63 Proj2.Coord(X2,Y2,Z2);
b8ddfc2f 64 if (LA->DrawSecondArrow())
65 Prs3d_Arrow::Draw(aPresentation,Proj2,D,LA->Arrow2Aspect()->Angle(),LA->Arrow2Aspect()->Length());
7fd59977 66
b8ddfc2f 67 gp_Pnt p( .5*(X+X2), .5*(Y+Y2), .5*(Z+Z2) );
7fd59977 68 Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,p);
69}