0030692: Data Exchange - introduce base framework RWMesh for importing mesh data...
[occt.git] / src / V3d / V3d_View.cxx
index a01ab03..b67123a 100644 (file)
@@ -27,7 +27,6 @@
 #include <Graphic3d_MapOfStructure.hxx>
 #include <Graphic3d_Structure.hxx>
 #include <Graphic3d_TextureEnv.hxx>
-#include <Graphic3d_Vector.hxx>
 #include <Image_AlienPixMap.hxx>
 #include <Message.hxx>
 #include <Message_Messenger.hxx>
@@ -51,7 +50,7 @@
 #include <V3d_UnMapped.hxx>
 #include <V3d_Viewer.hxx>
 
-IMPLEMENT_STANDARD_RTTIEXT(V3d_View,MMgt_TShared)
+IMPLEMENT_STANDARD_RTTIEXT(V3d_View,Standard_Transient)
 
 #define DEUXPI (2. * M_PI)
 
@@ -66,10 +65,9 @@ namespace
 //=============================================================================
 V3d_View::V3d_View (const Handle(V3d_Viewer)& theViewer, const V3d_TypeOfView theType)
 : MyViewer (theViewer.operator->()),
-  MyActiveLights(),
-  myActiveLightsIterator(),
   SwitchSetFront (Standard_False),
   myZRotation (Standard_False),
+  myTrihedron (new V3d_Trihedron()),
   MyTrsf (1, 4, 1, 4)
 {
   myView = theViewer->Driver()->CreateView (theViewer->StructureManager());
@@ -117,8 +115,6 @@ V3d_View::V3d_View (const Handle(V3d_Viewer)& theViewer, const V3d_TypeOfView th
 //=============================================================================
 V3d_View::V3d_View (const Handle(V3d_Viewer)& theViewer, const Handle(V3d_View)& theView)
 : MyViewer (theViewer.operator->()),
-  MyActiveLights(),
-  myActiveLightsIterator(),
   SwitchSetFront(Standard_False),
   myZRotation (Standard_False),
   MyTrsf (1, 4, 1, 4)
@@ -126,14 +122,13 @@ V3d_View::V3d_View (const Handle(V3d_Viewer)& theViewer, const Handle(V3d_View)&
   myView = theViewer->Driver()->CreateView (theViewer->StructureManager());
 
   myView->CopySettings (theView->View());
+  myDefaultViewPoint = theView->myDefaultViewPoint;
+  myDefaultViewAxis  = theView->myDefaultViewAxis;
 
-  myDefaultCamera = new Graphic3d_Camera();
+  myDefaultCamera = new Graphic3d_Camera (theView->DefaultCamera());
 
   myImmediateUpdate = Standard_False;
   SetAutoZFitMode (theView->AutoZFitMode(), theView->AutoZFitScaleFactor());
-  SetAxis (0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
-  SetViewMappingDefault();
-  SetViewOrientationDefault();
   theViewer->AddView (this);
   Init();
   myImmediateUpdate = Standard_True;
@@ -168,7 +163,7 @@ void V3d_View::SetMagnify (const Handle(Aspect_Window)& theWindow,
     thePreviousView->Convert (theX1, theY1, aU1, aV1);
     thePreviousView->Convert (theX2, theY2, aU2, aV2);
     myView->SetWindow (theWindow);
-    FitAll (theWindow, aU1, aV1, aU2, aV2);
+    FitAll (aU1, aV1, aU2, aV2);
     MyViewer->SetViewOn (this);
     MyWindow = theWindow;
     SetRatio();
@@ -194,7 +189,10 @@ void V3d_View::SetWindow (const Handle(Aspect_Window)&  theWindow,
   myView->SetWindow (theWindow, theContext);
   MyViewer->SetViewOn (this);
   SetRatio();
-  Redraw();
+  if (myImmediateUpdate)
+  {
+    Redraw();
+  }
 }
 
 //=============================================================================
@@ -203,6 +201,15 @@ void V3d_View::SetWindow (const Handle(Aspect_Window)&  theWindow,
 //=============================================================================
 void V3d_View::Remove() const
 {
+  if (!MyGrid.IsNull())
+  {
+    MyGrid->Erase();
+  }
+  if (!myTrihedron.IsNull())
+  {
+    myTrihedron->Erase();
+  }
+
   MyViewer->DelView (this);
   myView->Remove();
   Handle(Aspect_Window)& aWin = const_cast<Handle(Aspect_Window)&> (MyWindow);
@@ -221,7 +228,9 @@ void V3d_View::Update() const
     return;
   }
 
-  myView->Update (Aspect_TOU_ASAP);
+  myView->Update();
+  myView->Compute();
+  myView->Redraw();
 }
 
 //=============================================================================
@@ -236,21 +245,19 @@ void V3d_View::Redraw() const
     return;
   }
 
-  Handle(Graphic3d_GraphicDriver)    aGraphicDriver = MyViewer->Driver();
   Handle(Graphic3d_StructureManager) aStructureMgr  = MyViewer->StructureManager();
   for (Standard_Integer aRetryIter = 0; aRetryIter < 2; ++aRetryIter)
   {
-    if (aGraphicDriver->IsDeviceLost())
+    if (aStructureMgr->IsDeviceLost())
     {
       aStructureMgr->RecomputeStructures();
-      aGraphicDriver->ResetDeviceLostFlag();
     }
 
     AutoZFit();
 
     myView->Redraw();
 
-    if (!aGraphicDriver->IsDeviceLost())
+    if (!aStructureMgr->IsDeviceLost())
     {
       return;
     }
@@ -308,24 +315,6 @@ void V3d_View::SetAutoZFitMode (const Standard_Boolean theIsOn,
   myAutoZFitIsOn = theIsOn;
 }
 
-// ========================================================================
-// function : AutoZFitMode
-// purpose  :
-// ========================================================================
-Standard_Boolean V3d_View::AutoZFitMode() const
-{
-  return myAutoZFitIsOn;
-}
-
-// ========================================================================
-// function : AutoZFitScaleFactor
-// purpose  :
-// ========================================================================
-Standard_Real V3d_View::AutoZFitScaleFactor() const
-{
-  return myAutoZFitScaleFactor;
-}
-
 //=============================================================================
 //function : AutoZFit
 //purpose  :
@@ -372,16 +361,12 @@ Standard_Boolean V3d_View::IsEmpty() const
 //=============================================================================
 void V3d_View::UpdateLights() const
 {
-  Graphic3d_ListOfCLight aLights;
-
-  for (TColStd_ListIteratorOfListOfTransient anIt (MyActiveLights); anIt.More(); anIt.Next())
+  Handle(Graphic3d_LightSet) aLights = new Graphic3d_LightSet();
+  for (V3d_ListOfLight::Iterator anActiveLightIter (myActiveLights); anActiveLightIter.More(); anActiveLightIter.Next())
   {
-    aLights.Append (Handle(V3d_Light)::DownCast (anIt.Value())->Light());
+    aLights->Add (anActiveLightIter.Value());
   }
-
   myView->SetLights (aLights);
-
-  Update();
 }
 
 //=============================================================================
@@ -412,8 +397,10 @@ void V3d_View::MustBeResized()
   myView->Resized();
 
   SetRatio();
-
-  Redraw();
+  if (myImmediateUpdate)
+  {
+    Redraw();
+  }
 }
 
 //=============================================================================
@@ -446,15 +433,6 @@ void V3d_View::SetBackgroundColor (const Quantity_Color& theColor)
   }
 }
 
-//=============================================================================
-//function : SetBackgroundColor
-//purpose  :
-//=============================================================================
-void V3d_View::SetBackgroundColor (const Quantity_NameOfColor theName)
-{
-  SetBackgroundColor (Quantity_Color (theName));
-}
-
 //=============================================================================
 //function : SetBgGradientColors
 //purpose  :
@@ -474,21 +452,6 @@ void V3d_View::SetBgGradientColors (const Quantity_Color& theColor1,
   }
 }
 
-//=============================================================================
-//function : SetBgGradientColors
-//purpose  :
-//=============================================================================
-void V3d_View::SetBgGradientColors (const Quantity_NameOfColor theColor1,
-                                    const Quantity_NameOfColor theColor2,
-                                    const Aspect_GradientFillMethod theFillStyle,
-                                    const Standard_Boolean theToUpdate)
-{
-  Quantity_Color aColor1 (theColor1);
-  Quantity_Color aColor2 (theColor2);
-
-  SetBgGradientColors (aColor1, aColor2, theFillStyle, theToUpdate);
-}
-
 //=============================================================================
 //function : SetBgGradientStyle
 //purpose  :
@@ -537,24 +500,20 @@ void V3d_View::SetBgImageStyle (const Aspect_FillMethod theFillStyle, const Stan
 //function : SetAxis
 //purpose  :
 //=============================================================================
-void V3d_View::SetAxis(const Standard_Real X, const Standard_Real Y, const Standard_Real Z, const Standard_Real Vx, const Standard_Real Vy, const Standard_Real Vz)
+void V3d_View::SetAxis (const Standard_Real theX,  const Standard_Real theY,  const Standard_Real theZ,
+                        const Standard_Real theVx, const Standard_Real theVy, const Standard_Real theVz)
 {
-  Standard_Real D,Nx = Vx,Ny = Vy,Nz = Vz ;
-
-  D = Sqrt( Vx*Vx + Vy*Vy + Vz*Vz ) ;
-  V3d_BadValue_Raise_if ( D <= 0. , "V3d_View::SetAxis, bad axis");
-  Nx /= D ; Ny /= D ; Nz /= D ;
-  MyDefaultViewPoint.SetCoord(X,Y,Z) ;
-  MyDefaultViewAxis.SetCoord(Nx,Ny,Nz) ;
+  myDefaultViewPoint.SetCoord (theX, theY, theZ);
+  myDefaultViewAxis.SetCoord (theVx, theVy, theVz);
 }
 
 //=============================================================================
 //function : SetShadingModel
 //purpose  :
 //=============================================================================
-void V3d_View::SetShadingModel (const V3d_TypeOfShadingModel theShadingModel)
+void V3d_View::SetShadingModel (const Graphic3d_TypeOfShadingModel theShadingModel)
 {
-  myView->SetShadingModel (static_cast<Graphic3d_TypeOfShadingModel> (theShadingModel));
+  myView->SetShadingModel (theShadingModel);
 }
 
 //=============================================================================
@@ -754,33 +713,28 @@ void V3d_View::Rotate(const V3d_TypeOfAxe Axe, const Standard_Real angle, const
 //function : Rotate
 //purpose  :
 //=============================================================================
-void V3d_View::Rotate(const V3d_TypeOfAxe Axe, const Standard_Real angle,
-                      const Standard_Real X, const Standard_Real Y, const Standard_Real Z, const Standard_Boolean Start)
+void V3d_View::Rotate (const V3d_TypeOfAxe theAxe, const Standard_Real theAngle,
+                       const Standard_Real theX, const Standard_Real theY, const Standard_Real theZ, const Standard_Boolean theStart)
 {
-  Standard_Real Angle = angle ;
+  Standard_Real anAngle = theAngle;
 
-  if( Angle > 0. ) while ( Angle > DEUXPI ) Angle -= DEUXPI ;
-  else if( Angle < 0. ) while ( Angle < -DEUXPI ) Angle += DEUXPI ;
+  if (anAngle > 0.0) while (anAngle > DEUXPI) anAngle -= DEUXPI;
+  else if (anAngle < 0.0) while (anAngle < -DEUXPI) anAngle += DEUXPI;
 
   Handle(Graphic3d_Camera) aCamera = Camera();
 
-  if (Start)
+  if (theStart)
   {
-    myGravityReferencePoint.SetCoord (X, Y, Z);
+    myGravityReferencePoint.SetCoord (theX, theY, theZ);
     myCamStartOpUp     = aCamera->Up();
     myCamStartOpEye    = aCamera->Eye();
     myCamStartOpCenter = aCamera->Center();
 
-    switch (Axe) {
-    case V3d_X :
-      myViewAxis.SetCoord(1.,0.,0.) ;
-      break ;
-    case V3d_Y :
-      myViewAxis.SetCoord(0.,1.,0.) ;
-      break ;
-    case V3d_Z :
-      myViewAxis.SetCoord(0.,0.,1.) ;
-      break ;
+    switch (theAxe)
+    {
+      case V3d_X: myViewAxis = gp::DX(); break;
+      case V3d_Y: myViewAxis = gp::DY(); break;
+      case V3d_Z: myViewAxis = gp::DZ(); break;
     }
 
     myCamStartOpUp     = aCamera->Up();
@@ -797,11 +751,11 @@ void V3d_View::Rotate(const V3d_TypeOfAxe Axe, const Standard_Real angle,
   // rotate camera around passed axis
   gp_Trsf aRotation;
   gp_Pnt aRCenter (aVref.X(), aVref.Y(), aVref.Z());
-  gp_Dir aRAxis ((Axe == V3d_X) ? 1.0 : 0.0,
-                  (Axe == V3d_Y) ? 1.0 : 0.0,
-                  (Axe == V3d_Z) ? 1.0 : 0.0);
+  gp_Dir aRAxis ((theAxe == V3d_X) ? 1.0 : 0.0,
+                 (theAxe == V3d_Y) ? 1.0 : 0.0,
+                 (theAxe == V3d_Z) ? 1.0 : 0.0);
 
-  aRotation.SetRotation (gp_Ax1 (aRCenter, aRAxis), Angle);
+  aRotation.SetRotation (gp_Ax1 (aRCenter, aRAxis), anAngle);
 
   aCamera->Transform (aRotation);
 
@@ -829,16 +783,13 @@ void V3d_View::Rotate(const Standard_Real angle, const Standard_Boolean Start)
     myCamStartOpCenter = aCamera->Center();
   }
 
-  const Graphic3d_Vertex& aPnt = MyDefaultViewPoint;
-  const Graphic3d_Vector& anAxis = MyDefaultViewAxis;
-
   aCamera->SetUp     (myCamStartOpUp);
   aCamera->SetEye    (myCamStartOpEye);
   aCamera->SetCenter (myCamStartOpCenter);
 
   gp_Trsf aRotation;
-  gp_Pnt aRCenter (aPnt.X(), aPnt.Y(), aPnt.Z());
-  gp_Dir aRAxis (anAxis.X(), anAxis.Y(), anAxis.Z());
+  gp_Pnt aRCenter (myDefaultViewPoint);
+  gp_Dir aRAxis (myDefaultViewAxis);
   aRotation.SetRotation (gp_Ax1 (aRCenter, aRAxis), Angle);
 
   aCamera->Transform (aRotation);
@@ -940,11 +891,9 @@ void V3d_View::Turn(const Standard_Real angle, const Standard_Boolean Start)
   aCamera->SetEye    (myCamStartOpEye);
   aCamera->SetCenter (myCamStartOpCenter);
 
-  const Graphic3d_Vector& anAxis = MyDefaultViewAxis;
-
   gp_Trsf aRotation;
   gp_Pnt aRCenter = aCamera->Eye();
-  gp_Dir aRAxis (anAxis.X(), anAxis.Y(), anAxis.Z());
+  gp_Dir aRAxis (myDefaultViewAxis);
   aRotation.SetRotation (gp_Ax1 (aRCenter, aRAxis), Angle);
 
   aCamera->Transform (aRotation);
@@ -961,32 +910,19 @@ void V3d_View::Turn(const Standard_Real angle, const Standard_Boolean Start)
 void V3d_View::SetTwist(const Standard_Real angle)
 {
   Standard_Real Angle = angle ;
-  Standard_Boolean TheStatus;
 
   if( Angle > 0. ) while ( Angle > DEUXPI ) Angle -= DEUXPI ;
   else if( Angle < 0. ) while ( Angle < -DEUXPI ) Angle += DEUXPI ;
 
   Handle(Graphic3d_Camera) aCamera = Camera();
 
-  gp_Dir aReferencePlane (aCamera->Direction().Reversed());
-  gp_Dir anUp;
-
-  anUp = gp_Dir (0.0, 0.0, 1.0);
-
-  TheStatus = ScreenAxis(aReferencePlane, anUp,
-    myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
-  if( !TheStatus ) {
-    anUp = gp_Dir (0.0, 1.0, 0.0);
-    TheStatus = ScreenAxis(aReferencePlane, anUp,
-      myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
-  }
-  if( !TheStatus ) {
-    anUp = gp_Dir (1.0, 0.0, 0.0);
-    TheStatus = ScreenAxis(aReferencePlane, anUp,
-      myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
+  const gp_Dir aReferencePlane (aCamera->Direction().Reversed());
+  if (!screenAxis (aReferencePlane, gp::DZ(), myXscreenAxis, myYscreenAxis, myZscreenAxis)
+   && !screenAxis (aReferencePlane, gp::DY(), myXscreenAxis, myYscreenAxis, myZscreenAxis)
+   && !screenAxis (aReferencePlane, gp::DZ(), myXscreenAxis, myYscreenAxis, myZscreenAxis))
+  {
+    throw V3d_BadValue ("V3d_ViewSetTwist, alignment of Eye,At,Up,");
   }
-
-  V3d_BadValue_Raise_if( !TheStatus,"V3d_ViewSetTwist, alignment of Eye,At,Up,");
   
   gp_Pnt aRCenter = aCamera->Center();
   gp_Dir aZAxis (aCamera->Direction().Reversed());
@@ -994,10 +930,7 @@ void V3d_View::SetTwist(const Standard_Real angle)
   gp_Trsf aTrsf;
   aTrsf.SetRotation (gp_Ax1 (aRCenter, aZAxis), Angle);
 
-  Standard_Real myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ;
-  myYscreenAxis.Coord (myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ);
-
-  aCamera->SetUp (gp_Dir (myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ));
+  aCamera->SetUp (gp_Dir (myYscreenAxis));
   aCamera->Transform (aTrsf);
 
   AutoZFit();
@@ -1086,38 +1019,42 @@ void V3d_View::SetProj( const Standard_Real Vx,const Standard_Real Vy, const Sta
 //function : SetProj
 //purpose  :
 //=============================================================================
-void V3d_View::SetProj( const V3d_TypeOfOrientation Orientation )
+void V3d_View::SetProj (const V3d_TypeOfOrientation theOrientation,
+                        const Standard_Boolean theIsYup)
 {
-  Standard_Real Xpn=0;
-  Standard_Real Ypn=0;
-  Standard_Real Zpn=0;
-
-  switch (Orientation) {
-  case V3d_Zpos :
-    Ypn = 1.;
-    break;
-  case V3d_Zneg :
-    Ypn = -1.;
-    break;
-  default:
-    Zpn = 1.;
+  Graphic3d_Vec3d anUp = theIsYup ? Graphic3d_Vec3d (0.0, 1.0, 0.0) : Graphic3d_Vec3d (0.0, 0.0, 1.0);
+  if (theIsYup)
+  {
+    if (theOrientation == V3d_Ypos
+     || theOrientation == V3d_Yneg)
+    {
+      anUp.SetValues (0.0, 0.0, -1.0);
+    }
+  }
+  else
+  {
+    if (theOrientation == V3d_Zpos)
+    {
+      anUp.SetValues (0.0, 1.0, 0.0);
+    }
+    else if (theOrientation == V3d_Zneg)
+    {
+      anUp.SetValues (0.0, -1.0, 0.0);
+    }
   }
 
-  const Graphic3d_Vector& aBck = V3d::GetProjAxis (Orientation);
+  const gp_Dir aBck = V3d::GetProjAxis (theOrientation);
 
   // retain camera panning from origin when switching projection
-  Handle(Graphic3d_Camera) aCamera = Camera();
-
-  gp_Pnt anOriginVCS  = aCamera->ConvertWorld2View (gp::Origin());
-  Standard_Real aPanX = anOriginVCS.X();
-  Standard_Real aPanY = anOriginVCS.Y();
+  const Handle(Graphic3d_Camera)& aCamera = Camera();
+  const gp_Pnt anOriginVCS = aCamera->ConvertWorld2View (gp::Origin());
 
   aCamera->SetCenter (gp_Pnt (0, 0, 0));
   aCamera->SetDirection (gp_Dir (aBck.X(), aBck.Y(), aBck.Z()).Reversed());
-  aCamera->SetUp (gp_Dir (Xpn, Ypn, Zpn));
+  aCamera->SetUp (gp_Dir (anUp.x(), anUp.y(), anUp.z()));
   aCamera->OrthogonalizeUp();
 
-  Panning (aPanX, aPanY);
+  Panning (anOriginVCS.X(), anOriginVCS.Y());
 
   AutoZFit();
 
@@ -1149,40 +1086,21 @@ void V3d_View::SetAt(const Standard_Real X,const Standard_Real Y,const Standard_
 //function : SetUp
 //purpose  :
 //=============================================================================
-void V3d_View::SetUp(const Standard_Real Vx,const Standard_Real Vy,const Standard_Real Vz)
+void V3d_View::SetUp (const Standard_Real theVx, const Standard_Real theVy, const Standard_Real theVz)
 {
-  Standard_Boolean TheStatus ;
-  V3d_BadValue_Raise_if( Sqrt(Vx*Vx + Vy*Vy + Vz*Vz) <= 0. ,
-    "V3d_View::SetUp, nullUp vector");
-
   Handle(Graphic3d_Camera) aCamera = Camera();
 
-  gp_Dir aReferencePlane (aCamera->Direction().Reversed());
-  gp_Dir anUp (Vx, Vy, Vz);
-
-  TheStatus = ScreenAxis(aReferencePlane,anUp,
-    myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
-  if( !TheStatus ) {
-    anUp = gp_Dir (0.0, 0.0, 1.0);
-    TheStatus = ScreenAxis(aReferencePlane,anUp,
-      myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
-  }
-  if( !TheStatus ) {
-    anUp = gp_Dir (0.0, 1.0, 0.0);
-    TheStatus = ScreenAxis(aReferencePlane,anUp,
-      myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
-  }
-  if( !TheStatus ) {
-    anUp = gp_Dir (1.0, 0.0, 0.0);
-    TheStatus = ScreenAxis(aReferencePlane,anUp,
-      myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
+  const gp_Dir aReferencePlane (aCamera->Direction().Reversed());
+  const gp_Dir anUp (theVx, theVy, theVz);
+  if (!screenAxis (aReferencePlane, anUp,     myXscreenAxis, myYscreenAxis, myZscreenAxis)
+   && !screenAxis (aReferencePlane, gp::DZ(), myXscreenAxis, myYscreenAxis, myZscreenAxis)
+   && !screenAxis (aReferencePlane, gp::DY(), myXscreenAxis, myYscreenAxis, myZscreenAxis)
+   && !screenAxis (aReferencePlane, gp::DX(), myXscreenAxis, myYscreenAxis, myZscreenAxis))
+  {
+    throw V3d_BadValue ("V3d_View::Setup, alignment of Eye,At,Up");
   }
-  V3d_BadValue_Raise_if( !TheStatus,"V3d_View::Setup, alignment of Eye,At,Up");
-
-  Standard_Real myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ;
-  myYscreenAxis.Coord (myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ);
 
-  aCamera->SetUp (gp_Dir (myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ));
+  aCamera->SetUp (gp_Dir (myYscreenAxis));
 
   AutoZFit();
 
@@ -1193,41 +1111,21 @@ void V3d_View::SetUp(const Standard_Real Vx,const Standard_Real Vy,const Standar
 //function : SetUp
 //purpose  :
 //=============================================================================
-void V3d_View::SetUp( const V3d_TypeOfOrientation Orientation )
+void V3d_View::SetUp (const V3d_TypeOfOrientation theOrientation)
 {
-  Standard_Boolean TheStatus ;
-
   Handle(Graphic3d_Camera) aCamera = Camera();
 
-  gp_Dir aReferencePlane (aCamera->Direction().Reversed());
-  gp_Dir anUp;
-
-  const Graphic3d_Vector& aViewReferenceUp = V3d::GetProjAxis(Orientation) ;
-  anUp = gp_Dir (aViewReferenceUp.X(), aViewReferenceUp.Y(), aViewReferenceUp.Z());
-
-  TheStatus = ScreenAxis(aReferencePlane,anUp,
-    myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
-  if( !TheStatus ) {
-    anUp = gp_Dir (0.,0.,1.);
-    TheStatus = ScreenAxis(aReferencePlane,anUp,
-      myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
-  }
-  if( !TheStatus ) {
-    anUp = gp_Dir (0.,1.,0.);
-    TheStatus = ScreenAxis(aReferencePlane,anUp,
-      myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
-  }
-  if( !TheStatus ) {
-    anUp = gp_Dir (1.,0.,0.);
-    TheStatus = ScreenAxis(aReferencePlane,anUp,
-      myXscreenAxis,myYscreenAxis,myZscreenAxis) ;
+  const gp_Dir aReferencePlane (aCamera->Direction().Reversed());
+  const gp_Dir anUp = V3d::GetProjAxis (theOrientation);
+  if (!screenAxis (aReferencePlane, anUp,     myXscreenAxis, myYscreenAxis, myZscreenAxis)
+   && !screenAxis (aReferencePlane, gp::DZ(), myXscreenAxis, myYscreenAxis, myZscreenAxis)
+   && !screenAxis (aReferencePlane, gp::DY(), myXscreenAxis, myYscreenAxis, myZscreenAxis)
+   && !screenAxis (aReferencePlane, gp::DX(), myXscreenAxis, myYscreenAxis, myZscreenAxis))
+  {
+    throw V3d_BadValue ("V3d_View::SetUp, alignment of Eye,At,Up");
   }
-  V3d_BadValue_Raise_if( !TheStatus, "V3d_View::SetUp, alignment of Eye,At,Up");
-
-  Standard_Real myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ;
-  myYscreenAxis.Coord (myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ);
 
-  aCamera->SetUp (gp_Dir (myYscreenAxisX, myYscreenAxisY, myYscreenAxisZ));
+  aCamera->SetUp (gp_Dir (myYscreenAxis));
 
   AutoZFit();
 
@@ -1387,13 +1285,13 @@ void V3d_View::SetZSize (const Standard_Real theSize)
 //function : SetZoom
 //purpose  :
 //=============================================================================
-void V3d_View::SetZoom(const Standard_Real Coef,const Standard_Boolean Start)
+void V3d_View::SetZoom (const Standard_Real theCoef,const Standard_Boolean theToStart)
 {
-  V3d_BadValue_Raise_if( Coef <= 0.,"V3d_View::SetZoom, bad coefficient");
+  V3d_BadValue_Raise_if (theCoef <= 0., "V3d_View::SetZoom, bad coefficient");
 
   Handle(Graphic3d_Camera) aCamera = Camera();
 
-  if (Start)
+  if (theToStart)
   {
     myCamStartOpEye    = aCamera->Eye();
     myCamStartOpCenter = aCamera->Center();
@@ -1403,27 +1301,27 @@ void V3d_View::SetZoom(const Standard_Real Coef,const Standard_Boolean Start)
   Standard_Real aViewHeight = aCamera->ViewDimensions().Y();
 
   // ensure that zoom will not be too small or too big
-  Standard_Real coef = Coef;
-  if (aViewWidth < coef * Precision::Confusion())
+  Standard_Real aCoef = theCoef;
+  if (aViewWidth < aCoef * Precision::Confusion())
   {
-    coef = aViewWidth / Precision::Confusion();
+    aCoef = aViewWidth / Precision::Confusion();
   }
-  else if (aViewWidth > coef * 1e12)
+  else if (aViewWidth > aCoef * 1e12)
   {
-    coef = aViewWidth / 1e12;
+    aCoef = aViewWidth / 1e12;
   }
-  if (aViewHeight < coef * Precision::Confusion())
+  if (aViewHeight < aCoef * Precision::Confusion())
   {
-    coef = aViewHeight / Precision::Confusion();
+    aCoef = aViewHeight / Precision::Confusion();
   }
-  else if (aViewHeight > coef * 1e12)
+  else if (aViewHeight > aCoef * 1e12)
   {
-    coef = aViewHeight / 1e12;
+    aCoef = aViewHeight / 1e12;
   }
 
   aCamera->SetEye (myCamStartOpEye);
   aCamera->SetCenter (myCamStartOpCenter);
-  aCamera->SetScale (aCamera->Scale() / Coef);
+  aCamera->SetScale (aCamera->Scale() / aCoef);
 
   AutoZFit();
 
@@ -1490,7 +1388,7 @@ void V3d_View::SetRatio()
 //function : FitAll
 //purpose  :
 //=============================================================================
-void V3d_View::FitAll (const Quantity_Coefficient theMargin, const Standard_Boolean theToUpdate)
+void V3d_View::FitAll (const Standard_Real theMargin, const Standard_Boolean theToUpdate)
 {
   FitAll (myView->MinMaxValues(), theMargin, theToUpdate);
 }
@@ -1499,7 +1397,7 @@ void V3d_View::FitAll (const Quantity_Coefficient theMargin, const Standard_Bool
 //function : FitAll
 //purpose  :
 //=============================================================================
-void V3d_View::FitAll (const Bnd_Box& theBox, const Quantity_Coefficient theMargin, const Standard_Boolean theToUpdate)
+void V3d_View::FitAll (const Bnd_Box& theBox, const Standard_Real theMargin, const Standard_Boolean theToUpdate)
 {
   Standard_ASSERT_RAISE(theMargin >= 0.0 && theMargin < 1.0, "Invalid margin coefficient");
 
@@ -1525,8 +1423,8 @@ void V3d_View::FitAll (const Bnd_Box& theBox, const Quantity_Coefficient theMarg
 //function : DepthFitAll
 //purpose  :
 //=============================================================================
-void V3d_View::DepthFitAll(const Quantity_Coefficient Aspect,
-                           const Quantity_Coefficient Margin)
+void V3d_View::DepthFitAll(const Standard_Real Aspect,
+                           const Standard_Real Margin)
 {
   Standard_Real Xmin,Ymin,Zmin,Xmax,Ymax,Zmax,U,V,W,U1,V1,W1 ;
   Standard_Real Umin,Vmin,Wmin,Umax,Vmax,Wmax ;
@@ -1592,30 +1490,6 @@ void V3d_View::DepthFitAll(const Quantity_Coefficient Aspect,
     ImmediateUpdate();
 }
 
-//=============================================================================
-//function : FitAll
-//purpose  :
-//=============================================================================
-void V3d_View::FitAll(const Standard_Real theMinXv,
-                      const Standard_Real theMinYv,
-                      const Standard_Real theMaxXv,
-                      const Standard_Real theMaxYv)
-{
-  FitAll (MyWindow, theMinXv, theMinYv, theMaxXv, theMaxYv);
-}
-
-//=============================================================================
-//function : WindowFitAll
-//purpose  :
-//=============================================================================
-void V3d_View::WindowFitAll(const Standard_Integer Xmin,
-                            const Standard_Integer Ymin,
-                            const Standard_Integer Xmax,
-                            const Standard_Integer Ymax)
-{
-  WindowFit(Xmin,Ymin,Xmax,Ymax);
-}
-
 //=======================================================================
 //function : WindowFit
 //purpose  :
@@ -1828,45 +1702,38 @@ void V3d_View::Convert(const Standard_Integer Xp,
 //function : ConvertWithProj
 //purpose  :
 //=======================================================================
-void V3d_View::ConvertWithProj(const Standard_Integer Xp,
-                               const Standard_Integer Yp,
-                               Standard_Real& X,
-                               Standard_Real& Y,
-                               Standard_Real& Z,
-                               Standard_Real& Dx,
-                               Standard_Real& Dy,
-                               Standard_Real& Dz) const
+void V3d_View::ConvertWithProj(const Standard_Integer theXp,
+                               const Standard_Integer theYp,
+                               Standard_Real& theX,
+                               Standard_Real& theY,
+                               Standard_Real& theZ,
+                               Standard_Real& theDx,
+                               Standard_Real& theDy,
+                               Standard_Real& theDz) const
 {
   V3d_UnMapped_Raise_if (!myView->IsDefined(), "view has no window");
-  Standard_Integer aHeight, aWidth;
+  Standard_Integer aHeight = 0, aWidth = 0;
   MyWindow->Size (aWidth, aHeight);
 
-  Standard_Real anX = 2.0 * Xp / aWidth - 1.0;
-  Standard_Real anY = 2.0 * (aHeight - 1 - Yp) / aHeight - 1.0;
-  Standard_Real  aZ = 2.0 * 0.0 - 1.0;
+  const Standard_Real anX = 2.0 * theXp / aWidth - 1.0;
+  const Standard_Real anY = 2.0 * (aHeight - 1 - theYp) / aHeight - 1.0;
+  const Standard_Real  aZ = 2.0 * 0.0 - 1.0;
 
-  Handle(Graphic3d_Camera) aCamera = Camera();
-
-  gp_Pnt aResult = aCamera->UnProject (gp_Pnt (anX, anY, aZ));
+  const Handle(Graphic3d_Camera)& aCamera = Camera();
+  const gp_Pnt aResult1 = aCamera->UnProject (gp_Pnt (anX, anY, aZ));
+  const gp_Pnt aResult2 = aCamera->UnProject (gp_Pnt (anX, anY, aZ - 10.0));
 
-  X = aResult.X();
-  Y = aResult.Y();
-  Z = aResult.Z();
-
-  Graphic3d_Vertex aVrp;
-  aVrp.SetCoord (X, Y, Z);
-
-  aResult = aCamera->UnProject (gp_Pnt (anX, anY, aZ - 10.0));
-
-  Graphic3d_Vec3d aNormDir;
-  aNormDir.x() = X - aResult.X();
-  aNormDir.y() = Y - aResult.Y();
-  aNormDir.z() = Z - aResult.Z();
+  theX = aResult1.X();
+  theY = aResult1.Y();
+  theZ = aResult1.Z();
+  Graphic3d_Vec3d aNormDir (theX - aResult2.X(),
+                            theY - aResult2.Y(),
+                            theZ - aResult2.Z());
   aNormDir.Normalize();
 
-  Dx = aNormDir.x();
-  Dy = aNormDir.y();
-  Dz = aNormDir.z();
+  theDx = aNormDir.x();
+  theDy = aNormDir.y();
+  theDz = aNormDir.z();
 }
 
 //=======================================================================
@@ -2119,7 +1986,7 @@ void V3d_View::Gravity (Standard_Real& theX,
       continue;
     }
 
-    const Graphic3d_BndBox4f& aBox = aStruct->CStructure()->BoundingBox();
+    const Graphic3d_BndBox3d& aBox = aStruct->CStructure()->BoundingBox();
     if (!aBox.IsValid())
     {
       continue;
@@ -2132,12 +1999,12 @@ void V3d_View::Gravity (Standard_Real& theX,
     }
 
     // use camera projection to find gravity point
-    Xmin = (Standard_Real )aBox.CornerMin().x();
-    Ymin = (Standard_Real )aBox.CornerMin().y();
-    Zmin = (Standard_Real )aBox.CornerMin().z();
-    Xmax = (Standard_Real )aBox.CornerMax().x();
-    Ymax = (Standard_Real )aBox.CornerMax().y();
-    Zmax = (Standard_Real )aBox.CornerMax().z();
+    Xmin = aBox.CornerMin().x();
+    Ymin = aBox.CornerMin().y();
+    Zmin = aBox.CornerMin().z();
+    Xmax = aBox.CornerMax().x();
+    Ymax = aBox.CornerMax().y();
+    Zmax = aBox.CornerMax().z();
     gp_Pnt aPnts[THE_NB_BOUND_POINTS] =
     {
       gp_Pnt (Xmin, Ymin, Zmin), gp_Pnt (Xmin, Ymin, Zmax),
@@ -2205,15 +2072,6 @@ void V3d_View::Eye(Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const
   Z = aCameraEye.Z();
 }
 
-//=============================================================================
-//function : FocalReferencePoint
-//purpose  :
-//=============================================================================
-void V3d_View::FocalReferencePoint(Standard_Real& X, Standard_Real& Y,Standard_Real& Z) const
-{
-  Eye (X,Y,Z);
-}
-
 //=============================================================================
 //function : ProjReferenceAxe
 //purpose  :
@@ -2294,54 +2152,44 @@ void V3d_View::Up(Standard_Real& Vx, Standard_Real& Vy, Standard_Real& Vz) const
 //=============================================================================
 Standard_Real V3d_View::Twist() const
 {
-  Standard_Real Xup,Yup,Zup,Xpn,Ypn,Zpn,X0,Y0,Z0 ;
-  Standard_Real pvx,pvy,pvz,pvn,sca,angle ;
-  Graphic3d_Vector Xaxis,Yaxis,Zaxis ;
-  Standard_Boolean TheStatus ;
+  gp_Vec Xaxis, Yaxis, Zaxis;
+  const gp_Dir aReferencePlane (Camera()->Direction().Reversed());
+  if (!screenAxis (aReferencePlane, gp::DZ(), Xaxis, Yaxis, Zaxis)
+   && !screenAxis (aReferencePlane, gp::DY(), Xaxis, Yaxis, Zaxis)
+   && !screenAxis (aReferencePlane, gp::DX(), Xaxis, Yaxis, Zaxis))
+  {
+    //
+  }
 
-  gp_Dir aReferencePlane (Camera()->Direction().Reversed());
-  gp_Dir anUp;
+  // Compute Cross Vector From Up & Origin
+  const gp_Dir aCameraUp = Camera()->Up();
+  const gp_XYZ aP = Yaxis.XYZ().Crossed (aCameraUp.XYZ());
 
-  Proj(Xpn,Ypn,Zpn);
-  anUp = gp_Dir (0.,0.,1.) ;
-  TheStatus = ScreenAxis (aReferencePlane, anUp,Xaxis,Yaxis,Zaxis) ;
-  if( !TheStatus ) {
-    anUp = gp_Dir (0.,1.,0.) ;
-    TheStatus = ScreenAxis (aReferencePlane, anUp,Xaxis,Yaxis,Zaxis) ;
-  }
-  if( !TheStatus ) {
-    anUp = gp_Dir (1.,0.,0.) ;
-    TheStatus = ScreenAxis (aReferencePlane, anUp,Xaxis,Yaxis,Zaxis) ;
+  // compute Angle
+  Standard_Real anAngle = ASin (Max (Min (aP.Modulus(), 1.0), -1.0));
+  if (Yaxis.Dot (aCameraUp.XYZ()) < 0.0)
+  {
+    anAngle = M_PI - anAngle;
   }
-  Yaxis.Coord(X0,Y0,Z0) ;
-
-  Up(Xup,Yup,Zup) ;
-  /* Compute Cross Vector From Up & Origin */
-  pvx = Y0*Zup - Z0*Yup ;
-  pvy = Z0*Xup - X0*Zup ;
-  pvz = X0*Yup - Y0*Xup ;
-  pvn = pvx*pvx + pvy*pvy + pvz*pvz ;
-  sca = X0*Xup + Y0*Yup + Z0*Zup ;
-  /* Compute Angle */
-  angle = Sqrt(pvn) ;
-  if( angle > 1. ) angle = 1. ;
-  else if( angle < -1. ) angle = -1. ;
-  angle = asin(angle) ;
-  if( sca < 0. ) angle = M_PI - angle ;
-  if( angle > 0. && angle < M_PI ) {
-    sca = pvx*Xpn + pvy*Ypn + pvz*Zpn ;
-    if( sca < 0. ) angle = DEUXPI - angle ;
+  if (anAngle > 0.0
+   && anAngle < M_PI)
+  {
+    const gp_Dir aProjDir = Camera()->Direction().Reversed();
+    if (aP.Dot (aProjDir.XYZ()) < 0.0)
+    {
+      anAngle = DEUXPI - anAngle;
+    }
   }
-  return angle ;
+  return anAngle;
 }
 
 //=============================================================================
 //function : ShadingModel
 //purpose  :
 //=============================================================================
-V3d_TypeOfShadingModel V3d_View::ShadingModel() const
+Graphic3d_TypeOfShadingModel V3d_View::ShadingModel() const
 {
-  return static_cast<V3d_TypeOfShadingModel> (myView->ShadingModel());
+  return myView->ShadingModel();
 }
 
 //=============================================================================
@@ -2362,15 +2210,6 @@ V3d_TypeOfVisualization V3d_View::Visualization() const
   return static_cast<V3d_TypeOfVisualization> (myView->VisualizationType());
 }
 
-//=============================================================================
-//function : Viewer
-//purpose  :
-//=============================================================================
-Handle(V3d_Viewer) V3d_View::Viewer() const
-{
-  return MyViewer;
-}
-
 //=============================================================================
 //function : IfWindow
 //purpose  :
@@ -2380,15 +2219,6 @@ Standard_Boolean V3d_View::IfWindow() const
   return myView->IsDefined();
 }
 
-//=============================================================================
-//function : Window
-//purpose  :
-//=============================================================================
-Handle(Aspect_Window) V3d_View::Window() const
-{
-  return MyWindow;
-}
-
 //=============================================================================
 //function : Type
 //purpose  :
@@ -2435,41 +2265,28 @@ Standard_Real V3d_View::Focale() const
 }
 
 //=============================================================================
-//function : View
-//purpose  :
-//=============================================================================
-Handle(Graphic3d_CView) V3d_View::View() const
-{
-  return myView;
-}
-
-//=============================================================================
-//function : ScreenAxis
+//function : screenAxis
 //purpose  :
 //=============================================================================
-Standard_Boolean V3d_View::ScreenAxis( const gp_Dir &Vpn, const gp_Dir &Vup, Graphic3d_Vector &Xaxe, Graphic3d_Vector &Yaxe, Graphic3d_Vector &Zaxe)
+Standard_Boolean V3d_View::screenAxis (const gp_Dir& theVpn, const gp_Dir& theVup,
+                                       gp_Vec& theXaxe, gp_Vec& theYaxe, gp_Vec& theZaxe)
 {
-  Standard_Real Xpn, Ypn, Zpn, Xup, Yup, Zup;
-  Standard_Real dx1, dy1, dz1, xx, yy, zz;
+  theXaxe = theVup.XYZ().Crossed (theVpn.XYZ());
+  if (theXaxe.Magnitude() <= gp::Resolution())
+  {
+    return Standard_False;
+  }
+  theXaxe.Normalize();
 
-  Xpn = Vpn.X(); Ypn = Vpn.Y(); Zpn = Vpn.Z();
-  Xup = Vup.X(); Yup = Vup.Y(); Zup = Vup.Z();
-  xx = Yup*Zpn - Zup*Ypn;
-  yy = Zup*Xpn - Xup*Zpn;
-  zz = Xup*Ypn - Yup*Xpn;
-  Xaxe.SetCoord (xx, yy, zz);
-  if (Xaxe.LengthZero()) return Standard_False;
-  Xaxe.Normalize(); 
-  Xaxe.Coord(dx1, dy1, dz1);
-  xx = Ypn*dz1 - Zpn*dy1;
-  yy = Zpn*dx1 - Xpn*dz1;
-  zz = Xpn*dy1 - Ypn*dx1;
-  Yaxe.SetCoord (xx, yy, zz) ;
-  if (Yaxe.LengthZero()) return Standard_False;
-  Yaxe.Normalize(); 
+  theYaxe = theVpn.XYZ().Crossed (theXaxe.XYZ());
+  if (theYaxe.Magnitude() <= gp::Resolution())
+  {
+    return Standard_False;
+  }
+  theYaxe.Normalize();
 
-  Zaxe.SetCoord (Xpn, Ypn, Zpn);
-  Zaxe.Normalize();
+  theZaxe = theVpn.XYZ();
+  theZaxe.Normalize();
   return Standard_True;
 }
 
@@ -2477,33 +2294,24 @@ Standard_Boolean V3d_View::ScreenAxis( const gp_Dir &Vpn, const gp_Dir &Vup, Gra
 //function : TrsPoint
 //purpose  :
 //=============================================================================
-Graphic3d_Vertex V3d_View::TrsPoint( const Graphic3d_Vertex &P, const TColStd_Array2OfReal &Matrix )
+gp_XYZ V3d_View::TrsPoint (const Graphic3d_Vertex& thePnt, const TColStd_Array2OfReal& theMat)
 {
-  Graphic3d_Vertex PP ;
-  Standard_Real X,Y,Z,XX,YY,ZZ ;
-
   // CAL. S3892
-  Standard_Integer lr, ur, lc, uc;
-  lr    = Matrix.LowerRow ();
-  ur    = Matrix.UpperRow ();
-  lc    = Matrix.LowerCol ();
-  uc    = Matrix.UpperCol ();
-  if ((ur - lr + 1 != 4) || (uc - lc + 1 != 4) ) {
-    P.Coord(X,Y,Z) ;
-    PP.SetCoord(X,Y,Z) ;
-    return PP ;
+  const Standard_Integer lr = theMat.LowerRow();
+  const Standard_Integer ur = theMat.UpperRow();
+  const Standard_Integer lc = theMat.LowerCol();
+  const Standard_Integer uc = theMat.UpperCol();
+  if ((ur - lr + 1 != 4) || (uc - lc + 1 != 4))
+  {
+    return gp_XYZ (thePnt.X(), thePnt.Y(), thePnt.Z());
   }
-  P.Coord(X,Y,Z) ;
-  XX = (Matrix(lr,lc+3) + X*Matrix(lr,lc) + Y*Matrix(lr,lc+1)+
-    Z*Matrix(lr,lc+2))/Matrix(lr+3,lc+3) ;
 
-  YY = (Matrix(lr+1,lc+3) + X*Matrix(lr+1,lc) + Y*Matrix(lr+1,lc+1) +
-    Z*Matrix(lr+1,lc+2))/Matrix(lr+3,lc+3) ;
-
-  ZZ = (Matrix(lr+2,lc+3) + X*Matrix(lr+2,lc) + Y*Matrix(lr+2,lc+1) +
-    Z*Matrix(lr+2,lc+2))/Matrix(lr+3,lc+3) ;
-  PP.SetCoord(XX,YY,ZZ) ;
-  return PP ;
+  Standard_Real X, Y, Z;
+  thePnt.Coord (X,Y,Z);
+  const Standard_Real XX = (theMat(lr,lc+3)   + X*theMat(lr,lc)   + Y*theMat(lr,lc+1)   + Z*theMat(lr,lc+2)) / theMat(lr+3,lc+3);
+  const Standard_Real YY = (theMat(lr+1,lc+3) + X*theMat(lr+1,lc) + Y*theMat(lr+1,lc+1) + Z*theMat(lr+1,lc+2))/theMat(lr+3,lc+3);
+  const Standard_Real ZZ = (theMat(lr+2,lc+3) + X*theMat(lr+2,lc) + Y*theMat(lr+2,lc+1) + Z*theMat(lr+2,lc+2))/theMat(lr+3,lc+3);
+  return gp_XYZ (XX, YY, ZZ);
 }
 
 //=======================================================================
@@ -2512,7 +2320,7 @@ Graphic3d_Vertex V3d_View::TrsPoint( const Graphic3d_Vertex &P, const TColStd_Ar
 //=======================================================================
 void V3d_View::Pan (const Standard_Integer theDXp,
                     const Standard_Integer theDYp,
-                    const Quantity_Factor  theZoomFactor,
+                    const Standard_Real    theZoomFactor,
                     const Standard_Boolean theToStart)
 {
   Panning (Convert (theDXp), Convert (theDYp), theZoomFactor, theToStart);
@@ -2524,7 +2332,7 @@ void V3d_View::Pan (const Standard_Integer theDXp,
 //=======================================================================
 void V3d_View::Panning (const Standard_Real theDXv,
                         const Standard_Real theDYv,
-                        const Quantity_Factor theZoomFactor,
+                        const Standard_Real theZoomFactor,
                         const Standard_Boolean theToStart)
 {
   Standard_ASSERT_RAISE (theZoomFactor > 0.0, "Bad zoom factor");
@@ -2627,8 +2435,8 @@ void V3d_View::ZoomAtPoint (const Standard_Integer theMouseStartX,
   Standard_Real aZoomAtPointYv = 0.0;
   Convert (MyZoomAtPointX, MyZoomAtPointY, aZoomAtPointXv, aZoomAtPointYv);
 
-  V3d_Coordinate aDxv = aZoomAtPointXv / aCoef;
-  V3d_Coordinate aDyv = aZoomAtPointYv / aCoef;
+  Standard_Real aDxv = aZoomAtPointXv / aCoef;
+  Standard_Real aDyv = aZoomAtPointYv / aCoef;
 
   aCamera->SetScale (aCamera->Scale() / aCoef);
   Translate (aCamera, aZoomAtPointXv - aDxv, aZoomAtPointYv - aDyv);
@@ -2664,32 +2472,27 @@ void V3d_View::AxialScale (const Standard_Integer Dx,
 //function : FitAll
 //purpose  :
 //=============================================================================
-void V3d_View::FitAll(const Handle(Aspect_Window)& aWindow,
-                      const Standard_Real Xmin,
-                      const Standard_Real Ymin,
-                      const Standard_Real Xmax,
-                      const Standard_Real Ymax)
+void V3d_View::FitAll(const Standard_Real theXmin,
+                      const Standard_Real theYmin,
+                      const Standard_Real theXmax,
+                      const Standard_Real theYmax)
 {
-  Standard_Integer aWinWidth, aWinHeight;
-  aWindow->Size (aWinWidth, aWinHeight);
+  Handle(Graphic3d_Camera) aCamera = Camera();
+  Standard_Real anAspect = aCamera->Aspect();
 
-  Standard_Real aWinAspect = (Standard_Real)aWinWidth / aWinHeight;
-  Standard_Real aFitSizeU  = Abs (Xmax - Xmin);
-  Standard_Real aFitSizeV  = Abs (Ymax - Ymin);
+  Standard_Real aFitSizeU  = Abs (theXmax - theXmin);
+  Standard_Real aFitSizeV  = Abs (theYmax - theYmin);
   Standard_Real aFitAspect = aFitSizeU / aFitSizeV;
-  if (aFitAspect >= aWinAspect)
+  if (aFitAspect >= anAspect)
   {
-    aFitSizeV = aFitSizeU / aWinAspect;
+    aFitSizeV = aFitSizeU / anAspect;
   }
   else
   {
-    aFitSizeU = aFitSizeV * aWinAspect;
+    aFitSizeU = aFitSizeV * anAspect;
   }
 
-  Handle(Graphic3d_Camera) aCamera = Camera();
-
-  aCamera->SetAspect (aWinAspect);
-  Translate (aCamera, (Xmin + Xmax) * 0.5, (Ymin + Ymax) * 0.5);
+  Translate (aCamera, (theXmin + theXmax) * 0.5, (theYmin + theYmax) * 0.5);
   Scale (aCamera, aFitSizeU, aFitSizeV);
 
   AutoZFit();
@@ -2703,7 +2506,7 @@ void V3d_View::FitAll(const Handle(Aspect_Window)& aWindow,
 //=============================================================================
 void V3d_View::StartRotation(const Standard_Integer X,
                              const Standard_Integer Y,
-                             const Quantity_Ratio zRotationThreshold)
+                             const Standard_Real zRotationThreshold)
 {
   sx = X; sy = Y;
   Standard_Real x,y;
@@ -2757,13 +2560,11 @@ void V3d_View::SetComputedMode (const Standard_Boolean theMode)
     if (myComputedMode)
     {
       myView->SetComputedMode (Standard_True);
-      Update();
     }
   }
   else
   {
     myView->SetComputedMode (Standard_False);
-    Update();
   }
 }
 
@@ -2808,17 +2609,6 @@ void V3d_View::Init()
   }
 }
 
-//=============================================================================
-//function : Export
-//purpose  :
-//=============================================================================
-Standard_Boolean V3d_View::Export (const Standard_CString theFileName,
-                                   const Graphic3d_ExportFormat theFormat,
-                                   const Graphic3d_SortType theSortType)
-{
-  return myView->Export (theFileName, theFormat, theSortType);
-}
-
 //=============================================================================
 //function : Dump
 //purpose  :
@@ -2849,13 +2639,13 @@ Standard_Boolean V3d_View::ToPixMap (Image_PixMap&               theImage,
      || theImage.SizeX() != Standard_Size(aTargetSize.x())
      || theImage.SizeY() != Standard_Size(aTargetSize.y()))
     {
-      const bool isBigEndian = Image_PixMap::IsBigEndianHost();
-      Image_PixMap::ImgFormat aFormat = Image_PixMap::ImgUNKNOWN;
+      Image_Format aFormat = Image_Format_UNKNOWN;
       switch (theParams.BufferType)
       {
-        case Graphic3d_BT_RGB:   aFormat = isBigEndian ? Image_PixMap::ImgRGB  : Image_PixMap::ImgBGR;  break;
-        case Graphic3d_BT_RGBA:  aFormat = isBigEndian ? Image_PixMap::ImgRGBA : Image_PixMap::ImgBGRA; break;
-        case Graphic3d_BT_Depth: aFormat = Image_PixMap::ImgGrayF; break;
+        case Graphic3d_BT_RGB:                 aFormat = Image_Format_RGB;   break;
+        case Graphic3d_BT_RGBA:                aFormat = Image_Format_RGBA;  break;
+        case Graphic3d_BT_Depth:               aFormat = Image_Format_GrayF; break;
+        case Graphic3d_BT_RGB_RayTraceHdrLeft: aFormat = Image_Format_RGBF;  break;
       }
 
       if (!theImage.InitZero (aFormat, Standard_Size(aTargetSize.x()), Standard_Size(aTargetSize.y())))
@@ -2906,19 +2696,27 @@ Standard_Boolean V3d_View::ToPixMap (Image_PixMap&               theImage,
 
   if (aFBOPtr.IsNull())
   {
-    Standard_Integer aMaxTexSize = MyViewer->Driver()->InquireLimit (Graphic3d_TypeOfLimit_MaxTextureSize);
-    if (theParams.TileSize > aMaxTexSize)
+    Standard_Integer aMaxTexSizeX = MyViewer->Driver()->InquireLimit (Graphic3d_TypeOfLimit_MaxViewDumpSizeX);
+    Standard_Integer aMaxTexSizeY = MyViewer->Driver()->InquireLimit (Graphic3d_TypeOfLimit_MaxViewDumpSizeY);
+    if (theParams.TileSize > aMaxTexSizeX
+     || theParams.TileSize > aMaxTexSizeY)
     {
       Message::DefaultMessenger()->Send (TCollection_AsciiString ("Image dump can not be performed - specified tile size (")
-                                                                 + theParams.TileSize + ") exceeds hardware limits (" + aMaxTexSize + ")", Message_Fail);
+                                                                 + theParams.TileSize + ") exceeds hardware limits (" + aMaxTexSizeX + "x" + aMaxTexSizeY + ")", Message_Fail);
       return Standard_False;
     }
 
-    if (aFBOVPSize.x() > aMaxTexSize
-     || aFBOVPSize.y() > aMaxTexSize)
+    if (aFBOVPSize.x() > aMaxTexSizeX
+     || aFBOVPSize.y() > aMaxTexSizeY)
     {
-      aFBOVPSize.x() = Min (aFBOVPSize.x(), aMaxTexSize);
-      aFBOVPSize.y() = Min (aFBOVPSize.y(), aMaxTexSize);
+      if (MyViewer->Driver()->InquireLimit (Graphic3d_TypeOfLimit_IsWorkaroundFBO))
+      {
+        Message::DefaultMessenger ()->Send (TCollection_AsciiString ("Warning, workaround for Intel driver problem with empty FBO for images with big width is applyed."), Message_Warning);
+      }
+      Message::DefaultMessenger()->Send (TCollection_AsciiString ("Info, tiling image dump is used, image size (")
+                                                                 + aFBOVPSize.x() + "x" + aFBOVPSize.y() + ") exceeds hardware limits (" + aMaxTexSizeX + "x" + aMaxTexSizeY + ")", Message_Info);
+      aFBOVPSize.x() = Min (aFBOVPSize.x(), aMaxTexSizeX);
+      aFBOVPSize.y() = Min (aFBOVPSize.y(), aMaxTexSizeY);
       isTiling = true;
     }
 
@@ -3001,16 +2799,11 @@ Standard_Boolean V3d_View::ToPixMap (Image_PixMap&               theImage,
       anOffset.x() = 0;
       for (; anOffset.x() < aTargetSize.x(); anOffset.x() += aFBOVPSize.x())
       {
-        Graphic3d_CameraTile aTile;
-        aTile.Offset    = anOffset;
-        aTile.TotalSize = aTargetSize;
-        aTile.TileSize  = aFBOVPSize;
-        if (!aFBOPtr.IsNull())
-        {
-          // crop corners in case of FBO
-          // (no API to resize viewport of on-screen buffer - keep uncropped in this case)
-          aTile = aTile.Cropped();
-        }
+        Graphic3d_CameraTile aTileUncropped;
+        aTileUncropped.Offset    = anOffset;
+        aTileUncropped.TotalSize = aTargetSize;
+        aTileUncropped.TileSize  = aFBOVPSize;
+        const Graphic3d_CameraTile aTile = aTileUncropped.Cropped();
         if (aTile.TileSize.x() < 1
          || aTile.TileSize.y() < 1)
         {
@@ -3029,11 +2822,16 @@ Standard_Boolean V3d_View::ToPixMap (Image_PixMap&               theImage,
                                  aTile.TileSize.x(), aTile.TileSize.y(),
                                  theImage.SizeRowBytes());
 
-        aCamera->SetTile (aTile);
         if (!aFBOPtr.IsNull())
         {
+          aCamera->SetTile (aTile);
           myView->FBOChangeViewport (aFBOPtr, aTile.TileSize.x(), aTile.TileSize.y());
         }
+        else
+        {
+          // no API to resize viewport of on-screen buffer - render uncropped
+          aCamera->SetTile (aTileUncropped);
+        }
         Redraw();
         isSuccess = isSuccess && myView->BufferDump (aTilePixMap, theParams.BufferType);
         if (!isSuccess)
@@ -3314,29 +3112,47 @@ void V3d_View::Translate (const Handle(Graphic3d_Camera)& theCamera,
 }
 
 // =======================================================================
-// function : IsCullingEnabled
+// function : DiagnosticInformation
 // purpose  :
 // =======================================================================
-Standard_Boolean V3d_View::IsCullingEnabled() const
+void V3d_View::DiagnosticInformation (TColStd_IndexedDataMapOfStringString& theDict,
+                                      Graphic3d_DiagnosticInfo theFlags) const
 {
-  return myView->IsCullingEnabled();
+  myView->DiagnosticInformation (theDict, theFlags);
 }
 
-// =======================================================================
-// function : SetFrustumCulling
-// purpose  :
-// =======================================================================
-void V3d_View::SetFrustumCulling (const Standard_Boolean theToClip)
+//=======================================================================
+//function : StatisticInformation
+//purpose  :
+//=======================================================================
+void V3d_View::StatisticInformation (TColStd_IndexedDataMapOfStringString& theDict) const
 {
-  myView->SetCullingEnabled (theToClip);
+  myView->StatisticInformation (theDict);
 }
 
 // =======================================================================
-// function : DiagnosticInformation
+// function : StatisticInformation
 // purpose  :
 // =======================================================================
-void V3d_View::DiagnosticInformation (TColStd_IndexedDataMapOfStringString& theDict,
-                                      Graphic3d_DiagnosticInfo theFlags) const
+TCollection_AsciiString V3d_View::StatisticInformation() const
 {
-  myView->DiagnosticInformation (theDict, theFlags);
+  return myView->StatisticInformation();
+}
+
+//=============================================================================
+//function : RenderingParams
+//purpose  :
+//=============================================================================
+const Graphic3d_RenderingParams& V3d_View::RenderingParams() const
+{
+  return myView->RenderingParams();
+}
+
+//=============================================================================
+//function : ChangeRenderingParams
+//purpose  :
+//=============================================================================
+Graphic3d_RenderingParams& V3d_View::ChangeRenderingParams()
+{
+  return myView->ChangeRenderingParams();
 }