0024428: Implementation of LGPL license
[occt.git] / src / AIS / AIS_Plane.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 63e6e8c..21ad41c
@@ -1,7 +1,18 @@
-// File:       AIS_Plane.cxx
-// Created:    Wed Aug  2 16:20:31 1995
-// Author:     Arnaud BOUZY/Odile Olivier
-//             <adn>
+// Created on: 1995-08-02
+// Created by: Arnaud BOUZY/Odile Olivier
+// Copyright (c) 1995-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and / or modify it
+// under the terms of the GNU Lesser General Public version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
 
 #define GER61351               //GG_171199     Enable to set an object RGB color
 //                                               instead a restricted object NameOfColor.
@@ -15,7 +26,7 @@
 #include <gp_Pnt.hxx>
 #include <ElSLib.hxx>
 
-#include <Graphic3d_Array1OfVertex.hxx>
+#include <Graphic3d_ArrayOfQuadrangles.hxx>
 #include <Graphic3d_Group.hxx>
 #include <Prs3d_Drawer.hxx>
 #include <Prs3d_LineAspect.hxx>
@@ -58,7 +69,8 @@ myCenter(gp_Pnt(0.,0.,0.)),
 myCurrentMode(aCurrentMode),
 myAutomaticPosition(Standard_True),
 myTypeOfPlane(AIS_TOPL_Unknown),
-myIsXYZPlane(Standard_False)
+myIsXYZPlane(Standard_False),
+myTypeOfSensitivity (Select3D_TOS_BOUNDARY)
 {
   InitDrawerAttributes();
 }
@@ -75,7 +87,8 @@ myCenter(aCenter),
 myCurrentMode(aCurrentMode),
 myAutomaticPosition(Standard_True),
 myTypeOfPlane(AIS_TOPL_Unknown),
-myIsXYZPlane(Standard_False)
+myIsXYZPlane(Standard_False),
+myTypeOfSensitivity (Select3D_TOS_BOUNDARY)
 {
   InitDrawerAttributes();
 }
@@ -96,7 +109,8 @@ myPmax(aPmax),
 myCurrentMode(aCurrentMode),
 myAutomaticPosition(Standard_False),
 myTypeOfPlane(AIS_TOPL_Unknown),
-myIsXYZPlane(Standard_False)
+myIsXYZPlane(Standard_False),
+myTypeOfSensitivity (Select3D_TOS_BOUNDARY)
 {
   InitDrawerAttributes();
   SetHilightMode(0);
@@ -113,7 +127,8 @@ myAx2(aComponent),
 myCurrentMode(aCurrentMode),
 myAutomaticPosition(Standard_True),
 myTypeOfPlane(aPlaneType),
-myIsXYZPlane(Standard_True)
+myIsXYZPlane(Standard_True),
+myTypeOfSensitivity (Select3D_TOS_BOUNDARY)
 {
   InitDrawerAttributes();
   ComputeFields();
@@ -229,58 +244,59 @@ void AIS_Plane::Compute(const Handle(PrsMgr_PresentationManager3d)& ,
 
   ComputeFields();
   aPresentation->SetInfiniteState(myInfiniteState);
-  if (myCurrentMode) 
-    myDrawer->PlaneAspect()->EdgesAspect()->SetWidth(3);
-  else 
-    myDrawer->PlaneAspect()->EdgesAspect()->SetWidth(1);
-  if(aMode == 0){
-    if (!myIsXYZPlane){
-      ComputeFrame();
-      const Handle(Geom_Plane)& pl = myComponent;
-      const Handle(Geom_Plane)& thegoodpl = Handle(Geom_Plane)::DownCast
-       (pl->Translated(pl->Location(),myCenter));
-      GeomAdaptor_Surface surf(thegoodpl);
-      StdPrs_Plane::Add(aPresentation,surf,myDrawer);
-    }
-    else {
-      DsgPrs_XYZPlanePresentation::Add(aPresentation,myDrawer,myCenter,myPmin,myPmax);
+  myDrawer->PlaneAspect()->EdgesAspect()->SetWidth(myCurrentMode == 0? 1 : 3);
+
+  switch (aMode)
+  {
+    case 0:
+    {
+      if (!myIsXYZPlane)
+      {
+        ComputeFrame();
+        const Handle(Geom_Plane)& pl = myComponent;
+        const Handle(Geom_Plane)& thegoodpl = Handle(Geom_Plane)::DownCast(pl->Translated(pl->Location(),myCenter));
+        GeomAdaptor_Surface surf(thegoodpl);
+        StdPrs_Plane::Add(aPresentation,surf,myDrawer);
+      }
+      else
+        DsgPrs_XYZPlanePresentation::Add(aPresentation,myDrawer,myCenter,myPmin,myPmax);
+      break;
     }
-  }
-  else if (aMode == 1){
-    if (!myIsXYZPlane){
-      ComputeFrame();
-      Handle(Prs3d_PlaneAspect) theaspect = myDrawer->PlaneAspect();
-      Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation);
-      gp_Pnt p1;
-      Standard_Real Xmax,Ymax;
-      Xmax = Standard_Real(theaspect->PlaneXLength())/2.;
-      Ymax = Standard_Real(theaspect->PlaneYLength())/2.;
-      static Graphic3d_Array1OfVertex vertices(1,5);
-      TheGroup->SetPrimitivesAspect(myDrawer->ShadingAspect()->Aspect());
-      myComponent->D0(-Xmax,Ymax,p1);
-      vertices(1).SetCoord(p1.X(),p1.Y(),p1.Z());
-      vertices(5).SetCoord(p1.X(),p1.Y(),p1.Z());
-      myComponent->D0(Xmax,Ymax,p1);
-      vertices(2).SetCoord(p1.X(),p1.Y(),p1.Z());
-      myComponent->D0(Xmax,-Ymax,p1);
-      vertices(3).SetCoord(p1.X(),p1.Y(),p1.Z());
-      myComponent->D0(-Xmax,-Ymax,p1);
-      vertices(4).SetCoord(p1.X(),p1.Y(),p1.Z());
-      TheGroup->Polygon(vertices);
-       
+    case 1:
+    {
+      if (!myIsXYZPlane)
+      {
+        ComputeFrame();
+        Handle(Prs3d_PlaneAspect) theaspect = myDrawer->PlaneAspect();
+        Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation);
+        TheGroup->SetPrimitivesAspect(myDrawer->ShadingAspect()->Aspect());
+        gp_Pnt p1;
+        const Standard_Real Xmax = 0.5*Standard_Real(theaspect->PlaneXLength());
+        const Standard_Real Ymax = 0.5*Standard_Real(theaspect->PlaneYLength());
+
+        Handle(Graphic3d_ArrayOfQuadrangles) aQuads = new Graphic3d_ArrayOfQuadrangles(4);
+
+        myComponent->D0(-Xmax,Ymax,p1);
+        aQuads->AddVertex(p1);
+        myComponent->D0(Xmax,Ymax,p1);
+        aQuads->AddVertex(p1);
+        myComponent->D0(Xmax,-Ymax,p1);
+        aQuads->AddVertex(p1);
+        myComponent->D0(-Xmax,-Ymax,p1);
+        aQuads->AddVertex(p1);
+
+        TheGroup->AddPrimitiveArray(aQuads);
       }
-    else{
-      DsgPrs_ShadedPlanePresentation::Add(aPresentation,myDrawer,myCenter,myPmin,myPmax);
-      
+      else
+        DsgPrs_ShadedPlanePresentation::Add(aPresentation,myDrawer,myCenter,myPmin,myPmax);
+      break;
     }
   }
-
 }
 
 void AIS_Plane::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation)
 {
-// Standard_NotImplemented::Raise("AIS_Plane::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
- PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation) ;
+  PrsMgr_PresentableObject::Compute(aProjector, aTransformation, aPresentation);
 }
 
 //=======================================================================
@@ -308,7 +324,7 @@ void AIS_Plane::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
     thegoodpl->D0(-lx,-ly,arr(3));
     thegoodpl->D0(-lx,ly,arr(4));
     arr(5) = arr(1);
-    sfac = new Select3D_SensitiveFace(eown,harr,Select3D_TOS_BOUNDARY);
+    sfac = new Select3D_SensitiveFace(eown,harr,myTypeOfSensitivity);
 
   }
   else {
@@ -319,7 +335,7 @@ void AIS_Plane::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
     arr1(2) = myPmin;
     arr1(3) = myPmax;
     arr1(4) = myCenter;
-    sfac = new Select3D_SensitiveFace(eown,harr1,Select3D_TOS_BOUNDARY);
+    sfac = new Select3D_SensitiveFace(eown,harr1,myTypeOfSensitivity);
 
   }
     aSelection->Add(sfac);
@@ -518,16 +534,6 @@ void AIS_Plane::ComputeFrame()
   }
 }
 
-//=======================================================================
-//function : Compute
-//purpose  : to avoid warning
-//=======================================================================
-void AIS_Plane::Compute(const Handle(PrsMgr_PresentationManager2d)&, 
-                          const Handle(Graphic2d_GraphicObject)&,
-                          const Standard_Integer)
-{
-}
-
 //=======================================================================
 //function : Compute
 //purpose  : to avoid warning