Commit | Line | Data |
---|---|---|
b311480e | 1 | // Copyright (c) 1995-1999 Matra Datavision |
973c2be1 | 2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 3 | // |
973c2be1 | 4 | // This file is part of Open CASCADE Technology software library. |
b311480e | 5 | // |
d5f74e42 | 6 | // This library is free software; you can redistribute it and/or modify it under |
7 | // the terms of the GNU Lesser General Public License version 2.1 as published | |
973c2be1 | 8 | // by the Free Software Foundation, with special exception defined in the file |
9 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT | |
10 | // distribution for complete text of the license and disclaimer of any warranty. | |
b311480e | 11 | // |
973c2be1 | 12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. | |
b311480e | 14 | |
42cf5bc1 | 15 | #include <Prs3d_DatumAspect.hxx> |
7fd59977 | 16 | |
4e1bc39a | 17 | IMPLEMENT_STANDARD_RTTIEXT(Prs3d_DatumAspect, Prs3d_BasicAspect) |
92efcf78 | 18 | |
4e1bc39a | 19 | // ======================================================================= |
20 | // function : Prs3d_DatumAspect | |
21 | // purpose : | |
22 | // ======================================================================= | |
046a1c9d | 23 | Prs3d_DatumAspect::Prs3d_DatumAspect() |
bc001a40 | 24 | : myAxes (Prs3d_DA_XYZAxis), |
fae1ae11 ZA |
25 | myToDrawLabels (Standard_True), |
26 | myToDrawArrows (Standard_True) | |
bc001a40 | 27 | { |
fae1ae11 | 28 | Standard_Real aDefaultLength = 100.0; // default axis length, the same as in context |
bc001a40 | 29 | Quantity_Color aDefaultColor(Quantity_NOC_LIGHTSTEELBLUE4); // default axis color |
30 | ||
31 | myAttributes.Bind (Prs3d_DA_XAxisLength, aDefaultLength); | |
32 | myAttributes.Bind (Prs3d_DA_YAxisLength, aDefaultLength); | |
33 | myAttributes.Bind (Prs3d_DA_ZAxisLength, aDefaultLength); | |
34 | myAttributes.Bind (Prs3d_DP_ShadingTubeRadiusPercent, 0.02); | |
35 | myAttributes.Bind (Prs3d_DP_ShadingConeRadiusPercent, 0.04); | |
36 | myAttributes.Bind (Prs3d_DP_ShadingConeLengthPercent, 0.1); | |
37 | myAttributes.Bind (Prs3d_DP_ShadingOriginRadiusPercent, 0.015); | |
38 | myAttributes.Bind (Prs3d_DP_ShadingNumberOfFacettes, 12.0); | |
39 | ||
40 | Aspect_TypeOfLine aLineType = Aspect_TOL_SOLID; | |
41 | Standard_Real aWidth = 1.0; | |
42 | for (int aPartIter = Prs3d_DP_Origin; aPartIter <= Prs3d_DP_XOZAxis; ++aPartIter) | |
43 | { | |
44 | const Prs3d_DatumParts aPart = (Prs3d_DatumParts )aPartIter; | |
45 | if (aPart != Prs3d_DP_Origin) // origin point is used only in shading mode | |
46 | { | |
47 | myLineAspects.Bind (aPart, new Prs3d_LineAspect (aDefaultColor, aLineType, aWidth)); | |
48 | } | |
49 | ||
50 | Handle(Prs3d_ShadingAspect) aShadingAspect = new Prs3d_ShadingAspect(); | |
51 | aShadingAspect->SetColor (aDefaultColor); | |
52 | myShadedAspects.Bind (aPart, aShadingAspect); | |
53 | } | |
54 | myTextAspect = new Prs3d_TextAspect(); | |
55 | myPointAspect = new Prs3d_PointAspect (Aspect_TOM_EMPTY, aDefaultColor, 1.0); | |
56 | myArrowAspect = new Prs3d_ArrowAspect(); | |
57 | } | |
58 | ||
59 | // ======================================================================= | |
60 | // function : LineAspect | |
61 | // purpose : | |
62 | // ======================================================================= | |
63 | Handle(Prs3d_LineAspect) Prs3d_DatumAspect::LineAspect (Prs3d_DatumParts thePart) const | |
64 | { | |
65 | Handle(Prs3d_LineAspect) aLineAspect; | |
66 | myLineAspects.Find (thePart, aLineAspect); | |
67 | return aLineAspect; | |
68 | } | |
69 | ||
70 | // ======================================================================= | |
71 | // function : ShadingAspect | |
72 | // purpose : | |
73 | // ======================================================================= | |
74 | Handle(Prs3d_ShadingAspect) Prs3d_DatumAspect::ShadingAspect (Prs3d_DatumParts thePart) const | |
75 | { | |
76 | Handle(Prs3d_ShadingAspect) aShadingAspect; | |
77 | myShadedAspects.Find (thePart, aShadingAspect); | |
78 | return aShadingAspect; | |
79 | } | |
80 | ||
81 | // ======================================================================= | |
82 | // function : SetDrawFirstAndSecondAxis | |
83 | // purpose : | |
84 | // ======================================================================= | |
85 | void Prs3d_DatumAspect::SetDrawFirstAndSecondAxis (Standard_Boolean theToDraw) | |
86 | { | |
87 | if (theToDraw) | |
88 | { | |
03d960b8 | 89 | myAxes = ((myAxes & Prs3d_DA_ZAxis) != 0 ? Prs3d_DA_XYZAxis : Prs3d_DA_XYAxis); |
bc001a40 | 90 | } |
91 | else | |
92 | { | |
03d960b8 | 93 | myAxes = Prs3d_DA_ZAxis; |
bc001a40 | 94 | } |
95 | } | |
96 | ||
97 | // ======================================================================= | |
98 | // function : SetDrawThirdAxis | |
99 | // purpose : | |
100 | // ======================================================================= | |
101 | void Prs3d_DatumAspect::SetDrawThirdAxis (Standard_Boolean theToDraw) | |
102 | { | |
103 | if (theToDraw) | |
104 | { | |
03d960b8 | 105 | myAxes = ((myAxes & Prs3d_DA_XYAxis) != 0 ? Prs3d_DA_XYZAxis : Prs3d_DA_ZAxis); |
bc001a40 | 106 | } |
107 | else | |
108 | { | |
03d960b8 | 109 | myAxes = Prs3d_DA_XYAxis; |
bc001a40 | 110 | } |
111 | } | |
112 | ||
113 | // ======================================================================= | |
114 | // function : DrawDatumPart | |
115 | // purpose : | |
116 | // ======================================================================= | |
117 | bool Prs3d_DatumAspect::DrawDatumPart (Prs3d_DatumParts thePart) const | |
118 | { | |
119 | switch (thePart) | |
120 | { | |
121 | case Prs3d_DP_Origin: return true; | |
fae1ae11 ZA |
122 | case Prs3d_DP_XAxis: return (myAxes & Prs3d_DA_XAxis) != 0; |
123 | case Prs3d_DP_XArrow: return (myAxes & Prs3d_DA_XAxis) != 0 && myToDrawArrows; | |
124 | case Prs3d_DP_YAxis: return (myAxes & Prs3d_DA_YAxis) != 0; | |
125 | case Prs3d_DP_YArrow: return (myAxes & Prs3d_DA_YAxis) != 0 && myToDrawArrows; | |
126 | case Prs3d_DP_ZAxis: return (myAxes & Prs3d_DA_ZAxis) != 0; | |
127 | case Prs3d_DP_ZArrow: return (myAxes & Prs3d_DA_ZAxis) != 0 && myToDrawArrows; | |
bc001a40 | 128 | case Prs3d_DP_XOYAxis: return DrawDatumPart (Prs3d_DP_XAxis) |
129 | && DrawDatumPart (Prs3d_DP_YAxis); | |
130 | case Prs3d_DP_YOZAxis: return DrawDatumPart (Prs3d_DP_YAxis) | |
131 | && DrawDatumPart (Prs3d_DP_ZAxis); | |
132 | case Prs3d_DP_XOZAxis: return DrawDatumPart (Prs3d_DP_XAxis) | |
133 | && DrawDatumPart (Prs3d_DP_ZAxis); | |
134 | default: break; | |
135 | } | |
136 | return false; | |
137 | } | |
138 | ||
139 | // ======================================================================= | |
140 | // function : AxisLength | |
141 | // purpose : | |
142 | // ======================================================================= | |
143 | Standard_Real Prs3d_DatumAspect::AxisLength (Prs3d_DatumParts thePart) const | |
144 | { | |
145 | switch (thePart) | |
146 | { | |
147 | case Prs3d_DP_XAxis: return myAttributes.Find (Prs3d_DA_XAxisLength); | |
148 | case Prs3d_DP_YAxis: return myAttributes.Find (Prs3d_DA_YAxisLength); | |
149 | case Prs3d_DP_ZAxis: return myAttributes.Find (Prs3d_DA_ZAxisLength); | |
150 | default: break; | |
151 | } | |
152 | return 0.0; | |
153 | } | |
154 | ||
155 | // ======================================================================= | |
156 | // function : ArrowPartForAxis | |
157 | // purpose : | |
158 | // ======================================================================= | |
159 | Prs3d_DatumParts Prs3d_DatumAspect::ArrowPartForAxis (Prs3d_DatumParts thePart) const | |
160 | { | |
161 | switch (thePart) | |
162 | { | |
163 | case Prs3d_DP_XAxis: return Prs3d_DP_XArrow; | |
164 | case Prs3d_DP_YAxis: return Prs3d_DP_YArrow; | |
165 | case Prs3d_DP_ZAxis: return Prs3d_DP_ZArrow; | |
166 | default: break; | |
167 | } | |
168 | return Prs3d_DP_None; | |
7fd59977 | 169 | } |