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 constructor.
38 Standard_EXPORT Prs3d_DatumAspect();
40 //! Returns line aspect for specified part.
41 const Handle(Prs3d_LineAspect)& LineAspect (Prs3d_DatumParts thePart) const { return myLineAspects[thePart]; }
43 //! Returns shading aspect for specified part.
44 const Handle(Prs3d_ShadingAspect)& ShadingAspect (Prs3d_DatumParts thePart) const { return myShadedAspects[thePart]; }
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 true if the given part is used in axes of aspect
65 Standard_EXPORT Standard_Boolean DrawDatumPart (Prs3d_DatumParts thePart) const;
67 //! Sets the axes used in the datum aspect
68 void SetDrawDatumAxes (Prs3d_DatumAxes theType) { myAxes = theType; }
70 //! Returns axes used in the datum aspect
71 Prs3d_DatumAxes DatumAxes() const { return myAxes; }
73 //! Returns the attribute of the datum type
74 Standard_Real Attribute (Prs3d_DatumAttribute theType) const { return myAttributes[theType]; }
76 //! Sets the attribute of the datum type
77 void SetAttribute (Prs3d_DatumAttribute theType, const Standard_Real theValue) { myAttributes[theType] = theValue; }
79 //! Returns the length of the displayed first axis.
80 Standard_EXPORT Standard_Real AxisLength (Prs3d_DatumParts thePart) const;
82 //! Sets the lengths of the three axes.
83 void SetAxisLength (Standard_Real theL1, Standard_Real theL2, Standard_Real theL3)
85 myAttributes[Prs3d_DatumAttribute_XAxisLength] = theL1;
86 myAttributes[Prs3d_DatumAttribute_YAxisLength] = theL2;
87 myAttributes[Prs3d_DatumAttribute_ZAxisLength] = theL3;
90 //! @return true if axes labels are drawn; TRUE by default.
91 Standard_Boolean ToDrawLabels() const { return myToDrawLabels; }
93 //! Sets option to draw or not to draw text labels for axes
94 void SetDrawLabels (Standard_Boolean theToDraw) { myToDrawLabels = theToDraw; }
95 void SetToDrawLabels (Standard_Boolean theToDraw) { myToDrawLabels = theToDraw; }
97 //! @return true if axes arrows are drawn; TRUE by default.
98 Standard_Boolean ToDrawArrows() const { return myToDrawArrows; }
100 //! Sets option to draw or not arrows for axes
101 void SetDrawArrows (Standard_Boolean theToDraw) { myToDrawArrows = theToDraw; }
103 //! Returns type of arrow for a type of axis
104 Standard_EXPORT Prs3d_DatumParts ArrowPartForAxis (Prs3d_DatumParts thePart) const;
106 //! Dumps the content of me into the stream
107 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
111 //! Returns the attributes for display of the first axis.
112 Standard_DEPRECATED("This method is deprecated - LineAspect() should be called instead")
113 const Handle(Prs3d_LineAspect)& FirstAxisAspect() const { return myLineAspects[Prs3d_DatumParts_XAxis]; }
115 //! Returns the attributes for display of the second axis.
116 Standard_DEPRECATED("This method is deprecated - LineAspect() should be called instead")
117 const Handle(Prs3d_LineAspect)& SecondAxisAspect() const { return myLineAspects[Prs3d_DatumParts_YAxis]; }
119 //! Returns the attributes for display of the third axis.
120 Standard_DEPRECATED("This method is deprecated - LineAspect() should be called instead")
121 const Handle(Prs3d_LineAspect)& ThirdAxisAspect() const { return myLineAspects[Prs3d_DatumParts_ZAxis]; }
123 //! Sets the DrawFirstAndSecondAxis attributes to active.
124 Standard_DEPRECATED("This method is deprecated - SetDrawDatumAxes() should be called instead")
125 Standard_EXPORT void SetDrawFirstAndSecondAxis (Standard_Boolean theToDraw);
127 //! Returns true if the first and second axes can be drawn.
128 Standard_DEPRECATED("This method is deprecated - DatumAxes() should be called instead")
129 Standard_Boolean DrawFirstAndSecondAxis() const
131 return (myAxes & Prs3d_DatumAxes_XAxis) != 0
132 && (myAxes & Prs3d_DatumAxes_YAxis) != 0;
135 //! Sets the DrawThirdAxis attributes to active.
136 Standard_DEPRECATED("This method is deprecated - SetDrawDatumAxes() should be called instead")
137 Standard_EXPORT void SetDrawThirdAxis (Standard_Boolean theToDraw);
139 //! Returns true if the third axis can be drawn.
140 Standard_DEPRECATED("This method is deprecated - DatumAxes() should be called instead")
141 Standard_Boolean DrawThirdAxis() const { return (myAxes & Prs3d_DatumAxes_ZAxis) != 0; }
143 //! Returns the length of the displayed first axis.
144 Standard_DEPRECATED("This method is deprecated - AxisLength() should be called instead")
145 Standard_Real FirstAxisLength() const { return myAttributes[Prs3d_DatumAttribute_XAxisLength]; }
147 //! Returns the length of the displayed second axis.
148 Standard_DEPRECATED("This method is deprecated - AxisLength() should be called instead")
149 Standard_Real SecondAxisLength() const { return myAttributes[Prs3d_DatumAttribute_YAxisLength]; }
151 //! Returns the length of the displayed third axis.
152 Standard_DEPRECATED("This method is deprecated - AxisLength() should be called instead")
153 Standard_Real ThirdAxisLength() const { return myAttributes[Prs3d_DatumAttribute_ZAxisLength]; }
157 Handle(Prs3d_ShadingAspect) myShadedAspects[Prs3d_DatumParts_NB];
158 Handle(Prs3d_LineAspect) myLineAspects[Prs3d_DatumParts_NB];
159 Handle(Prs3d_TextAspect) myTextAspect;
160 Handle(Prs3d_PointAspect) myPointAspect;
161 Handle(Prs3d_ArrowAspect) myArrowAspect;
162 Standard_Real myAttributes[Prs3d_DatumAttribute_NB];
163 Prs3d_DatumAxes myAxes;
164 Standard_Boolean myToDrawLabels;
165 Standard_Boolean myToDrawArrows;
169 DEFINE_STANDARD_HANDLE(Prs3d_DatumAspect, Prs3d_BasicAspect)
171 #endif // _Prs3d_DatumAspect_HeaderFile