bb88f3ff |
1 | // Copyright (c) 2013-2014 OPEN CASCADE SAS |
2 | // |
3 | // This file is part of Open CASCADE Technology software library. |
4 | // |
5 | // This library is free software; you can redistribute it and/or modify it under |
6 | // the terms of the GNU Lesser General Public License version 2.1 as published |
7 | // by the Free Software Foundation, with special exception defined in the file |
8 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
9 | // distribution for complete text of the license and disclaimer of any warranty. |
10 | // |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
13 | |
14 | #include <DsgPrs_DatumPrs.hxx> |
15 | #include <DsgPrs_XYZAxisPresentation.hxx> |
16 | #include <gp_Dir.hxx> |
17 | #include <gp_Pnt.hxx> |
18 | #include <gp_Ax2.hxx> |
19 | #include <Graphic3d_Group.hxx> |
20 | #include <Graphic3d_AspectLine3d.hxx> |
21 | #include <Graphic3d_ArrayOfSegments.hxx> |
22 | #include <Prs3d_Arrow.hxx> |
23 | #include <Prs3d_LineAspect.hxx> |
24 | #include <Prs3d_DatumAspect.hxx> |
25 | #include <Prs3d_TextAspect.hxx> |
26 | #include <Prs3d_ArrowAspect.hxx> |
27 | |
28 | // ======================================================================= |
29 | // function : Add |
30 | // purpose : |
31 | // ======================================================================= |
32 | void DsgPrs_DatumPrs::Add (const Handle(Prs3d_Presentation)& thePresentation, |
33 | const gp_Ax2& theDatum, |
34 | const Handle(Prs3d_Drawer)& theDrawer) |
35 | { |
36 | Handle(Prs3d_DatumAspect) aDatumAspect = theDrawer->DatumAspect(); |
37 | Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation); |
38 | |
39 | gp_Ax2 anAxis (theDatum); |
40 | gp_Pnt anOrigin = anAxis.Location(); |
41 | gp_Dir aXDir = anAxis.XDirection(); |
42 | gp_Dir aYDir = anAxis.YDirection(); |
43 | gp_Dir aZDir = anAxis.Direction(); |
44 | |
45 | Standard_Real anAxisLength; |
46 | const Standard_Boolean toDrawLabels = theDrawer->DatumAspect()->ToDrawLabels(); |
47 | |
48 | Prs3d_DatumAxes anAxes = aDatumAspect->DatumAxes(); |
49 | Handle(Prs3d_ArrowAspect) anArrowAspect = aDatumAspect->ArrowAspect(); |
50 | Handle(Prs3d_TextAspect) aTextAspect = theDrawer->TextAspect(); |
51 | |
52 | if ((anAxes & Prs3d_DA_XAxis) != 0) |
53 | { |
54 | anAxisLength = aDatumAspect->Attribute (Prs3d_DA_XAxisLength); |
55 | const gp_Pnt aPoint1 (anOrigin.XYZ() + aXDir.XYZ()*anAxisLength); |
56 | DsgPrs_XYZAxisPresentation::Add (thePresentation, aDatumAspect->LineAspect(Prs3d_DP_XAxis), anArrowAspect, |
57 | aTextAspect, aXDir, anAxisLength, toDrawLabels ? "X" : "", anOrigin, aPoint1); |
58 | } |
59 | |
60 | if ((anAxes & Prs3d_DA_YAxis) != 0) |
61 | { |
62 | anAxisLength = aDatumAspect->Attribute (Prs3d_DA_YAxisLength); |
63 | const gp_Pnt aPoint2 (anOrigin.XYZ() + aYDir.XYZ()*anAxisLength); |
64 | DsgPrs_XYZAxisPresentation::Add (thePresentation, aDatumAspect->LineAspect(Prs3d_DP_YAxis), anArrowAspect, |
65 | aTextAspect, aYDir, anAxisLength, toDrawLabels ? "Y" : "", anOrigin, aPoint2); |
66 | } |
67 | |
68 | if ((anAxes & Prs3d_DA_ZAxis) != 0) |
69 | { |
70 | anAxisLength = aDatumAspect->Attribute (Prs3d_DA_ZAxisLength); |
71 | const gp_Pnt aPoint3 (anOrigin.XYZ() + aZDir.XYZ()*anAxisLength); |
72 | DsgPrs_XYZAxisPresentation::Add (thePresentation, aDatumAspect->LineAspect(Prs3d_DP_ZAxis), anArrowAspect, |
73 | aTextAspect, aZDir, anAxisLength, toDrawLabels ? "Z" : "", anOrigin, aPoint3); |
74 | } |
75 | } |