0024133: Development of improvement of dimensions implementation; new length, radius...
[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
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
6// The content of this file is subject to the Open CASCADE Technology Public
7// License Version 6.5 (the "License"). You may not use the content of this file
8// except in compliance with the License. Please obtain a copy of the License
9// at http://www.opencascade.org and read it completely before using this file.
10//
11// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13//
14// The Original Code and all software distributed under the License is
15// distributed on an "AS IS" basis, without warranty of any kind, and the
16// Initial Developer hereby disclaims all such warranties, including without
17// limitation, any warranties of merchantability, fitness for a particular
18// purpose or non-infringement. Please see the License for the specific terms
19// and conditions governing the rights and limitations under the License.
20
7fd59977 21
22
23#include <DsgPrs_PerpenPresentation.ixx>
24
25#include <gp_Lin.hxx>
26#include <gp_Dir.hxx>
27#include <ElCLib.hxx>
28#include <gce_MakeLin.hxx>
29#include <gce_MakeDir.hxx>
30#include <Geom_CartesianPoint.hxx>
31#include <Graphic3d_Group.hxx>
32#include <Prs3d_Arrow.hxx>
33#include <Prs3d_Text.hxx>
34#include <Prs3d_ArrowAspect.hxx>
35#include <Prs3d_LineAspect.hxx>
36#include <Prs3d_TextAspect.hxx>
37#include <Prs3d_PointAspect.hxx>
a6eb515f 38#include <Prs3d_DimensionAspect.hxx>
7fd59977 39#include <TCollection_AsciiString.hxx>
40#include <Graphic3d_AspectLine3d.hxx>
b8ddfc2f 41#include <Graphic3d_ArrayOfSegments.hxx>
42#include <Graphic3d_ArrayOfPolylines.hxx>
7fd59977 43
44#include <StdPrs_Point.hxx>
45
46void DsgPrs_PerpenPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
47 const Handle(Prs3d_Drawer)& aDrawer,
48 const gp_Pnt& pAx1,
49 const gp_Pnt& pAx2,
50 const gp_Pnt& pnt1,
51 const gp_Pnt& pnt2,
52 const gp_Pnt& OffsetPoint,
53 const Standard_Boolean intOut1,
54 const Standard_Boolean intOut2)
55{
a6eb515f 56 Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect();
7fd59977 57 LA->LineAspect()->SetTypeOfLine(Aspect_TOL_SOLID); // ou DOT ou DOTDASH
58 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
59
b8ddfc2f 60 // segments
61 Handle(Graphic3d_ArrayOfPrimitives) aPrims = new Graphic3d_ArrayOfPolylines(6,2);
7fd59977 62
b8ddfc2f 63 aPrims->AddBound(3);
64 aPrims->AddVertex(OffsetPoint);
65 aPrims->AddVertex(pAx1);
66 aPrims->AddVertex(pAx2);
7fd59977 67
68 // Symbol
7fd59977 69 gp_Vec vec1(gce_MakeDir(OffsetPoint,pAx1));
70 gp_Vec vec2(gce_MakeDir(OffsetPoint,pAx2));
b8ddfc2f 71 vec1 *= .2 * OffsetPoint.Distance(pAx1);
72 vec2 *= .2 * OffsetPoint.Distance(pAx2);
7fd59977 73
74 gp_Pnt pAx11 = OffsetPoint.Translated(vec1);
75 gp_Pnt pAx22 = OffsetPoint.Translated(vec2);
76 gp_Pnt p_symb = pAx22.Translated(vec1);
77
b8ddfc2f 78 aPrims->AddBound(3);
79 aPrims->AddVertex(pAx11);
80 aPrims->AddVertex(p_symb);
81 aPrims->AddVertex(pAx22);
7fd59977 82
b8ddfc2f 83 Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
7fd59977 84
b8ddfc2f 85 // points attache
86 if (intOut1 || intOut2)
87 {
88 LA->LineAspect()->SetTypeOfLine(Aspect_TOL_DOT); // ou DOT ou DOTDASH
89 Prs3d_Root::NewGroup(aPresentation);
90 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
7fd59977 91
b8ddfc2f 92 if (intOut1) {
93 aPrims = new Graphic3d_ArrayOfSegments(2);
94 aPrims->AddVertex(pAx1);
95 aPrims->AddVertex(pnt1);
96 Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
97 }
98 if (intOut2) {
99 aPrims = new Graphic3d_ArrayOfSegments(2);
100 aPrims->AddVertex(pAx2);
101 aPrims->AddVertex(pnt2);
102 Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
103 }
104 }
105}