0031313: Foundation Classes - Dump improvement for classes
[occt.git] / src / Prs3d / Prs3d_DatumAspect.cxx
CommitLineData
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 19IMPLEMENT_STANDARD_RTTIEXT(Prs3d_DatumAspect, Prs3d_BasicAspect)
92efcf78 20
4e1bc39a 21// =======================================================================
22// function : Prs3d_DatumAspect
23// purpose :
24// =======================================================================
046a1c9d 25Prs3d_DatumAspect::Prs3d_DatumAspect()
bc001a40 26: myAxes (Prs3d_DA_XYZAxis),
fae1ae11
ZA
27 myToDrawLabels (Standard_True),
28 myToDrawArrows (Standard_True)
bc001a40 29{
fae1ae11 30 Standard_Real aDefaultLength = 100.0; // default axis length, the same as in context
bc001a40 31 Quantity_Color aDefaultColor(Quantity_NOC_LIGHTSTEELBLUE4); // default axis color
32
33 myAttributes.Bind (Prs3d_DA_XAxisLength, aDefaultLength);
34 myAttributes.Bind (Prs3d_DA_YAxisLength, aDefaultLength);
35 myAttributes.Bind (Prs3d_DA_ZAxisLength, aDefaultLength);
36 myAttributes.Bind (Prs3d_DP_ShadingTubeRadiusPercent, 0.02);
37 myAttributes.Bind (Prs3d_DP_ShadingConeRadiusPercent, 0.04);
38 myAttributes.Bind (Prs3d_DP_ShadingConeLengthPercent, 0.1);
39 myAttributes.Bind (Prs3d_DP_ShadingOriginRadiusPercent, 0.015);
40 myAttributes.Bind (Prs3d_DP_ShadingNumberOfFacettes, 12.0);
41
42 Aspect_TypeOfLine aLineType = Aspect_TOL_SOLID;
43 Standard_Real aWidth = 1.0;
44 for (int aPartIter = Prs3d_DP_Origin; aPartIter <= Prs3d_DP_XOZAxis; ++aPartIter)
45 {
46 const Prs3d_DatumParts aPart = (Prs3d_DatumParts )aPartIter;
47 if (aPart != Prs3d_DP_Origin) // origin point is used only in shading mode
48 {
49 myLineAspects.Bind (aPart, new Prs3d_LineAspect (aDefaultColor, aLineType, aWidth));
50 }
51
52 Handle(Prs3d_ShadingAspect) aShadingAspect = new Prs3d_ShadingAspect();
53 aShadingAspect->SetColor (aDefaultColor);
54 myShadedAspects.Bind (aPart, aShadingAspect);
55 }
56 myTextAspect = new Prs3d_TextAspect();
57 myPointAspect = new Prs3d_PointAspect (Aspect_TOM_EMPTY, aDefaultColor, 1.0);
58 myArrowAspect = new Prs3d_ArrowAspect();
59}
60
61// =======================================================================
62// function : LineAspect
63// purpose :
64// =======================================================================
65Handle(Prs3d_LineAspect) Prs3d_DatumAspect::LineAspect (Prs3d_DatumParts thePart) const
66{
67 Handle(Prs3d_LineAspect) aLineAspect;
68 myLineAspects.Find (thePart, aLineAspect);
69 return aLineAspect;
70}
71
72// =======================================================================
73// function : ShadingAspect
74// purpose :
75// =======================================================================
76Handle(Prs3d_ShadingAspect) Prs3d_DatumAspect::ShadingAspect (Prs3d_DatumParts thePart) const
77{
78 Handle(Prs3d_ShadingAspect) aShadingAspect;
79 myShadedAspects.Find (thePart, aShadingAspect);
80 return aShadingAspect;
81}
82
83// =======================================================================
84// function : SetDrawFirstAndSecondAxis
85// purpose :
86// =======================================================================
87void Prs3d_DatumAspect::SetDrawFirstAndSecondAxis (Standard_Boolean theToDraw)
88{
89 if (theToDraw)
90 {
03d960b8 91 myAxes = ((myAxes & Prs3d_DA_ZAxis) != 0 ? Prs3d_DA_XYZAxis : Prs3d_DA_XYAxis);
bc001a40 92 }
93 else
94 {
03d960b8 95 myAxes = Prs3d_DA_ZAxis;
bc001a40 96 }
97}
98
99// =======================================================================
100// function : SetDrawThirdAxis
101// purpose :
102// =======================================================================
103void Prs3d_DatumAspect::SetDrawThirdAxis (Standard_Boolean theToDraw)
104{
105 if (theToDraw)
106 {
03d960b8 107 myAxes = ((myAxes & Prs3d_DA_XYAxis) != 0 ? Prs3d_DA_XYZAxis : Prs3d_DA_ZAxis);
bc001a40 108 }
109 else
110 {
03d960b8 111 myAxes = Prs3d_DA_XYAxis;
bc001a40 112 }
113}
114
115// =======================================================================
116// function : DrawDatumPart
117// purpose :
118// =======================================================================
119bool Prs3d_DatumAspect::DrawDatumPart (Prs3d_DatumParts thePart) const
120{
121 switch (thePart)
122 {
123 case Prs3d_DP_Origin: return true;
fae1ae11
ZA
124 case Prs3d_DP_XAxis: return (myAxes & Prs3d_DA_XAxis) != 0;
125 case Prs3d_DP_XArrow: return (myAxes & Prs3d_DA_XAxis) != 0 && myToDrawArrows;
126 case Prs3d_DP_YAxis: return (myAxes & Prs3d_DA_YAxis) != 0;
127 case Prs3d_DP_YArrow: return (myAxes & Prs3d_DA_YAxis) != 0 && myToDrawArrows;
128 case Prs3d_DP_ZAxis: return (myAxes & Prs3d_DA_ZAxis) != 0;
129 case Prs3d_DP_ZArrow: return (myAxes & Prs3d_DA_ZAxis) != 0 && myToDrawArrows;
bc001a40 130 case Prs3d_DP_XOYAxis: return DrawDatumPart (Prs3d_DP_XAxis)
131 && DrawDatumPart (Prs3d_DP_YAxis);
132 case Prs3d_DP_YOZAxis: return DrawDatumPart (Prs3d_DP_YAxis)
133 && DrawDatumPart (Prs3d_DP_ZAxis);
134 case Prs3d_DP_XOZAxis: return DrawDatumPart (Prs3d_DP_XAxis)
135 && DrawDatumPart (Prs3d_DP_ZAxis);
136 default: break;
137 }
138 return false;
139}
140
141// =======================================================================
142// function : AxisLength
143// purpose :
144// =======================================================================
145Standard_Real Prs3d_DatumAspect::AxisLength (Prs3d_DatumParts thePart) const
146{
147 switch (thePart)
148 {
149 case Prs3d_DP_XAxis: return myAttributes.Find (Prs3d_DA_XAxisLength);
150 case Prs3d_DP_YAxis: return myAttributes.Find (Prs3d_DA_YAxisLength);
151 case Prs3d_DP_ZAxis: return myAttributes.Find (Prs3d_DA_ZAxisLength);
152 default: break;
153 }
154 return 0.0;
155}
156
157// =======================================================================
158// function : ArrowPartForAxis
159// purpose :
160// =======================================================================
161Prs3d_DatumParts Prs3d_DatumAspect::ArrowPartForAxis (Prs3d_DatumParts thePart) const
162{
163 switch (thePart)
164 {
165 case Prs3d_DP_XAxis: return Prs3d_DP_XArrow;
166 case Prs3d_DP_YAxis: return Prs3d_DP_YArrow;
167 case Prs3d_DP_ZAxis: return Prs3d_DP_ZArrow;
168 default: break;
169 }
170 return Prs3d_DP_None;
7fd59977 171}
0904aa63 172
173// =======================================================================
174// function : DumpJson
175// purpose :
176// =======================================================================
bc73b006 177void Prs3d_DatumAspect::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
0904aa63 178{
bc73b006 179 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
0904aa63 180
bc73b006 181 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myTextAspect.get())
182 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myPointAspect.get())
183 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myArrowAspect.get())
0904aa63 184
bc73b006 185 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myAxes)
186 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToDrawLabels)
187 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToDrawArrows)
0904aa63 188}