0030675: Visualization - remove redundant proxy classes in hierarchy of PrsMgr_Presen...
[occt.git] / src / DsgPrs / DsgPrs_Chamf2dPresentation.cxx
1 // Created on: 1996-03-19
2 // Created by: Flore Lantheaume
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <DsgPrs.hxx>
19 #include <DsgPrs_Chamf2dPresentation.hxx>
20 #include <gp_Dir.hxx>
21 #include <gp_Pnt.hxx>
22 #include <Graphic3d_ArrayOfSegments.hxx>
23 #include <Graphic3d_Group.hxx>
24 #include <Prs3d_Arrow.hxx>
25 #include <Prs3d_ArrowAspect.hxx>
26 #include <Prs3d_DimensionAspect.hxx>
27 #include <Prs3d_LineAspect.hxx>
28 #include <Prs3d_Presentation.hxx>
29 #include <Prs3d_Text.hxx>
30 #include <TCollection_ExtendedString.hxx>
31
32 void DsgPrs_Chamf2dPresentation::Add(
33                            const Handle(Prs3d_Presentation)& aPresentation,
34                            const Handle(Prs3d_Drawer)& aDrawer,
35                            const gp_Pnt& aPntAttach,
36                            const gp_Pnt& aPntEnd,
37                            const TCollection_ExtendedString& aText)
38 {
39   Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect();
40   
41   Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
42   
43   Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2);
44   aPrims->AddVertex(aPntAttach);
45   aPrims->AddVertex(aPntEnd);
46   Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
47
48   gp_Dir ArrowDir(aPntAttach.XYZ()-aPntEnd.XYZ());
49   Prs3d_Arrow::Draw (Prs3d_Root::CurrentGroup (aPresentation), aPntAttach, ArrowDir, LA->ArrowAspect()->Angle(), LA->ArrowAspect()->Length());
50                      
51   Prs3d_Text::Draw (Prs3d_Root::CurrentGroup (aPresentation), LA->TextAspect(), aText, aPntEnd);
52 }
53
54
55 //==========================================================================
56 // function : DsgPrs_Chamf2dPresentation::Add
57 // purpose  : it is possible to choose the symbol of extremities of the face (arrow, point ...)
58 //==========================================================================
59
60 void DsgPrs_Chamf2dPresentation::Add(
61                            const Handle(Prs3d_Presentation)& aPresentation,
62                            const Handle(Prs3d_Drawer)& aDrawer,
63                            const gp_Pnt& aPntAttach,
64                            const gp_Pnt& aPntEnd,
65                            const TCollection_ExtendedString& aText,
66                            const DsgPrs_ArrowSide ArrowPrs) 
67 {
68   Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect();
69   
70   Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
71   
72   Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2);
73   aPrims->AddVertex(aPntAttach);
74   aPrims->AddVertex(aPntEnd);
75   Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
76
77   Prs3d_Text::Draw (Prs3d_Root::CurrentGroup (aPresentation), LA->TextAspect(), aText, aPntEnd);
78
79   gp_Dir ArrowDir(aPntAttach.XYZ()-aPntEnd.XYZ());
80   gp_Dir ArrowDir1 = ArrowDir;
81   ArrowDir1.Reverse();
82
83   DsgPrs::ComputeSymbol(aPresentation,LA,aPntEnd,aPntAttach,ArrowDir1,ArrowDir,ArrowPrs);
84 }