0025180: Visualization - Homogeneous transformation API in TKV3d
[occt.git] / src / AIS / AIS_Circle.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 983eb90..b337894
@@ -1,30 +1,43 @@
-// File:       AIS_Circle.cxx
-// Created:    Tue Jan 21 11:45:01 1997
-// Author:     Prestataire Christiane ARMAND
-//             <car@chamalox.paris1.matra-dtv.fr>
-// Copyright:   Matra Datavision 1997
-
-#define GER61351               //GG_171199     Enable to set an object RGB color
-//                                               instead a restricted object NameOfColor.
-
-#include <AIS_Circle.ixx>
+// Created on: 1997-01-21
+// Created by: Prestataire Christiane ARMAND
+// Copyright (c) 1997-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 License 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.
+
+
+#include <AIS_Circle.hxx>
+#include <AIS_GraphicTool.hxx>
 #include <Aspect_TypeOfLine.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Prs3d_LineAspect.hxx>
-#include <Graphic3d_ArrayOfPrimitives.hxx>
+#include <GC_MakeArcOfCircle.hxx>
+#include <Geom_Circle.hxx>
+#include <Geom_Transformation.hxx>
+#include <GeomAdaptor_Curve.hxx>
 #include <Graphic3d_AspectLine3d.hxx>
 #include <Graphic3d_Structure.hxx>
-#include <TColgp_Array1OfPnt.hxx>
-#include <SelectMgr_EntityOwner.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_LineAspect.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Prs3d_Projector.hxx>
+#include <Quantity_Color.hxx>
 #include <Select3D_SensitiveCircle.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <Standard_Type.hxx>
 #include <StdPrs_DeflectionCurve.hxx>
+#include <TColgp_Array1OfPnt.hxx>
 #include <TopoDS.hxx>
-#include <Geom_Circle.hxx>
-#include <GeomAdaptor_Curve.hxx>
-#include <AIS_Drawer.hxx>
-#include <GC_MakeArcOfCircle.hxx>
-#include <Quantity_Color.hxx>
-#include <AIS_GraphicTool.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(AIS_Circle,AIS_InteractiveObject)
 
 //=======================================================================
 //function : AIS_Circle
@@ -35,7 +48,8 @@ AIS_InteractiveObject(PrsMgr_TOP_AllView),
 myComponent(aComponent),
 myUStart(0.),
 myUEnd(2*M_PI),
-myCircleIsArc(Standard_False)
+myCircleIsArc(Standard_False),
+myIsFilledCircleSens (Standard_False)
 {
 }
 
@@ -43,17 +57,17 @@ myCircleIsArc(Standard_False)
 //function : AIS_Circle
 //purpose  : 
 //=======================================================================
-AIS_Circle::AIS_Circle(const Handle(Geom_Circle)& aComponent,
-                       const Standard_Real aUStart,
-                       const Standard_Real aUEnd,
-                       const Standard_Boolean aSens):
-       AIS_InteractiveObject(PrsMgr_TOP_AllView)
+AIS_Circle::AIS_Circle(const Handle(Geom_Circle)& theComponent,
+                       const Standard_Real theUStart,
+                       const Standard_Real theUEnd,
+                       const Standard_Boolean theIsFilledCircleSens)
+: AIS_InteractiveObject(PrsMgr_TOP_AllView),
+  myComponent (theComponent),
+  myUStart (theUStart),
+  myUEnd (theUEnd),
+  myCircleIsArc (Standard_True),
+  myIsFilledCircleSens (theIsFilledCircleSens)
 {
-  myComponent = aComponent;
-  myUStart    = aUStart;
-  myUEnd      = aUEnd;
-  mySens      = aSens;
-  myCircleIsArc = Standard_True;
 }
 
 //=======================================================================
@@ -78,11 +92,11 @@ void AIS_Circle::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresenta
 //purpose  : 
 //=======================================================================
 
-void AIS_Circle::Compute(const Handle_Prs3d_Projector& aProjector,
-                         const Handle_Geom_Transformation& aTransformation,
-                         const Handle_Prs3d_Presentation& aPresentation)
+void AIS_Circle::Compute(const Handle(Prs3d_Projector)& aProjector,
+                         const Handle(Geom_Transformation)& aTransformation,
+                         const Handle(Prs3d_Presentation)& aPresentation)
 {
-// Standard_NotImplemented::Raise("AIS_Circle::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
+// Standard_NotImplemented::Raise("AIS_Circle::Compute(const Handle(Prs3d_Projector)&, const Handle(Geom_Transformation)&, const Handle(Prs3d_Presentation)&)");
   PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ;
 }
 
@@ -107,7 +121,6 @@ void AIS_Circle::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
 //=======================================================================
 
 void AIS_Circle::SetColor(const Quantity_NameOfColor aCol)
-#ifdef GER61351
 {
   SetColor(Quantity_Color(aCol));
 }
@@ -118,15 +131,16 @@ void AIS_Circle::SetColor(const Quantity_NameOfColor aCol)
 //=======================================================================
 
 void AIS_Circle::SetColor(const Quantity_Color &aCol)
-#endif
 {
   hasOwnColor=Standard_True;
   myOwnColor=aCol;
 
-  Standard_Real WW = HasWidth()? myOwnWidth:
-                                 AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line);
+  Standard_Real WW = HasWidth() ? myOwnWidth :
+                                  myDrawer->HasLink() ?
+                                  AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Line) :
+                                  1.;
 
-  if (!myDrawer->HasLineAspect ())
+  if (!myDrawer->HasOwnLineAspect ())
     myDrawer->SetLineAspect (new Prs3d_LineAspect(aCol,Aspect_TOL_SOLID,WW));
   else
     myDrawer->LineAspect()->SetColor(aCol);
@@ -142,17 +156,10 @@ void AIS_Circle::SetWidth(const Standard_Real aValue)
 {
   myOwnWidth=aValue;
 
-#ifndef GER61351
-  Quantity_NameOfColor CC = 
-       HasColor() ? myOwnColor : AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line);
-#endif
-
-  if (!myDrawer->HasLineAspect ()) {
-#ifdef GER61351
-    Quantity_Color CC;
+  if (!myDrawer->HasOwnLineAspect ()) {
+    Quantity_Color CC = Quantity_NOC_YELLOW;
     if( HasColor() ) CC = myOwnColor;
-    else AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC);
-#endif
+    else if(myDrawer->HasLink()) AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Line, CC);
     myDrawer->SetLineAspect (new Prs3d_LineAspect(CC,Aspect_TOL_SOLID,aValue));
   } else
     myDrawer->LineAspect()->SetWidth(aValue);
@@ -171,17 +178,12 @@ void AIS_Circle::UnsetColor()
 
   if (!HasWidth()) myDrawer->SetLineAspect(NullAsp);
   else{
-#ifdef GER61351
-  Quantity_Color CC;
-  if( HasColor() ) CC = myOwnColor;
-  else AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC);
-#else
-    Quantity_NameOfColor CC = 
-#endif
-               AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line);
+    Quantity_Color CC = Quantity_NOC_YELLOW;;
+    if( HasColor() ) CC = myOwnColor;
+    else if (myDrawer->HasLink()) AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC);
     myDrawer->LineAspect()->SetColor(CC);
     myOwnColor = CC;
- }
 }
 }
 
 //=======================================================================
@@ -194,7 +196,7 @@ void AIS_Circle::UnsetWidth()
 
   if (!HasColor()) myDrawer->SetLineAspect(NullAsp);
   else{
-   Standard_Real WW = AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line);
+   Standard_Real WW = myDrawer->HasLink() ? AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line) : 1.;
    myDrawer->LineAspect()->SetWidth(WW);
    myOwnWidth = WW;
   }
@@ -210,10 +212,7 @@ void AIS_Circle::ComputeCircle( const Handle(Prs3d_Presentation)& aPresentation)
   GeomAdaptor_Curve curv(myComponent);
   Standard_Real prevdev = myDrawer->DeviationCoefficient();
   myDrawer->SetDeviationCoefficient(1.e-5);
-  Standard_Boolean isPrimitiveArraysEnabled = Graphic3d_ArrayOfPrimitives::IsEnable();
-  if(isPrimitiveArraysEnabled) Graphic3d_ArrayOfPrimitives::Disable();
   StdPrs_DeflectionCurve::Add(aPresentation,curv,myDrawer);
-  if(isPrimitiveArraysEnabled) Graphic3d_ArrayOfPrimitives::Enable();
   myDrawer->SetDeviationCoefficient(prevdev);
 
 }
@@ -225,16 +224,11 @@ void AIS_Circle::ComputeCircle( const Handle(Prs3d_Presentation)& aPresentation)
 //=======================================================================
 void AIS_Circle::ComputeArc( const Handle(Prs3d_Presentation)& aPresentation)
 {
-
   GeomAdaptor_Curve curv(myComponent,myUStart,myUEnd);
   Standard_Real prevdev = myDrawer->DeviationCoefficient();
   myDrawer->SetDeviationCoefficient(1.e-5);
-  Standard_Boolean isPrimitiveArraysEnabled = Graphic3d_ArrayOfPrimitives::IsEnable();
-  if(isPrimitiveArraysEnabled) Graphic3d_ArrayOfPrimitives::Disable();
   StdPrs_DeflectionCurve::Add(aPresentation,curv,myDrawer);
-  if(isPrimitiveArraysEnabled) Graphic3d_ArrayOfPrimitives::Enable();
   myDrawer->SetDeviationCoefficient(prevdev);
-
 }
 
 //=======================================================================
@@ -245,8 +239,9 @@ void AIS_Circle::ComputeArc( const Handle(Prs3d_Presentation)& aPresentation)
 void AIS_Circle::ComputeCircleSelection(const Handle(SelectMgr_Selection)& aSelection)
 {
   Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this);
-  Handle(Select3D_SensitiveCircle) seg = new Select3D_SensitiveCircle(eown,
-                                                                      myComponent);
+  Handle(Select3D_SensitiveCircle) seg = new Select3D_SensitiveCircle (eown,
+                                                                       myComponent,
+                                                                       myIsFilledCircleSens);
   aSelection->Add(seg);
 }
 //=======================================================================
@@ -259,19 +254,12 @@ void AIS_Circle::ComputeArcSelection(const Handle(SelectMgr_Selection)& aSelecti
 
 
   Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this);
-  Handle(Select3D_SensitiveCircle) seg = new Select3D_SensitiveCircle(eown,
-                                                                     myComponent,myUStart,myUEnd);
+  Handle(Select3D_SensitiveCircle) seg = new Select3D_SensitiveCircle (eown,
+                                                                       myComponent,
+                                                                       myUStart, myUEnd,
+                                                                       myIsFilledCircleSens);
   aSelection->Add(seg);
 }
-//=======================================================================
-//function : Compute
-//purpose  : to avoid warning
-//=======================================================================
-void AIS_Circle::Compute(const Handle(PrsMgr_PresentationManager2d)&, 
-                         const Handle(Graphic2d_GraphicObject)&,
-                         const Standard_Integer)
-{
-}
 
 //=======================================================================
 //function : Compute