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 | |
17 | #include <DsgPrs_PerpenPresentation.ixx> |
18 | |
19 | #include <gp_Lin.hxx> |
20 | #include <gp_Dir.hxx> |
21 | #include <ElCLib.hxx> |
22 | #include <gce_MakeLin.hxx> |
23 | #include <gce_MakeDir.hxx> |
24 | #include <Geom_CartesianPoint.hxx> |
25 | #include <Graphic3d_Group.hxx> |
26 | #include <Prs3d_Arrow.hxx> |
27 | #include <Prs3d_Text.hxx> |
28 | #include <Prs3d_ArrowAspect.hxx> |
29 | #include <Prs3d_LineAspect.hxx> |
30 | #include <Prs3d_TextAspect.hxx> |
31 | #include <Prs3d_PointAspect.hxx> |
a6eb515f |
32 | #include <Prs3d_DimensionAspect.hxx> |
7fd59977 |
33 | #include <TCollection_AsciiString.hxx> |
34 | #include <Graphic3d_AspectLine3d.hxx> |
b8ddfc2f |
35 | #include <Graphic3d_ArrayOfSegments.hxx> |
36 | #include <Graphic3d_ArrayOfPolylines.hxx> |
7fd59977 |
37 | |
38 | #include <StdPrs_Point.hxx> |
39 | |
40 | void DsgPrs_PerpenPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation, |
41 | const Handle(Prs3d_Drawer)& aDrawer, |
42 | const gp_Pnt& pAx1, |
43 | const gp_Pnt& pAx2, |
44 | const gp_Pnt& pnt1, |
45 | const gp_Pnt& pnt2, |
46 | const gp_Pnt& OffsetPoint, |
47 | const Standard_Boolean intOut1, |
48 | const Standard_Boolean intOut2) |
49 | { |
a6eb515f |
50 | Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); |
7fd59977 |
51 | LA->LineAspect()->SetTypeOfLine(Aspect_TOL_SOLID); // ou DOT ou DOTDASH |
52 | Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); |
53 | |
b8ddfc2f |
54 | // segments |
55 | Handle(Graphic3d_ArrayOfPrimitives) aPrims = new Graphic3d_ArrayOfPolylines(6,2); |
7fd59977 |
56 | |
b8ddfc2f |
57 | aPrims->AddBound(3); |
58 | aPrims->AddVertex(OffsetPoint); |
59 | aPrims->AddVertex(pAx1); |
60 | aPrims->AddVertex(pAx2); |
7fd59977 |
61 | |
62 | // Symbol |
7fd59977 |
63 | gp_Vec vec1(gce_MakeDir(OffsetPoint,pAx1)); |
64 | gp_Vec vec2(gce_MakeDir(OffsetPoint,pAx2)); |
b8ddfc2f |
65 | vec1 *= .2 * OffsetPoint.Distance(pAx1); |
66 | vec2 *= .2 * OffsetPoint.Distance(pAx2); |
7fd59977 |
67 | |
68 | gp_Pnt pAx11 = OffsetPoint.Translated(vec1); |
69 | gp_Pnt pAx22 = OffsetPoint.Translated(vec2); |
70 | gp_Pnt p_symb = pAx22.Translated(vec1); |
71 | |
b8ddfc2f |
72 | aPrims->AddBound(3); |
73 | aPrims->AddVertex(pAx11); |
74 | aPrims->AddVertex(p_symb); |
75 | aPrims->AddVertex(pAx22); |
7fd59977 |
76 | |
b8ddfc2f |
77 | Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); |
7fd59977 |
78 | |
b8ddfc2f |
79 | // points attache |
80 | if (intOut1 || intOut2) |
81 | { |
82 | LA->LineAspect()->SetTypeOfLine(Aspect_TOL_DOT); // ou DOT ou DOTDASH |
83 | Prs3d_Root::NewGroup(aPresentation); |
84 | Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); |
7fd59977 |
85 | |
b8ddfc2f |
86 | if (intOut1) { |
87 | aPrims = new Graphic3d_ArrayOfSegments(2); |
88 | aPrims->AddVertex(pAx1); |
89 | aPrims->AddVertex(pnt1); |
90 | Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); |
91 | } |
92 | if (intOut2) { |
93 | aPrims = new Graphic3d_ArrayOfSegments(2); |
94 | aPrims->AddVertex(pAx2); |
95 | aPrims->AddVertex(pnt2); |
96 | Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); |
97 | } |
98 | } |
99 | } |