0027958: Visualization, AIS_Trihedron - add shaded presentation option
[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 right-handed coordinate system set in SetComponent.
47   const Handle(Prs3d_TextAspect)& TextAspect() const { return myTextAspect; }
48
49   //! Returns the point aspect of origin wireframe presentation
50   const Handle(Prs3d_PointAspect)& PointAspect() const { return myPointAspect; }
51
52   //! Returns the arrow aspect of presentation
53   const Handle(Prs3d_ArrowAspect)& ArrowAspect() const { return myArrowAspect; }
54
55   //! Returns the attributes for display of the first axis.
56   Standard_DEPRECATED("This method is deprecated - LineAspect() should be called instead")
57   const Handle(Prs3d_LineAspect)& FirstAxisAspect() const { return myLineAspects.Find (Prs3d_DP_XAxis); }
58
59   //! Returns the attributes for display of the second axis.
60   Standard_DEPRECATED("This method is deprecated - LineAspect() should be called instead")
61   const Handle(Prs3d_LineAspect)& SecondAxisAspect() const { return myLineAspects.Find (Prs3d_DP_YAxis); }
62
63   //! Returns the attributes for display of the third axis.
64   Standard_DEPRECATED("This method is deprecated - LineAspect() should be called instead")
65   const Handle(Prs3d_LineAspect)& ThirdAxisAspect() const { return myLineAspects.Find (Prs3d_DP_ZAxis); }
66
67   //! Sets the DrawFirstAndSecondAxis attributes to active.
68   Standard_DEPRECATED("This method is deprecated - SetDrawDatumAxes() should be called instead")
69   Standard_EXPORT void SetDrawFirstAndSecondAxis (Standard_Boolean theToDraw);
70
71   //! Returns true if the first and second axes can be drawn.
72   Standard_DEPRECATED("This method is deprecated - DatumAxes() should be called instead")
73   Standard_Boolean DrawFirstAndSecondAxis() const
74   {
75     return (myAxes & Prs3d_DA_XAxis) != 0
76         && (myAxes & Prs3d_DA_YAxis) != 0;
77   }
78
79   //! Sets the DrawThirdAxis attributes to active.
80   Standard_DEPRECATED("This method is deprecated - SetDrawDatumAxes() should be called instead")
81   Standard_EXPORT void SetDrawThirdAxis (Standard_Boolean theToDraw);
82
83   //! Returns true if the third axis can be drawn.
84   Standard_DEPRECATED("This method is deprecated - DatumAxes() should be called instead")
85   Standard_Boolean DrawThirdAxis() const { return (myAxes & Prs3d_DA_ZAxis) != 0; }
86
87   //! Returns true if the given part is used in axes of aspect
88   Standard_EXPORT Standard_Boolean DrawDatumPart (Prs3d_DatumParts thePart) const;
89
90   //! Sets the axes used in the datum aspect
91    void SetDrawDatumAxes (Prs3d_DatumAxes theType) { myAxes = theType; }
92
93   //! Returns axes used in the datum aspect
94    Prs3d_DatumAxes DatumAxes() const { return myAxes; }
95
96   //! Sets the attribute of the datum type
97   void SetAttribute (Prs3d_DatumAttribute theType, const Standard_Real& theValue)
98   {
99     myAttributes.Bind (theType, theValue);
100   }
101
102   //! Returns the attribute of the datum type
103   Standard_Real Attribute (Prs3d_DatumAttribute theType) const
104   {
105     return myAttributes.Find (theType);
106   }
107
108   //! Sets the lengths of the three axes.
109   void SetAxisLength (Standard_Real theL1, Standard_Real theL2, Standard_Real theL3)
110   {
111     myAttributes.Bind (Prs3d_DA_XAxisLength, theL1);
112     myAttributes.Bind (Prs3d_DA_YAxisLength, theL2);
113     myAttributes.Bind (Prs3d_DA_ZAxisLength, theL3);
114   }
115
116   //! Returns the length of the displayed first axis.
117   Standard_EXPORT Standard_Real AxisLength (Prs3d_DatumParts thePart) const;
118
119   //! Returns the length of the displayed first axis.
120   Standard_DEPRECATED("This method is deprecated - AxisLength() should be called instead")
121   Standard_Real FirstAxisLength() const { return myAttributes.Find (Prs3d_DA_XAxisLength); }
122
123   //! Returns the length of the displayed second axis.
124   Standard_DEPRECATED("This method is deprecated - AxisLength() should be called instead")
125   Standard_Real SecondAxisLength() const { return myAttributes.Find (Prs3d_DA_YAxisLength); }
126
127   //! Returns the length of the displayed third axis.
128   Standard_DEPRECATED("This method is deprecated - AxisLength() should be called instead")
129   Standard_Real ThirdAxisLength() const { return myAttributes.Find (Prs3d_DA_ZAxisLength); }
130
131   //! Sets option to draw or not to draw text labels for axes
132   void SetToDrawLabels (Standard_Boolean theToDraw) { myToDrawLabels = theToDraw; }
133
134   //! @return true if axes labels are drawn
135   Standard_Boolean ToDrawLabels() const { return myToDrawLabels; }
136
137   //! Returns type of arrow for a type of axis
138   Standard_EXPORT Prs3d_DatumParts ArrowPartForAxis (Prs3d_DatumParts thePart) const;
139
140 private:
141   Prs3d_DatumAxes myAxes;
142   Standard_Boolean myToDrawLabels;
143   NCollection_DataMap<Prs3d_DatumAttribute, Standard_Real> myAttributes;
144
145   NCollection_DataMap<Prs3d_DatumParts, Handle(Prs3d_ShadingAspect)> myShadedAspects;
146   NCollection_DataMap<Prs3d_DatumParts, Handle(Prs3d_LineAspect)> myLineAspects;
147
148   Handle(Prs3d_TextAspect)  myTextAspect;
149   Handle(Prs3d_PointAspect) myPointAspect;
150   Handle(Prs3d_ArrowAspect) myArrowAspect;
151 };
152
153 DEFINE_STANDARD_HANDLE(Prs3d_DatumAspect, Prs3d_BasicAspect)
154
155 #endif // _Prs3d_DatumAspect_HeaderFile