0031909: Visualization, AIS_Trihedron - replace maps with arrays
[occt.git] / src / Prs3d / Prs3d_DatumAspect.hxx
index d739c79..d4e364a 100644 (file)
@@ -34,14 +34,14 @@ class Prs3d_DatumAspect : public Prs3d_BasicAspect
   DEFINE_STANDARD_RTTIEXT(Prs3d_DatumAspect, Prs3d_BasicAspect)
 public:
 
-  //! An empty framework to define the display of datums.
+  //! An empty constructor.
   Standard_EXPORT Prs3d_DatumAspect();
 
-  //! Returns the right-handed coordinate system set in SetComponent.
-  Standard_EXPORT Handle(Prs3d_LineAspect) LineAspect (Prs3d_DatumParts thePart) const;
+  //! Returns line aspect for specified part.
+  const Handle(Prs3d_LineAspect)& LineAspect (Prs3d_DatumParts thePart) const { return myLineAspects[thePart]; }
 
-  //! Returns the right-handed coordinate system set in SetComponent.
-  Standard_EXPORT Handle(Prs3d_ShadingAspect) ShadingAspect (Prs3d_DatumParts thePart) const;
+  //! Returns shading aspect for specified part.
+  const Handle(Prs3d_ShadingAspect)& ShadingAspect (Prs3d_DatumParts thePart) const { return myShadedAspects[thePart]; }
 
   //! Returns the text attributes for rendering labels.
   const Handle(Prs3d_TextAspect)& TextAspect() const { return myTextAspect; }
@@ -61,38 +61,6 @@ public:
   //! Sets the arrow aspect of presentation
   void SetArrowAspect (const Handle(Prs3d_ArrowAspect)& theAspect) { myArrowAspect = theAspect; }
 
-  //! Returns the attributes for display of the first axis.
-  Standard_DEPRECATED("This method is deprecated - LineAspect() should be called instead")
-  const Handle(Prs3d_LineAspect)& FirstAxisAspect() const { return myLineAspects.Find (Prs3d_DP_XAxis); }
-
-  //! Returns the attributes for display of the second axis.
-  Standard_DEPRECATED("This method is deprecated - LineAspect() should be called instead")
-  const Handle(Prs3d_LineAspect)& SecondAxisAspect() const { return myLineAspects.Find (Prs3d_DP_YAxis); }
-
-  //! Returns the attributes for display of the third axis.
-  Standard_DEPRECATED("This method is deprecated - LineAspect() should be called instead")
-  const Handle(Prs3d_LineAspect)& ThirdAxisAspect() const { return myLineAspects.Find (Prs3d_DP_ZAxis); }
-
-  //! Sets the DrawFirstAndSecondAxis attributes to active.
-  Standard_DEPRECATED("This method is deprecated - SetDrawDatumAxes() should be called instead")
-  Standard_EXPORT void SetDrawFirstAndSecondAxis (Standard_Boolean theToDraw);
-
-  //! Returns true if the first and second axes can be drawn.
-  Standard_DEPRECATED("This method is deprecated - DatumAxes() should be called instead")
-  Standard_Boolean DrawFirstAndSecondAxis() const
-  {
-    return (myAxes & Prs3d_DA_XAxis) != 0
-        && (myAxes & Prs3d_DA_YAxis) != 0;
-  }
-
-  //! Sets the DrawThirdAxis attributes to active.
-  Standard_DEPRECATED("This method is deprecated - SetDrawDatumAxes() should be called instead")
-  Standard_EXPORT void SetDrawThirdAxis (Standard_Boolean theToDraw);
-
-  //! Returns true if the third axis can be drawn.
-  Standard_DEPRECATED("This method is deprecated - DatumAxes() should be called instead")
-  Standard_Boolean DrawThirdAxis() const { return (myAxes & Prs3d_DA_ZAxis) != 0; }
-
   //! Returns true if the given part is used in axes of aspect
   Standard_EXPORT Standard_Boolean DrawDatumPart (Prs3d_DatumParts thePart) const;
 
@@ -102,41 +70,23 @@ public:
   //! Returns axes used in the datum aspect
   Prs3d_DatumAxes DatumAxes() const { return myAxes; }
 
+  //! Returns the attribute of the datum type
+  Standard_Real Attribute (Prs3d_DatumAttribute theType) const { return myAttributes[theType]; }
+
   //! Sets the attribute of the datum type
-  void SetAttribute (Prs3d_DatumAttribute theType, const Standard_Real& theValue)
-  {
-    myAttributes.Bind (theType, theValue);
-  }
+  void SetAttribute (Prs3d_DatumAttribute theType, const Standard_Real theValue) { myAttributes[theType] = theValue; }
 
-  //! Returns the attribute of the datum type
-  Standard_Real Attribute (Prs3d_DatumAttribute theType) const
-  {
-    return myAttributes.Find (theType);
-  }
+  //! Returns the length of the displayed first axis.
+  Standard_EXPORT Standard_Real AxisLength (Prs3d_DatumParts thePart) const;
 
   //! Sets the lengths of the three axes.
   void SetAxisLength (Standard_Real theL1, Standard_Real theL2, Standard_Real theL3)
   {
-    myAttributes.Bind (Prs3d_DA_XAxisLength, theL1);
-    myAttributes.Bind (Prs3d_DA_YAxisLength, theL2);
-    myAttributes.Bind (Prs3d_DA_ZAxisLength, theL3);
+    myAttributes[Prs3d_DatumAttribute_XAxisLength] = theL1;
+    myAttributes[Prs3d_DatumAttribute_YAxisLength] = theL2;
+    myAttributes[Prs3d_DatumAttribute_ZAxisLength] = theL3;
   }
 
-  //! Returns the length of the displayed first axis.
-  Standard_EXPORT Standard_Real AxisLength (Prs3d_DatumParts thePart) const;
-
-  //! Returns the length of the displayed first axis.
-  Standard_DEPRECATED("This method is deprecated - AxisLength() should be called instead")
-  Standard_Real FirstAxisLength() const { return myAttributes.Find (Prs3d_DA_XAxisLength); }
-
-  //! Returns the length of the displayed second axis.
-  Standard_DEPRECATED("This method is deprecated - AxisLength() should be called instead")
-  Standard_Real SecondAxisLength() const { return myAttributes.Find (Prs3d_DA_YAxisLength); }
-
-  //! Returns the length of the displayed third axis.
-  Standard_DEPRECATED("This method is deprecated - AxisLength() should be called instead")
-  Standard_Real ThirdAxisLength() const { return myAttributes.Find (Prs3d_DA_ZAxisLength); }
-
   //! @return true if axes labels are drawn; TRUE by default.
   Standard_Boolean ToDrawLabels() const { return myToDrawLabels; }
 
@@ -156,18 +106,64 @@ public:
   //! Dumps the content of me into the stream
   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
 
+public:
+
+  //! Returns the attributes for display of the first axis.
+  Standard_DEPRECATED("This method is deprecated - LineAspect() should be called instead")
+  const Handle(Prs3d_LineAspect)& FirstAxisAspect() const { return myLineAspects[Prs3d_DatumParts_XAxis]; }
+
+  //! Returns the attributes for display of the second axis.
+  Standard_DEPRECATED("This method is deprecated - LineAspect() should be called instead")
+  const Handle(Prs3d_LineAspect)& SecondAxisAspect() const { return myLineAspects[Prs3d_DatumParts_YAxis]; }
+
+  //! Returns the attributes for display of the third axis.
+  Standard_DEPRECATED("This method is deprecated - LineAspect() should be called instead")
+  const Handle(Prs3d_LineAspect)& ThirdAxisAspect() const { return myLineAspects[Prs3d_DatumParts_ZAxis]; }
+
+  //! Sets the DrawFirstAndSecondAxis attributes to active.
+  Standard_DEPRECATED("This method is deprecated - SetDrawDatumAxes() should be called instead")
+  Standard_EXPORT void SetDrawFirstAndSecondAxis (Standard_Boolean theToDraw);
+
+  //! Returns true if the first and second axes can be drawn.
+  Standard_DEPRECATED("This method is deprecated - DatumAxes() should be called instead")
+  Standard_Boolean DrawFirstAndSecondAxis() const
+  {
+    return (myAxes & Prs3d_DatumAxes_XAxis) != 0
+        && (myAxes & Prs3d_DatumAxes_YAxis) != 0;
+  }
+
+  //! Sets the DrawThirdAxis attributes to active.
+  Standard_DEPRECATED("This method is deprecated - SetDrawDatumAxes() should be called instead")
+  Standard_EXPORT void SetDrawThirdAxis (Standard_Boolean theToDraw);
+
+  //! Returns true if the third axis can be drawn.
+  Standard_DEPRECATED("This method is deprecated - DatumAxes() should be called instead")
+  Standard_Boolean DrawThirdAxis() const { return (myAxes & Prs3d_DatumAxes_ZAxis) != 0; }
+
+  //! Returns the length of the displayed first axis.
+  Standard_DEPRECATED("This method is deprecated - AxisLength() should be called instead")
+  Standard_Real FirstAxisLength() const { return myAttributes[Prs3d_DatumAttribute_XAxisLength]; }
+
+  //! Returns the length of the displayed second axis.
+  Standard_DEPRECATED("This method is deprecated - AxisLength() should be called instead")
+  Standard_Real SecondAxisLength() const { return myAttributes[Prs3d_DatumAttribute_YAxisLength]; }
+
+  //! Returns the length of the displayed third axis.
+  Standard_DEPRECATED("This method is deprecated - AxisLength() should be called instead")
+  Standard_Real ThirdAxisLength() const { return myAttributes[Prs3d_DatumAttribute_ZAxisLength]; }
+
 private:
-  Prs3d_DatumAxes myAxes;
-  Standard_Boolean myToDrawLabels;
-  Standard_Boolean myToDrawArrows;
-  NCollection_DataMap<Prs3d_DatumAttribute, Standard_Real> myAttributes;
 
-  NCollection_DataMap<Prs3d_DatumParts, Handle(Prs3d_ShadingAspect)> myShadedAspects;
-  NCollection_DataMap<Prs3d_DatumParts, Handle(Prs3d_LineAspect)> myLineAspects;
+  Handle(Prs3d_ShadingAspect) myShadedAspects[Prs3d_DatumParts_NB];
+  Handle(Prs3d_LineAspect)    myLineAspects[Prs3d_DatumParts_NB];
+  Handle(Prs3d_TextAspect)    myTextAspect;
+  Handle(Prs3d_PointAspect)   myPointAspect;
+  Handle(Prs3d_ArrowAspect)   myArrowAspect;
+  Standard_Real               myAttributes[Prs3d_DatumAttribute_NB];
+  Prs3d_DatumAxes             myAxes;
+  Standard_Boolean            myToDrawLabels;
+  Standard_Boolean            myToDrawArrows;
 
-  Handle(Prs3d_TextAspect)  myTextAspect;
-  Handle(Prs3d_PointAspect) myPointAspect;
-  Handle(Prs3d_ArrowAspect) myArrowAspect;
 };
 
 DEFINE_STANDARD_HANDLE(Prs3d_DatumAspect, Prs3d_BasicAspect)