0028726: Quantity_NameOfColor should be replaced by Quantity_Color in function input...
[occt.git] / src / AIS / AIS_Axis.cxx
index f1be5fe..3aa1600 100644 (file)
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
-//GER61351             //GG_171199     Enable to set an object RGB color instead a restricted object NameOfColor.
+#include <AIS_Axis.hxx>
 
-#include <AIS_Axis.ixx>
 #include <Aspect_TypeOfLine.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Prs3d_LineAspect.hxx>
-#include <Prs3d_DatumAspect.hxx>
+#include <DsgPrs_XYZAxisPresentation.hxx>
+#include <Geom_Axis1Placement.hxx>
+#include <Geom_Axis2Placement.hxx>
+#include <Geom_Line.hxx>
+#include <Geom_Transformation.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <gp_Ax1.hxx>
+#include <gp_Ax2.hxx>
 #include <Graphic3d_AspectLine3d.hxx>
 #include <Graphic3d_Structure.hxx>
-#include <TColgp_Array1OfPnt.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <SelectBasics_EntityOwner.hxx>
+#include <Prs3d_DatumAspect.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_LineAspect.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Prs3d_Projector.hxx>
+#include <Quantity_Color.hxx>
 #include <Select3D_SensitiveSegment.hxx>
+#include <SelectBasics_EntityOwner.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <Standard_Type.hxx>
 #include <StdPrs_Curve.hxx>
+#include <TColgp_Array1OfPnt.hxx>
 #include <TopoDS.hxx>
-#include <Geom_Axis1Placement.hxx>
-#include <gp_Ax1.hxx>
-#include <gp_Ax2.hxx>
-#include <Geom_Line.hxx>
-#include <GeomAdaptor_Curve.hxx>
-#include <AIS_Drawer.hxx>
-#include <DsgPrs_XYZAxisPresentation.hxx>
 #include <UnitsAPI.hxx>
 
+IMPLEMENT_STANDARD_RTTIEXT(AIS_Axis,AIS_InteractiveObject)
+
 //=======================================================================
 //function : AIS_Axis
 //purpose  :
@@ -78,10 +85,10 @@ myIsXYZAxis(Standard_True)
     aLength = 0.1;
   }
   DA->SetAxisLength(aLength,aLength,aLength);
-  Quantity_NameOfColor col = Quantity_NOC_TURQUOISE;
-  DA->FirstAxisAspect()->SetColor(col);
-  DA->SecondAxisAspect()->SetColor(col);
-  DA->ThirdAxisAspect()->SetColor(col);
+  Quantity_Color col (Quantity_NOC_TURQUOISE);
+  DA->LineAspect(Prs3d_DP_XAxis)->SetColor(col);
+  DA->LineAspect(Prs3d_DP_YAxis)->SetColor(col);
+  DA->LineAspect(Prs3d_DP_ZAxis)->SetColor(col);
   myDrawer->SetDatumAspect(DA); 
   
   ComputeFields();
@@ -162,9 +169,6 @@ void AIS_Axis::Compute(const Handle(PrsMgr_PresentationManager3d)&,
                       const Handle(Prs3d_Presentation)& aPresentation, 
                       const Standard_Integer)
 {
-  aPresentation->Clear();
-
-  //Pro.... : pas de prise en compte des axes lors du FITALL (jmi)
   aPresentation->SetInfiniteState (myInfiniteState);
 
   aPresentation->SetDisplayPriority(5);
@@ -172,15 +176,18 @@ void AIS_Axis::Compute(const Handle(PrsMgr_PresentationManager3d)&,
     GeomAdaptor_Curve curv(myComponent);
     StdPrs_Curve::Add(aPresentation,curv,myDrawer);
   }
-  else {
-    DsgPrs_XYZAxisPresentation::Add(aPresentation,myLineAspect,myDir,myVal,myText,myPfirst,myPlast);
+  else
+  {
+    DsgPrs_XYZAxisPresentation::Add (aPresentation,myLineAspect,myDir,myVal,
+                                     myDrawer->DatumAspect()->ToDrawLabels() ? myText : "",
+                                     myPfirst, myPlast);
   }
 
 }
 
-void AIS_Axis::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation)
+void AIS_Axis::Compute(const Handle(Prs3d_Projector)& aProjector, const Handle(Geom_Transformation)& aTransformation, const Handle(Prs3d_Presentation)& aPresentation)
 {
-// Standard_NotImplemented::Raise("AIS_Axis::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
+// throw Standard_NotImplemented("AIS_Axis::Compute(const Handle(Prs3d_Projector)&, const Handle(Geom_Transformation)&, const Handle(Prs3d_Presentation)&)");
   PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ;
 }
 
@@ -202,25 +209,18 @@ void AIS_Axis::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
 
 //=======================================================================
 //function : SetColor
-//purpose  : 
+//purpose  :
 //=======================================================================
-
-
-void AIS_Axis::SetColor(const Quantity_NameOfColor aCol)
-{
-  SetColor(Quantity_Color(aCol));
-}
-
 void AIS_Axis::SetColor(const Quantity_Color &aCol)
 {
   hasOwnColor=Standard_True;
-  myOwnColor=aCol;
+  myDrawer->SetColor (aCol);
   myDrawer->LineAspect()->SetColor(aCol);
   
   const Handle(Prs3d_DatumAspect)& DA = myDrawer->DatumAspect();
-  DA->FirstAxisAspect()->SetColor(aCol);
-  DA->SecondAxisAspect()->SetColor(aCol);
-  DA->ThirdAxisAspect()->SetColor(aCol);
+  DA->LineAspect(Prs3d_DP_XAxis)->SetColor(aCol);
+  DA->LineAspect(Prs3d_DP_YAxis)->SetColor(aCol);
+  DA->LineAspect(Prs3d_DP_ZAxis)->SetColor(aCol);
   
 }
 
@@ -237,9 +237,9 @@ void AIS_Axis::SetWidth(const Standard_Real aValue)
   myDrawer->LineAspect()->SetWidth(aValue);
   
   const Handle(Prs3d_DatumAspect)& DA = myDrawer->DatumAspect();
-  DA->FirstAxisAspect()->SetWidth(aValue);
-  DA->SecondAxisAspect()->SetWidth(aValue);
-  DA->ThirdAxisAspect()->SetWidth(aValue);
+  DA->LineAspect(Prs3d_DP_XAxis)->SetWidth(aValue);
+  DA->LineAspect(Prs3d_DP_YAxis)->SetWidth(aValue);
+  DA->LineAspect(Prs3d_DP_ZAxis)->SetWidth(aValue);
 }
 
 
@@ -261,10 +261,11 @@ void AIS_Axis::ComputeFields()
   if (myIsXYZAxis){
     // calcul de myPFirst,myPlast
     Handle(Prs3d_DatumAspect) DA = myDrawer->DatumAspect();
-    gp_Pnt Orig = myAx2->Ax2().Location();
-    gp_Dir oX = myAx2->Ax2().XDirection();
-    gp_Dir oY = myAx2->Ax2().YDirection();
-    gp_Dir oZ = myAx2->Ax2().Direction();
+    gp_Ax2 anAxis = myAx2->Ax2();
+    const gp_Pnt& Orig = anAxis.Location();
+    const gp_Dir& oX   = anAxis.XDirection();
+    const gp_Dir& oY   = anAxis.YDirection();
+    const gp_Dir& oZ   = anAxis.Direction();
     Quantity_Length xo,yo,zo,x = 0.,y = 0.,z = 0.;
     Orig.Coord(xo,yo,zo);
     myPfirst.SetCoord(xo,yo,zo);
@@ -273,27 +274,27 @@ void AIS_Axis::ComputeFields()
     case AIS_TOAX_XAxis:
       {
        oX.Coord(x,y,z);
-       myVal = DA->FirstAxisLength();
+    myVal = DA->AxisLength(Prs3d_DP_XAxis);
        myDir = oX;
-       myLineAspect = DA->FirstAxisAspect();
+       myLineAspect = DA->LineAspect(Prs3d_DP_XAxis);
        myText = Standard_CString ("X");
        break;
       }
     case AIS_TOAX_YAxis:
       {
        oY.Coord(x,y,z);
-       myVal = DA->SecondAxisLength();
+       myVal = DA->AxisLength(Prs3d_DP_YAxis);
        myDir = oY;
-       myLineAspect = DA->SecondAxisAspect();
+       myLineAspect = DA->LineAspect(Prs3d_DP_YAxis);
        myText = Standard_CString ("Y");
        break;
       }
     case AIS_TOAX_ZAxis:
       {
        oZ.Coord(x,y,z); 
-       myVal = DA->ThirdAxisLength();
+       myVal = DA->AxisLength(Prs3d_DP_ZAxis);
        myDir = oZ;
-       myLineAspect = DA->ThirdAxisAspect();
+       myLineAspect = DA->LineAspect(Prs3d_DP_ZAxis);
        myText = Standard_CString ("Z");
        break;
       }
@@ -328,9 +329,9 @@ void AIS_Axis::UnsetColor()
 
   hasOwnColor=Standard_False;
 
-  myDrawer->DatumAspect()->FirstAxisAspect()->SetColor(Quantity_NOC_TURQUOISE);
-  myDrawer->DatumAspect()->SecondAxisAspect()->SetColor(Quantity_NOC_TURQUOISE);
-  myDrawer->DatumAspect()->ThirdAxisAspect()->SetColor(Quantity_NOC_TURQUOISE);
+  myDrawer->DatumAspect()->LineAspect(Prs3d_DP_XAxis)->SetColor(Quantity_NOC_TURQUOISE);
+  myDrawer->DatumAspect()->LineAspect(Prs3d_DP_YAxis)->SetColor(Quantity_NOC_TURQUOISE);
+  myDrawer->DatumAspect()->LineAspect(Prs3d_DP_ZAxis)->SetColor(Quantity_NOC_TURQUOISE);
 }
 //=======================================================================
 //function : UnsetWidth
@@ -341,8 +342,8 @@ void AIS_Axis::UnsetWidth()
 {
   myOwnWidth = 0.0;
   myDrawer->LineAspect()->SetWidth(1.);
-  myDrawer->DatumAspect()->FirstAxisAspect()->SetWidth(1.);
-  myDrawer->DatumAspect()->SecondAxisAspect()->SetWidth(1.);
-  myDrawer->DatumAspect()->ThirdAxisAspect()->SetWidth(1.);
+  myDrawer->DatumAspect()->LineAspect(Prs3d_DP_XAxis)->SetWidth(1.);
+  myDrawer->DatumAspect()->LineAspect(Prs3d_DP_YAxis)->SetWidth(1.);
+  myDrawer->DatumAspect()->LineAspect(Prs3d_DP_ZAxis)->SetWidth(1.);
 }