0031456: Visualization - move out Dimensions and Relations from package AIS to PrsDims
[occt.git] / src / PrsDim / PrsDim_EqualDistanceRelation.cxx
similarity index 87%
rename from src/AIS/AIS_EqualDistanceRelation.cxx
rename to src/PrsDim/PrsDim_EqualDistanceRelation.cxx
index 39fbb70..72c2868 100644 (file)
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
+#include <PrsDim_EqualDistanceRelation.hxx>
 
-#include <AIS_EqualDistanceRelation.hxx>
-#include <AIS_LengthDimension.hxx>
+#include <PrsDim.hxx>
+#include <PrsDim_LengthDimension.hxx>
 #include <Bnd_Box.hxx>
 #include <BRep_Tool.hxx>
 #include <BRepAdaptor_Curve.hxx>
@@ -27,7 +28,6 @@
 #include <Geom_Circle.hxx>
 #include <Geom_Line.hxx>
 #include <Geom_Plane.hxx>
-#include <Geom_Transformation.hxx>
 #include <GeomAPI_ProjectPointOnCurve.hxx>
 #include <GeomAPI_ProjectPointOnSurf.hxx>
 #include <gp_Lin.hxx>
 #include <Select3D_SensitiveSegment.hxx>
 #include <SelectMgr_EntityOwner.hxx>
 #include <Standard_NotImplemented.hxx>
-#include <Standard_Type.hxx>
 #include <TopoDS_Edge.hxx>
 #include <TopoDS_Shape.hxx>
 #include <TopoDS_Vertex.hxx>
 
-IMPLEMENT_STANDARD_RTTIEXT(AIS_EqualDistanceRelation,AIS_Relation)
+IMPLEMENT_STANDARD_RTTIEXT(PrsDim_EqualDistanceRelation, PrsDim_Relation)
 
 //=======================================================================
-//function : AIS_EqualDistanceRelation
+//function : PrsDim_EqualDistanceRelation
 //purpose  : 
 //=======================================================================
-AIS_EqualDistanceRelation::AIS_EqualDistanceRelation( const TopoDS_Shape& aShape1,
+PrsDim_EqualDistanceRelation::PrsDim_EqualDistanceRelation( const TopoDS_Shape& aShape1,
                                                      const TopoDS_Shape& aShape2,
                                                      const TopoDS_Shape& aShape3,
                                                      const TopoDS_Shape& aShape4,
                                                      const Handle( Geom_Plane )& aPlane )
-     :AIS_Relation()
+: PrsDim_Relation()
 {
   myFShape = aShape1;
   mySShape = aShape2;
@@ -76,7 +75,7 @@ AIS_EqualDistanceRelation::AIS_EqualDistanceRelation( const TopoDS_Shape& aShape
 //purpose  : 
 //=======================================================================
 
-void AIS_EqualDistanceRelation::Compute( const Handle( PrsMgr_PresentationManager3d )&,
+void PrsDim_EqualDistanceRelation::Compute( const Handle( PrsMgr_PresentationManager3d )&,
                                         const Handle( Prs3d_Presentation )& aPresentation,
                                         const Standard_Integer ) 
 {
@@ -98,7 +97,7 @@ void AIS_EqualDistanceRelation::Compute( const Handle( PrsMgr_PresentationManage
   }
   
   if (myFShape.ShapeType() == TopAbs_EDGE && mySShape.ShapeType() == TopAbs_EDGE)
-    AIS_EqualDistanceRelation::ComputeTwoEdgesLength(aPresentation,
+    PrsDim_EqualDistanceRelation::ComputeTwoEdgesLength(aPresentation,
                                                     myDrawer,
                                                     myArrowSize,
                                                     TopoDS::Edge(myFShape),
@@ -116,7 +115,7 @@ void AIS_EqualDistanceRelation::Compute( const Handle( PrsMgr_PresentationManage
         
   
   else if (myFShape.ShapeType() == TopAbs_VERTEX && mySShape.ShapeType() == TopAbs_VERTEX)
-    AIS_EqualDistanceRelation::ComputeTwoVerticesLength( aPresentation,
+    PrsDim_EqualDistanceRelation::ComputeTwoVerticesLength( aPresentation,
                                                        myDrawer,
                                                        myArrowSize,
                                                        TopoDS::Vertex(myFShape),
@@ -125,7 +124,7 @@ void AIS_EqualDistanceRelation::Compute( const Handle( PrsMgr_PresentationManage
                                                        myAutomaticPosition,
                                                        myIsSetBndBox,
                                                        myBndBox,
-                                                       AIS_TOD_Unknown,
+                                                       PrsDim_TypeOfDist_Unknown,
                                                        Position12,
                                                        myAttachPoint1,
                                                        myAttachPoint2,
@@ -133,7 +132,7 @@ void AIS_EqualDistanceRelation::Compute( const Handle( PrsMgr_PresentationManage
                                                        myPoint2,
                                                        mySymbolPrs );
   else 
-    AIS_EqualDistanceRelation::ComputeOneEdgeOneVertexLength( aPresentation,
+    PrsDim_EqualDistanceRelation::ComputeOneEdgeOneVertexLength( aPresentation,
                                                             myDrawer,
                                                             myArrowSize,
                                                             myFShape,
@@ -150,7 +149,7 @@ void AIS_EqualDistanceRelation::Compute( const Handle( PrsMgr_PresentationManage
                                                             mySymbolPrs );
 
   if (myShape3.ShapeType() == TopAbs_EDGE && myShape4.ShapeType() == TopAbs_EDGE)
-    AIS_EqualDistanceRelation::ComputeTwoEdgesLength(aPresentation,
+    PrsDim_EqualDistanceRelation::ComputeTwoEdgesLength(aPresentation,
                                                     myDrawer,
                                                     myArrowSize,
                                                     TopoDS::Edge(myShape3),
@@ -167,7 +166,7 @@ void AIS_EqualDistanceRelation::Compute( const Handle( PrsMgr_PresentationManage
                                                     mySymbolPrs );
   
   else if (myShape3.ShapeType() == TopAbs_VERTEX && myShape4.ShapeType() == TopAbs_VERTEX)
-    AIS_EqualDistanceRelation::ComputeTwoVerticesLength( aPresentation,
+    PrsDim_EqualDistanceRelation::ComputeTwoVerticesLength( aPresentation,
                                                        myDrawer,
                                                        myArrowSize,
                                                        TopoDS::Vertex(myShape3),
@@ -176,7 +175,7 @@ void AIS_EqualDistanceRelation::Compute( const Handle( PrsMgr_PresentationManage
                                                        myAutomaticPosition,
                                                        myIsSetBndBox,
                                                        myBndBox,
-                                                       AIS_TOD_Unknown,
+                                                       PrsDim_TypeOfDist_Unknown,
                                                        Position34,
                                                        myAttachPoint3,
                                                        myAttachPoint4,
@@ -185,7 +184,7 @@ void AIS_EqualDistanceRelation::Compute( const Handle( PrsMgr_PresentationManage
                                                        mySymbolPrs );
    
   else
-    AIS_EqualDistanceRelation::ComputeOneEdgeOneVertexLength( aPresentation,
+    PrsDim_EqualDistanceRelation::ComputeOneEdgeOneVertexLength( aPresentation,
                                                             myDrawer,
                                                             myArrowSize,
                                                             myShape3,
@@ -210,7 +209,7 @@ void AIS_EqualDistanceRelation::Compute( const Handle( PrsMgr_PresentationManage
 //purpose  : 
 //=======================================================================
 
-void AIS_EqualDistanceRelation::ComputeSelection( const Handle( SelectMgr_Selection )& aSelection,
+void PrsDim_EqualDistanceRelation::ComputeSelection( const Handle( SelectMgr_Selection )& aSelection,
                                                  const Standard_Integer ) 
 {
   Handle( SelectMgr_EntityOwner ) own = new SelectMgr_EntityOwner( this, 7 );
@@ -339,7 +338,7 @@ void AIS_EqualDistanceRelation::ComputeSelection( const Handle( SelectMgr_Select
 //function : ComputeTwoEdgesLength
 //purpose  : 
 //=======================================================================
-void AIS_EqualDistanceRelation::ComputeTwoEdgesLength( const Handle( Prs3d_Presentation )& aPresentation,
+void PrsDim_EqualDistanceRelation::ComputeTwoEdgesLength( const Handle( Prs3d_Presentation )& aPresentation,
                                                      const Handle( Prs3d_Drawer )& aDrawer,
                                                      const Standard_Real ArrowSize,
                                                      const TopoDS_Edge & FirstEdge,
@@ -369,9 +368,9 @@ void AIS_EqualDistanceRelation::ComputeTwoEdgesLength( const Handle( Prs3d_Prese
   Standard_Real Val=0.;
   Standard_Boolean isInPlane1, isInPlane2;
 
-  if(!AIS::ComputeGeometry(FirstEdge,geom1, ptat11, ptat12,extCurv,isInfinite1,isInPlane1, Plane ))
+  if(!PrsDim::ComputeGeometry(FirstEdge,geom1, ptat11, ptat12,extCurv,isInfinite1,isInPlane1, Plane ))
     return;
-  if(!AIS::ComputeGeometry(SecondEdge, geom2, ptat21, ptat22, extCurv, isInfinite2,isInPlane2, Plane))
+  if(!PrsDim::ComputeGeometry(SecondEdge, geom2, ptat21, ptat22, extCurv, isInfinite2,isInPlane2, Plane))
     return;
   
   aPresentation->SetInfiniteState(isInfinite1 || isInfinite2);
@@ -424,7 +423,7 @@ void AIS_EqualDistanceRelation::ComputeTwoEdgesLength( const Handle( Prs3d_Prese
     Position = curpos;
   }
   else {    // project point on the plane
-    Position = AIS::ProjectPointOnPlane( Position, Plane->Pln() );
+    Position = PrsDim::ProjectPointOnPlane( Position, Plane->Pln() );
   }
 
   // find attach points
@@ -455,7 +454,7 @@ void AIS_EqualDistanceRelation::ComputeTwoEdgesLength( const Handle( Prs3d_Prese
   arr->SetLength(arrsize);
 
   if (AutomaticPos && IsSetBndBox)
-    Position = AIS::TranslatePointToBound( Position, DirAttach, BndBox );
+    Position = PrsDim::TranslatePointToBound( Position, DirAttach, BndBox );
  
    DsgPrs_EqualDistancePresentation::AddInterval(aPresentation,
                                                aDrawer,
@@ -490,10 +489,10 @@ void AIS_EqualDistanceRelation::ComputeTwoEdgesLength( const Handle( Prs3d_Prese
       Standard_Real par1 = 0, par2 = 0;
       gp_Pln aPln =  Plane->Pln();
       //Project ptat12 and ptat22 on constraint plane
-      gp_Pnt PrPnt12 = AIS::ProjectPointOnPlane(ptat12, aPln);
-      gp_Pnt PrPnt22 = AIS::ProjectPointOnPlane(ptat22, aPln);
+      gp_Pnt PrPnt12 = PrsDim::ProjectPointOnPlane(ptat12, aPln);
+      gp_Pnt PrPnt22 = PrsDim::ProjectPointOnPlane(ptat22, aPln);
       //Project circles center on constraint plane
-      gp_Pnt PrCenter = AIS::ProjectPointOnPlane(aCirc1.Location(), aPln);
+      gp_Pnt PrCenter = PrsDim::ProjectPointOnPlane(aCirc1.Location(), aPln);
 
       gp_Dir XDir = aPln.XAxis().Direction();
       gp_Dir YDir = aPln.YAxis().Direction();
@@ -555,10 +554,10 @@ void AIS_EqualDistanceRelation::ComputeTwoEdgesLength( const Handle( Prs3d_Prese
 
 //  gp_Pnt pf, pl;
   if (!isInPlane1) {
-    AIS::ComputeProjEdgePresentation( aPresentation, aDrawer, FirstEdge, geom1, ptat11, ptat12);
+    PrsDim::ComputeProjEdgePresentation( aPresentation, aDrawer, FirstEdge, geom1, ptat11, ptat12);
   }
   if(!isInPlane2) {
-    AIS::ComputeProjEdgePresentation( aPresentation, aDrawer, SecondEdge, geom2, ptat21, ptat22);
+    PrsDim::ComputeProjEdgePresentation( aPresentation, aDrawer, SecondEdge, geom2, ptat21, ptat22);
   }
 }
 
@@ -567,7 +566,7 @@ void AIS_EqualDistanceRelation::ComputeTwoEdgesLength( const Handle( Prs3d_Prese
 //purpose  : 
 //=======================================================================
 
-void AIS_EqualDistanceRelation::ComputeTwoVerticesLength( const Handle( Prs3d_Presentation )& aPresentation,
+void PrsDim_EqualDistanceRelation::ComputeTwoVerticesLength( const Handle( Prs3d_Presentation )& aPresentation,
                                                         const Handle( Prs3d_Drawer )& aDrawer,
                                                         const Standard_Real ArrowSize,
                                                         const TopoDS_Vertex& FirstVertex,
@@ -576,7 +575,7 @@ void AIS_EqualDistanceRelation::ComputeTwoVerticesLength( const Handle( Prs3d_Pr
                                                         const Standard_Boolean AutomaticPos,
                                                         const Standard_Boolean IsSetBndBox,
                                                         const Bnd_Box& BndBox,
-                                                        const AIS_TypeOfDist TypeDist,
+                                                        const PrsDim_TypeOfDist TypeDist,
                                                         gp_Pnt& Position,
                                                         gp_Pnt& FirstAttach,
                                                         gp_Pnt& SecondAttach,
@@ -586,14 +585,14 @@ void AIS_EqualDistanceRelation::ComputeTwoVerticesLength( const Handle( Prs3d_Pr
 {
   Standard_Boolean isOnPlane1, isOnPlane2;
   gp_Dir DirAttach;
-  AIS::ComputeGeometry( FirstVertex, FirstAttach, Plane, isOnPlane1);
-  AIS::ComputeGeometry( SecondVertex, SecondAttach, Plane, isOnPlane2);
+  PrsDim::ComputeGeometry( FirstVertex, FirstAttach, Plane, isOnPlane1);
+  PrsDim::ComputeGeometry( SecondVertex, SecondAttach, Plane, isOnPlane2);
 
   Standard_Real confusion(Precision::Confusion());
   Standard_Boolean samePoint(FirstAttach.IsEqual(SecondAttach,confusion));
 
-  if (TypeDist == AIS_TOD_Vertical) DirAttach =  Plane->Pln().XAxis().Direction();
-  else if (TypeDist == AIS_TOD_Horizontal) DirAttach =  Plane->Pln().YAxis().Direction();
+  if (TypeDist == PrsDim_TypeOfDist_Vertical) DirAttach =  Plane->Pln().XAxis().Direction();
+  else if (TypeDist == PrsDim_TypeOfDist_Horizontal) DirAttach =  Plane->Pln().YAxis().Direction();
   else {
     if (!samePoint) {
       DirAttach.SetXYZ(SecondAttach.XYZ() - FirstAttach.XYZ());
@@ -616,12 +615,12 @@ void AIS_EqualDistanceRelation::ComputeTwoVerticesLength( const Handle( Prs3d_Pr
      gp_Vec aVec (aDir.XYZ()*10*ArrowSize);
      //Position = gp_Pnt(FirstAttach.XYZ()+gp_XYZ(1.,1.,1.)); // not correct
      Position = FirstAttach.Translated(aVec);
-     Position = AIS::ProjectPointOnPlane( Position, Plane->Pln() );//not needed really
+     Position = PrsDim::ProjectPointOnPlane( Position, Plane->Pln() );//not needed really
      DirAttach.SetXYZ(Position.XYZ() - FirstAttach.XYZ());
    }
   }
   else {   
-    Position = AIS::ProjectPointOnPlane( Position, Plane->Pln() );
+    Position = PrsDim::ProjectPointOnPlane( Position, Plane->Pln() );
   }
 
  
@@ -632,7 +631,7 @@ void AIS_EqualDistanceRelation::ComputeTwoVerticesLength( const Handle( Prs3d_Pr
   arr->SetLength(ArrowSize);
 
   if (AutomaticPos && IsSetBndBox)
-    Position = AIS::TranslatePointToBound( Position, DirAttach, BndBox );
+    Position = PrsDim::TranslatePointToBound( Position, DirAttach, BndBox );
 
   DsgPrs_EqualDistancePresentation::AddInterval(aPresentation,
                                                aDrawer,
@@ -646,9 +645,9 @@ void AIS_EqualDistanceRelation::ComputeTwoVerticesLength( const Handle( Prs3d_Pr
 
   // Compute projection
   if ( !isOnPlane1)
-    AIS::ComputeProjVertexPresentation(aPresentation, aDrawer, FirstVertex, FirstAttach);
+    PrsDim::ComputeProjVertexPresentation(aPresentation, aDrawer, FirstVertex, FirstAttach);
   if ( !isOnPlane2)
-    AIS::ComputeProjVertexPresentation(aPresentation, aDrawer, SecondVertex, SecondAttach);
+    PrsDim::ComputeProjVertexPresentation(aPresentation, aDrawer, SecondVertex, SecondAttach);
 
 } 
 
@@ -658,7 +657,7 @@ void AIS_EqualDistanceRelation::ComputeTwoVerticesLength( const Handle( Prs3d_Pr
 //purpose  : 
 //=======================================================================
 
-void AIS_EqualDistanceRelation::ComputeOneEdgeOneVertexLength( const Handle( Prs3d_Presentation )& aPresentation,
+void PrsDim_EqualDistanceRelation::ComputeOneEdgeOneVertexLength( const Handle( Prs3d_Presentation )& aPresentation,
                                                              const Handle( Prs3d_Drawer )& aDrawer,
                                                              const Standard_Real ArrowSize,
                                                              const TopoDS_Shape & FirstShape,
@@ -695,10 +694,10 @@ void AIS_EqualDistanceRelation::ComputeOneEdgeOneVertexLength( const Handle( Prs
     theedge   = TopoDS::Edge(FirstShape);
     edgenum   = 1;//edge is the first shape
   }
-  if (!AIS::ComputeGeometry(theedge,aCurve,ptonedge1,ptonedge2,extCurv,isInfinite,isOnPlanEdge,Plane))
+  if (!PrsDim::ComputeGeometry(theedge,aCurve,ptonedge1,ptonedge2,extCurv,isInfinite,isOnPlanEdge,Plane))
     return;
   aPresentation->SetInfiniteState(isInfinite);
-  AIS::ComputeGeometry(thevertex, FirstAttach, Plane, isOnPlanVertex);
+  PrsDim::ComputeGeometry(thevertex, FirstAttach, Plane, isOnPlanVertex);
 
   if ( aCurve->IsInstance(STANDARD_TYPE(Geom_Line)) ) 
     {
@@ -723,7 +722,7 @@ void AIS_EqualDistanceRelation::ComputeOneEdgeOneVertexLength( const Handle( Prs
     Position = curpos;
   }
   else { // project point on the plane
-    Position = AIS::ProjectPointOnPlane( Position, Plane->Pln() );
+    Position = PrsDim::ProjectPointOnPlane( Position, Plane->Pln() );
   }
   
   if (!isInfinite) {
@@ -741,7 +740,7 @@ void AIS_EqualDistanceRelation::ComputeOneEdgeOneVertexLength( const Handle( Prs
   arr->SetLength(arrsize);
 
   if (AutomaticPos && IsSetBndBox)
-    Position = AIS::TranslatePointToBound( Position, DirAttach, BndBox );
+    Position = PrsDim::TranslatePointToBound( Position, DirAttach, BndBox );
   DsgPrs_EqualDistancePresentation::AddInterval(aPresentation,
                                                aDrawer,
                                                FirstAttach,
@@ -793,10 +792,10 @@ void AIS_EqualDistanceRelation::ComputeOneEdgeOneVertexLength( const Handle( Prs
   //Display the pieces of attached to the curve if it is not 
   // in the WP
   if (!isOnPlanEdge) { // add presentation of projection of the edge in WP
-      AIS::ComputeProjEdgePresentation(aPresentation,aDrawer,theedge,aCurve,ptonedge1,ptonedge2);
+    PrsDim::ComputeProjEdgePresentation(aPresentation,aDrawer,theedge,aCurve,ptonedge1,ptonedge2);
       }
   if (!isOnPlanVertex) { // add presentation of projection of the vertex in WP 
-    AIS::ComputeProjVertexPresentation(aPresentation,aDrawer,thevertex,FirstAttach);
+    PrsDim::ComputeProjVertexPresentation(aPresentation,aDrawer,thevertex,FirstAttach);
     }
   
 }