1 // Created on: 1993-07-30
2 // Created by: Jean-Louis FRENKEL
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _Prs3d_DatumAspect_HeaderFile
18 #define _Prs3d_DatumAspect_HeaderFile
20 #include <NCollection_DataMap.hxx>
21 #include <Prs3d_ArrowAspect.hxx>
22 #include <Prs3d_DatumAttribute.hxx>
23 #include <Prs3d_DatumAxes.hxx>
24 #include <Prs3d_DatumMode.hxx>
25 #include <Prs3d_DatumParts.hxx>
26 #include <Prs3d_LineAspect.hxx>
27 #include <Prs3d_PointAspect.hxx>
28 #include <Prs3d_ShadingAspect.hxx>
29 #include <Prs3d_TextAspect.hxx>
31 //! A framework to define the display of datums.
32 class Prs3d_DatumAspect : public Prs3d_BasicAspect
34 DEFINE_STANDARD_RTTIEXT(Prs3d_DatumAspect, Prs3d_BasicAspect)
37 //! An empty framework to define the display of datums.
38 Standard_EXPORT Prs3d_DatumAspect();
40 //! Returns the right-handed coordinate system set in SetComponent.
41 Standard_EXPORT Handle(Prs3d_LineAspect) LineAspect (Prs3d_DatumParts thePart) const;
43 //! Returns the right-handed coordinate system set in SetComponent.
44 Standard_EXPORT Handle(Prs3d_ShadingAspect) ShadingAspect (Prs3d_DatumParts thePart) const;
46 //! Returns the text attributes for rendering labels.
47 const Handle(Prs3d_TextAspect)& TextAspect() const { return myTextAspect; }
49 //! Sets text attributes for rendering labels.
50 void SetTextAspect (const Handle(Prs3d_TextAspect)& theTextAspect) { myTextAspect = theTextAspect; }
52 //! Returns the point aspect of origin wireframe presentation
53 const Handle(Prs3d_PointAspect)& PointAspect() const { return myPointAspect; }
55 //! Returns the point aspect of origin wireframe presentation
56 void SetPointAspect (const Handle(Prs3d_PointAspect)& theAspect) { myPointAspect = theAspect; }
58 //! Returns the arrow aspect of presentation
59 const Handle(Prs3d_ArrowAspect)& ArrowAspect() const { return myArrowAspect; }
61 //! Sets the arrow aspect of presentation
62 void SetArrowAspect (const Handle(Prs3d_ArrowAspect)& theAspect) { myArrowAspect = theAspect; }
64 //! Returns the attributes for display of the first axis.
65 Standard_DEPRECATED("This method is deprecated - LineAspect() should be called instead")
66 const Handle(Prs3d_LineAspect)& FirstAxisAspect() const { return myLineAspects.Find (Prs3d_DP_XAxis); }
68 //! Returns the attributes for display of the second axis.
69 Standard_DEPRECATED("This method is deprecated - LineAspect() should be called instead")
70 const Handle(Prs3d_LineAspect)& SecondAxisAspect() const { return myLineAspects.Find (Prs3d_DP_YAxis); }
72 //! Returns the attributes for display of the third axis.
73 Standard_DEPRECATED("This method is deprecated - LineAspect() should be called instead")
74 const Handle(Prs3d_LineAspect)& ThirdAxisAspect() const { return myLineAspects.Find (Prs3d_DP_ZAxis); }
76 //! Sets the DrawFirstAndSecondAxis attributes to active.
77 Standard_DEPRECATED("This method is deprecated - SetDrawDatumAxes() should be called instead")
78 Standard_EXPORT void SetDrawFirstAndSecondAxis (Standard_Boolean theToDraw);
80 //! Returns true if the first and second axes can be drawn.
81 Standard_DEPRECATED("This method is deprecated - DatumAxes() should be called instead")
82 Standard_Boolean DrawFirstAndSecondAxis() const
84 return (myAxes & Prs3d_DA_XAxis) != 0
85 && (myAxes & Prs3d_DA_YAxis) != 0;
88 //! Sets the DrawThirdAxis attributes to active.
89 Standard_DEPRECATED("This method is deprecated - SetDrawDatumAxes() should be called instead")
90 Standard_EXPORT void SetDrawThirdAxis (Standard_Boolean theToDraw);
92 //! Returns true if the third axis can be drawn.
93 Standard_DEPRECATED("This method is deprecated - DatumAxes() should be called instead")
94 Standard_Boolean DrawThirdAxis() const { return (myAxes & Prs3d_DA_ZAxis) != 0; }
96 //! Returns true if the given part is used in axes of aspect
97 Standard_EXPORT Standard_Boolean DrawDatumPart (Prs3d_DatumParts thePart) const;
99 //! Sets the axes used in the datum aspect
100 void SetDrawDatumAxes (Prs3d_DatumAxes theType) { myAxes = theType; }
102 //! Returns axes used in the datum aspect
103 Prs3d_DatumAxes DatumAxes() const { return myAxes; }
105 //! Sets the attribute of the datum type
106 void SetAttribute (Prs3d_DatumAttribute theType, const Standard_Real& theValue)
108 myAttributes.Bind (theType, theValue);
111 //! Returns the attribute of the datum type
112 Standard_Real Attribute (Prs3d_DatumAttribute theType) const
114 return myAttributes.Find (theType);
117 //! Sets the lengths of the three axes.
118 void SetAxisLength (Standard_Real theL1, Standard_Real theL2, Standard_Real theL3)
120 myAttributes.Bind (Prs3d_DA_XAxisLength, theL1);
121 myAttributes.Bind (Prs3d_DA_YAxisLength, theL2);
122 myAttributes.Bind (Prs3d_DA_ZAxisLength, theL3);
125 //! Returns the length of the displayed first axis.
126 Standard_EXPORT Standard_Real AxisLength (Prs3d_DatumParts thePart) const;
128 //! Returns the length of the displayed first axis.
129 Standard_DEPRECATED("This method is deprecated - AxisLength() should be called instead")
130 Standard_Real FirstAxisLength() const { return myAttributes.Find (Prs3d_DA_XAxisLength); }
132 //! Returns the length of the displayed second axis.
133 Standard_DEPRECATED("This method is deprecated - AxisLength() should be called instead")
134 Standard_Real SecondAxisLength() const { return myAttributes.Find (Prs3d_DA_YAxisLength); }
136 //! Returns the length of the displayed third axis.
137 Standard_DEPRECATED("This method is deprecated - AxisLength() should be called instead")
138 Standard_Real ThirdAxisLength() const { return myAttributes.Find (Prs3d_DA_ZAxisLength); }
140 //! @return true if axes labels are drawn; TRUE by default.
141 Standard_Boolean ToDrawLabels() const { return myToDrawLabels; }
143 //! Sets option to draw or not to draw text labels for axes
144 void SetDrawLabels (Standard_Boolean theToDraw) { myToDrawLabels = theToDraw; }
145 void SetToDrawLabels (Standard_Boolean theToDraw) { myToDrawLabels = theToDraw; }
147 //! @return true if axes arrows are drawn; TRUE by default.
148 Standard_Boolean ToDrawArrows() const { return myToDrawArrows; }
150 //! Sets option to draw or not arrows for axes
151 void SetDrawArrows (Standard_Boolean theToDraw) { myToDrawArrows = theToDraw; }
153 //! Returns type of arrow for a type of axis
154 Standard_EXPORT Prs3d_DatumParts ArrowPartForAxis (Prs3d_DatumParts thePart) const;
156 //! Dumps the content of me into the stream
157 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
160 Prs3d_DatumAxes myAxes;
161 Standard_Boolean myToDrawLabels;
162 Standard_Boolean myToDrawArrows;
163 NCollection_DataMap<Prs3d_DatumAttribute, Standard_Real> myAttributes;
165 NCollection_DataMap<Prs3d_DatumParts, Handle(Prs3d_ShadingAspect)> myShadedAspects;
166 NCollection_DataMap<Prs3d_DatumParts, Handle(Prs3d_LineAspect)> myLineAspects;
168 Handle(Prs3d_TextAspect) myTextAspect;
169 Handle(Prs3d_PointAspect) myPointAspect;
170 Handle(Prs3d_ArrowAspect) myArrowAspect;
173 DEFINE_STANDARD_HANDLE(Prs3d_DatumAspect, Prs3d_BasicAspect)
175 #endif // _Prs3d_DatumAspect_HeaderFile