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 | |
0904aa63 | 17 | #include <Standard_Dump.hxx> |
18 | ||
4e1bc39a | 19 | IMPLEMENT_STANDARD_RTTIEXT(Prs3d_DatumAspect, Prs3d_BasicAspect) |
92efcf78 | 20 | |
4e1bc39a | 21 | // ======================================================================= |
22 | // function : Prs3d_DatumAspect | |
23 | // purpose : | |
24 | // ======================================================================= | |
046a1c9d | 25 | Prs3d_DatumAspect::Prs3d_DatumAspect() |
24f9d04c | 26 | : myAxes (Prs3d_DatumAxes_XYZAxes), |
fae1ae11 ZA |
27 | myToDrawLabels (Standard_True), |
28 | myToDrawArrows (Standard_True) | |
bc001a40 | 29 | { |
24f9d04c | 30 | const Standard_Real aDefaultLength = 100.0; // default axis length, the same as in context |
31 | const Quantity_Color aDefaultColor (Quantity_NOC_LIGHTSTEELBLUE4); // default axis color | |
32 | ||
33 | myAttributes[Prs3d_DatumAttribute_XAxisLength] = aDefaultLength; | |
34 | myAttributes[Prs3d_DatumAttribute_YAxisLength] = aDefaultLength; | |
35 | myAttributes[Prs3d_DatumAttribute_ZAxisLength] = aDefaultLength; | |
36 | myAttributes[Prs3d_DatumAttribute_ShadingTubeRadiusPercent] = 0.02; | |
37 | myAttributes[Prs3d_DatumAttribute_ShadingConeRadiusPercent] = 0.04; | |
38 | myAttributes[Prs3d_DatumAttribute_ShadingConeLengthPercent] = 0.1; | |
39 | myAttributes[Prs3d_DatumAttribute_ShadingOriginRadiusPercent] = 0.015; | |
40 | myAttributes[Prs3d_DatumAttribute_ShadingNumberOfFacettes] = 12.0; | |
41 | ||
42 | for (int aPartIter = Prs3d_DatumParts_Origin; aPartIter <= Prs3d_DatumParts_XOZAxis; ++aPartIter) | |
bc001a40 | 43 | { |
44 | const Prs3d_DatumParts aPart = (Prs3d_DatumParts )aPartIter; | |
24f9d04c | 45 | if (aPart != Prs3d_DatumParts_Origin) // origin point is used only in shading mode |
bc001a40 | 46 | { |
24f9d04c | 47 | myLineAspects[aPart] = new Prs3d_LineAspect (aDefaultColor, Aspect_TOL_SOLID, 1.0); |
bc001a40 | 48 | } |
49 | ||
50 | Handle(Prs3d_ShadingAspect) aShadingAspect = new Prs3d_ShadingAspect(); | |
51 | aShadingAspect->SetColor (aDefaultColor); | |
24f9d04c | 52 | myShadedAspects[aPart] = aShadingAspect; |
bc001a40 | 53 | } |
54 | myTextAspect = new Prs3d_TextAspect(); | |
55 | myPointAspect = new Prs3d_PointAspect (Aspect_TOM_EMPTY, aDefaultColor, 1.0); | |
56 | myArrowAspect = new Prs3d_ArrowAspect(); | |
57 | } | |
58 | ||
bc001a40 | 59 | // ======================================================================= |
60 | // function : SetDrawFirstAndSecondAxis | |
61 | // purpose : | |
62 | // ======================================================================= | |
63 | void Prs3d_DatumAspect::SetDrawFirstAndSecondAxis (Standard_Boolean theToDraw) | |
64 | { | |
65 | if (theToDraw) | |
66 | { | |
24f9d04c | 67 | myAxes = ((myAxes & Prs3d_DatumAxes_ZAxis) != 0 ? Prs3d_DatumAxes_XYZAxes : Prs3d_DatumAxes_XYAxes); |
bc001a40 | 68 | } |
69 | else | |
70 | { | |
24f9d04c | 71 | myAxes = Prs3d_DatumAxes_ZAxis; |
bc001a40 | 72 | } |
73 | } | |
74 | ||
75 | // ======================================================================= | |
76 | // function : SetDrawThirdAxis | |
77 | // purpose : | |
78 | // ======================================================================= | |
79 | void Prs3d_DatumAspect::SetDrawThirdAxis (Standard_Boolean theToDraw) | |
80 | { | |
81 | if (theToDraw) | |
82 | { | |
24f9d04c | 83 | myAxes = ((myAxes & Prs3d_DatumAxes_XYAxes) != 0 ? Prs3d_DatumAxes_XYZAxes : Prs3d_DatumAxes_ZAxis); |
bc001a40 | 84 | } |
85 | else | |
86 | { | |
24f9d04c | 87 | myAxes = Prs3d_DatumAxes_XYAxes; |
bc001a40 | 88 | } |
89 | } | |
90 | ||
91 | // ======================================================================= | |
92 | // function : DrawDatumPart | |
93 | // purpose : | |
94 | // ======================================================================= | |
95 | bool Prs3d_DatumAspect::DrawDatumPart (Prs3d_DatumParts thePart) const | |
96 | { | |
97 | switch (thePart) | |
98 | { | |
24f9d04c | 99 | case Prs3d_DatumParts_Origin: return true; |
100 | case Prs3d_DatumParts_XAxis: return (myAxes & Prs3d_DatumAxes_XAxis) != 0; | |
101 | case Prs3d_DatumParts_XArrow: return (myAxes & Prs3d_DatumAxes_XAxis) != 0 && myToDrawArrows; | |
102 | case Prs3d_DatumParts_YAxis: return (myAxes & Prs3d_DatumAxes_YAxis) != 0; | |
103 | case Prs3d_DatumParts_YArrow: return (myAxes & Prs3d_DatumAxes_YAxis) != 0 && myToDrawArrows; | |
104 | case Prs3d_DatumParts_ZAxis: return (myAxes & Prs3d_DatumAxes_ZAxis) != 0; | |
105 | case Prs3d_DatumParts_ZArrow: return (myAxes & Prs3d_DatumAxes_ZAxis) != 0 && myToDrawArrows; | |
106 | case Prs3d_DatumParts_XOYAxis: return DrawDatumPart (Prs3d_DatumParts_XAxis) | |
107 | && DrawDatumPart (Prs3d_DatumParts_YAxis); | |
108 | case Prs3d_DatumParts_YOZAxis: return DrawDatumPart (Prs3d_DatumParts_YAxis) | |
109 | && DrawDatumPart (Prs3d_DatumParts_ZAxis); | |
110 | case Prs3d_DatumParts_XOZAxis: return DrawDatumPart (Prs3d_DatumParts_XAxis) | |
111 | && DrawDatumPart (Prs3d_DatumParts_ZAxis); | |
bc001a40 | 112 | default: break; |
113 | } | |
114 | return false; | |
115 | } | |
116 | ||
117 | // ======================================================================= | |
118 | // function : AxisLength | |
119 | // purpose : | |
120 | // ======================================================================= | |
121 | Standard_Real Prs3d_DatumAspect::AxisLength (Prs3d_DatumParts thePart) const | |
122 | { | |
123 | switch (thePart) | |
124 | { | |
24f9d04c | 125 | case Prs3d_DatumParts_XAxis: return myAttributes[Prs3d_DatumAttribute_XAxisLength]; |
126 | case Prs3d_DatumParts_YAxis: return myAttributes[Prs3d_DatumAttribute_YAxisLength]; | |
127 | case Prs3d_DatumParts_ZAxis: return myAttributes[Prs3d_DatumAttribute_ZAxisLength]; | |
bc001a40 | 128 | default: break; |
129 | } | |
130 | return 0.0; | |
131 | } | |
132 | ||
133 | // ======================================================================= | |
134 | // function : ArrowPartForAxis | |
135 | // purpose : | |
136 | // ======================================================================= | |
137 | Prs3d_DatumParts Prs3d_DatumAspect::ArrowPartForAxis (Prs3d_DatumParts thePart) const | |
138 | { | |
139 | switch (thePart) | |
140 | { | |
24f9d04c | 141 | case Prs3d_DatumParts_XAxis: return Prs3d_DatumParts_XArrow; |
142 | case Prs3d_DatumParts_YAxis: return Prs3d_DatumParts_YArrow; | |
143 | case Prs3d_DatumParts_ZAxis: return Prs3d_DatumParts_ZArrow; | |
bc001a40 | 144 | default: break; |
145 | } | |
24f9d04c | 146 | return Prs3d_DatumParts_None; |
7fd59977 | 147 | } |
0904aa63 | 148 | |
149 | // ======================================================================= | |
150 | // function : DumpJson | |
151 | // purpose : | |
152 | // ======================================================================= | |
bc73b006 | 153 | void Prs3d_DatumAspect::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const |
0904aa63 | 154 | { |
bc73b006 | 155 | OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream) |
0904aa63 | 156 | |
bc73b006 | 157 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myTextAspect.get()) |
158 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myPointAspect.get()) | |
159 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myArrowAspect.get()) | |
0904aa63 | 160 | |
bc73b006 | 161 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myAxes) |
162 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToDrawLabels) | |
163 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToDrawArrows) | |
0904aa63 | 164 | } |