0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / DsgPrs / DsgPrs_PerpenPresentation.cxx
CommitLineData
b311480e 1// Created on: 1995-11-28
2// Created by: Jean-Pierre COMBE
3// Copyright (c) 1995-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
7fd59977 17
42cf5bc1 18#include <DsgPrs_PerpenPresentation.hxx>
7fd59977 19#include <ElCLib.hxx>
7fd59977 20#include <gce_MakeDir.hxx>
42cf5bc1 21#include <gce_MakeLin.hxx>
7fd59977 22#include <Geom_CartesianPoint.hxx>
42cf5bc1 23#include <gp_Dir.hxx>
24#include <gp_Lin.hxx>
25#include <gp_Pnt.hxx>
26#include <Graphic3d_ArrayOfPolylines.hxx>
27#include <Graphic3d_ArrayOfSegments.hxx>
28#include <Graphic3d_AspectLine3d.hxx>
7fd59977 29#include <Graphic3d_Group.hxx>
30#include <Prs3d_Arrow.hxx>
7fd59977 31#include <Prs3d_ArrowAspect.hxx>
42cf5bc1 32#include <Prs3d_DimensionAspect.hxx>
7fd59977 33#include <Prs3d_LineAspect.hxx>
7fd59977 34#include <Prs3d_PointAspect.hxx>
42cf5bc1 35#include <Prs3d_Presentation.hxx>
36#include <Prs3d_Text.hxx>
37#include <Prs3d_TextAspect.hxx>
7fd59977 38#include <StdPrs_Point.hxx>
42cf5bc1 39#include <TCollection_AsciiString.hxx>
7fd59977 40
41void DsgPrs_PerpenPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
42 const Handle(Prs3d_Drawer)& aDrawer,
43 const gp_Pnt& pAx1,
44 const gp_Pnt& pAx2,
45 const gp_Pnt& pnt1,
46 const gp_Pnt& pnt2,
47 const gp_Pnt& OffsetPoint,
48 const Standard_Boolean intOut1,
49 const Standard_Boolean intOut2)
50{
a6eb515f 51 Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect();
7fd59977 52 LA->LineAspect()->SetTypeOfLine(Aspect_TOL_SOLID); // ou DOT ou DOTDASH
53 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
54
b8ddfc2f 55 // segments
56 Handle(Graphic3d_ArrayOfPrimitives) aPrims = new Graphic3d_ArrayOfPolylines(6,2);
7fd59977 57
b8ddfc2f 58 aPrims->AddBound(3);
59 aPrims->AddVertex(OffsetPoint);
60 aPrims->AddVertex(pAx1);
61 aPrims->AddVertex(pAx2);
7fd59977 62
63 // Symbol
7fd59977 64 gp_Vec vec1(gce_MakeDir(OffsetPoint,pAx1));
65 gp_Vec vec2(gce_MakeDir(OffsetPoint,pAx2));
b8ddfc2f 66 vec1 *= .2 * OffsetPoint.Distance(pAx1);
67 vec2 *= .2 * OffsetPoint.Distance(pAx2);
7fd59977 68
69 gp_Pnt pAx11 = OffsetPoint.Translated(vec1);
70 gp_Pnt pAx22 = OffsetPoint.Translated(vec2);
71 gp_Pnt p_symb = pAx22.Translated(vec1);
72
b8ddfc2f 73 aPrims->AddBound(3);
74 aPrims->AddVertex(pAx11);
75 aPrims->AddVertex(p_symb);
76 aPrims->AddVertex(pAx22);
7fd59977 77
b8ddfc2f 78 Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
7fd59977 79
b8ddfc2f 80 // points attache
81 if (intOut1 || intOut2)
82 {
83 LA->LineAspect()->SetTypeOfLine(Aspect_TOL_DOT); // ou DOT ou DOTDASH
84 Prs3d_Root::NewGroup(aPresentation);
85 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
7fd59977 86
b8ddfc2f 87 if (intOut1) {
88 aPrims = new Graphic3d_ArrayOfSegments(2);
89 aPrims->AddVertex(pAx1);
90 aPrims->AddVertex(pnt1);
91 Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
92 }
93 if (intOut2) {
94 aPrims = new Graphic3d_ArrayOfSegments(2);
95 aPrims->AddVertex(pAx2);
96 aPrims->AddVertex(pnt2);
97 Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
98 }
99 }
100}