0028726: Quantity_NameOfColor should be replaced by Quantity_Color in function input...
[occt.git] / src / V3d / V3d_PositionLight.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 6976c11..5443156
+// 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.
+
 /***********************************************************************
   V3d_PositionLight.cxx
   Created:    30-03-98  ZOV (ZELENKOV Oleg)
-
 ************************************************************************/
 
-#include <V3d.hxx>
-#include <V3d_PositionLight.ixx>
-#include <Graphic3d_Vector.hxx>
-#include <Graphic3d_Vertex.hxx>
-#include <Graphic3d_Structure.hxx>
-#include <Graphic3d_Group.hxx>
-#include <Graphic3d_Array1OfVertex.hxx>
-#include <Graphic3d_AspectMarker3d.hxx>
-#include <Graphic3d_AspectLine3d.hxx>
-#include <Graphic3d_AspectText3d.hxx>
-#include <V3d_SpotLight.hxx>
-#include <Visual3d_Light.hxx>
-#include <Visual3d_ViewManager.hxx>
-#include <Visual3d_ContextPick.hxx>
-#include <Visual3d_PickDescriptor.hxx>
-#include <Visual3d_HSequenceOfPickPath.hxx>
-#include <Visual3d_PickPath.hxx>
-#include <Viewer_BadValue.hxx>
-#include <gp_Dir.hxx>
 #include <gp_Ax1.hxx>
-#include <gp_Vec.hxx>
+#include <gp_Dir.hxx>
 #include <gp_Pnt.hxx>
 #include <gp_Trsf.hxx>
+#include <gp_Vec.hxx>
+#include <Graphic3d_ArrayOfSegments.hxx>
+#include <Graphic3d_AspectLine3d.hxx>
+#include <Graphic3d_AspectMarker3d.hxx>
+#include <Graphic3d_AspectText3d.hxx>
+#include <Graphic3d_Group.hxx>
+#include <Graphic3d_Structure.hxx>
+#include <Graphic3d_Vector.hxx>
+#include <Graphic3d_Vertex.hxx>
+#include <Standard_Type.hxx>
 #include <TCollection_AsciiString.hxx>
-#ifdef WNT
-# include <WNT_Window.hxx>
-#else
-# include <Xw_Window.hxx>
-#endif
-
-V3d_PositionLight::V3d_PositionLight(const Handle(V3d_Viewer)& VM) : V3d_Light(VM) {
+#include <V3d.hxx>
+#include <V3d_BadValue.hxx>
+#include <V3d_PositionLight.hxx>
+#include <V3d_SpotLight.hxx>
+#include <V3d_View.hxx>
+#include <V3d_Viewer.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(V3d_PositionLight,V3d_Light)
+
+// =======================================================================
+// function : V3d_PositionLight
+// purpose  :
+// =======================================================================
+V3d_PositionLight::V3d_PositionLight (const Handle(V3d_Viewer)& theViewer)
+: V3d_Light(theViewer)
+{
 }
 
-void V3d_PositionLight::SetTarget(const Standard_Real X, const Standard_Real Y, const Standard_Real Z) {
-
+// =======================================================================
+// function : SetTarget
+// purpose  :
+// =======================================================================
+void V3d_PositionLight::SetTarget (const Standard_Real theX, const Standard_Real theY, const Standard_Real theZ)
+{
   Standard_Real Xc,Yc,Zc, Xp,Yp,Zp;
   
-  // Recalcul de la position
-  MyTarget.Coord(Xc,Yc,Zc);
+  // Recalculation of the position
+  myTarget.Coord(Xc,Yc,Zc);
   Position (Xp,Yp,Zp) ;
 
-  Xp = Xp + (X - Xc);
-  Yp = Yp + (Y - Yc);
-  Zp = Zp + (Z - Zc);
+  Xp = Xp + (theX - Xc);
+  Yp = Yp + (theY - Yc);
+  Zp = Zp + (theZ - Zc);
 
   // Affectation
-  MyTarget.SetCoord(X,Y,Z);
+  myTarget.SetCoord(theX,theY,theZ);
   SetPosition(Xp,Yp,Zp) ;
 }
 
-void V3d_PositionLight::SetRadius(const Standard_Real Radius) {
-
-  Viewer_BadValue_Raise_if( Radius <= 0. , "V3d_PositionLight::SetRadius, bad radius");
-  Viewer_BadValue_Raise_if( MyType == V3d_DIRECTIONAL , "V3d_PositionLight::SetRadius, bad light type");
+// =======================================================================
+// function : SetRadius
+// purpose  :
+// =======================================================================
+void V3d_PositionLight::SetRadius (const Standard_Real theRadius)
+{
+  V3d_BadValue_Raise_if( theRadius <= 0. , "V3d_PositionLight::SetRadius, bad radius");
+  V3d_BadValue_Raise_if( Type() == V3d_DIRECTIONAL , "V3d_PositionLight::SetRadius, bad light type");
 
   Standard_Real X0,Y0,Z0, Xn,Yn,Zn, Xp,Yp,Zp;
   
-  // Le point cible reste inchange, seul la position de la lumiere est modifiee
-  // en conservant la direction.
+  // The target point remains unchanged, only the position of the light is modified
+  // by preserving the direction.
        Position (Xp,Yp,Zp);
-  Graphic3d_Vector  D(MyTarget, Graphic3d_Vertex(Xp, Yp, Zp));
+  Graphic3d_Vector  D(myTarget, Graphic3d_Vertex(Xp, Yp, Zp));
   D.Normalize();
   D.Coord(Xn,Yn,Zn);
-  MyTarget.Coord(X0,Y0,Z0);
-  Xn = X0 + Radius*Xn;
-  Yn = Y0 + Radius*Yn;
-  Zn = Z0 + Radius*Zn;
+  myTarget.Coord(X0,Y0,Z0);
+  Xn = X0 + theRadius*Xn;
+  Yn = Y0 + theRadius*Yn;
+  Zn = Z0 + theRadius*Zn;
 
   SetPosition(Xn,Yn,Zn) ;
 }
 
-void V3d_PositionLight::OnHideFace(const Handle(V3d_View)& aView) {
-
+// =======================================================================
+// function : OnHideFace
+// purpose  :
+// =======================================================================
+void V3d_PositionLight::OnHideFace (const Handle(V3d_View)& theView)
+{
   Standard_Real Xp,Yp,Zp, X,Y,Z, VX,VY,VZ;
   
   Position (Xp,Yp,Zp);
-       V3d_Light::SymetricPointOnSphere (aView, 
-               MyTarget, Graphic3d_Vertex(Xp,Yp,Yp), Radius(), X,Y,Z, VX,VY,VZ);
+  V3d_Light::SymetricPointOnSphere (theView, 
+    myTarget, Graphic3d_Vertex(Xp,Yp,Yp), Radius(), X,Y,Z, VX,VY,VZ);
 
-  // Actuellement est on sur le point vu
+  // This is a visible point
   if ((VX*(X-Xp) < 0.) && (VY*(Y-Yp) < 0.) && (VZ*(Z-Zp) < 0.))
     SetPosition (X,Y,Z);
 }
 
-void V3d_PositionLight::OnSeeFace(const Handle(V3d_View)& aView) {
-
+// =======================================================================
+// function : OnSeeFace
+// purpose  :
+// =======================================================================
+void V3d_PositionLight::OnSeeFace (const Handle(V3d_View)& theView)
+{
   Standard_Real Xp,Yp,Zp, X,Y,Z, VX,VY,VZ;
   
   Position (Xp,Yp,Zp);
-       V3d_Light::SymetricPointOnSphere (aView, 
-               MyTarget, Graphic3d_Vertex(Xp,Yp,Yp), Radius(), X,Y,Z, VX,VY,VZ);
+  V3d_Light::SymetricPointOnSphere (theView, 
+    myTarget, Graphic3d_Vertex(Xp,Yp,Yp), Radius(), X,Y,Z, VX,VY,VZ);
 
-  // Actuellement est on sur le point cache
+  // This is a hidden point
   if ((VX*(X-Xp) > 0.) && (VY*(Y-Yp) > 0.) && (VZ*(Z-Zp) > 0.))
     SetPosition (X,Y,Z);
 }
 
-Standard_Boolean V3d_PositionLight::SeeOrHide(const Handle(V3d_View)& aView) const {
-
+// =======================================================================
+// function : SeeOrHide
+// purpose  :
+// =======================================================================
+Standard_Boolean V3d_PositionLight::SeeOrHide (const Handle(V3d_View)& theView) const
+{
   Standard_Real Xp,Yp,Zp, X,Y,Z, VX,VY,VZ;
   
   Position (Xp,Yp,Zp);
-       V3d_Light::SymetricPointOnSphere (aView, 
-               MyTarget, Graphic3d_Vertex(Xp,Yp,Yp), Radius(), X,Y,Z, VX,VY,VZ);
+  V3d_Light::SymetricPointOnSphere (theView, 
+    myTarget, Graphic3d_Vertex(Xp,Yp,Yp), Radius(), X,Y,Z, VX,VY,VZ);
 
-  // Avons nous le point cache ou le point vu
+  // Is it a visible or a hidden point
   return ( (VX*(X-Xp) > 0.) || (VY*(Y-Yp) > 0.) || (VZ*(Z-Zp) > 0.) )?
-    // la source est sur la face cachee
+    // the source is on the hidden face 
     Standard_False:
-    // la source est sur la face vue.
+    // the source is on the visible face.
     Standard_True;
 }
 
-void V3d_PositionLight::Target(Standard_Real& Xp, Standard_Real& Yp, Standard_Real& Zp)const  {
-  
-  MyTarget.Coord(Xp,Yp,Zp) ;
+// =======================================================================
+// function : Target
+// purpose  :
+// =======================================================================
+void V3d_PositionLight::Target (Standard_Real& theXp, Standard_Real& theYp, Standard_Real& theZp) const
+{
+  myTarget.Coord (theXp, theYp, theZp);
 }
 
-void V3d_PositionLight::Display( const Handle(V3d_View)& aView,
-                                    const V3d_TypeOfRepresentation TPres ) {
-
-  Graphic3d_Array1OfVertex PRadius(0,1);
+// =======================================================================
+// function : Display
+// purpose  :
+// =======================================================================
+void V3d_PositionLight::Display (const Handle(V3d_View)& theView, const V3d_TypeOfRepresentation theTPres)
+{
   Graphic3d_Vertex PText ;
   Standard_Real X,Y,Z,Rayon;
   Standard_Real X0,Y0,Z0,VX,VY,VZ;
   Standard_Real X1,Y1,Z1;
   Standard_Real DXRef,DYRef,DZRef,DXini,DYini,DZini;
-  Standard_Real R1,G1,B1;
   V3d_TypeOfRepresentation Pres;
-  V3d_TypeOfUpdate UpdSov;
-
-//  Creation d'une structure slight d'elements reperables (la position de
-//  la light, et le domaine d'eclairage represente par un cercle)
-//  Creation d'une structure snopick d'elements non reperables ( cible, meridien et 
-//  parallele ).
-
-    Pres = TPres;
-    Handle(V3d_Viewer) TheViewer = aView->Viewer();
-    UpdSov = TheViewer->UpdateMode();
-    TheViewer->SetUpdateMode(V3d_WAIT);
-    if (!MyGraphicStructure.IsNull()) {
-       MyGraphicStructure->Disconnect(MyGraphicStructure1);
-       MyGraphicStructure->Clear();
-       MyGraphicStructure1->Clear();
-       if (Pres == V3d_SAMELAST) Pres = MyTypeOfRepresentation;
-    }
-    else {
-      if (Pres == V3d_SAMELAST) Pres = V3d_SIMPLE;
-      Handle(Graphic3d_Structure) slight = new Graphic3d_Structure(TheViewer->Viewer());
-      MyGraphicStructure = slight;
-      Handle(Graphic3d_Structure) snopick = new Graphic3d_Structure(TheViewer->Viewer()); 
-      MyGraphicStructure1 = snopick;
-    }
 
-               
-       Handle(Graphic3d_Group) gradius;
-       Handle(Graphic3d_Group) gExtArrow;
-       Handle(Graphic3d_Group) gIntArrow;
-
-       if (MyType != V3d_DIRECTIONAL) {
-               if (Pres == V3d_COMPLETE) {
-                       gradius = new Graphic3d_Group(MyGraphicStructure);
-                       gExtArrow = new Graphic3d_Group(MyGraphicStructure);
-                       gIntArrow = new Graphic3d_Group(MyGraphicStructure);
-               }
-       }
-  Handle(Graphic3d_Group) glight  = new Graphic3d_Group(MyGraphicStructure);
+//  Creation of a structure of markable elements (position of the
+//  light, and the domain of lighting represented by a circle)
+//  Creation of a structure snopick of non-markable elements (target, meridian and 
+//  parallel).
+
+  Pres = theTPres;
+  Handle(V3d_Viewer) TheViewer = theView->Viewer();
+  if (!myGraphicStructure.IsNull()) {
+    myGraphicStructure->Disconnect(myGraphicStructure1);
+    myGraphicStructure->Clear();
+    myGraphicStructure1->Clear();
+    if (Pres == V3d_SAMELAST) Pres = myTypeOfRepresentation;
+  }
+  else {
+    if (Pres == V3d_SAMELAST) Pres = V3d_SIMPLE;
+    Handle(Graphic3d_Structure) slight = new Graphic3d_Structure(TheViewer->StructureManager());
+    myGraphicStructure = slight;
+    Handle(Graphic3d_Structure) snopick = new Graphic3d_Structure(TheViewer->StructureManager()); 
+    myGraphicStructure1 = snopick;
+  }
+
+  Handle(Graphic3d_Group) gradius, gExtArrow, gIntArrow;
+  if (Type() != V3d_DIRECTIONAL
+   && Pres == V3d_COMPLETE)
+  {
+    gradius   = myGraphicStructure->NewGroup();
+    gExtArrow = myGraphicStructure->NewGroup();
+    gIntArrow = myGraphicStructure->NewGroup();
+  }
+  Handle(Graphic3d_Group) glight = myGraphicStructure->NewGroup();
   Handle(Graphic3d_Group) gsphere;
-  if (Pres == V3d_COMPLETE || Pres == V3d_PARTIAL) gsphere = new Graphic3d_Group(MyGraphicStructure);
+  if (Pres == V3d_COMPLETE
+   || Pres == V3d_PARTIAL)
+  {
+    gsphere = myGraphicStructure->NewGroup();
+  }
   
-  Handle(Graphic3d_Group) gnopick = new Graphic3d_Group(MyGraphicStructure1);
-  MyGraphicStructure1->SetPick(Standard_False);
+  Handle(Graphic3d_Group) gnopick = myGraphicStructure1->NewGroup();
   
-  X0 = MyTarget.X();
-  Y0 = MyTarget.Y();
-  Z0 = MyTarget.Z();
+  X0 = myTarget.X();
+  Y0 = myTarget.Y();
+  Z0 = myTarget.Z();
   
-//Affichage de la position de la light.
+// Display of the light position.
 
-  glight->SetPickId(1);
-  this->Color(Quantity_TOC_RGB,R1,G1,B1);
-  Quantity_Color Col1(R1,G1,B1,Quantity_TOC_RGB);
+  const Quantity_Color Col1 = this->Color();
   Handle(Graphic3d_AspectLine3d) Asp1 = new Graphic3d_AspectLine3d();
   Asp1->SetColor(Col1);
   glight->SetPrimitivesAspect(Asp1);
-  this->Symbol(glight,aView);
+  this->Symbol(glight,theView);
 
-//Affichage de la sphere de reperage (limite au cercle).
+// Display of the marking sphere (limit at the circle).
 
   if (Pres == V3d_COMPLETE || Pres == V3d_PARTIAL) {
       
     Rayon = this->Radius();
-    aView->Proj(VX,VY,VZ);
-    gsphere->SetPickId(2);
+    theView->Proj(VX,VY,VZ);
     V3d::CircleInPlane(gsphere,X0,Y0,Z0,VX,VY,VZ,Rayon);
 
+    if (Type() != V3d_DIRECTIONAL) {
+
+      //Display of the radius of the sphere (line + text)
+
+      if (Pres == V3d_COMPLETE) {
+        this->Position(X,Y,Z);
+        Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2);
+        aPrims->AddVertex(X0,Y0,Z0);
+        aPrims->AddVertex(X,Y,Z);
+        gnopick->AddPrimitiveArray(aPrims);
+        V3d::ArrowOfRadius(gExtArrow,X-.1*(X-X0),Y-.1*(Y-Y0),Z-.1*(Z-Z0),X-X0,Y-Y0,Z-Z0,M_PI/15.,Rayon/20.);
+        V3d::ArrowOfRadius(gIntArrow,X0,Y0,Z0,X0-X,Y0-Y,Z0-Z,M_PI/15.,Rayon/20.);
+        TCollection_AsciiString ValOfRadius(Rayon);
+        PText.SetCoord( .5*(X0+X), .5*(Y0+Y), .5*(Z0+Z) );
+        gradius->Text(ValOfRadius.ToCString(),PText,0.01);
+      }
+    }
 
-               if (MyType != V3d_DIRECTIONAL) {
-
-      //Affichage du rayon de la sphere (ligne + texte)
-
-                       if (Pres == V3d_COMPLETE) {
-                               gradius->SetPickId(3);
-                               gExtArrow->SetPickId(4);
-                               gIntArrow->SetPickId(5);
-                               PRadius(0).SetCoord(X0,Y0,Z0);
-                               this->Position(X,Y,Z);
-                               PRadius(1).SetCoord(X,Y,Z);
-                               gnopick->Polyline(PRadius);
-                               V3d::ArrowOfRadius(gExtArrow,X-(X-X0)/10.,
-                                Y-(Y-Y0)/10.,
-                                Z-(Z-Z0)/10.,X-X0,Y-Y0,Z-Z0,PI/15.,Rayon/20.);
-                               V3d::ArrowOfRadius(gIntArrow,X0,Y0,Z0,X0-X,Y0-Y,Z0-Z,PI/15.,Rayon/20.);
-                               TCollection_AsciiString ValOfRadius(Rayon);
-                               PText.SetCoord( (X0+X)/2., (Y0+Y)/2. , (Z0+Z)/2. );
-                               gradius->Text(ValOfRadius.ToCString(),PText,0.01);
-                       }
-               }
-
-
-    //Affichage du meridien
+    // Display of the meridian
 
     Quantity_Color Col2(Quantity_NOC_GREEN);
-    Handle(Graphic3d_AspectLine3d) Asp2 = new Graphic3d_AspectLine3d
-      (Col2,Aspect_TOL_SOLID,1.);
+    Handle(Graphic3d_AspectLine3d) Asp2 = new Graphic3d_AspectLine3d(Col2,Aspect_TOL_SOLID,1.);
     gnopick->SetPrimitivesAspect(Asp2);
     
-    // Definition de l'axe du cercle
-    aView->Up(DXRef,DYRef,DZRef);
+    // Definition of the axis of circle
+    theView->Up(DXRef,DYRef,DZRef);
     this->Position(X,Y,Z);
     DXini = X-X0; DYini = Y-Y0; DZini = Z-Z0;
     VX = DYRef*DZini - DZRef*DYini;
@@ -242,11 +264,11 @@ void V3d_PositionLight::Display( const Handle(V3d_View)& aView,
     
     V3d::CircleInPlane(gnopick,X0,Y0,Z0,VX,VY,VZ,Rayon);
       
-    // Affichage de la parallele
+    // Display of the parallel
 
-    // Definition de l'axe du cercle
-    aView->Proj(VX,VY,VZ);
-    aView->Up(X1,Y1,Z1);
+    // Definition of the axis of circle
+    theView->Proj(VX,VY,VZ);
+    theView->Up(X1,Y1,Z1);
     DXRef = VY * Z1 - VZ * Y1;
     DYRef = VZ * X1 - VX * Z1;
     DZRef = VX * Y1 - VY * X1;
@@ -259,69 +281,20 @@ void V3d_PositionLight::Display( const Handle(V3d_View)& aView,
     V3d::CircleInPlane(gnopick,X0,Y0,Z0,VX,VY,VZ,Rayon);
   }
 
-  MyGraphicStructure->Connect(MyGraphicStructure1,Graphic3d_TOC_DESCENDANT);
-  MyTypeOfRepresentation = Pres;
-  MyGraphicStructure->Display();
-  TheViewer->SetUpdateMode(UpdSov);
-}
-
-V3d_TypeOfPickLight V3d_PositionLight::Pick(const Handle(V3d_View)& aView,
-                                             const Standard_Integer Xpix,
-                                             const Standard_Integer Ypix) 
-const {
-  
-  Standard_Integer i, Lng, Id;
-  Standard_Boolean kcont;
-  V3d_TypeOfPickLight TPick;
-  
-  Handle(Visual3d_ViewManager) VM = (aView->Viewer())->Viewer();
-#ifdef WNT
-  Handle( WNT_Window ) WW = Handle( WNT_Window ) :: DownCast (  aView -> Window ()  );
-#else
-  Handle( Xw_Window  ) WW = Handle( Xw_Window  ) :: DownCast (  aView -> Window ()  );
-#endif
-  Visual3d_ContextPick CTXP;
-  Visual3d_PickDescriptor Pdes = VM->Pick(CTXP,WW,Xpix,Ypix);
-  Visual3d_PickPath OnePPath;
-  Handle(Visual3d_HSequenceOfPickPath) PPath = Pdes.PickPath();
-  Lng = PPath->Length();      
-  kcont = Standard_True;
-  TPick = V3d_NOTHING;  
-  for (i=1; i<=Lng && kcont; i++) {
-    OnePPath = PPath->Value(i);
-    Id = OnePPath.PickIdentifier();
-    if (MyGraphicStructure == OnePPath.StructIdentifier()){
-      switch (Id) {
-      case 1 : 
-       TPick = V3d_POSITIONLIGHT;
-       break;
-      case 2 : 
-       TPick = V3d_SPACELIGHT;
-       break;
-      case 3 :
-       if (MyType != V3d_DIRECTIONAL)
-         TPick = V3d_RADIUSTEXTLIGHT;
-       break;
-      case 4 : 
-       if (MyType != V3d_DIRECTIONAL)
-       TPick = V3d_ExtRADIUSLIGHT;
-       break;
-      case 5 : 
-       if (MyType != V3d_DIRECTIONAL)
-       TPick = V3d_IntRADIUSLIGHT;
-       break;
-      }
-      kcont = Standard_False;
-    }
-  }
-  return TPick;
+  myGraphicStructure->Connect(myGraphicStructure1,Graphic3d_TOC_DESCENDANT);
+  myTypeOfRepresentation = Pres;
+  myGraphicStructure->Display();
 }
 
-void V3d_PositionLight::Tracking( const Handle(V3d_View)& aView,
-                         const V3d_TypeOfPickLight WhatPick,
-                         const Standard_Integer Xpix,
-                         const Standard_Integer Ypix) {
-
+// =======================================================================
+// function : Display
+// purpose  :
+// =======================================================================
+void V3d_PositionLight::Tracking (const Handle(V3d_View)& theView,
+                                  const V3d_TypeOfPickLight theWhatPick,
+                                  const Standard_Integer theXpix,
+                                  const Standard_Integer theYpix)
+{
 //  Quantity_Color   Col ;
   Standard_Real    xPos, yPos, zPos;
   Standard_Real    XPp,YPp,PXT,PYT,X,Y,Z,Rayon,Ylim;
@@ -332,17 +305,17 @@ void V3d_PositionLight::Tracking( const Handle(V3d_View)& aView,
   Standard_Real    Xi,Yi,Zi,DeltaX,DeltaY,DeltaZ,Lambda;
   Standard_Integer IPX,IPY;
   
-  aView->Convert(Xpix,Ypix,XPp,YPp);
-  X0 = MyTarget.X();
-  Y0 = MyTarget.Y();
-  Z0 = MyTarget.Z();
-  aView->Project(X0,Y0,Z0,PXT,PYT);
-  aView->Convert(PXT,PYT,IPX,IPY);
-//      Coord 3d dans le plan de projection de la cible.
-  aView->Convert(IPX,IPY,XT,YT,ZT);
-  switch (WhatPick) {
+  theView->Convert(theXpix,theYpix,XPp,YPp);
+  X0 = myTarget.X();
+  Y0 = myTarget.Y();
+  Z0 = myTarget.Z();
+  theView->Project(X0,Y0,Z0,PXT,PYT);
+  theView->Convert(PXT,PYT,IPX,IPY);
+//      Coord 3d in the plane of projection of the target.
+  theView->Convert(IPX,IPY,XT,YT,ZT);
+  switch (theWhatPick) {
   case V3d_POSITIONLIGHT :
-         // Les Coordonnees doivent rester a l'interieur de la sphere
+         // The Coordinates should remain inside of the sphere
     Rayon = Radius();
     XMinTrack = PXT - Rayon;
     XMaxTrack = PXT + Rayon;
@@ -351,19 +324,17 @@ void V3d_PositionLight::Tracking( const Handle(V3d_View)& aView,
     YMaxTrack = PYT + Ylim;
     if (XPp >= XMinTrack && XPp <= XMaxTrack) {
       if (YPp >= YMinTrack && YPp <= YMaxTrack) {
-                               aView->ProjReferenceAxe(Xpix,Ypix,XP,YP,ZP,VX,VY,VZ);
+                               theView->ProjReferenceAxe(theXpix,theYpix,XP,YP,ZP,VX,VY,VZ);
        DeltaX = X0 - XP;
        DeltaY = Y0 - YP;
        DeltaZ = Z0 - ZP;
        
-//                   On recherche le point d'intersection des droites definies
-//                   par :
-//                   - Droite passant par le point de projection et l'oeil
-//                     si on est en perspective, parralele a la normale de la 
-//                     vue si on a une vue axonometrique.
-//                     position dans la vue est // a la normale de la vue
-//                   - La distance position de la camera cible est egale au 
-//                     rayon.
+//      The point of intersection of straight lines defined by :
+//      - Straight line passing by the point of projection and the eye
+//        if this is a perspective, parralel to the normal of the view 
+//        if this is an axonometric view.
+//        position in the view is parallel to the normal of the view
+//      - The distance position of the target camera is equal to the radius.
 
        A = VX*VX + VY*VY + VZ*VZ ;
        B = -2. * (VX*DeltaX + VY*DeltaY + VZ*DeltaZ);
@@ -377,36 +348,36 @@ void V3d_PositionLight::Tracking( const Handle(V3d_View)& aView,
          Z = ZP + Lambda*VZ;
          SetPosition(X,Y,Z);
 
-               if (MyType == V3d_SPOT)
+               if (Type() == V3d_SPOT)
            ((V3d_SpotLight*)this)->SetDirection(X0-X,Y0-Y,Z0-Z);
 
-         Display(aView,MyTypeOfRepresentation);
-         (aView->Viewer())->UpdateLights();
+         Display(theView,myTypeOfRepresentation);
+         (theView->Viewer())->UpdateLights();
        }
       }
     }
     break;
 
   case V3d_SPACELIGHT :
-    aView->Convert(PXT,PYT,IPX,IPY);
-//               Dans ce cas Xpix,Ypix correspondent a une distance , relative
-//               a la translation que l'on veut effectuer sur la sphere. 
-    aView->Convert(IPX+Xpix,IPY+Ypix,X,Y,Z);
+    theView->Convert(PXT,PYT,IPX,IPY);
+//               In this case Xpix,Ypix correspond to a distance, relative
+//               to the translation that is planned to be performed on the sphere. 
+    theView->Convert(IPX+theXpix,IPY+theYpix,X,Y,Z);
     X = X+X0-XT;
     Y = Y+Y0-YT; 
     Z = Z+Z0-ZT;
     SetTarget(X,Y,Z);
-    Display(aView,MyTypeOfRepresentation);
-    (aView->Viewer())->UpdateLights();
+    Display(theView,myTypeOfRepresentation);
+    (theView->Viewer())->UpdateLights();
     break;
 
   case V3d_ExtRADIUSLIGHT :
-               if (MyType == V3d_DIRECTIONAL)
+               if (Type() == V3d_DIRECTIONAL)
                        break;
-//             on cherche a conserver la direction cible positionnement de la 
-//             source ==> on projette le point sur la direction cible source.
+//             it is attempted to preserve the target direction position of the  
+//             source ==> the point is projected on the target source direction.
     this->Position(Xi,Yi,Zi);
-    aView->Project(Xi,Yi,Zi,PXP,PYP);
+    theView->Project(Xi,Yi,Zi,PXP,PYP);
     DX = PXP - PXT;
     DY = PYP - PYT;
     A1 = DY/DX ; B1 = PYT - A1*PXT;
@@ -420,19 +391,18 @@ void V3d_PositionLight::Tracking( const Handle(V3d_View)& aView,
       Rayon = Radius();
       Rayon = Rayon * Rap;
       SetRadius(Rayon);
-      Display(aView,MyTypeOfRepresentation);
-      (aView->Viewer())->UpdateLights();
+      Display(theView,myTypeOfRepresentation);
+      (theView->Viewer())->UpdateLights();
     }
     break;
 
   case V3d_IntRADIUSLIGHT :
-               if (MyType == V3d_DIRECTIONAL)
+               if (Type() == V3d_DIRECTIONAL)
                        break;
-//               on cherche a conserver la direction cible positionnement 
-//               de la source ==> on projette le point sur la direction 
-//               cible source.
+//             it is attempted to preserve the target direction position of the  
+//             source ==> the point is projected on the target source direction.
     Position(Xi,Yi,Zi);
-    aView->Project(Xi,Yi,Zi,PXP,PYP);
+    theView->Project(Xi,Yi,Zi,PXP,PYP);
     DX = PXP - PXT;
     DY = PYP - PYT;
     A1 = DY/DX ; B1 = PYT - A1*PXT;
@@ -445,20 +415,20 @@ void V3d_PositionLight::Tracking( const Handle(V3d_View)& aView,
       Rap = NewRprj/OldRprj;
       Rayon = Radius();
       Rayon = Rayon * Rap;
-//                 la source doit rester a une position fixe, seule la cible
-//                 est modifie.
+//                 the source should remain at a fixed position, 
+//                 only the target is modified.
       Position (xPos, yPos, zPos);
-      Graphic3d_Vector  Dir(Graphic3d_Vertex(xPos,yPos,zPos), MyTarget);
+      Graphic3d_Vector  Dir(Graphic3d_Vertex(xPos,yPos,zPos), myTarget);
       Dir.Normalize();
       Dir.Coord(X,Y,Z);
       X = Xi + Rayon*X;
       Y = Yi + Rayon*Y;
       Z = Zi + Rayon*Z;
-//                 la source doit rester a une position fixe, seule la cible
-//                 est modifie.
-      MyTarget.SetCoord(X,Y,Z);
-      Display(aView,MyTypeOfRepresentation);            
-      (aView->Viewer())->UpdateLights();
+//                 the source should remain at a fixed position, 
+//                 only the target is modified.
+      myTarget.SetCoord(X,Y,Z);
+      Display(theView,myTypeOfRepresentation);          
+      (theView->Viewer())->UpdateLights();
     }
                break;
 
@@ -470,19 +440,27 @@ void V3d_PositionLight::Tracking( const Handle(V3d_View)& aView,
   }
 }
 
-Standard_Real V3d_PositionLight::Radius() const {
-
+// =======================================================================
+// function : Radius
+// purpose  :
+// =======================================================================
+Standard_Real V3d_PositionLight::Radius() const
+{
   Standard_Real  Xp,Yp,Zp, Xc,Yc,Zc;
   
   Position (Xp,Yp,Zp);
-  MyTarget.Coord(Xc,Yc,Zc);
+  myTarget.Coord(Xc,Yc,Zc);
 
   return Sqrt (Square(Xc - Xp) + Square(Yc - Yp) + Square(Zc - Zp));
 }
 
-void V3d_PositionLight::Erase() {
-
-  if (!MyGraphicStructure.IsNull()) MyGraphicStructure->Erase();
-  if (!MyGraphicStructure1.IsNull()) MyGraphicStructure1->Erase();
+// =======================================================================
+// function : Radius
+// purpose  :
+// =======================================================================
+void V3d_PositionLight::Erase()
+{
+  if (!myGraphicStructure.IsNull()) myGraphicStructure->Erase();
+  if (!myGraphicStructure1.IsNull()) myGraphicStructure1->Erase();
 }