0031682: Visualization - Prs3d_ShadingAspect::SetTransparency() has no effect with...
[occt.git] / src / Prs3d / Prs3d_DatumAspect.hxx
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
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _Prs3d_DatumAspect_HeaderFile
18 #define _Prs3d_DatumAspect_HeaderFile
19
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>
30
31 //! A framework to define the display of datums.
32 class Prs3d_DatumAspect : public Prs3d_BasicAspect
33 {
34   DEFINE_STANDARD_RTTIEXT(Prs3d_DatumAspect, Prs3d_BasicAspect)
35 public:
36
37   //! An empty framework to define the display of datums.
38   Standard_EXPORT Prs3d_DatumAspect();
39
40   //! Returns the right-handed coordinate system set in SetComponent.
41   Standard_EXPORT Handle(Prs3d_LineAspect) LineAspect (Prs3d_DatumParts thePart) const;
42
43   //! Returns the right-handed coordinate system set in SetComponent.
44   Standard_EXPORT Handle(Prs3d_ShadingAspect) ShadingAspect (Prs3d_DatumParts thePart) const;
45
46   //! Returns the text attributes for rendering labels.
47   const Handle(Prs3d_TextAspect)& TextAspect() const { return myTextAspect; }
48
49   //! Sets text attributes for rendering labels.
50   void SetTextAspect (const Handle(Prs3d_TextAspect)& theTextAspect) { myTextAspect = theTextAspect; }
51
52   //! Returns the point aspect of origin wireframe presentation
53   const Handle(Prs3d_PointAspect)& PointAspect() const { return myPointAspect; }
54
55   //! Returns the point aspect of origin wireframe presentation
56   void SetPointAspect (const Handle(Prs3d_PointAspect)& theAspect) { myPointAspect = theAspect; }
57
58   //! Returns the arrow aspect of presentation
59   const Handle(Prs3d_ArrowAspect)& ArrowAspect() const { return myArrowAspect; }
60
61   //! Sets the arrow aspect of presentation
62   void SetArrowAspect (const Handle(Prs3d_ArrowAspect)& theAspect) { myArrowAspect = theAspect; }
63
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); }
67
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); }
71
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); }
75
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);
79
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
83   {
84     return (myAxes & Prs3d_DA_XAxis) != 0
85         && (myAxes & Prs3d_DA_YAxis) != 0;
86   }
87
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);
91
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; }
95
96   //! Returns true if the given part is used in axes of aspect
97   Standard_EXPORT Standard_Boolean DrawDatumPart (Prs3d_DatumParts thePart) const;
98
99   //! Sets the axes used in the datum aspect
100   void SetDrawDatumAxes (Prs3d_DatumAxes theType) { myAxes = theType; }
101
102   //! Returns axes used in the datum aspect
103   Prs3d_DatumAxes DatumAxes() const { return myAxes; }
104
105   //! Sets the attribute of the datum type
106   void SetAttribute (Prs3d_DatumAttribute theType, const Standard_Real& theValue)
107   {
108     myAttributes.Bind (theType, theValue);
109   }
110
111   //! Returns the attribute of the datum type
112   Standard_Real Attribute (Prs3d_DatumAttribute theType) const
113   {
114     return myAttributes.Find (theType);
115   }
116
117   //! Sets the lengths of the three axes.
118   void SetAxisLength (Standard_Real theL1, Standard_Real theL2, Standard_Real theL3)
119   {
120     myAttributes.Bind (Prs3d_DA_XAxisLength, theL1);
121     myAttributes.Bind (Prs3d_DA_YAxisLength, theL2);
122     myAttributes.Bind (Prs3d_DA_ZAxisLength, theL3);
123   }
124
125   //! Returns the length of the displayed first axis.
126   Standard_EXPORT Standard_Real AxisLength (Prs3d_DatumParts thePart) const;
127
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); }
131
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); }
135
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); }
139
140   //! @return true if axes labels are drawn; TRUE by default.
141   Standard_Boolean ToDrawLabels() const { return myToDrawLabels; }
142
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; }
146
147   //! @return true if axes arrows are drawn; TRUE by default.
148   Standard_Boolean ToDrawArrows() const { return myToDrawArrows; }
149
150   //! Sets option to draw or not arrows for axes
151   void SetDrawArrows (Standard_Boolean theToDraw) { myToDrawArrows = theToDraw; }
152
153   //! Returns type of arrow for a type of axis
154   Standard_EXPORT Prs3d_DatumParts ArrowPartForAxis (Prs3d_DatumParts thePart) const;
155
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;
158
159 private:
160   Prs3d_DatumAxes myAxes;
161   Standard_Boolean myToDrawLabels;
162   Standard_Boolean myToDrawArrows;
163   NCollection_DataMap<Prs3d_DatumAttribute, Standard_Real> myAttributes;
164
165   NCollection_DataMap<Prs3d_DatumParts, Handle(Prs3d_ShadingAspect)> myShadedAspects;
166   NCollection_DataMap<Prs3d_DatumParts, Handle(Prs3d_LineAspect)> myLineAspects;
167
168   Handle(Prs3d_TextAspect)  myTextAspect;
169   Handle(Prs3d_PointAspect) myPointAspect;
170   Handle(Prs3d_ArrowAspect) myArrowAspect;
171 };
172
173 DEFINE_STANDARD_HANDLE(Prs3d_DatumAspect, Prs3d_BasicAspect)
174
175 #endif // _Prs3d_DatumAspect_HeaderFile