0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / AIS / AIS_Plane.cxx
index 8d4bba6..64fd3e1 100644 (file)
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
-#include <AIS_Plane.ixx>
 
-#include <TColgp_Array1OfPnt.hxx>
-#include <TColgp_HArray1OfPnt.hxx>
-
-#include <Precision.hxx>
-#include <gp_Pnt.hxx>
+#include <AIS_InteractiveContext.hxx>
+#include <AIS_Plane.hxx>
+#include <Aspect_TypeOfLine.hxx>
+#include <DsgPrs_ShadedPlanePresentation.hxx>
+#include <DsgPrs_XYZPlanePresentation.hxx>
 #include <ElSLib.hxx>
-
+#include <Geom_Axis2Placement.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom_Transformation.hxx>
+#include <GeomAdaptor_Surface.hxx>
+#include <gp_Pnt.hxx>
 #include <Graphic3d_ArrayOfQuadrangles.hxx>
+#include <Graphic3d_AspectFillArea3d.hxx>
+#include <Graphic3d_AspectLine3d.hxx>
 #include <Graphic3d_Group.hxx>
+#include <Graphic3d_MaterialAspect.hxx>
+#include <Graphic3d_Structure.hxx>
+#include <Poly_Triangulation.hxx>
+#include <Precision.hxx>
+#include <Prs3d_DatumAspect.hxx>
 #include <Prs3d_Drawer.hxx>
 #include <Prs3d_LineAspect.hxx>
 #include <Prs3d_PlaneAspect.hxx>
-#include <Prs3d_DatumAspect.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Prs3d_Projector.hxx>
 #include <Prs3d_ShadingAspect.hxx>
-#include <StdPrs_Plane.hxx>
-#include <StdPrs_ShadedSurface.hxx>
-
-#include <Geom_Plane.hxx>
-#include <GeomAdaptor_Surface.hxx>
-
-#include <Aspect_TypeOfLine.hxx>
-#include <Graphic3d_AspectLine3d.hxx>
-#include <Graphic3d_Structure.hxx>
-#include <Graphic3d_MaterialAspect.hxx>
-#include <Graphic3d_AspectFillArea3d.hxx>
-
-#include <DsgPrs_XYZPlanePresentation.hxx>
-#include <DsgPrs_ShadedPlanePresentation.hxx>
-#include <UnitsAPI.hxx>
-
+#include <Quantity_Color.hxx>
 #include <Select3D_SensitiveTriangulation.hxx>
 #include <SelectBasics_EntityOwner.hxx>
 #include <SelectMgr_EntityOwner.hxx>
+#include <Standard_Type.hxx>
+#include <StdPrs_Plane.hxx>
 #include <StdPrs_ShadedShape.hxx>
-
-#include <Poly_Triangulation.hxx>
-
-#include <AIS_Drawer.hxx>
-
+#include <StdPrs_ShadedSurface.hxx>
+#include <TColgp_Array1OfPnt.hxx>
+#include <TColgp_HArray1OfPnt.hxx>
 #include <TCollection_AsciiString.hxx>
+#include <UnitsAPI.hxx>
 
 //=======================================================================
 //function : AIS_Plane
@@ -253,7 +250,7 @@ void AIS_Plane::Compute(const Handle(PrsMgr_PresentationManager3d)& ,
       {
         ComputeFrame();
         const Handle(Geom_Plane)& pl = myComponent;
-        const Handle(Geom_Plane)& thegoodpl = Handle(Geom_Plane)::DownCast(pl->Translated(pl->Location(),myCenter));
+        Handle(Geom_Plane) thegoodpl (Handle(Geom_Plane)::DownCast(pl->Translated(pl->Location(),myCenter)));
         GeomAdaptor_Surface surf(thegoodpl);
         StdPrs_Plane::Add(aPresentation,surf,myDrawer);
       }
@@ -375,10 +372,10 @@ void AIS_Plane::SetSize(const Standard_Real aXLength,
   DA = myDrawer->DatumAspect();
 
   Standard_Boolean yenavaitPA(Standard_True),yenavaitDA(Standard_True);
-  if(myDrawer->Link()->PlaneAspect() == PA){
+  if(myDrawer->HasLink() && myDrawer->Link()->PlaneAspect() == PA){
     yenavaitPA = Standard_False;
     PA = new Prs3d_PlaneAspect();}
-  if(myDrawer->Link()->DatumAspect() == DA){
+  if(myDrawer->HasLink() && myDrawer->Link()->DatumAspect() == DA){
     yenavaitDA = Standard_False;
     DA = new Prs3d_DatumAspect();
   }
@@ -406,13 +403,16 @@ void AIS_Plane::UnsetSize()
 {
   
   if(!myHasOwnSize) return;
-  if(!hasOwnColor){
-    myDrawer->PlaneAspect().Nullify();
-    myDrawer->DatumAspect().Nullify();
+  if(!hasOwnColor)
+  {
+    myDrawer->SetPlaneAspect (Handle(Prs3d_PlaneAspect)());
+    myDrawer->SetDatumAspect (Handle(Prs3d_DatumAspect)());
   }
   else{
-    const Handle(Prs3d_PlaneAspect)& PA = myDrawer->Link()->PlaneAspect();
-    const Handle(Prs3d_DatumAspect)& DA = myDrawer->Link()->DatumAspect();
+    const Handle(Prs3d_PlaneAspect) PA = myDrawer->HasLink() ? myDrawer->Link()->PlaneAspect() :
+                                                               new Prs3d_PlaneAspect();
+    const Handle(Prs3d_DatumAspect) DA = myDrawer->HasLink() ? myDrawer->Link()->DatumAspect() :
+                                                               new Prs3d_DatumAspect();
 
     myDrawer->PlaneAspect()->SetPlaneLength(PA->PlaneXLength(),PA->PlaneYLength());
     myDrawer->DatumAspect()->SetAxisLength(DA->FirstAxisLength(),
@@ -461,10 +461,10 @@ void AIS_Plane::SetColor(const Quantity_Color &aCol)
   DA = myDrawer->DatumAspect();
 
   Standard_Boolean yenavaitPA(Standard_True),yenavaitDA(Standard_True);
-  if(myDrawer->Link()->PlaneAspect() == PA){
+  if(myDrawer->HasLink() && myDrawer->Link()->PlaneAspect() == PA){
     yenavaitPA = Standard_False;
     PA = new Prs3d_PlaneAspect();}
-  if(myDrawer->Link()->DatumAspect() == DA){
+  if(myDrawer->HasLink() && myDrawer->Link()->DatumAspect() == DA){
     yenavaitDA = Standard_False;
     DA = new Prs3d_DatumAspect();
   }
@@ -491,12 +491,14 @@ void AIS_Plane::SetColor(const Quantity_Color &aCol)
 void AIS_Plane::UnsetColor()
 {
   if(!hasOwnColor) return;
-  if(!myHasOwnSize){
-    myDrawer->PlaneAspect().Nullify();
-    myDrawer->DatumAspect().Nullify();
+  if(!myHasOwnSize)
+  {
+    myDrawer->SetPlaneAspect (Handle(Prs3d_PlaneAspect)());
+    myDrawer->SetDatumAspect (Handle(Prs3d_DatumAspect)());
   }
   else{
-    const Handle(Prs3d_PlaneAspect)& PA = myDrawer->Link()->PlaneAspect();
+    const Handle(Prs3d_PlaneAspect) PA = myDrawer->HasLink() ? myDrawer->Link()->PlaneAspect() :
+                                                               new Prs3d_PlaneAspect();
 //    const Handle(Prs3d_DatumAspect)& DA = myDrawer->Link()->DatumAspect();
     Quantity_Color C;Aspect_TypeOfLine T;Standard_Real W;
     PA->EdgesAspect()->Aspect()->Values(C,T,W);
@@ -528,8 +530,7 @@ void AIS_Plane::ComputeFrame()
     pl->D0 (U, V, myCenter);     
   }
   else {
-    const Handle(Geom_Plane)& thegoodpl = 
-      Handle(Geom_Plane)::DownCast(pl->Translated(pl->Location(),myCenter));
+    Handle(Geom_Plane) thegoodpl (Handle(Geom_Plane)::DownCast(pl->Translated(pl->Location(),myCenter)));
     ElSLib::Parameters(thegoodpl->Pln(),myPmin,U,V);
     
     U = 2.4*Abs(U);