0028306: Visualization - viewer crashes if style for shaded display is set to HATCH
[occt.git] / src / ViewerTest / ViewerTest.cxx
index e8d03fd..bdb5c6f 100644 (file)
@@ -25,7 +25,9 @@
 #include <Standard_Stream.hxx>
 
 #include <ViewerTest.hxx>
+#include <ViewerTest_CmdParser.hxx>
 
+#include <Draw.hxx>
 #include <TopLoc_Location.hxx>
 #include <TopTools_HArray1OfShape.hxx>
 #include <TColStd_HArray1OfTransient.hxx>
@@ -62,6 +64,7 @@
 #include <Prs3d_IsoAspect.hxx>
 #include <Prs3d_PointAspect.hxx>
 #include <Select3D_SensitiveWire.hxx>
+#include <Select3D_SensitivePrimitiveArray.hxx>
 #include <SelectMgr_EntityOwner.hxx>
 #include <StdSelect_BRepOwner.hxx>
 #include <StdSelect_ViewerSelector3d.hxx>
 #include <TCollection_AsciiString.hxx>
 #include <Draw_PluginMacro.hxx>
 
-// avoid warnings on 'extern "C"' functions returning C++ classes
-#ifdef WNT
-#define _CRT_SECURE_NO_DEPRECATE
-#pragma warning(4:4190)
-#pragma warning (disable:4996)
-#endif
-
-#include <NIS_InteractiveContext.hxx>
-#include <NIS_Triangulated.hxx>
 extern int ViewerMainLoop(Standard_Integer argc, const char** argv);
 
 #include <Quantity_Color.hxx>
@@ -156,6 +150,87 @@ Standard_Integer ViewerTest::ParseColor (Standard_Integer  theArgNb,
   return 0;
 }
 
+//=======================================================================
+//function : ParseOnOff
+//purpose  :
+//=======================================================================
+Standard_Boolean ViewerTest::ParseOnOff (Standard_CString  theArg,
+                                         Standard_Boolean& theIsOn)
+{
+  TCollection_AsciiString aFlag(theArg);
+  aFlag.LowerCase();
+  if (aFlag == "on"
+   || aFlag == "1")
+  {
+    theIsOn = Standard_True;
+    return Standard_True;
+  }
+  else if (aFlag == "off"
+        || aFlag == "0")
+  {
+    theIsOn = Standard_False;
+    return Standard_True;
+  }
+  return Standard_False;
+}
+
+//=======================================================================
+//function : GetSelectedShapes
+//purpose  :
+//=======================================================================
+void ViewerTest::GetSelectedShapes (TopTools_ListOfShape& theSelectedShapes)
+{
+  for (GetAISContext()->InitSelected(); GetAISContext()->MoreSelected(); GetAISContext()->NextSelected())
+  {
+    TopoDS_Shape aShape = GetAISContext()->SelectedShape();
+    if (!aShape.IsNull())
+    {
+      theSelectedShapes.Append (aShape);
+    }
+  }
+}
+
+//=======================================================================
+//function : ParseLineType
+//purpose  :
+//=======================================================================
+Standard_Boolean ViewerTest::ParseLineType (Standard_CString   theArg,
+                                            Aspect_TypeOfLine& theType)
+{
+  TCollection_AsciiString aTypeStr (theArg);
+  aTypeStr.LowerCase();
+  if (aTypeStr == "empty")
+  {
+    theType = Aspect_TOL_EMPTY;
+  }
+  else if (aTypeStr == "solid")
+  {
+    theType = Aspect_TOL_SOLID;
+  }
+  else if (aTypeStr == "dot")
+  {
+    theType = Aspect_TOL_DOT;
+  }
+  else if (aTypeStr == "dash")
+  {
+    theType = Aspect_TOL_DASH;
+  }
+  else if (aTypeStr == "dotdash")
+  {
+    theType = Aspect_TOL_DOTDASH;
+  }
+  else
+  {
+    const int aTypeInt = Draw::Atoi (theArg);
+    if (aTypeInt < -1 || aTypeInt >= Aspect_TOL_USERDEFINED)
+    {
+      return Standard_False;
+    }
+    theType = (Aspect_TypeOfLine )aTypeInt;
+  }
+  return Standard_True;
+}
+
 //=======================================================================
 //function : GetTypeNames
 //purpose  :
@@ -257,24 +332,20 @@ Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS(){
   return TheMap;
 }
 
-
-//==============================================================================
-//function : VDisplayAISObject
-//purpose  : register interactive object in the map of AIS objects;
-//           if other object with such name already registered, it will be kept
-//           or replaced depending on value of <theReplaceIfExists>,
-//           if "true" - the old object will be cleared from AIS context;
-//           returns Standard_True if <theAISObj> registered in map;
-//==============================================================================
-Standard_EXPORT Standard_Boolean VDisplayAISObject (const TCollection_AsciiString& theName,
-                                                    const Handle(AIS_InteractiveObject)& theAISObj,
-                                                    Standard_Boolean theReplaceIfExists = Standard_True)
+//=======================================================================
+//function : Display
+//purpose  :
+//=======================================================================
+Standard_Boolean ViewerTest::Display (const TCollection_AsciiString&       theName,
+                                      const Handle(AIS_InteractiveObject)& theObject,
+                                      const Standard_Boolean               theToUpdate,
+                                      const Standard_Boolean               theReplaceIfExists)
 {
   ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
-  Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
-  if (aContextAIS.IsNull())
+  Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
+  if (aCtx.IsNull())
   {
-    std::cout << "AIS context is not available.\n";
+    std::cout << "Error: AIS context is not available.\n";
     return Standard_False;
   }
 
@@ -282,42 +353,46 @@ Standard_EXPORT Standard_Boolean VDisplayAISObject (const TCollection_AsciiStrin
   {
     if (!theReplaceIfExists)
     {
-      std::cout << "Other interactive object has been already "
-                << "registered with name: " << theName << ".\n"
+      std::cout << "Error: other interactive object has been already registered with name: " << theName << ".\n"
                 << "Please use another name.\n";
       return Standard_False;
     }
 
-    // stop displaying object
-    Handle(AIS_InteractiveObject) anOldObj =
-       Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (theName));
-
+    Handle(AIS_InteractiveObject) anOldObj = Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (theName));
     if (!anOldObj.IsNull())
-      aContextAIS->Remove (anOldObj, Standard_True);
-
-    // remove name and old object from map
+    {
+      aCtx->Remove (anOldObj, theObject.IsNull() && theToUpdate);
+    }
     aMap.UnBind2 (theName);
   }
 
-  if (theAISObj.IsNull())
+  if (theObject.IsNull())
   {
-    // object with specified name already unbound
+    // object with specified name has been already unbound
     return Standard_True;
   }
 
-  // unbind AIS object if was bound with another name
-  aMap.UnBind1 (theAISObj);
+  // unbind AIS object if it was bound with another name
+  aMap.UnBind1 (theObject);
 
   // can be registered without rebinding
-  aMap.Bind (theAISObj, theName);
-  aContextAIS->Display (theAISObj, Standard_True);
+  aMap.Bind (theObject, theName);
+  aCtx->Display (theObject, theToUpdate);
   return Standard_True;
 }
 
+//! Alias for ViewerTest::Display(), compatibility with old code.
+Standard_EXPORT Standard_Boolean VDisplayAISObject (const TCollection_AsciiString&       theName,
+                                                    const Handle(AIS_InteractiveObject)& theObject,
+                                                    Standard_Boolean theReplaceIfExists = Standard_True)
+{
+  return ViewerTest::Display (theName, theObject, Standard_True, theReplaceIfExists);
+}
+
 static TColStd_MapOfInteger theactivatedmodes(8);
 static TColStd_ListOfTransient theEventMgrs;
 
-static void VwrTst_InitEventMgr(const Handle(NIS_View)& aView,
+static void VwrTst_InitEventMgr(const Handle(V3d_View)& aView,
                                 const Handle(AIS_InteractiveContext)& Ctx)
 {
   theEventMgrs.Clear();
@@ -345,16 +420,6 @@ void ViewerTest::CurrentView(const Handle(V3d_View)& V)
   a3DView() = V;
 }
 
-Standard_EXPORT const Handle(NIS_InteractiveContext)& TheNISContext()
-{
-  static Handle(NIS_InteractiveContext) aContext;
-  if (aContext.IsNull()) {
-    aContext = new NIS_InteractiveContext;
-    aContext->SetSelectionMode (NIS_InteractiveContext::Mode_Normal);
-  }
-  return aContext;
-}
-
 const Handle(AIS_InteractiveContext)& ViewerTest::GetAISContext()
 {
   return TheAISContext();
@@ -389,8 +454,7 @@ void ViewerTest::UnsetEventManager()
 
 void ViewerTest::ResetEventManager()
 {
-  const Handle(NIS_View) aView =
-    Handle(NIS_View)::DownCast(ViewerTest::CurrentView());
+  const Handle(V3d_View) aView = ViewerTest::CurrentView();
   VwrTst_InitEventMgr(aView, ViewerTest::GetAISContext());
 }
 
@@ -399,7 +463,7 @@ Handle(ViewerTest_EventManager) ViewerTest::CurrentEventManager()
   Handle(ViewerTest_EventManager) EM;
   if(theEventMgrs.IsEmpty()) return EM;
   Handle(Standard_Transient) Tr =  theEventMgrs.First();
-  EM = *((Handle(ViewerTest_EventManager)*)&Tr);
+  EM = Handle(ViewerTest_EventManager)::DownCast (Tr);
   return EM;
 }
 
@@ -452,7 +516,7 @@ Handle(AIS_Shape) GetAISShapeFromName(const char* name)
     if (!IO.IsNull()) {
       if(IO->Type()==AIS_KOI_Shape) {
         if(IO->Signature()==0){
-          retsh = *((Handle(AIS_Shape)*)&IO);
+          retsh = Handle(AIS_Shape)::DownCast (IO);
         }
         else
           cout << "an Object which is not an AIS_Shape "
@@ -478,25 +542,15 @@ Handle(AIS_Shape) GetAISShapeFromName(const char* name)
 void ViewerTest::Clear()
 {
   if ( !a3DView().IsNull() ) {
-    if (TheAISContext()->HasOpenedContext())
-      TheAISContext()->CloseLocalContext();
     ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it(GetMapOfAIS());
     while ( it.More() ) {
       cout << "Remove " << it.Key2() << endl;
-      if (it.Key1()->IsKind(STANDARD_TYPE(AIS_InteractiveObject))) {
-        const Handle(AIS_InteractiveObject) anObj =
-          Handle(AIS_InteractiveObject)::DownCast (it.Key1());
-        TheAISContext()->Remove(anObj,Standard_False);
-      } else if (it.Key1()->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
-        const Handle(NIS_InteractiveObject) anObj =
-          Handle(NIS_InteractiveObject)::DownCast (it.Key1());
-        TheNISContext()->Remove(anObj);
-      }
+      const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (it.Key1());
+      TheAISContext()->Remove(anObj,Standard_False);
       it.Next();
     }
     TheAISContext()->RebuildSelectionStructs();
     TheAISContext()->UpdateCurrentViewer();
-//    TheNISContext()->UpdateViews();
     GetMapOfAIS().Clear();
   }
 }
@@ -506,28 +560,33 @@ void ViewerTest::Clear()
 //purpose  : Activate a selection mode, vertex, edge, wire ..., in a local
 //           Context
 //==============================================================================
+Standard_DISABLE_DEPRECATION_WARNINGS
 void ViewerTest::StandardModeActivation(const Standard_Integer mode )
 {
   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
   if(mode==0) {
     if (TheAISContext()->HasOpenedContext())
+    {
       aContext->CloseLocalContext();
+    }
   } else {
 
     if(!aContext->HasOpenedContext()) {
       // To unhilight the preselected object
-      aContext->UnhilightCurrents(Standard_False);
+      aContext->UnhilightSelected(Standard_False);
       // Open a local Context in order to be able to select subshape from
       // the selected shape if any or for all if there is no selection
-      if (!aContext->FirstCurrentObject().IsNull()){
-       aContext->OpenLocalContext(Standard_False);
+      if (!aContext->FirstSelectedObject().IsNull()){
+        aContext->OpenLocalContext(Standard_False);
 
-       for(aContext->InitCurrent();aContext->MoreCurrent();aContext->NextCurrent()){
-         aContext->Load(       aContext->Current(),-1,Standard_True);
+       for(aContext->InitSelected();aContext->MoreSelected();aContext->NextSelected()){
+         aContext->Load(       aContext->SelectedInteractive(),-1,Standard_True);
        }
       }
       else
-       aContext->OpenLocalContext();
+      {
+        aContext->OpenLocalContext();
+      }
     }
 
     const char *cmode="???";
@@ -545,19 +604,20 @@ void ViewerTest::StandardModeActivation(const Standard_Integer mode )
     }
 
     if(theactivatedmodes.Contains(mode))
-      { // Desactivate
-       aContext->DeactivateStandardMode(AIS_Shape::SelectionType(mode));
-       theactivatedmodes.Remove(mode);
-       cout<<"Mode "<< cmode <<" OFF"<<endl;
-      }
+    { // Desactivate
+      aContext->DeactivateStandardMode(AIS_Shape::SelectionType(mode));
+      theactivatedmodes.Remove(mode);
+      cout<<"Mode "<< cmode <<" OFF"<<endl;
+    }
     else
-      { // Activate
-       aContext->ActivateStandardMode(AIS_Shape::SelectionType(mode));
-       theactivatedmodes.Add(mode);
-       cout<<"Mode "<< cmode << " ON" << endl;
-      }
+    { // Activate
+      aContext->ActivateStandardMode(AIS_Shape::SelectionType(mode));
+      theactivatedmodes.Add(mode);
+      cout<<"Mode "<< cmode << " ON" << endl;
+    }
   }
 }
+Standard_ENABLE_DEPRECATION_WARNINGS
 
 //==============================================================================
 //function : CopyIsoAspect
@@ -567,11 +627,9 @@ static Handle(Prs3d_IsoAspect) CopyIsoAspect
       (const Handle(Prs3d_IsoAspect) &theIsoAspect,
        const Standard_Integer theNbIsos)
 {
-  Quantity_Color    aColor;
-  Aspect_TypeOfLine aType;
-  Standard_Real     aWidth;
-
-  theIsoAspect->Aspect()->Values(aColor, aType, aWidth);
+  Quantity_Color    aColor = theIsoAspect->Aspect()->Color();
+  Aspect_TypeOfLine aType  = theIsoAspect->Aspect()->Type();
+  Standard_Real     aWidth = theIsoAspect->Aspect()->Width();
 
   Handle(Prs3d_IsoAspect) aResult =
     new Prs3d_IsoAspect(aColor, aType, aWidth, theNbIsos);
@@ -597,7 +655,8 @@ static int visos (Draw_Interpretor& di, Standard_Integer argc, const char** argv
       TheAISContext()->IsoNumber(AIS_TOI_IsoV) << "\n";
     di << "IsoOnPlane mode is " <<
       (TheAISContext()->IsoOnPlane() ? "ON" : "OFF") << "\n";
-
+    di << "IsoOnTriangulation mode is " <<
+      (TheAISContext()->IsoOnTriangulation() ? "ON" : "OFF") << "\n";
     return 0;
   }
 
@@ -655,7 +714,7 @@ static int visos (Draw_Interpretor& di, Standard_Integer argc, const char** argv
           CurDrawer->SetVIsoAspect(CopyIsoAspect(aVIso, aNbVIsos));
           TheAISContext()->SetLocalAttributes
                   (aShape, CurDrawer, Standard_False);
-          TheAISContext()->Redisplay(aShape);
+          TheAISContext()->Redisplay (aShape, Standard_False);
         } else {
           di << "Number of isos for " << argv[i] << " : "
              << aUIso->Number() << " " << aVIso->Number() << "\n";
@@ -738,40 +797,13 @@ static int VDir (Draw_Interpretor& theDI,
   return 0;
 }
 
-//==============================================================================
-//function : VSelPrecision
-//purpose  : To set the selection tolerance value
-//Draw arg : Selection tolerance value (real value determining the width and
-//           height of selecting frustum bases). Without arguments the function
-//           just prints current tolerance.
-//==============================================================================
-static int VSelPrecision(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+//! Auxiliary enumeration
+enum ViewerTest_StereoPair
 {
-  if( argc > 2 )
-  {
-    di << "Use: " << argv[0] << " [tolerance_value]\n";
-    return 1;
-  }
-
-  Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
-  if( aContext.IsNull() )
-    return 1;
-
-  if( argc == 1 )
-  {
-    Standard_Real aPixelTolerance = aContext->PixelTolerance();
-    di << "Precision mode  : 0 (window)\n";
-    di << "Pixel tolerance : " << aPixelTolerance << "\n";
-  }
-  else if (argc == 2)
-  {
-
-    Standard_Integer aPixelTolerance = Draw::Atoi (argv[1]);
-    aContext->SetPixelTolerance (aPixelTolerance);
-  }
-
-  return 0;
-}
+  ViewerTest_SP_Single,
+  ViewerTest_SP_SideBySide,
+  ViewerTest_SP_OverUnder
+};
 
 //==============================================================================
 //function : VDump
@@ -789,44 +821,108 @@ static Standard_Integer VDump (Draw_Interpretor& theDI,
 
   Standard_Integer      anArgIter   = 1;
   Standard_CString      aFilePath   = theArgVec[anArgIter++];
-  Graphic3d_BufferType  aBufferType = Graphic3d_BT_RGB;
-  V3d_StereoDumpOptions aStereoOpts = V3d_SDO_MONO;
-  Standard_Integer      aWidth      = 0;
-  Standard_Integer      aHeight     = 0;
+  ViewerTest_StereoPair aStereoPair = ViewerTest_SP_Single;
+  V3d_ImageDumpOptions  aParams;
+  aParams.BufferType    = Graphic3d_BT_RGB;
+  aParams.StereoOptions = V3d_SDO_MONO;
   for (; anArgIter < theArgNb; ++anArgIter)
   {
     TCollection_AsciiString anArg (theArgVec[anArgIter]);
     anArg.LowerCase();
-    if (anArg == "rgba")
-    {
-      aBufferType = Graphic3d_BT_RGBA;
-    }
-    else if (anArg == "rgb")
+    if (anArg == "-buffer")
     {
-      aBufferType = Graphic3d_BT_RGB;
+      if (++anArgIter >= theArgNb)
+      {
+        std::cout << "Error: wrong syntax at '" << anArg << "'\n";
+        return 1;
+      }
+
+      TCollection_AsciiString aBufArg (theArgVec[anArgIter]);
+      aBufArg.LowerCase();
+      if (aBufArg == "rgba")
+      {
+        aParams.BufferType = Graphic3d_BT_RGBA;
+      }
+      else if (aBufArg == "rgb")
+      {
+        aParams.BufferType = Graphic3d_BT_RGB;
+      }
+      else if (aBufArg == "depth")
+      {
+        aParams.BufferType = Graphic3d_BT_Depth;
+      }
+      else
+      {
+        std::cout << "Error: unknown buffer '" << aBufArg << "'\n";
+        return 1;
+      }
     }
-    else if (anArg == "depth")
+    else if (anArg == "-stereo")
     {
-      aBufferType = Graphic3d_BT_Depth;
+      if (++anArgIter >= theArgNb)
+      {
+        std::cout << "Error: wrong syntax at '" << anArg << "'\n";
+        return 1;
+      }
+
+      TCollection_AsciiString aStereoArg (theArgVec[anArgIter]);
+      aStereoArg.LowerCase();
+      if (aStereoArg == "l"
+       || aStereoArg == "left")
+      {
+        aParams.StereoOptions = V3d_SDO_LEFT_EYE;
+      }
+      else if (aStereoArg == "r"
+            || aStereoArg == "right")
+      {
+        aParams.StereoOptions = V3d_SDO_RIGHT_EYE;
+      }
+      else if (aStereoArg == "mono")
+      {
+        aParams.StereoOptions = V3d_SDO_MONO;
+      }
+      else if (aStereoArg == "blended"
+            || aStereoArg == "blend"
+            || aStereoArg == "stereo")
+      {
+        aParams.StereoOptions = V3d_SDO_BLENDED;
+      }
+      else if (aStereoArg == "sbs"
+            || aStereoArg == "sidebyside")
+      {
+        aStereoPair = ViewerTest_SP_SideBySide;
+      }
+      else if (aStereoArg == "ou"
+            || aStereoArg == "overunder")
+      {
+        aStereoPair = ViewerTest_SP_OverUnder;
+      }
+      else
+      {
+        std::cout << "Error: unknown stereo format '" << aStereoArg << "'\n";
+        return 1;
+      }
     }
-    else if (anArg == "l"
-          || anArg == "left")
+    else if (anArg == "-rgba"
+          || anArg ==  "rgba")
     {
-      aStereoOpts = V3d_SDO_LEFT_EYE;
+      aParams.BufferType = Graphic3d_BT_RGBA;
     }
-    else if (anArg == "r"
-          || anArg == "right")
+    else if (anArg == "-rgb"
+          || anArg ==  "rgb")
     {
-      aStereoOpts = V3d_SDO_RIGHT_EYE;
+      aParams.BufferType = Graphic3d_BT_RGB;
     }
-    else if (anArg == "mono")
+    else if (anArg == "-depth"
+          || anArg ==  "depth")
     {
-      aStereoOpts = V3d_SDO_MONO;
+      aParams.BufferType = Graphic3d_BT_Depth;
     }
-    else if (anArg == "w"
-          || anArg == "width")
+    else if (anArg == "-width"
+          || anArg ==  "width"
+          || anArg ==  "sizex")
     {
-      if (aWidth  != 0)
+      if (aParams.Width != 0)
       {
         std::cout << "Error: wrong syntax at " << theArgVec[anArgIter] << "\n";
         return 1;
@@ -836,39 +932,33 @@ static Standard_Integer VDump (Draw_Interpretor& theDI,
         std::cout << "Error: integer value is expected right after 'width'\n";
         return 1;
       }
-      aWidth = Draw::Atoi (theArgVec[anArgIter]);
+      aParams.Width = Draw::Atoi (theArgVec[anArgIter]);
     }
-    else if (anArg == "h"
-          || anArg == "height")
+    else if (anArg == "-height"
+          || anArg ==  "height"
+          || anArg ==  "-sizey")
     {
-      if (aHeight != 0)
+      if (aParams.Height != 0)
       {
         std::cout << "Error: wrong syntax at " << theArgVec[anArgIter] << "\n";
         return 1;
       }
-      if (++anArgIter >= theArgNb)
+      else if (++anArgIter >= theArgNb)
       {
         std::cout << "Error: integer value is expected right after 'height'\n";
         return 1;
       }
-      aHeight = Draw::Atoi (theArgVec[anArgIter]);
+      aParams.Height = Draw::Atoi (theArgVec[anArgIter]);
     }
-    else if (anArg.IsIntegerValue())
+    else if (anArg == "-tile"
+          || anArg == "-tilesize")
     {
-      // compatibility with old syntax
-      if (aWidth  != 0
-       || aHeight != 0)
-      {
-        std::cout << "Error: wrong syntax at " << theArgVec[anArgIter] << "\n";
-        return 1;
-      }
-      else if (++anArgIter >= theArgNb)
+      if (++anArgIter >= theArgNb)
       {
-        std::cout << "Error: height value is expected right after width\n";
+        std::cout << "Error: integer value is expected right after 'tileSize'\n";
         return 1;
       }
-      aWidth  = Draw::Atoi (theArgVec[anArgIter - 1]);
-      aHeight = Draw::Atoi (theArgVec[anArgIter]);
+      aParams.TileSize = Draw::Atoi (theArgVec[anArgIter]);
     }
     else
     {
@@ -876,10 +966,10 @@ static Standard_Integer VDump (Draw_Interpretor& theDI,
       return 1;
     }
   }
-  if ((aWidth <= 0 && aHeight >  0)
-   || (aWidth >  0 && aHeight <= 0))
+  if ((aParams.Width <= 0 && aParams.Height >  0)
+   || (aParams.Width >  0 && aParams.Height <= 0))
   {
-    std::cout << "Error: dimensions " << aWidth << "x" << aHeight << " are incorrect\n";
+    std::cout << "Error: dimensions " << aParams.Width << "x" << aParams.Height << " are incorrect\n";
     return 1;
   }
 
@@ -890,35 +980,89 @@ static Standard_Integer VDump (Draw_Interpretor& theDI,
     return 1;
   }
 
-  if (aWidth <= 0 || aHeight <= 0)
+  if (aParams.Width <= 0 || aParams.Height <= 0)
+  {
+    aView->Window()->Size (aParams.Width, aParams.Height);
+  }
+
+  Image_AlienPixMap aPixMap;
+  Image_PixMap::ImgFormat aFormat = Image_PixMap::ImgUNKNOWN;
+  switch (aParams.BufferType)
   {
-    if (aStereoOpts != V3d_SDO_MONO)
+    case Graphic3d_BT_RGB:   aFormat = Image_PixMap::ImgRGB;   break;
+    case Graphic3d_BT_RGBA:  aFormat = Image_PixMap::ImgRGBA;  break;
+    case Graphic3d_BT_Depth: aFormat = Image_PixMap::ImgGrayF; break;
+  }
+
+  switch (aStereoPair)
+  {
+    case ViewerTest_SP_Single:
     {
-      aView->Window()->Size (aWidth, aHeight);
+      if (!aView->ToPixMap (aPixMap, aParams))
+      {
+        theDI << "Fail: view dump failed!\n";
+        return 0;
+      }
+      else if (aPixMap.SizeX() != Standard_Size(aParams.Width)
+            || aPixMap.SizeY() != Standard_Size(aParams.Height))
+      {
+        theDI << "Fail: dumped dimensions "    << (Standard_Integer )aPixMap.SizeX() << "x" << (Standard_Integer )aPixMap.SizeY()
+              << " are lesser than requested " << aParams.Width << "x" << aParams.Height << "\n";
+      }
+      break;
     }
-    else
+    case ViewerTest_SP_SideBySide:
     {
-      if (!aView->Dump (aFilePath, aBufferType))
+      if (!aPixMap.InitZero (aFormat, aParams.Width * 2, aParams.Height))
+      {
+        theDI << "Fail: not enough memory for image allocation!\n";
+        return 0;
+      }
+
+      Image_PixMap aPixMapL, aPixMapR;
+      aPixMapL.InitWrapper (aPixMap.Format(), aPixMap.ChangeData(),
+                            aParams.Width, aParams.Height, aPixMap.SizeRowBytes());
+      aPixMapR.InitWrapper (aPixMap.Format(), aPixMap.ChangeData() + aPixMap.SizePixelBytes() * aParams.Width,
+                            aParams.Width, aParams.Height, aPixMap.SizeRowBytes());
+
+      aParams.StereoOptions = V3d_SDO_LEFT_EYE;
+      Standard_Boolean isOk = aView->ToPixMap (aPixMapL, aParams);
+      aParams.StereoOptions = V3d_SDO_RIGHT_EYE;
+      isOk          = isOk && aView->ToPixMap (aPixMapR, aParams);
+      if (!isOk)
       {
         theDI << "Fail: view dump failed!\n";
+        return 0;
       }
-      return 0;
+      break;
     }
-  }
+    case ViewerTest_SP_OverUnder:
+    {
+      if (!aPixMap.InitZero (aFormat, aParams.Width, aParams.Height * 2))
+      {
+        theDI << "Fail: not enough memory for image allocation!\n";
+        return 0;
+      }
 
-  Image_AlienPixMap aPixMap;
-  if (!aView->ToPixMap (aPixMap, aWidth, aHeight, aBufferType, Standard_True, aStereoOpts))
-  {
-    theDI << "Fail: view dump failed!\n";
-    return 0;
-  }
+      Image_PixMap aPixMapL, aPixMapR;
+      aPixMapL.InitWrapper (aPixMap.Format(), aPixMap.ChangeData(),
+                            aParams.Width, aParams.Height, aPixMap.SizeRowBytes());
+      aPixMapR.InitWrapper (aPixMap.Format(), aPixMap.ChangeData() + aPixMap.SizeRowBytes() * aParams.Height,
+                            aParams.Width, aParams.Height, aPixMap.SizeRowBytes());
 
-  if (aPixMap.SizeX() != Standard_Size(aWidth)
-   || aPixMap.SizeY() != Standard_Size(aHeight))
-  {
-    theDI << "Fail: dumped dimensions "    << (Standard_Integer )aPixMap.SizeX() << "x" << (Standard_Integer )aPixMap.SizeY()
-          << " are lesser than requested " << aWidth << "x" << aHeight << "\n";
+      aParams.StereoOptions = V3d_SDO_LEFT_EYE;
+      Standard_Boolean isOk = aView->ToPixMap (aPixMapL, aParams);
+      aParams.StereoOptions = V3d_SDO_RIGHT_EYE;
+      isOk          = isOk && aView->ToPixMap (aPixMapR, aParams);
+      if (!isOk)
+      {
+        theDI << "Fail: view dump failed!\n";
+        return 0;
+      }
+      break;
+    }
   }
+
   if (!aPixMap.Save (aFilePath))
   {
     theDI << "Fail: image can not be saved!\n";
@@ -926,43 +1070,46 @@ static Standard_Integer VDump (Draw_Interpretor& theDI,
   return 0;
 }
 
-
-//==============================================================================
-//function : Displays,Erase...
-//purpose  :
-//Draw arg :
-//==============================================================================
-static int VwrTst_DispErase(const Handle(AIS_InteractiveObject)& IO,
-                           const Standard_Integer Mode,
-                           const Standard_Integer TypeOfOperation,
-                           const Standard_Boolean Upd)
+enum TypeOfDispOperation
 {
-  Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
+  TypeOfDispOperation_SetDispMode,
+  TypeOfDispOperation_UnsetDispMode
+};
 
-  switch(TypeOfOperation){
-  case 1:
-    Ctx->Display(IO,Mode,Upd);
-    break;
-  case 2:{
-    Ctx->Erase(IO,Upd);
-    break;
-  }
-  case 3:{
-    if(IO.IsNull())
-      Ctx->SetDisplayMode((AIS_DisplayMode)Mode,Upd);
-    else
-      Ctx->SetDisplayMode(IO,Mode,Upd);
-    break;
-  }
-  case 4:{
-    if(IO.IsNull())
-      Ctx->SetDisplayMode(0,Upd);
-    else
-      Ctx->UnsetDisplayMode(IO,Upd);
-    break;
-  }
+//! Displays,Erase...
+static void VwrTst_DispErase (const Handle(AIS_InteractiveObject)& thePrs,
+                                               const Standard_Integer theMode,
+                                               const TypeOfDispOperation theType,
+                                               const Standard_Boolean theToUpdate)
+{
+  Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
+  switch (theType)
+  {
+    case TypeOfDispOperation_SetDispMode:
+    {
+      if (!thePrs.IsNull())
+      {
+        aCtx->SetDisplayMode (thePrs, theMode, theToUpdate);
+      }
+      else
+      {
+        aCtx->SetDisplayMode ((AIS_DisplayMode )theMode, theToUpdate);
+      }
+      break;
+    }
+    case TypeOfDispOperation_UnsetDispMode:
+    {
+      if (!thePrs.IsNull())
+      {
+        aCtx->UnsetDisplayMode (thePrs, theToUpdate);
+      }
+      else
+      {
+        aCtx->SetDisplayMode (AIS_WireFrame, theToUpdate);
+      }
+      break;
+    }
   }
-  return 0;
 }
 
 //=======================================================================
@@ -971,70 +1118,73 @@ static int VwrTst_DispErase(const Handle(AIS_InteractiveObject)& IO,
 //=======================================================================
 static int VDispMode (Draw_Interpretor& , Standard_Integer argc, const char** argv)
 {
-
-  TCollection_AsciiString name;
-  if(argc>3)
+  if (argc < 1
+   || argc > 3)
+  {
+    std::cout << "Syntax error: wrong number of arguments\n";
     return 1;
-  // display others presentations
-  Standard_Integer TypeOfOperation = (strcasecmp(argv[0],"vdispmode")==0)? 1:
-    (strcasecmp(argv[0],"verasemode")==0) ? 2 :
-      (strcasecmp(argv[0],"vsetdispmode")==0) ? 3 :
-       (strcasecmp(argv[0],"vunsetdispmode")==0) ? 4 : -1;
-
-  Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
+  }
 
-  //unset displaymode.. comportement particulier...
-  if(TypeOfOperation==4){
-    if(argc==1){
-      if(Ctx->NbCurrents()==0 ||
-        Ctx->NbSelected()==0){
-       Handle(AIS_InteractiveObject) IO;
-       VwrTst_DispErase(IO,-1,4,Standard_False);
+  TypeOfDispOperation aType = TCollection_AsciiString (argv[0]) == "vunsetdispmode"
+                            ? TypeOfDispOperation_UnsetDispMode
+                            : TypeOfDispOperation_SetDispMode;
+  Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
+  if (aType == TypeOfDispOperation_UnsetDispMode)
+  {
+    if (argc == 1)
+    {
+      if (aCtx->NbSelected() == 0)
+      {
+        VwrTst_DispErase (Handle(AIS_InteractiveObject)(), -1, TypeOfDispOperation_UnsetDispMode, Standard_False);
       }
-      else if(!Ctx->HasOpenedContext()){
-       for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent())
-         VwrTst_DispErase(Ctx->Current(),-1,4,Standard_False);
+      else
+      {
+        for (aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected())
+        {
+          VwrTst_DispErase (aCtx->SelectedInteractive(), -1, TypeOfDispOperation_UnsetDispMode, Standard_False);
+        }
       }
-      else{
-       for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected())
-         VwrTst_DispErase(Ctx->Interactive(),-1,4,Standard_False);}
-      Ctx->UpdateCurrentViewer();
+      aCtx->UpdateCurrentViewer();
     }
-    else{
-      Handle(AIS_InteractiveObject) IO;
-      name = argv[1];
-      if(GetMapOfAIS().IsBound2(name)){
-       IO = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
-        if (!IO.IsNull())
-          VwrTst_DispErase(IO,-1,4,Standard_True);
+    else
+    {
+      TCollection_AsciiString aName = argv[1];
+      if (GetMapOfAIS().IsBound2 (aName))
+      {
+        Handle(AIS_InteractiveObject) aPrs = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2 (aName));
+        if (!aPrs.IsNull())
+        {
+          VwrTst_DispErase (aPrs, -1, TypeOfDispOperation_UnsetDispMode, Standard_True);
+        }
       }
     }
   }
-  else if(argc==2){
-    Standard_Integer Dmode = Draw::Atoi(argv[1]);
-    if(Ctx->NbCurrents()==0 && TypeOfOperation==3){
-      Handle(AIS_InteractiveObject) IO;
-      VwrTst_DispErase(IO,Dmode,TypeOfOperation,Standard_True);
-    }
-    if(!Ctx->HasOpenedContext()){
-      // set/unset display mode sur le Contexte...
-      for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent()){
-       VwrTst_DispErase(Ctx->Current(),Dmode,TypeOfOperation,Standard_False);
-      }
-      Ctx->UpdateCurrentViewer();
+  else if (argc == 2)
+  {
+    Standard_Integer aDispMode = Draw::Atoi (argv[1]);
+    if (aCtx->NbSelected() == 0
+     && aType == TypeOfDispOperation_SetDispMode)
+    {
+      VwrTst_DispErase (Handle(AIS_InteractiveObject)(), aDispMode, TypeOfDispOperation_SetDispMode, Standard_True);
     }
-    else{
-      for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected())
-       Ctx->Display(Ctx->Interactive(),Dmode);
+    for (aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected())
+    {
+      VwrTst_DispErase (aCtx->SelectedInteractive(), aDispMode, aType, Standard_False);
     }
+    aCtx->UpdateCurrentViewer();
   }
-  else{
-    Handle(AIS_InteractiveObject) IO;
-    name = argv[1];
-    if(GetMapOfAIS().IsBound2(name))
-      IO = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
-    if (!IO.IsNull())
-      VwrTst_DispErase(IO,Draw::Atoi(argv[2]),TypeOfOperation,Standard_True);
+  else
+  {
+    Handle(AIS_InteractiveObject) aPrs;
+    TCollection_AsciiString aName (argv[1]);
+    if (GetMapOfAIS().IsBound2 (aName))
+    {
+      aPrs = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2 (aName));
+    }
+    if (!aPrs.IsNull())
+    {
+      VwrTst_DispErase (aPrs, Draw::Atoi(argv[2]), aType, Standard_True);
+    }
   }
   return 0;
 }
@@ -1050,30 +1200,22 @@ static int VSubInt(Draw_Interpretor& di, Standard_Integer argc, const char** arg
   Standard_Integer On = Draw::Atoi(argv[1]);
   const Handle(AIS_InteractiveContext)& Ctx = ViewerTest::GetAISContext();
 
-  if(argc==2){
-
-    if(!Ctx->HasOpenedContext()){
-      di<<"sub intensite ";
-      if(On==1) di<<"On";
-      else di<<"Off";
-      di<<" pour "<<Ctx->NbCurrents()<<"  objets"<<"\n";
-      for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent()){
-       if(On==1){
-         Ctx->SubIntensityOn(Ctx->Current(),Standard_False);}
-       else{
-         di <<"passage dans off"<<"\n";
-         Ctx->SubIntensityOff(Ctx->Current(),Standard_False);
-       }
+  if(argc==2)
+  {
+    TCollection_AsciiString isOnOff = On == 1 ? "on" : "off";
+    di << "Sub intensite is turned " << isOnOff << " for " << Ctx->NbSelected() << "objects\n";
+    for (Ctx->InitSelected(); Ctx->MoreSelected(); Ctx->NextSelected())
+    {
+      if(On==1)
+      {
+        Ctx->SubIntensityOn (Ctx->SelectedInteractive(), Standard_False);
       }
-    }
-    else{
-      for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected()){
-       if(On==1){
-         Ctx->SubIntensityOn(Ctx->Interactive(),Standard_False);}
-       else{
-         Ctx->SubIntensityOff(Ctx->Interactive(),Standard_False);}
+      else
+      {
+        Ctx->SubIntensityOff (Ctx->SelectedInteractive(), Standard_False);
       }
     }
+
     Ctx->UpdateCurrentViewer();
   }
   else {
@@ -1083,9 +1225,9 @@ static int VSubInt(Draw_Interpretor& di, Standard_Integer argc, const char** arg
       IO = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
       if (!IO.IsNull()) {
         if(On==1)
-          Ctx->SubIntensityOn(IO);
+          Ctx->SubIntensityOn(IO, Standard_True);
         else
-          Ctx->SubIntensityOff(IO);
+          Ctx->SubIntensityOff(IO, Standard_True);
       }
     }
     else return 1;
@@ -1128,11 +1270,11 @@ public:
       mySource = IterSource_List;
       mySeqIter = NCollection_Sequence<TCollection_AsciiString>::Iterator (mySeq);
     }
-    else if (aCtx->NbCurrents() > 0)
+    else if (aCtx->NbSelected() > 0)
     {
       mySource  = IterSource_Selected;
       mySelIter = aCtx;
-      mySelIter->InitCurrent();
+      mySelIter->InitSelected();
     }
     else
     {
@@ -1164,7 +1306,7 @@ public:
     {
       case IterSource_All:      return myMapIter.More();
       case IterSource_List:     return mySeqIter.More();
-      case IterSource_Selected: return mySelIter->MoreCurrent();
+      case IterSource_Selected: return mySelIter->MoreSelected();
     }
     return Standard_False;
   }
@@ -1189,7 +1331,7 @@ public:
       }
       case IterSource_Selected:
       {
-        mySelIter->NextCurrent();
+        mySelIter->NextSelected();
         break;
       }
     }
@@ -1229,10 +1371,10 @@ private:
       }
       case IterSource_Selected:
       {
-        if (mySelIter->MoreCurrent())
+        if (mySelIter->MoreSelected())
         {
-          myCurrentName = GetMapOfAIS().Find1 (mySelIter->Current());
-          myCurrent     = mySelIter->Current();
+          myCurrentName = GetMapOfAIS().Find1 (mySelIter->SelectedInteractive());
+          myCurrent     = mySelIter->SelectedInteractive();
         }
         break;
       }
@@ -1298,39 +1440,44 @@ static int VSetInteriorStyle (Draw_Interpretor& theDI,
     theDI.PrintHelp (theArgVec[0]);
     return 1;
   }
-  Standard_Integer        anInterStyle = Aspect_IS_SOLID;
+  Aspect_InteriorStyle    anInterStyle = Aspect_IS_SOLID;
   TCollection_AsciiString aStyleArg (theArgVec[anArgIter++]);
   aStyleArg.LowerCase();
   if (aStyleArg == "empty")
   {
-    anInterStyle = 0;
+    anInterStyle = Aspect_IS_EMPTY;
   }
   else if (aStyleArg == "hollow")
   {
-    anInterStyle = 1;
+    anInterStyle = Aspect_IS_HOLLOW;
   }
   else if (aStyleArg == "hatch")
   {
-    anInterStyle = 2;
+    anInterStyle = Aspect_IS_HATCH;
   }
   else if (aStyleArg == "solid")
   {
-    anInterStyle = 3;
+    anInterStyle = Aspect_IS_SOLID;
   }
   else if (aStyleArg == "hiddenline")
   {
-    anInterStyle = 4;
+    anInterStyle = Aspect_IS_HIDDENLINE;
   }
-  else
+  else if (aStyleArg == "point")
   {
-    anInterStyle = aStyleArg.IntegerValue();
+    anInterStyle = Aspect_IS_POINT;
   }
-  if (anInterStyle < Aspect_IS_EMPTY
-   || anInterStyle > Aspect_IS_HIDDENLINE)
+  else
   {
-    std::cout << "Error: style must be within a range [0 (Aspect_IS_EMPTY), "
-              << Aspect_IS_HIDDENLINE << " (Aspect_IS_HIDDENLINE)]\n";
-    return 1;
+    const Standard_Integer anIntStyle = aStyleArg.IntegerValue();
+    if (anIntStyle < Aspect_IS_EMPTY
+     || anIntStyle > Aspect_IS_POINT)
+    {
+      std::cout << "Error: style must be within a range [0 (Aspect_IS_EMPTY), "
+                << Aspect_IS_POINT << " (Aspect_IS_POINT)]\n";
+      return 1;
+    }
+    anInterStyle = (Aspect_InteriorStyle )anIntStyle;
   }
 
   if (!aName.IsEmpty()
@@ -1340,10 +1487,6 @@ static int VSetInteriorStyle (Draw_Interpretor& theDI,
     return 1;
   }
 
-  if (aCtx->HasOpenedContext())
-  {
-    aCtx->CloseLocalContext();
-  }
   for (ViewTest_PrsIter anIter (aName); anIter.More(); anIter.Next())
   {
     const Handle(AIS_InteractiveObject)& anIO = anIter.Current();
@@ -1352,7 +1495,12 @@ static int VSetInteriorStyle (Draw_Interpretor& theDI,
       const Handle(Prs3d_Drawer)& aDrawer        = anIO->Attributes();
       Handle(Prs3d_ShadingAspect) aShadingAspect = aDrawer->ShadingAspect();
       Handle(Graphic3d_AspectFillArea3d) aFillAspect = aShadingAspect->Aspect();
-      aFillAspect->SetInteriorStyle ((Aspect_InteriorStyle )anInterStyle);
+      aFillAspect->SetInteriorStyle (anInterStyle);
+      if (anInterStyle == Aspect_IS_HATCH
+       && aFillAspect->HatchStyle().IsNull())
+      {
+        aFillAspect->SetHatchStyle (Aspect_HS_VERTICAL);
+      }
       aCtx->RecomputePrsOnly (anIO, Standard_False, Standard_True);
     }
   }
@@ -1371,6 +1519,9 @@ struct ViewerTest_AspectsChangeSet
   Standard_Integer         ToSetLineWidth;
   Standard_Real            LineWidth;
 
+  Standard_Integer         ToSetTypeOfLine;
+  Aspect_TypeOfLine        TypeOfLine;
+
   Standard_Integer         ToSetTransparency;
   Standard_Real            Transparency;
 
@@ -1386,6 +1537,19 @@ struct ViewerTest_AspectsChangeSet
   Standard_Integer         ToSetFreeBoundaryColor;
   Quantity_Color           FreeBoundaryColor;
 
+  Standard_Integer         ToEnableIsoOnTriangulation;
+
+  Standard_Integer         ToSetMaxParamValue;
+  Standard_Real            MaxParamValue;
+
+  Standard_Integer         ToSetSensitivity;
+  Standard_Integer         SelectionMode;
+  Standard_Integer         Sensitivity;
+
+  Standard_Integer         ToSetHatch;
+  Standard_Integer         StdHatchStyle;
+  TCollection_AsciiString  PathToHatchPattern;
+
   //! Empty constructor
   ViewerTest_AspectsChangeSet()
   : ToSetVisibility   (0),
@@ -1394,15 +1558,26 @@ struct ViewerTest_AspectsChangeSet
     Color             (DEFAULT_COLOR),
     ToSetLineWidth    (0),
     LineWidth         (1.0),
+    ToSetTypeOfLine   (0),
+    TypeOfLine        (Aspect_TOL_SOLID),
     ToSetTransparency (0),
     Transparency      (0.0),
     ToSetMaterial     (0),
     Material          (Graphic3d_NOM_DEFAULT),
-    ToSetShowFreeBoundary  (0),
-    ToSetFreeBoundaryWidth (0),
-    FreeBoundaryWidth      (1.0),
-    ToSetFreeBoundaryColor (0),
-    FreeBoundaryColor      (DEFAULT_FREEBOUNDARY_COLOR) {}
+    ToSetShowFreeBoundary      (0),
+    ToSetFreeBoundaryWidth     (0),
+    FreeBoundaryWidth          (1.0),
+    ToSetFreeBoundaryColor     (0),
+    FreeBoundaryColor          (DEFAULT_FREEBOUNDARY_COLOR),
+    ToEnableIsoOnTriangulation (-1),
+    ToSetMaxParamValue (0),
+    MaxParamValue (500000),
+    ToSetSensitivity (0),
+    SelectionMode (-1),
+    Sensitivity (-1),
+    ToSetHatch (0),
+    StdHatchStyle (-1)
+    {}
 
   //! @return true if no changes have been requested
   Standard_Boolean IsEmpty() const
@@ -1414,7 +1589,10 @@ struct ViewerTest_AspectsChangeSet
         && ToSetMaterial          == 0
         && ToSetShowFreeBoundary  == 0
         && ToSetFreeBoundaryColor == 0
-        && ToSetFreeBoundaryWidth == 0;
+        && ToSetFreeBoundaryWidth == 0
+        && ToSetMaxParamValue     == 0
+        && ToSetSensitivity       == 0
+        && ToSetHatch             == 0;
   }
 
   //! @return true if properties are valid
@@ -1456,6 +1634,21 @@ struct ViewerTest_AspectsChangeSet
       std::cout << "Error: the free boundary width should be within [1; 10] range (specified " << FreeBoundaryWidth << ")\n";
       isOk = Standard_False;
     }
+    if (MaxParamValue < 0.0)
+    {
+      std::cout << "Error: the max parameter value should be greater than zero (specified " << MaxParamValue << ")\n";
+      isOk = Standard_False;
+    }
+    if (Sensitivity <= 0 && ToSetSensitivity)
+    {
+      std::cout << "Error: sensitivity parameter value should be positive (specified " << Sensitivity << ")\n";
+      isOk = Standard_False;
+    }
+    if (ToSetHatch == 1 && StdHatchStyle < 0 && PathToHatchPattern == "")
+    {
+      std::cout << "Error: hatch style must be specified\n";
+      isOk = Standard_False;
+    }
     return isOk;
   }
 
@@ -1761,6 +1954,25 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       aChangeSet->ToSetColor = 1;
       anArgIter += aNbComps;
     }
+    else if (anArg == "-setlinetype")
+    {
+      if (++anArgIter >= theArgNb)
+      {
+        std::cout << "Error: wrong syntax at " << anArg << "\n";
+        return 1;
+      }
+      if (!ViewerTest::ParseLineType (theArgVec[anArgIter], aChangeSet->TypeOfLine))
+      {
+        std::cout << "Error: wrong syntax at " << anArg << "\n";
+        return 1;
+      }
+
+      aChangeSet->ToSetTypeOfLine = 1;
+    }
+    else if (anArg == "-unsetlinetype")
+    {
+      aChangeSet->ToSetTypeOfLine = -1;
+    }
     else if (anArg == "-unsetcolor")
     {
       aChangeSet->ToSetColor = -1;
@@ -1932,6 +2144,8 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       aChangeSet->Visibility = 1;
       aChangeSet->ToSetLineWidth = -1;
       aChangeSet->LineWidth = 1.0;
+      aChangeSet->ToSetTypeOfLine = -1;
+      aChangeSet->TypeOfLine = Aspect_TOL_SOLID;
       aChangeSet->ToSetTransparency = -1;
       aChangeSet->Transparency = 0.0;
       aChangeSet->ToSetColor = -1;
@@ -1943,6 +2157,100 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       aChangeSet->FreeBoundaryColor = DEFAULT_FREEBOUNDARY_COLOR;
       aChangeSet->ToSetFreeBoundaryWidth = -1;
       aChangeSet->FreeBoundaryWidth = 1.0;
+      aChangeSet->ToSetHatch = -1;
+      aChangeSet->StdHatchStyle = -1;
+      aChangeSet->PathToHatchPattern.Clear();
+    }
+    else if (anArg == "-isoontriangulation"
+          || anArg == "-isoontriang")
+    {
+      if (++anArgIter >= theArgNb)
+      {
+        std::cout << "Error: wrong syntax at " << anArg << "\n";
+        return 1;
+      }
+      TCollection_AsciiString aValue (theArgVec[anArgIter]);
+      aValue.LowerCase();
+      if (aValue == "on"
+        || aValue == "1")
+      {
+        aChangeSet->ToEnableIsoOnTriangulation = 1;
+      }
+      else if (aValue == "off"
+        || aValue == "0")
+      {
+        aChangeSet->ToEnableIsoOnTriangulation = 0;
+      }
+      else
+      {
+        std::cout << "Error: wrong syntax at " << anArg << "\n";
+        return 1;
+      }
+    }
+    else if (anArg == "-setmaxparamvalue")
+    {
+      if (++anArgIter >= theArgNb)
+      {
+        std::cout << "Error: wrong syntax at " << anArg << "\n";
+        return 1;
+      }
+      aChangeSet->ToSetMaxParamValue = 1;
+      aChangeSet->MaxParamValue = Draw::Atof (theArgVec[anArgIter]);
+    }
+    else if (anArg == "-setsensitivity")
+    {
+      if (isDefaults)
+      {
+        std::cout << "Error: wrong syntax. -setSensitivity can not be used together with -defaults call!\n";
+        return 1;
+      }
+
+      if (aNames.IsEmpty())
+      {
+        std::cout << "Error: object and selection mode should specified explicitly when -setSensitivity is used!\n";
+        return 1;
+      }
+
+      if (anArgIter + 2 >= theArgNb)
+      {
+        std::cout << "Error: wrong syntax at " << anArg << "\n";
+        return 1;
+      }
+      aChangeSet->ToSetSensitivity = 1;
+      aChangeSet->SelectionMode = Draw::Atoi (theArgVec[++anArgIter]);
+      aChangeSet->Sensitivity = Draw::Atoi (theArgVec[++anArgIter]);
+    }
+    else if (anArg == "-sethatch")
+    {
+      if (isDefaults)
+      {
+        std::cout << "Error: wrong syntax. -setHatch can not be used together with -defaults call!\n";
+        return 1;
+      }
+
+      if (aNames.IsEmpty())
+      {
+        std::cout << "Error: object should be specified explicitly when -setHatch is used!\n";
+        return 1;
+      }
+
+      aChangeSet->ToSetHatch = 1;
+      TCollection_AsciiString anArgHatch (theArgVec[++anArgIter]);
+      if (anArgHatch.Length() <= 2)
+      {
+        const Standard_Integer anIntStyle = Draw::Atoi (anArgHatch.ToCString());
+        if (anIntStyle < 0
+         || anIntStyle >= Aspect_HS_NB)
+        {
+          std::cout << "Error: hatch style is out of range [0, " << (Aspect_HS_NB - 1) << "]!\n";
+          return 1;
+        }
+        aChangeSet->StdHatchStyle = anIntStyle;
+      }
+      else
+      {
+        aChangeSet->PathToHatchPattern = anArgHatch;
+      }
     }
     else
     {
@@ -1962,11 +2270,6 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
     isFirst = Standard_False;
   }
 
-  if (aCtx->HasOpenedContext())
-  {
-    aCtx->CloseLocalContext();
-  }
-
   // special case for -defaults parameter.
   // all changed values will be set to DefaultDrawer.
   if (isDefaults)
@@ -1989,6 +2292,14 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       aDrawer->WireAspect()->SetColor           (aChangeSet->Color);
       aDrawer->PointAspect()->SetColor          (aChangeSet->Color);
     }
+    if (aChangeSet->ToSetTypeOfLine != 0)
+    {
+      aDrawer->LineAspect()->SetTypeOfLine           (aChangeSet->TypeOfLine);
+      aDrawer->WireAspect()->SetTypeOfLine           (aChangeSet->TypeOfLine);
+      aDrawer->FreeBoundaryAspect()->SetTypeOfLine   (aChangeSet->TypeOfLine);
+      aDrawer->UnFreeBoundaryAspect()->SetTypeOfLine (aChangeSet->TypeOfLine);
+      aDrawer->SeenLineAspect()->SetTypeOfLine       (aChangeSet->TypeOfLine);
+    }
     if (aChangeSet->ToSetTransparency != 0)
     {
       aDrawer->ShadingAspect()->SetTransparency (aChangeSet->Transparency);
@@ -2013,6 +2324,14 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
     {
       aDrawer->FreeBoundaryAspect()->SetColor (aChangeSet->FreeBoundaryColor);
     }
+    if (aChangeSet->ToEnableIsoOnTriangulation != -1)
+    {
+      aDrawer->SetIsoOnTriangulation (aChangeSet->ToEnableIsoOnTriangulation == 1);
+    }
+    if (aChangeSet->ToSetMaxParamValue != 0)
+    {
+      aDrawer->SetMaximalParameterValue (aChangeSet->MaxParamValue);
+    }
 
     // redisplay all objects in context
     for (ViewTest_PrsIter aPrsIter (aNames); aPrsIter.More(); aPrsIter.Next())
@@ -2046,6 +2365,11 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       if (aColoredPrs.IsNull())
       {
         aColoredPrs = new AIS_ColoredShape (aShapePrs);
+        if (aShapePrs->HasDisplayMode())
+        {
+          aColoredPrs->SetDisplayMode (aShapePrs->DisplayMode());
+        }
+        aColoredPrs->SetLocalTransformation (aShapePrs->LocalTransformation());
         aCtx->Remove (aShapePrs, Standard_False);
         GetMapOfAIS().UnBind2 (aName);
         GetMapOfAIS().Bind (aColoredPrs, aName);
@@ -2096,6 +2420,15 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       {
         aCtx->UnsetWidth (aPrs, Standard_False);
       }
+      else if (aChangeSet->ToEnableIsoOnTriangulation != -1)
+      {
+        aCtx->IsoOnTriangulation (aChangeSet->ToEnableIsoOnTriangulation == 1, aPrs);
+        toRedisplay = Standard_True;
+      }
+      else if (aChangeSet->ToSetSensitivity != 0)
+      {
+        aCtx->SetSelectionSensitivity (aPrs, aChangeSet->SelectionMode, aChangeSet->Sensitivity);
+      }
       if (!aDrawer.IsNull())
       {
         if (aChangeSet->ToSetShowFreeBoundary == 1)
@@ -2126,6 +2459,55 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
           aDrawer->SetFreeBoundaryAspect (aBoundaryAspect);
           toRedisplay = Standard_True;
         }
+        if (aChangeSet->ToSetTypeOfLine != 0)
+        {
+          aDrawer->LineAspect()->SetTypeOfLine           (aChangeSet->TypeOfLine);
+          aDrawer->WireAspect()->SetTypeOfLine           (aChangeSet->TypeOfLine);
+          aDrawer->FreeBoundaryAspect()->SetTypeOfLine   (aChangeSet->TypeOfLine);
+          aDrawer->UnFreeBoundaryAspect()->SetTypeOfLine (aChangeSet->TypeOfLine);
+          aDrawer->SeenLineAspect()->SetTypeOfLine       (aChangeSet->TypeOfLine);
+          toRedisplay = Standard_True;
+        }
+        if (aChangeSet->ToSetMaxParamValue != 0)
+        {
+          aDrawer->SetMaximalParameterValue (aChangeSet->MaxParamValue);
+        }
+        if (aChangeSet->ToSetHatch != 0)
+        {
+          if (!aDrawer->HasOwnShadingAspect())
+          {
+            aDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
+            *aDrawer->ShadingAspect()->Aspect() = *aCtx->DefaultDrawer()->ShadingAspect()->Aspect();
+          }
+
+          Handle(Graphic3d_AspectFillArea3d) anAsp = aDrawer->ShadingAspect()->Aspect();
+          if (aChangeSet->ToSetHatch == -1)
+          {
+            anAsp->SetInteriorStyle (Aspect_IS_SOLID);
+          }
+          else
+          {
+            anAsp->SetInteriorStyle (Aspect_IS_HATCH);
+            if (!aChangeSet->PathToHatchPattern.IsEmpty())
+            {
+              Handle(Image_AlienPixMap) anImage = new Image_AlienPixMap();
+              if (anImage->Load (TCollection_AsciiString (aChangeSet->PathToHatchPattern.ToCString())))
+              {
+                anAsp->SetHatchStyle (new Graphic3d_HatchStyle (anImage));
+              }
+              else
+              {
+                std::cout << "Error: cannot load the following image: " << aChangeSet->PathToHatchPattern << std::endl;
+                return 1;
+              }
+            }
+            else if (aChangeSet->StdHatchStyle != -1)
+            {
+              anAsp->SetHatchStyle (new Graphic3d_HatchStyle ((Aspect_HatchStyle)aChangeSet->StdHatchStyle));
+            }
+          }
+          toRedisplay = Standard_True;
+        }
       }
 
       for (aChangesIter.Next(); aChangesIter.More(); aChangesIter.Next())
@@ -2153,6 +2535,15 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
           {
             aColoredPrs->UnsetCustomAspects (aSubShape, Standard_True);
           }
+          if (aChangeSet->ToSetMaxParamValue != 0)
+          {
+            Handle(AIS_ColoredDrawer) aCurColDrawer = aColoredPrs->CustomAspects (aSubShape);
+            aCurColDrawer->SetMaximalParameterValue (aChangeSet->MaxParamValue);
+          }
+          if (aChangeSet->ToSetSensitivity != 0)
+          {
+            aCtx->SetSelectionSensitivity (aPrs, aChangeSet->SelectionMode, aChangeSet->Sensitivity);
+          }
         }
       }
       if (toDisplay)
@@ -2168,29 +2559,6 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
         aCtx->Redisplay (aColoredPrs, Standard_False);
       }
     }
-    else
-    {
-      Handle(NIS_InteractiveObject) aNisObj = Handle(NIS_InteractiveObject)::DownCast (aPrsIter.CurrentTrs());
-      Handle(NIS_Triangulated)      aNisTri = Handle(NIS_Triangulated)::DownCast (aNisObj);
-      if (!aNisObj.IsNull())
-      {
-        if (aChangeSet->ToSetTransparency != 0)
-        {
-          aNisObj->SetTransparency (aChangeSet->Transparency);
-        }
-      }
-      if (!aNisTri.IsNull())
-      {
-        if (aChangeSet->ToSetColor != 0)
-        {
-          aNisTri->SetColor (aChangeSet->Color);
-        }
-        if (aChangeSet->ToSetLineWidth != 0)
-        {
-          aNisTri->SetLineWidth (aChangeSet->LineWidth);
-        }
-      }
-    }
   }
   return 0;
 }
@@ -2213,10 +2581,12 @@ static int VDonly2 (Draw_Interpretor& ,
     return 1;
   }
 
+  Standard_DISABLE_DEPRECATION_WARNINGS
   if (aCtx->HasOpenedContext())
   {
     aCtx->CloseLocalContext();
   }
+  Standard_ENABLE_DEPRECATION_WARNINGS
 
   Standard_Integer anArgIter = 1;
   for (; anArgIter < theArgNb; ++anArgIter)
@@ -2231,14 +2601,14 @@ static int VDonly2 (Draw_Interpretor& ,
   if (anArgIter >= theArgNb)
   {
     // display only selected objects
-    if (aCtx->NbCurrents() < 1)
+    if (aCtx->NbSelected() < 1)
     {
       return 0;
     }
 
-    for (aCtx->InitCurrent(); aCtx->MoreCurrent(); aCtx->NextCurrent())
+    for (aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected())
     {
-      aDispSet.Add (aCtx->Current());
+      aDispSet.Add (aCtx->SelectedInteractive());
     }
   }
   else
@@ -2249,18 +2619,12 @@ static int VDonly2 (Draw_Interpretor& ,
       TCollection_AsciiString aName = theArgVec[anArgIter];
       if (GetMapOfAIS().IsBound2 (aName))
       {
-        const Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (aName);
-        if (anObj->IsKind (STANDARD_TYPE(AIS_InteractiveObject)))
+        const Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aName));
+        if (!aShape.IsNull())
         {
-          const Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (anObj);
           aCtx->Display (aShape, Standard_False);
+          aDispSet.Add (aShape);
         }
-        else if (anObj->IsKind (STANDARD_TYPE(NIS_InteractiveObject)))
-        {
-          Handle(NIS_InteractiveObject) aShape = Handle(NIS_InteractiveObject)::DownCast (anObj);
-          TheNISContext()->Display (aShape);
-        }
-        aDispSet.Add (anObj);
       }
     }
   }
@@ -2273,16 +2637,11 @@ static int VDonly2 (Draw_Interpretor& ,
       continue;
     }
 
-    if (anIter.Key1()->IsKind (STANDARD_TYPE(AIS_InteractiveObject)))
+    const Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
+    if (aShape.IsNull())
     {
-      const Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
       aCtx->Erase (aShape, Standard_False);
     }
-    else if (anIter.Key1()->IsKind (STANDARD_TYPE(NIS_InteractiveObject)))
-    {
-      const Handle(NIS_InteractiveObject) aShape = Handle(NIS_InteractiveObject)::DownCast (anIter.Key1());
-      TheNISContext()->Erase (aShape);
-    }
   }
   return 0;
 }
@@ -2349,6 +2708,7 @@ int VRemove (Draw_Interpretor& theDI,
     return 1;
   }
 
+  Standard_DISABLE_DEPRECATION_WARNINGS
   if (toRemoveLocal && !aCtx->HasOpenedContext())
   {
     std::cerr << "Error: local selection context is not open.\n";
@@ -2358,6 +2718,7 @@ int VRemove (Draw_Interpretor& theDI,
   {
     aCtx->CloseAllContexts (Standard_False);
   }
+  Standard_ENABLE_DEPRECATION_WARNINGS
 
   NCollection_List<TCollection_AsciiString> anIONameList;
   if (toRemoveAll)
@@ -2379,84 +2740,43 @@ int VRemove (Draw_Interpretor& theDI,
         continue;
       }
 
-      const Handle(Standard_Transient)& aTransientObj = GetMapOfAIS().Find2 (aName);
-
-      const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (aTransientObj);
-      if (!anIO.IsNull())
+      const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aName));
+      if (anIO->GetContext() != aCtx)
       {
-        if (anIO->GetContext() != aCtx)
-        {
-          theDI << aName.ToCString() << " was not displayed in current context.\n";
-          theDI << "Please activate view with this object displayed and try again.\n";
-          continue;
-        }
-
-        anIONameList.Append (aName);
+        theDI << aName.ToCString() << " was not displayed in current context.\n";
+        theDI << "Please activate view with this object displayed and try again.\n";
         continue;
       }
 
-      const Handle(NIS_InteractiveObject) aNisIO = Handle(NIS_InteractiveObject)::DownCast (aTransientObj);
-      if (!aNisIO.IsNull())
-      {
-        anIONameList.Append (aName);
-      }
+      anIONameList.Append (aName);
+      continue;
     }
   }
-  else if (aCtx->NbCurrents() > 0
-        || TheNISContext()->GetSelected().Extent() > 0)
+  else if (aCtx->NbSelected() > 0)
   {
     for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
          anIter.More(); anIter.Next())
     {
       const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
-      if (!anIO.IsNull())
+      if (!aCtx->IsSelected (anIO))
       {
-        if (!aCtx->IsCurrent (anIO))
-        {
-          continue;
-        }
-
-        anIONameList.Append (anIter.Key2());
         continue;
       }
 
-      const Handle(NIS_InteractiveObject) aNisIO = Handle(NIS_InteractiveObject)::DownCast (anIter.Key1());
-      if (!aNisIO.IsNull())
-      {
-        if (!TheNISContext()->IsSelected (aNisIO))
-        {
-          continue;
-        }
-
-        anIONameList.Append (anIter.Key2());
-      }
+      anIONameList.Append (anIter.Key2());
+      continue;
     }
   }
 
-  // Unbind all removed objects from the map of displayed IO.
-  for (NCollection_List<TCollection_AsciiString>::Iterator anIter (anIONameList);
-       anIter.More(); anIter.Next())
-  {
-    const Handle(AIS_InteractiveObject) anIO  = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (anIter.Value()));
-    if (!anIO.IsNull())
-    {
-      aCtx->Remove (anIO, Standard_False);
-      if (toPrintInfo)
-      {
-        theDI << anIter.Value().ToCString() << " was removed\n";
-      }
-    }
-    else
+  // Unbind all removed objects from the map of displayed IO.
+  for (NCollection_List<TCollection_AsciiString>::Iterator anIter (anIONameList);
+       anIter.More(); anIter.Next())
+  {
+    const Handle(AIS_InteractiveObject) anIO  = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (anIter.Value()));
+    aCtx->Remove (anIO, Standard_False);
+    if (toPrintInfo)
     {
-      const Handle(NIS_InteractiveObject) aNisIO = Handle(NIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (anIter.Value()));
-      if (!aNisIO.IsNull())
-      {
-        TheNISContext()->Remove (aNisIO);
-        if (toPrintInfo)
-        {
-          theDI << anIter.Value().ToCString() << " was removed\n";
-        }
-      }
+      theDI << anIter.Value().ToCString() << " was removed\n";
     }
     if (!isContextOnly)
     {
@@ -2466,11 +2786,13 @@ int VRemove (Draw_Interpretor& theDI,
 
   // Close local context if it is empty
   TColStd_MapOfTransient aLocalIO;
+  Standard_DISABLE_DEPRECATION_WARNINGS
   if (aCtx->HasOpenedContext()
    && !aCtx->LocalContext()->DisplayedObjects (aLocalIO))
   {
     aCtx->CloseAllContexts (Standard_False);
   }
+  Standard_ENABLE_DEPRECATION_WARNINGS
 
   return 0;
 }
@@ -2528,6 +2850,7 @@ int VErase (Draw_Interpretor& theDI,
     return 1;
   }
 
+  Standard_DISABLE_DEPRECATION_WARNINGS
   if (toEraseLocal && !aCtx->HasOpenedContext())
   {
     std::cerr << "Error: local selection context is not open.\n";
@@ -2537,6 +2860,7 @@ int VErase (Draw_Interpretor& theDI,
   {
     aCtx->CloseAllContexts (Standard_False);
   }
+  Standard_ENABLE_DEPRECATION_WARNINGS
 
   if (!aNamesOfEraseIO.IsEmpty())
   {
@@ -2563,37 +2887,35 @@ int VErase (Draw_Interpretor& theDI,
           aCtx->Erase (anIO, Standard_False);
         }
       }
-      else
-      {
-        const Handle(NIS_InteractiveObject) aNisIO = Handle(NIS_InteractiveObject)::DownCast (anObj);
-        if (!aNisIO.IsNull())
-        {
-          TheNISContext()->Erase (aNisIO);
-        }
-      }
     }
   }
-  else if (!toEraseAll && aCtx->NbCurrents() > 0)
+  else if (!toEraseAll && aCtx->NbSelected() > 0)
   {
     // Erase selected objects
+    const Standard_Boolean aHasOpenedContext = aCtx->HasOpenedContext();
     for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
          anIter.More(); anIter.Next())
     {
       const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
       if (!anIO.IsNull()
-       && aCtx->IsCurrent (anIO))
+       && aCtx->IsSelected (anIO))
       {
         theDI << anIter.Key2().ToCString() << " ";
         if (toEraseInView)
         {
           aCtx->SetViewAffinity (anIO, aView, Standard_False);
         }
-        else
+        else if (aHasOpenedContext)
         {
           aCtx->Erase (anIO, Standard_False);
         }
       }
     }
+
+    if (!toEraseInView)
+    {
+      aCtx->EraseSelected (Standard_False);
+    }
   }
   else
   {
@@ -2613,14 +2935,6 @@ int VErase (Draw_Interpretor& theDI,
           aCtx->Erase (anIO, Standard_False);
         }
       }
-      else
-      {
-        const Handle(NIS_InteractiveObject) aNisIO = Handle(NIS_InteractiveObject)::DownCast (anIter.Key1());
-        if (!aNisIO.IsNull())
-        {
-          TheNISContext()->Erase (aNisIO);
-        }
-      }
     }
   }
 
@@ -2670,6 +2984,7 @@ static int VDisplayAll (Draw_Interpretor& ,
     return 1;
   }
 
+  Standard_DISABLE_DEPRECATION_WARNINGS
   if (toDisplayLocal && !aCtx->HasOpenedContext())
   {
     std::cerr << "Error: local selection context is not open.\n";
@@ -2679,65 +2994,51 @@ static int VDisplayAll (Draw_Interpretor& ,
   {
     aCtx->CloseLocalContext (Standard_False);
   }
+  Standard_ENABLE_DEPRECATION_WARNINGS
 
   for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
        anIter.More(); anIter.Next())
   {
-    if (anIter.Key1()->IsKind (STANDARD_TYPE(AIS_InteractiveObject)))
-    {
-      const Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
-      aCtx->Erase (aShape, Standard_False);
-    }
-    else if (anIter.Key1()->IsKind(STANDARD_TYPE(NIS_InteractiveObject)))
-    {
-      const Handle(NIS_InteractiveObject) aShape = Handle(NIS_InteractiveObject)::DownCast (anIter.Key1());
-      TheNISContext()->Erase (aShape);
-    }
+    const Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
+    aCtx->Erase (aShape, Standard_False);
   }
 
   for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
        anIter.More(); anIter.Next())
   {
-    if (anIter.Key1()->IsKind (STANDARD_TYPE(AIS_InteractiveObject)))
-    {
-      const Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
-      aCtx->Display (aShape, Standard_False);
-    }
-    else if (anIter.Key1()->IsKind (STANDARD_TYPE(NIS_InteractiveObject)))
-    {
-      Handle(NIS_InteractiveObject) aShape = Handle(NIS_InteractiveObject)::DownCast (anIter.Key1());
-      TheNISContext()->Display (aShape);
-    }
+    const Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
+    aCtx->Display (aShape, Standard_False);
   }
   return 0;
 }
 
-//! Auxiliary method to find presentation
-inline Handle(PrsMgr_Presentation) findPresentation (const Handle(AIS_InteractiveContext)& theCtx,
-                                                     const Handle(AIS_InteractiveObject)&  theIO,
-                                                     const Standard_Integer                theMode)
+//! Auxiliary method to check if presentation exists
+inline Standard_Integer checkMode (const Handle(AIS_InteractiveContext)& theCtx,
+                                   const Handle(AIS_InteractiveObject)&  theIO,
+                                   const Standard_Integer                theMode)
 {
-  if (theIO.IsNull())
+  if (theIO.IsNull() || theCtx.IsNull())
   {
-    return Handle(PrsMgr_Presentation)();
+    return -1;
   }
 
   if (theMode != -1)
   {
     if (theCtx->MainPrsMgr()->HasPresentation (theIO, theMode))
     {
-      return theCtx->MainPrsMgr()->Presentation (theIO, theMode);
+      return theMode;
     }
   }
   else if (theCtx->MainPrsMgr()->HasPresentation (theIO, theIO->DisplayMode()))
   {
-    return theCtx->MainPrsMgr()->Presentation (theIO, theIO->DisplayMode());
+    return theIO->DisplayMode();
   }
   else if (theCtx->MainPrsMgr()->HasPresentation (theIO, theCtx->DisplayMode()))
   {
-    return theCtx->MainPrsMgr()->Presentation (theIO, theCtx->DisplayMode());
+    return theCtx->DisplayMode();
   }
-  return Handle(PrsMgr_Presentation)();
+
+  return -1;
 }
 
 enum ViewerTest_BndAction
@@ -2748,30 +3049,36 @@ enum ViewerTest_BndAction
 };
 
 //! Auxiliary method to print bounding box of presentation
-inline void bndPresentation (Draw_Interpretor&                  theDI,
-                             const Handle(PrsMgr_Presentation)& thePrs,
-                             const TCollection_AsciiString&     theName,
-                             const ViewerTest_BndAction         theAction)
+inline void bndPresentation (Draw_Interpretor&                         theDI,
+                             const Handle(PrsMgr_PresentationManager)& theMgr,
+                             const Handle(AIS_InteractiveObject)&      theObj,
+                             const Standard_Integer                    theDispMode,
+                             const TCollection_AsciiString&            theName,
+                             const ViewerTest_BndAction                theAction,
+                             const Handle(Prs3d_Drawer)&               theStyle)
 {
   switch (theAction)
   {
     case BndAction_Hide:
     {
-      thePrs->Presentation()->GraphicUnHighlight();
+      theMgr->Unhighlight (theObj);
       break;
     }
     case BndAction_Show:
     {
-      Handle(Graphic3d_Structure) aPrs = thePrs->Presentation();
-      aPrs->CStructure()->HighlightColor.r = 0.988235f;
-      aPrs->CStructure()->HighlightColor.g = 0.988235f;
-      aPrs->CStructure()->HighlightColor.b = 0.988235f;
-      aPrs->CStructure()->HighlightWithBndBox (aPrs, Standard_True);
+      theMgr->Color (theObj, theStyle, theDispMode);
       break;
     }
     case BndAction_Print:
     {
-      Bnd_Box aBox = thePrs->Presentation()->MinMaxValues();
+      Bnd_Box aBox;
+      for (PrsMgr_Presentations::Iterator aPrsIter (theObj->Presentations()); aPrsIter.More(); aPrsIter.Next())
+      {
+        if (aPrsIter.Value().Mode() != theDispMode)
+          continue;
+
+        aBox = aPrsIter.Value().Presentation()->Presentation()->MinMaxValues();
+      }
       gp_Pnt aMin = aBox.CornerMin();
       gp_Pnt aMax = aBox.CornerMax();
       theDI << theName  << "\n"
@@ -2801,6 +3108,8 @@ int VBounding (Draw_Interpretor& theDI,
   ViewerTest_BndAction anAction = BndAction_Show;
   Standard_Integer     aMode    = -1;
 
+  Handle(Prs3d_Drawer) aStyle;
+
   Standard_Integer anArgIter = 1;
   for (; anArgIter < theArgNb; ++anArgIter)
   {
@@ -2833,6 +3142,14 @@ int VBounding (Draw_Interpretor& theDI,
     }
   }
 
+  if (anAction == BndAction_Show)
+  {
+    aStyle = new Prs3d_Drawer();
+    aStyle->SetMethod (Aspect_TOHM_BOUNDBOX);
+    aStyle->SetColor  (Quantity_NOC_GRAY99);
+  }
+
+  Standard_Integer aHighlightedMode = -1;
   if (anArgIter < theArgNb)
   {
     // has a list of names
@@ -2846,25 +3163,26 @@ int VBounding (Draw_Interpretor& theDI,
       }
 
       Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aName));
-      Handle(PrsMgr_Presentation)   aPrs = findPresentation (aCtx, anIO, aMode);
-      if (aPrs.IsNull())
+      aHighlightedMode = checkMode (aCtx, anIO, aMode);
+      if (aHighlightedMode == -1)
       {
-        std::cout << "Error: presentation " << aName << " does not exist\n";
+        std::cout << "Error: object " << aName << " has no presentation with mode " << aMode << std::endl;
         return 1;
       }
-      bndPresentation (theDI, aPrs, aName, anAction);
+      bndPresentation (theDI, aCtx->MainPrsMgr(), anIO, aHighlightedMode, aName, anAction, aStyle);
     }
   }
-  else if (aCtx->NbCurrents() > 0)
+  else if (aCtx->NbSelected() > 0)
   {
     // remove all currently selected objects
-    for (aCtx->InitCurrent(); aCtx->MoreCurrent(); aCtx->NextCurrent())
+    for (aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected())
     {
-      Handle(AIS_InteractiveObject) anIO = aCtx->Current();
-      Handle(PrsMgr_Presentation)   aPrs = findPresentation (aCtx, anIO, aMode);
-      if (!aPrs.IsNull())
+      Handle(AIS_InteractiveObject) anIO = aCtx->SelectedInteractive();
+      aHighlightedMode = checkMode (aCtx, anIO, aMode);
+      if (aHighlightedMode != -1)
       {
-        bndPresentation (theDI, aPrs, GetMapOfAIS().IsBound1 (anIO) ? GetMapOfAIS().Find1 (anIO) : "", anAction);
+        bndPresentation (theDI, aCtx->MainPrsMgr(), anIO, aHighlightedMode,
+          GetMapOfAIS().IsBound1 (anIO) ? GetMapOfAIS().Find1 (anIO) : "", anAction, aStyle);
       }
     }
   }
@@ -2875,10 +3193,10 @@ int VBounding (Draw_Interpretor& theDI,
          anIter.More(); anIter.Next())
     {
       Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
-      Handle(PrsMgr_Presentation)   aPrs = findPresentation (aCtx, anIO, aMode);
-      if (!aPrs.IsNull())
+      aHighlightedMode = checkMode (aCtx, anIO, aMode);
+      if (aHighlightedMode != -1)
       {
-        bndPresentation (theDI, aPrs, anIter.Key2(), anAction);
+        bndPresentation (theDI, aCtx->MainPrsMgr(), anIO, aHighlightedMode, anIter.Key2(), anAction, aStyle);
       }
     }
   }
@@ -2898,7 +3216,7 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
   {
     if (theArgsNb < 2)
     {
-      std::cout << theArgv[0] << ": " << " invalid arguments.\n";
+      std::cout << theArgv[0] << ":  invalid arguments.\n";
       std::cout << "Type help for more information.\n";
       return 1;
     }
@@ -2935,7 +3253,7 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
     // equal to -scale, -origin, -repeat options of vtexture command
     if (theArgsNb < 2 || theArgsNb > 4)
     {
-      std::cout << theArgv[0] << ": " << " invalid arguments.\n";
+      std::cout << theArgv[0] << ":  invalid arguments.\n";
       std::cout << "Type help for more information.\n";
       return 1;
     }
@@ -3013,14 +3331,12 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
   Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
   if (anAISContext.IsNull())
   {
-    std::cout << aCommandName << ": " << " please use 'vinit' command to initialize view.\n";
+    std::cout << aCommandName << ":  please use 'vinit' command to initialize view.\n";
     return 1;
   }
 
   Standard_Integer aPreviousMode = 0;
 
-  ViewerTest::CurrentView()->SetSurfaceDetail (V3d_TEX_ALL);
-
   TCollection_AsciiString aShapeName (theArgv[1]);
   Handle(AIS_InteractiveObject) anIO;
 
@@ -3044,8 +3360,15 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
   }
   else
   {
-    anAISContext->Remove (anIO, Standard_False);
     aTexturedIO = new AIS_TexturedShape (DBRep::Get (theArgv[1]));
+
+    if (anIO->HasTransformation())
+    {
+      const gp_Trsf& aLocalTrsf = anIO->LocalTransformation();
+      aTexturedIO->SetLocalTransformation (aLocalTrsf);
+    }
+
+    anAISContext->Remove (anIO, Standard_False);
     GetMapOfAIS().UnBind1 (anIO);
     GetMapOfAIS().UnBind2 (aShapeName);
     GetMapOfAIS().Bind (aTexturedIO, aShapeName);
@@ -3061,13 +3384,13 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
 
     if (aTextureArg.IsEmpty())
     {
-      std::cout << aCommandName << ": " << " Texture mapping disabled.\n";
-      std::cout << "To enable it, use 'vtexture NameOfShape NameOfTexture'\n" << "\n";
+      std::cout << aCommandName << ":  Texture mapping disabled.\n";
+      std::cout << "To enable it, use 'vtexture NameOfShape NameOfTexture'\n\n";
 
       anAISContext->SetDisplayMode (aTexturedIO, AIS_Shaded, Standard_False);
       if (aPreviousMode == 3)
       {
-        anAISContext->RecomputePrsOnly (aTexturedIO);
+        anAISContext->RecomputePrsOnly (aTexturedIO, Standard_False);
       }
 
       anAISContext->Display (aTexturedIO, Standard_True);
@@ -3079,14 +3402,14 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
       {
         TCollection_AsciiString aTextureFolder = Graphic3d_TextureRoot::TexturesFolder();
 
-        theDi << "\n Files in current directory : \n" << "\n";
+        theDi << "\n Files in current directory : \n\n";
         theDi.Eval ("glob -nocomplain *");
 
         TCollection_AsciiString aCmnd ("glob -nocomplain ");
         aCmnd += aTextureFolder;
         aCmnd += "/* ";
 
-        theDi << "Files in " << aTextureFolder.ToCString() << " : \n" << "\n";
+        theDi << "Files in " << aTextureFolder.ToCString() << " : \n\n";
         theDi.Eval (aCmnd.ToCString());
         return 0;
       }
@@ -3162,7 +3485,7 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
 
   if (aTexturedIO->DisplayMode() == 3 || aPreviousMode == 3)
   {
-    anAISContext->RecomputePrsOnly (aTexturedIO);
+    anAISContext->RecomputePrsOnly (aTexturedIO, Standard_True);
   }
   else
   {
@@ -3176,27 +3499,24 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
 
 //! Auxiliary method to parse transformation persistence flags
 inline Standard_Boolean parseTrsfPersFlag (const TCollection_AsciiString& theFlagString,
-                                           Standard_Integer&              theFlags)
+                                           Graphic3d_TransModeFlags&      theFlags)
 {
-  if (theFlagString == "pan")
+  if (theFlagString == "zoom")
   {
-    theFlags |= Graphic3d_TMF_PanPers;
-  }
-  else if (theFlagString == "zoom")
-  {
-    theFlags |= Graphic3d_TMF_ZoomPers;
+    theFlags = Graphic3d_TMF_ZoomPers;
   }
   else if (theFlagString == "rotate")
   {
-    theFlags |= Graphic3d_TMF_RotatePers;
+    theFlags = Graphic3d_TMF_RotatePers;
   }
-  else if (theFlagString == "trihedron")
+  else if (theFlagString == "zoomrotate")
   {
-    theFlags = Graphic3d_TMF_TriedronPers;
+    theFlags = Graphic3d_TMF_ZoomRotatePers;
   }
-  else if (theFlagString == "full")
+  else if (theFlagString == "trihedron"
+        || theFlagString == "triedron")
   {
-    theFlags = Graphic3d_TMF_FullPers;
+    theFlags = Graphic3d_TMF_TriedronPers;
   }
   else if (theFlagString == "none")
   {
@@ -3210,6 +3530,66 @@ inline Standard_Boolean parseTrsfPersFlag (const TCollection_AsciiString& theFla
   return Standard_True;
 }
 
+//! Auxiliary method to parse transformation persistence flags
+inline Standard_Boolean parseTrsfPersCorner (const TCollection_AsciiString& theString,
+                                             Aspect_TypeOfTriedronPosition& theCorner)
+{
+  TCollection_AsciiString aString (theString);
+  aString.LowerCase();
+  if (aString == "center")
+  {
+    theCorner = Aspect_TOTP_CENTER;
+  }
+  else if (aString == "top"
+        || aString == "upper")
+  {
+    theCorner = Aspect_TOTP_TOP;
+  }
+  else if (aString == "bottom"
+        || aString == "lower")
+  {
+    theCorner = Aspect_TOTP_BOTTOM;
+  }
+  else if (aString == "left")
+  {
+    theCorner = Aspect_TOTP_LEFT;
+  }
+  else if (aString == "right")
+  {
+    theCorner = Aspect_TOTP_RIGHT;
+  }
+  else if (aString == "topleft"
+        || aString == "leftupper"
+        || aString == "upperleft")
+  {
+    theCorner = Aspect_TOTP_LEFT_UPPER;
+  }
+  else if (aString == "bottomleft"
+        || aString == "leftlower"
+        || aString == "lowerleft")
+  {
+    theCorner = Aspect_TOTP_LEFT_LOWER;
+  }
+  else if (aString == "topright"
+        || aString == "rightupper"
+        || aString == "upperright")
+  {
+    theCorner = Aspect_TOTP_RIGHT_UPPER;
+  }
+  else if (aString == "bottomright"
+        || aString == "lowerright"
+        || aString == "rightlower")
+  {
+    theCorner = Aspect_TOTP_RIGHT_LOWER;
+  }
+  else
+  {
+    return Standard_False;
+  }
+
+  return Standard_True;
+}
+
 //==============================================================================
 //function : VDisplay2
 //author   : ege
@@ -3242,8 +3622,7 @@ static int VDisplay2 (Draw_Interpretor& theDI,
   Standard_Integer   anObjDispMode  = -2;
   Standard_Integer   anObjHighMode  = -2;
   Standard_Boolean   toSetTrsfPers  = Standard_False;
-  Graphic3d_TransModeFlags aTrsfPersFlags = Graphic3d_TMF_None;
-  gp_Pnt aTPPosition;
+  Handle(Graphic3d_TransformPers) aTrsfPers;
   TColStd_SequenceOfAsciiString aNamesOfDisplayIO;
   AIS_DisplayStatus aDispStatus = AIS_DS_None;
   Standard_Integer toDisplayInView = Standard_False;
@@ -3319,56 +3698,71 @@ static int VDisplay2 (Draw_Interpretor& theDI,
     else if (aNameCase == "-3d")
     {
       toSetTrsfPers  = Standard_True;
-      aTrsfPersFlags = Graphic3d_TMF_None;
-    }
-    else if (aNameCase == "-2d")
-    {
-      toSetTrsfPers  = Standard_True;
-      aTrsfPersFlags = Graphic3d_TMF_2d;
+      aTrsfPers.Nullify();
     }
-    else if (aNameCase == "-2dtopdown")
+    else if (aNameCase == "-2d"
+          || aNameCase == "-trihedron"
+          || aNameCase == "-triedron")
     {
       toSetTrsfPers  = Standard_True;
-      aTrsfPersFlags = Graphic3d_TMF_2d | Graphic3d_TMF_2d_IsTopDown;
+      aTrsfPers = new Graphic3d_TransformPers (aNameCase == "-2d" ? Graphic3d_TMF_2d : Graphic3d_TMF_TriedronPers, Aspect_TOTP_LEFT_LOWER);
+
+      if (anArgIter + 1 < theArgNb)
+      {
+        Aspect_TypeOfTriedronPosition aCorner = Aspect_TOTP_CENTER;
+        if (parseTrsfPersCorner (theArgVec[anArgIter + 1], aCorner))
+        {
+          ++anArgIter;
+          aTrsfPers->SetCorner2d (aCorner);
+
+          if (anArgIter + 2 < theArgNb)
+          {
+            TCollection_AsciiString anX (theArgVec[anArgIter + 1]);
+            TCollection_AsciiString anY (theArgVec[anArgIter + 2]);
+            if (anX.IsIntegerValue()
+             && anY.IsIntegerValue())
+            {
+              anArgIter += 2;
+              aTrsfPers->SetOffset2d (Graphic3d_Vec2i (anX.IntegerValue(), anY.IntegerValue()));
+            }
+          }
+        }
+      }
     }
     else if (aNameCase == "-trsfpers"
           || aNameCase == "-pers")
     {
-      if (++anArgIter >= theArgNb)
+      if (++anArgIter >= theArgNb
+       || !aTrsfPers.IsNull())
       {
         std::cerr << "Error: wrong syntax at " << aName << ".\n";
         return 1;
       }
 
       toSetTrsfPers  = Standard_True;
-      aTrsfPersFlags = Graphic3d_TMF_None;
+      Graphic3d_TransModeFlags aTrsfPersFlags = Graphic3d_TMF_None;
       TCollection_AsciiString aPersFlags (theArgVec [anArgIter]);
       aPersFlags.LowerCase();
-      for (Standard_Integer aParserPos = aPersFlags.Search ("|");; aParserPos = aPersFlags.Search ("|"))
+      if (!parseTrsfPersFlag (aPersFlags, aTrsfPersFlags))
       {
-        if (aParserPos == -1)
-        {
-          if (!parseTrsfPersFlag (aPersFlags, aTrsfPersFlags))
-          {
-            std::cerr << "Error: wrong transform persistence flags " << theArgVec [anArgIter] << ".\n";
-            return 1;
-          }
-          break;
-        }
+        std::cerr << "Error: wrong transform persistence flags " << theArgVec [anArgIter] << ".\n";
+        return 1;
+      }
 
-        TCollection_AsciiString anOtherFlags = aPersFlags.Split (aParserPos - 1);
-        if (!parseTrsfPersFlag (aPersFlags, aTrsfPersFlags))
-        {
-          std::cerr << "Error: wrong transform persistence flags " << theArgVec [anArgIter] << ".\n";
-          return 1;
-        }
-        aPersFlags = anOtherFlags;
+      if (aTrsfPersFlags == Graphic3d_TMF_TriedronPers)
+      {
+        aTrsfPers = new Graphic3d_TransformPers (Graphic3d_TMF_TriedronPers, Aspect_TOTP_LEFT_LOWER);
+      }
+      else if (aTrsfPersFlags != Graphic3d_TMF_None)
+      {
+        aTrsfPers = new Graphic3d_TransformPers (aTrsfPersFlags, gp_Pnt());
       }
     }
     else if (aNameCase == "-trsfperspos"
           || aNameCase == "-perspos")
     {
-      if (anArgIter + 2 >= theArgNb)
+      if (anArgIter + 2 >= theArgNb
+       || aTrsfPers.IsNull())
       {
         std::cerr << "Error: wrong syntax at " << aName << ".\n";
         return 1;
@@ -3377,8 +3771,8 @@ static int VDisplay2 (Draw_Interpretor& theDI,
       TCollection_AsciiString aX (theArgVec[++anArgIter]);
       TCollection_AsciiString aY (theArgVec[++anArgIter]);
       TCollection_AsciiString aZ = "0";
-      if (!aX.IsIntegerValue()
-       || !aY.IsIntegerValue())
+      if (!aX.IsRealValue()
+       || !aY.IsRealValue())
       {
         std::cerr << "Error: wrong syntax at " << aName << ".\n";
         return 1;
@@ -3386,13 +3780,22 @@ static int VDisplay2 (Draw_Interpretor& theDI,
       if (anArgIter + 1 < theArgNb)
       {
         TCollection_AsciiString aTemp = theArgVec[anArgIter + 1];
-        if (aTemp.IsIntegerValue())
+        if (aTemp.IsRealValue())
         {
           aZ = aTemp;
           ++anArgIter;
         }
       }
-      aTPPosition.SetCoord (aX.IntegerValue(), aY.IntegerValue(), aZ.IntegerValue());
+
+      const gp_Pnt aPnt (aX.RealValue(), aY.RealValue(), aZ.RealValue());
+      if (aTrsfPers->IsZoomOrRotate())
+      {
+        aTrsfPers->SetAnchorPoint (aPnt);
+      }
+      else if (aTrsfPers->IsTrihedronOr2d())
+      {
+        aTrsfPers = Graphic3d_TransformPers::FromDeprecatedParams (aTrsfPers->Mode(), aPnt);
+      }
     }
     else if (aNameCase == "-layer")
     {
@@ -3438,6 +3841,7 @@ static int VDisplay2 (Draw_Interpretor& theDI,
   }
 
   // Prepare context for display
+  Standard_DISABLE_DEPRECATION_WARNINGS
   if (toDisplayLocal && !aCtx->HasOpenedContext())
   {
     aCtx->OpenLocalContext (Standard_False);
@@ -3446,6 +3850,7 @@ static int VDisplay2 (Draw_Interpretor& theDI,
   {
     aCtx->CloseAllContexts (Standard_False);
   }
+  Standard_ENABLE_DEPRECATION_WARNINGS
 
   // Display interactive objects
   for (Standard_Integer anIter = 1; anIter <= aNamesOfDisplayIO.Length(); ++anIter)
@@ -3468,7 +3873,7 @@ static int VDisplay2 (Draw_Interpretor& theDI,
         }
         if (toSetTrsfPers)
         {
-          aShape->SetTransformPersistence (aTrsfPersFlags, aTPPosition);
+          aCtx->SetTransformPersistence (aShape, aTrsfPers);
         }
         if (anObjDispMode != -2)
         {
@@ -3478,7 +3883,8 @@ static int VDisplay2 (Draw_Interpretor& theDI,
         {
           aShape->SetHilightMode (anObjHighMode);
         }
-        GetMapOfAIS().Bind (aShape, aName);
+        if (!toDisplayLocal)
+          GetMapOfAIS().Bind (aShape, aName);
 
         Standard_Integer aDispMode = aShape->HasDisplayMode()
                                    ? aShape->DisplayMode()
@@ -3486,12 +3892,9 @@ static int VDisplay2 (Draw_Interpretor& theDI,
                                     ? aCtx->DisplayMode()
                                     : 0);
         Standard_Integer aSelMode = -1;
-        if ( isSelectable ==  1
-         || (isSelectable == -1
-          && aCtx->GetAutoActivateSelection()
-          && aShape->GetTransformPersistenceMode() == 0))
+        if (isSelectable ==  1 || (isSelectable == -1 && aCtx->GetAutoActivateSelection()))
         {
-          aSelMode = aShape->HasSelectionMode() ? aShape->SelectionMode() : -1;
+          aSelMode = aShape->GlobalSelectionMode();
         }
 
         aCtx->Display (aShape, aDispMode, aSelMode,
@@ -3499,9 +3902,9 @@ static int VDisplay2 (Draw_Interpretor& theDI,
                        aDispStatus);
         if (toDisplayInView)
         {
-          for (aCtx->CurrentViewer()->InitDefinedViews(); aCtx->CurrentViewer()->MoreDefinedViews(); aCtx->CurrentViewer()->NextDefinedViews())
+          for (V3d_ListOfViewIterator aViewIter (aCtx->CurrentViewer()->DefinedViewIterator()); aViewIter.More(); aViewIter.Next())
           {
-            aCtx->SetViewAffinity (aShape, aCtx->CurrentViewer()->DefinedView(), Standard_False);
+            aCtx->SetViewAffinity (aShape, aViewIter.Value(), Standard_False);
           }
           aCtx->SetViewAffinity (aShape, ViewerTest::CurrentView(), Standard_True);
         }
@@ -3513,333 +3916,130 @@ static int VDisplay2 (Draw_Interpretor& theDI,
       continue;
     }
 
-    Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (aName);
-    if (anObj->IsKind (STANDARD_TYPE (AIS_InteractiveObject)))
+    Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aName));
+    if (isMutable != -1)
     {
-      Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (anObj);
-      if (isMutable != -1)
-      {
-        aShape->SetMutable (isMutable == 1);
-      }
-      if (aZLayer != Graphic3d_ZLayerId_UNKNOWN)
-      {
-        aShape->SetZLayer (aZLayer);
-      }
-      if (toSetTrsfPers)
-      {
-        aShape->SetTransformPersistence (aTrsfPersFlags, aTPPosition);
-      }
-      if (anObjDispMode != -2)
-      {
-        aShape->SetDisplayMode (anObjDispMode);
-      }
-      if (anObjHighMode != -2)
-      {
-        aShape->SetHilightMode (anObjHighMode);
-      }
-      Standard_Integer aDispMode = aShape->HasDisplayMode()
-                                  ? aShape->DisplayMode()
-                                  : (aShape->AcceptDisplayMode (aCtx->DisplayMode())
-                                  ? aCtx->DisplayMode()
-                                  : 0);
-      Standard_Integer aSelMode = -1;
-      if ( isSelectable ==  1
-       || (isSelectable == -1
-        && aCtx->GetAutoActivateSelection()
-        && aShape->GetTransformPersistenceMode() == 0))
-      {
-        aSelMode = aShape->HasSelectionMode() ? aShape->SelectionMode() : -1;
-      }
-
-      if (aShape->Type() == AIS_KOI_Datum)
-      {
-        aCtx->Display (aShape, Standard_False);
-      }
-      else
-      {
-        theDI << "Display " << aName.ToCString() << "\n";
-
-        // update the Shape in the AIS_Shape
-        TopoDS_Shape      aNewShape = GetShapeFromName (aName.ToCString());
-        Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(aShape);
-        if (!aShapePrs.IsNull())
-        {
-          if (!aShapePrs->Shape().IsEqual (aNewShape))
-          {
-            toReDisplay = Standard_True;
-          }
-          aShapePrs->Set (aNewShape);
-        }
-        if (toReDisplay)
-        {
-          aCtx->Redisplay (aShape, Standard_False);
-        }
-
-        if (aSelMode == -1)
-        {
-          aCtx->Erase (aShape);
-        }
-        aCtx->Display (aShape, aDispMode, aSelMode,
-                       Standard_False, aShape->AcceptShapeDecomposition(),
-                       aDispStatus);
-        if (toDisplayInView)
-        {
-          aCtx->SetViewAffinity (aShape, ViewerTest::CurrentView(), Standard_True);
-        }
-      }
+      aShape->SetMutable (isMutable == 1);
     }
-    else if (anObj->IsKind (STANDARD_TYPE (NIS_InteractiveObject)))
+    if (aZLayer != Graphic3d_ZLayerId_UNKNOWN)
     {
-      Handle(NIS_InteractiveObject) aShape = Handle(NIS_InteractiveObject)::DownCast (anObj);
-      TheNISContext()->Display (aShape);
+      aShape->SetZLayer (aZLayer);
     }
-  }
-
-  return 0;
-}
-
-//===============================================================================================
-//function : VUpdate
-//purpose  :
-//===============================================================================================
-static int VUpdate (Draw_Interpretor& /*theDi*/, Standard_Integer theArgsNb, const char** theArgVec)
-{
-  Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
-  if (aContextAIS.IsNull())
-  {
-    std::cout << theArgVec[0] << "AIS context is not available.\n";
-    return 1;
-  }
-
-  if (theArgsNb < 2)
-  {
-    std::cout << theArgVec[0] << ": insufficient arguments. Type help for more information.\n";
-    return 1;
-  }
-
-  const ViewerTest_DoubleMapOfInteractiveAndName& anAISMap = GetMapOfAIS();
-
-  AIS_ListOfInteractive aListOfIO;
-
-  for (int anArgIt = 1; anArgIt < theArgsNb; ++anArgIt)
-  {
-    TCollection_AsciiString aName = TCollection_AsciiString (theArgVec[anArgIt]);
-
-    Handle(AIS_InteractiveObject) anAISObj;
-    if (anAISMap.IsBound2 (aName))
+    if (toSetTrsfPers)
     {
-      anAISObj = Handle(AIS_InteractiveObject)::DownCast (anAISMap.Find2 (aName));
+      aCtx->SetTransformPersistence (aShape, aTrsfPers);
     }
-
-    if (anAISObj.IsNull())
+    if (anObjDispMode != -2)
     {
-      std::cout << theArgVec[0] << ": no AIS interactive object named \"" << aName << "\".\n";
-      return 1;
+      aShape->SetDisplayMode (anObjDispMode);
     }
-
-    aListOfIO.Append (anAISObj);
-  }
-
-  AIS_ListIteratorOfListOfInteractive anIOIt (aListOfIO);
-  for (; anIOIt.More(); anIOIt.Next())
-  {
-    aContextAIS->Update (anIOIt.Value(), Standard_False);
-  }
-
-  aContextAIS->UpdateCurrentViewer();
-
-  return 0;
-}
-
-//==============================================================================
-//function : VPerf
-//purpose  : Test the annimation of an object along a
-//           predifined trajectory
-//Draw arg : vperf ShapeName 1/0(Transfo/Location) 1/0(Primitives sensibles ON/OFF)
-//==============================================================================
-
-static int VPerf(Draw_Interpretor& di, Standard_Integer , const char** argv) {
-
-  OSD_Timer myTimer;
-  if (TheAISContext()->HasOpenedContext())
-    TheAISContext()->CloseLocalContext();
-
-  Standard_Real Step=4*M_PI/180;
-  Standard_Real Angle=0;
-
-  Handle(AIS_InteractiveObject) aIO;
-  if (GetMapOfAIS().IsBound2(argv[1]))
-    aIO = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(argv[1]));
-  if (aIO.IsNull())
-    return 1;
-
-  Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(aIO);
-
-  myTimer.Start();
-
-  if (Draw::Atoi(argv[3])==1 ) {
-    di<<" Primitives sensibles OFF"<<"\n";
-    TheAISContext()->Deactivate(aIO);
-  }
-  else {
-    di<<" Primitives sensibles ON"<<"\n";
-  }
-  // Movement par transformation
-  if(Draw::Atoi(argv[2]) ==1) {
-    di<<" Calcul par Transformation"<<"\n";
-    for (Standard_Real myAngle=0;Angle<10*2*M_PI; myAngle++) {
-
-      Angle=Step*myAngle;
-      gp_Trsf myTransfo;
-      myTransfo.SetRotation(gp_Ax1(gp_Pnt(0,0,0),gp_Dir(0,0,1) ) ,Angle );
-      TheAISContext()->SetLocation(aShape,myTransfo);
-      TheAISContext() ->UpdateCurrentViewer();
-
+    if (anObjHighMode != -2)
+    {
+      aShape->SetHilightMode (anObjHighMode);
     }
-  }
-  else {
-    di<<" Calcul par Locations"<<"\n";
-    gp_Trsf myAngleTrsf;
-    myAngleTrsf.SetRotation(gp_Ax1(gp_Pnt(0,0,0),gp_Dir(0,0,1) ), Step  );
-    TopLoc_Location myDeltaAngle (myAngleTrsf);
-    TopLoc_Location myTrueLoc;
-
-    for (Standard_Real myAngle=0;Angle<10*2*M_PI; myAngle++) {
-
-      Angle=Step*myAngle;
-      myTrueLoc=myTrueLoc*myDeltaAngle;
-      TheAISContext()->SetLocation(aShape,myTrueLoc );
-      TheAISContext() ->UpdateCurrentViewer();
+    Standard_Integer aDispMode = aShape->HasDisplayMode()
+                                ? aShape->DisplayMode()
+                                : (aShape->AcceptDisplayMode (aCtx->DisplayMode())
+                                ? aCtx->DisplayMode()
+                                : 0);
+    Standard_Integer aSelMode = -1;
+    if (isSelectable ==  1 || (isSelectable == -1 && aCtx->GetAutoActivateSelection()))
+    {
+      aSelMode = aShape->GlobalSelectionMode();
     }
-  }
-  if (Draw::Atoi(argv[3])==1 ){
-    // On reactive la selection des primitives sensibles
-    TheAISContext()->Activate(aIO,0);
-  }
-  a3DView() -> Redraw();
-  myTimer.Stop();
-  di<<" Temps ecoule "<<"\n";
-  myTimer.Show();
-  return 0;
-}
-
-
-//==================================================================================
-// Function : VAnimation
-//==================================================================================
-static int VAnimation (Draw_Interpretor& di, Standard_Integer argc, const char** argv) {
-  if (argc != 5) {
-    di<<"Use: "<<argv[0]<<" CrankArmFile CylinderHeadFile PropellerFile EngineBlockFile"<<"\n";
-    return 1;
-  }
-
-  Standard_Real thread = 4;
-  Standard_Real angleA=0;
-  Standard_Real angleB;
-  Standard_Real X;
-  gp_Ax1 Ax1(gp_Pnt(0,0,0),gp_Vec(0,0,1));
 
-  BRep_Builder B;
-  TopoDS_Shape CrankArm;
-  TopoDS_Shape CylinderHead;
-  TopoDS_Shape Propeller;
-  TopoDS_Shape EngineBlock;
-
-  //BRepTools::Read(CrankArm,"/dp_26/Indus/ege/assemblage/CrankArm.rle",B);
-  //BRepTools::Read(CylinderHead,"/dp_26/Indus/ege/assemblage/CylinderHead.rle",B);
-  //BRepTools::Read(Propeller,"/dp_26/Indus/ege/assemblage/Propeller.rle",B);
-  //BRepTools::Read(EngineBlock,"/dp_26/Indus/ege/assemblage/EngineBlock.rle",B);
-  BRepTools::Read(CrankArm,argv[1],B);
-  BRepTools::Read(CylinderHead,argv[2],B);
-  BRepTools::Read(Propeller,argv[3],B);
-  BRepTools::Read(EngineBlock,argv[4],B);
-
-  if (CrankArm.IsNull() || CylinderHead.IsNull() || Propeller.IsNull() || EngineBlock.IsNull()) {di<<" Syntaxe error:loading failure."<<"\n";}
-
-
-  OSD_Timer myTimer;
-  myTimer.Start();
-
-  Handle(AIS_Shape) myAisCylinderHead = new AIS_Shape (CylinderHead);
-  Handle(AIS_Shape) myAisEngineBlock  = new AIS_Shape (EngineBlock);
-  Handle(AIS_Shape) myAisCrankArm     = new AIS_Shape (CrankArm);
-  Handle(AIS_Shape) myAisPropeller    = new AIS_Shape (Propeller);
-
-  GetMapOfAIS().Bind(myAisCylinderHead,"a");
-  GetMapOfAIS().Bind(myAisEngineBlock,"b");
-  GetMapOfAIS().Bind(myAisCrankArm,"c");
-  GetMapOfAIS().Bind(myAisPropeller,"d");
-
-  myAisCylinderHead->SetMutable (Standard_True);
-  myAisEngineBlock ->SetMutable (Standard_True);
-  myAisCrankArm    ->SetMutable (Standard_True);
-  myAisPropeller   ->SetMutable (Standard_True);
-
-  TheAISContext()->SetColor (myAisCylinderHead, Quantity_NOC_INDIANRED);
-  TheAISContext()->SetColor (myAisEngineBlock,  Quantity_NOC_RED);
-  TheAISContext()->SetColor (myAisPropeller,    Quantity_NOC_GREEN);
-
-  TheAISContext()->Display (myAisCylinderHead, Standard_False);
-  TheAISContext()->Display (myAisEngineBlock,  Standard_False);
-  TheAISContext()->Display (myAisCrankArm,     Standard_False);
-  TheAISContext()->Display (myAisPropeller,    Standard_False);
-
-  TheAISContext()->Deactivate(myAisCylinderHead);
-  TheAISContext()->Deactivate(myAisEngineBlock );
-  TheAISContext()->Deactivate(myAisCrankArm    );
-  TheAISContext()->Deactivate(myAisPropeller   );
-
-  // Boucle de mouvement
-  for (Standard_Real myAngle = 0;angleA<2*M_PI*10.175 ;myAngle++) {
+    if (aShape->Type() == AIS_KOI_Datum)
+    {
+      aCtx->Display (aShape, Standard_False);
+    }
+    else
+    {
+      theDI << "Display " << aName.ToCString() << "\n";
 
-    angleA = thread*myAngle*M_PI/180;
-    X = Sin(angleA)*3/8;
-    angleB = atan(X / Sqrt(-X * X + 1));
-    Standard_Real decal(25*0.6);
+      // update the Shape in the AIS_Shape
+      TopoDS_Shape      aNewShape = GetShapeFromName (aName.ToCString());
+      Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(aShape);
+      if (!aShapePrs.IsNull())
+      {
+        if (!aShapePrs->Shape().IsEqual (aNewShape))
+        {
+          toReDisplay = Standard_True;
+        }
+        aShapePrs->Set (aNewShape);
+      }
+      if (toReDisplay)
+      {
+        aCtx->Redisplay (aShape, Standard_False);
+      }
 
+      if (aSelMode == -1)
+      {
+        aCtx->Erase (aShape, Standard_False);
+      }
+      aCtx->Display (aShape, aDispMode, aSelMode,
+                     Standard_False, aShape->AcceptShapeDecomposition(),
+                     aDispStatus);
+      if (toDisplayInView)
+      {
+        aCtx->SetViewAffinity (aShape, ViewerTest::CurrentView(), Standard_True);
+      }
+    }
+  }
 
-    //Build a transformation on the display
-    gp_Trsf aPropellerTrsf;
-    aPropellerTrsf.SetRotation(Ax1,angleA);
-    TheAISContext()->SetLocation(myAisPropeller,aPropellerTrsf);
+  return 0;
+}
 
-    gp_Ax3 base(gp_Pnt(3*decal*(1-Cos(angleA)),-3*decal*Sin(angleA),0),gp_Vec(0,0,1),gp_Vec(1,0,0));
-    gp_Trsf aCrankArmTrsf;
-    aCrankArmTrsf.SetTransformation(   base.Rotated(gp_Ax1(gp_Pnt(3*decal,0,0),gp_Dir(0,0,1)),angleB));
-    TheAISContext()->SetLocation(myAisCrankArm,aCrankArmTrsf);
+//===============================================================================================
+//function : VUpdate
+//purpose  :
+//===============================================================================================
+static int VUpdate (Draw_Interpretor& /*theDi*/, Standard_Integer theArgsNb, const char** theArgVec)
+{
+  Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
+  if (aContextAIS.IsNull())
+  {
+    std::cout << theArgVec[0] << "AIS context is not available.\n";
+    return 1;
+  }
 
-    TheAISContext()->UpdateCurrentViewer();
+  if (theArgsNb < 2)
+  {
+    std::cout << theArgVec[0] << ": insufficient arguments. Type help for more information.\n";
+    return 1;
   }
 
-  TopoDS_Shape myNewCrankArm  =myAisCrankArm ->Shape().Located( myAisCrankArm ->Transformation() );
-  TopoDS_Shape myNewPropeller =myAisPropeller->Shape().Located( myAisPropeller->Transformation() );
+  const ViewerTest_DoubleMapOfInteractiveAndName& anAISMap = GetMapOfAIS();
 
-  myAisCrankArm ->ResetTransformation();
-  myAisPropeller->ResetTransformation();
+  AIS_ListOfInteractive aListOfIO;
 
-  myAisCrankArm  -> Set(myNewCrankArm );
-  myAisPropeller -> Set(myNewPropeller);
+  for (int anArgIt = 1; anArgIt < theArgsNb; ++anArgIt)
+  {
+    TCollection_AsciiString aName = TCollection_AsciiString (theArgVec[anArgIt]);
 
-  TheAISContext()->Activate(myAisCylinderHead,0);
-  TheAISContext()->Activate(myAisEngineBlock,0 );
-  TheAISContext()->Activate(myAisCrankArm ,0   );
-  TheAISContext()->Activate(myAisPropeller ,0  );
+    Handle(AIS_InteractiveObject) anAISObj;
+    if (anAISMap.IsBound2 (aName))
+    {
+      anAISObj = Handle(AIS_InteractiveObject)::DownCast (anAISMap.Find2 (aName));
+    }
 
-  myTimer.Stop();
-  myTimer.Show();
-  myTimer.Start();
+    if (anAISObj.IsNull())
+    {
+      std::cout << theArgVec[0] << ": no AIS interactive object named \"" << aName << "\".\n";
+      return 1;
+    }
 
-  TheAISContext()->Redisplay(myAisCrankArm ,Standard_False);
-  TheAISContext()->Redisplay(myAisPropeller,Standard_False);
+    aListOfIO.Append (anAISObj);
+  }
 
-  TheAISContext()->UpdateCurrentViewer();
-  a3DView()->Redraw();
+  AIS_ListIteratorOfListOfInteractive anIOIt (aListOfIO);
+  for (; anIOIt.More(); anIOIt.Next())
+  {
+    aContextAIS->Update (anIOIt.Value(), Standard_False);
+  }
 
-  myTimer.Stop();
-  myTimer.Show();
+  aContextAIS->UpdateCurrentViewer();
 
   return 0;
-
 }
 
 //==============================================================================
@@ -3854,10 +4054,6 @@ static int VShading(Draw_Interpretor& ,Standard_Integer argc, const char** argv)
 
   // Verifications
   const Standard_Boolean HaveToSet = (strcasecmp(argv[0],"vsetshading") == 0);
-
-  if (TheAISContext()->HasOpenedContext())
-    TheAISContext()->CloseLocalContext();
-
   if (argc < 3) {
     myDevCoef  = 0.0008;
   } else {
@@ -3875,7 +4071,7 @@ static int VShading(Draw_Interpretor& ,Standard_Integer argc, const char** argv)
   else
     TheAISContext()->SetDeviationCoefficient(TheAisIO,0.0008,Standard_True);
 
-  TheAISContext()->Redisplay(TheAisIO);
+  TheAISContext()->Redisplay (TheAisIO, Standard_True);
   return 0;
 }
 //==============================================================================
@@ -3920,18 +4116,23 @@ static int VActivatedMode (Draw_Interpretor& di, Standard_Integer argc, const ch
     const Standard_Boolean HaveToSet = (strcasecmp(argv[0],"vsetam") == 0);
     // verification des arguments
     if (HaveToSet) {
-      if (argc<2||argc>3) { di<<" Syntaxe error"<<"\n";return 1;}
+      if (argc<2||argc>3) { di<<" Syntaxe error\n";return 1;}
       ThereIsName = (argc == 3);
     }
-    else {
+    else
+    {
+      Standard_DISABLE_DEPRECATION_WARNINGS
       // vunsetam
-      if (argc>1) {di<<" Syntaxe error"<<"\n";return 1;}
+      if (argc>1) {di<<" Syntaxe error\n";return 1;}
       else {
-        di<<" R.A.Z de tous les modes de selecion"<<"\n";
-        di<<" Fermeture du Context local"<<"\n";
+        di<<" R.A.Z de tous les modes de selecion\n";
+        di<<" Fermeture du Context local\n";
         if (TheAISContext()->HasOpenedContext())
+        {
           TheAISContext()->CloseLocalContext();
+        }
       }
+      Standard_ENABLE_DEPRECATION_WARNINGS
     }
 
     // IL n'y a aps de nom de shape passe en argument
@@ -3956,15 +4157,17 @@ static int VActivatedMode (Draw_Interpretor& di, Standard_Integer argc, const ch
         // on load tous les objets displayees et on Activate les objets de la liste
         AIS_ListOfInteractive ListOfIO;
         // on sauve dans une AISListOfInteractive tous les objets currents
-        if (TheAISContext()->NbCurrents()>0 ){
-          TheAISContext()->UnhilightCurrents(Standard_False);
+        if (TheAISContext()->NbSelected()>0 ){
+          TheAISContext()->UnhilightSelected(Standard_False);
 
-          for (TheAISContext()->InitCurrent(); TheAISContext()->MoreCurrent(); TheAISContext()->NextCurrent() ){
-            ListOfIO.Append(TheAISContext()->Current() );
+          for (TheAISContext()->InitSelected(); TheAISContext()->MoreSelected(); TheAISContext()->NextSelected() ){
+            ListOfIO.Append(TheAISContext()->SelectedInteractive() );
          }
        }
 
+  Standard_DISABLE_DEPRECATION_WARNINGS
        TheAISContext()->OpenLocalContext(Standard_False);
+  Standard_ENABLE_DEPRECATION_WARNINGS
        ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
           it (GetMapOfAIS());
        while(it.More()){
@@ -4008,7 +4211,7 @@ static int VActivatedMode (Draw_Interpretor& di, Standard_Integer argc, const ch
          TheAISContext()->UnhilightSelected(Standard_False);
          // il y a des objets selected,on les parcourt
          for (TheAISContext()->InitSelected(); TheAISContext()->MoreSelected(); TheAISContext()->NextSelected() ){
-           Handle(AIS_InteractiveObject) aIO=TheAISContext()->Interactive();
+           Handle(AIS_InteractiveObject) aIO=TheAISContext()->SelectedInteractive();
 
 
            if (HaveMode(aIO,aMode) ) {
@@ -4067,7 +4270,9 @@ static int VActivatedMode (Draw_Interpretor& di, Standard_Integer argc, const ch
         }
 
         if( !TheAISContext()->HasOpenedContext() ) {
+          Standard_DISABLE_DEPRECATION_WARNINGS
           TheAISContext()->OpenLocalContext(Standard_False);
+          Standard_ENABLE_DEPRECATION_WARNINGS
           // On charge tous les objets de la map
           ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS());
           while(it.More()){
@@ -4155,20 +4360,23 @@ static void objInfo (const NCollection_Map<Handle(AIS_InteractiveObject)>& theDe
 }
 
 //! Print information about locally selected sub-shapes
-static void localCtxInfo (Draw_Interpretor& theDI)
+template <typename T>
+static void printLocalSelectionInfo (const T& theContext, Draw_Interpretor& theDI)
 {
-  Handle(AIS_InteractiveContext) aCtx = TheAISContext();
-  if (!aCtx->HasOpenedContext())
-  {
-    return;
-  }
-
+  const Standard_Boolean isGlobalCtx = (theContext->DynamicType() == STANDARD_TYPE(AIS_InteractiveContext));
   TCollection_AsciiString aPrevName;
-  Handle(AIS_LocalContext) aCtxLoc = aCtx->LocalContext();
-  for (aCtxLoc->InitSelected(); aCtxLoc->MoreSelected(); aCtxLoc->NextSelected())
+  for (theContext->InitSelected(); theContext->MoreSelected(); theContext->NextSelected())
   {
-    const TopoDS_Shape      aSubShape = aCtxLoc->SelectedShape();
-    const Handle(AIS_Shape) aShapeIO  = Handle(AIS_Shape)::DownCast (aCtxLoc->SelectedInteractive());
+    const Handle(AIS_Shape) aShapeIO = Handle(AIS_Shape)::DownCast (theContext->SelectedInteractive());
+    const Handle(SelectMgr_EntityOwner) anOwner = theContext->SelectedOwner();
+    if (aShapeIO.IsNull() || anOwner.IsNull())
+      continue;
+    if (isGlobalCtx)
+    {
+      if (anOwner == aShapeIO->GlobalSelOwner())
+        continue;
+    }
+    const TopoDS_Shape      aSubShape = theContext->SelectedShape();
     if (aSubShape.IsNull()
       || aShapeIO.IsNull()
       || !GetMapOfAIS().IsBound1 (aShapeIO))
@@ -4265,26 +4473,24 @@ static Standard_Integer VState (Draw_Interpretor& theDI,
   if (toPrintEntities)
   {
     theDI << "Detected entities:\n";
+    Standard_DISABLE_DEPRECATION_WARNINGS
     Handle(StdSelect_ViewerSelector3d) aSelector = aCtx->HasOpenedContext() ? aCtx->LocalSelector() : aCtx->MainSelector();
-    for (aSelector->InitDetected(); aSelector->MoreDetected(); aSelector->NextDetected())
+    Standard_ENABLE_DEPRECATION_WARNINGS
+    SelectMgr_SelectingVolumeManager aMgr = aSelector->GetManager();
+    for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter)
     {
-      const Handle(SelectBasics_SensitiveEntity)& anEntity = aSelector->DetectedEntity();
+      const SelectMgr_SortCriterion&              aPickData = aSelector->PickedData (aPickIter);
+      const Handle(SelectBasics_SensitiveEntity)& anEntity = aSelector->PickedEntity (aPickIter);
       Handle(SelectMgr_EntityOwner) anOwner    = Handle(SelectMgr_EntityOwner)::DownCast (anEntity->OwnerId());
       Handle(AIS_InteractiveObject) anObj      = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
-      SelectMgr_SelectingVolumeManager aMgr = anObj->HasTransformation() ? aSelector->GetManager().Transform (anObj->InversedTransformation())
-                                                                         : aSelector->GetManager();
-      SelectBasics_PickResult aResult;
-      anEntity->Matches (aMgr, aResult);
-      NCollection_Vec3<Standard_Real> aDetectedPnt = aMgr.DetectedPoint (aResult.Depth());
-
       TCollection_AsciiString aName = GetMapOfAIS().Find1 (anObj);
       aName.LeftJustify (20, ' ');
       char anInfoStr[512];
       Sprintf (anInfoStr,
-               " Depth: %+.3f Distance: %+.3f Point: %+.3f %+.3f %+.3f",
-               aResult.Depth(),
-               aResult.DistToGeomCenter(),
-               aDetectedPnt.x(), aDetectedPnt.y(), aDetectedPnt.z());
+               " Depth: %g Distance: %g Point: %g %g %g",
+               aPickData.Depth,
+               aPickData.MinDist,
+               aPickData.Point.X(), aPickData.Point.Y(), aPickData.Point.Z());
       theDI << "  " << aName
             << anInfoStr
             << " (" << anEntity->DynamicType()->Name() << ")"
@@ -4306,15 +4512,25 @@ static Standard_Integer VState (Draw_Interpretor& theDI,
               << aSen->DynamicType()->Name()
               << "\n";
       }
+
+      Handle(Select3D_SensitivePrimitiveArray) aPrimArr = Handle(Select3D_SensitivePrimitiveArray)::DownCast (anEntity);
+      if (!aPrimArr.IsNull())
+      {
+        theDI << "                       Detected Element: "
+              << aPrimArr->LastDetectedElement()
+              << "\n";
+      }
     }
     return 0;
   }
 
   NCollection_Map<Handle(AIS_InteractiveObject)> aDetected;
+  Standard_DISABLE_DEPRECATION_WARNINGS
   for (aCtx->InitDetected(); aCtx->MoreDetected(); aCtx->NextDetected())
   {
     aDetected.Add (aCtx->DetectedCurrentObject());
   }
+  Standard_ENABLE_DEPRECATION_WARNINGS
 
   const Standard_Boolean toShowAll = (theArgNb >= 2 && *theArgVec[1] == '*');
   if (theArgNb >= 2
@@ -4339,18 +4555,27 @@ static Standard_Integer VState (Draw_Interpretor& theDI,
     return 0;
   }
 
-  if (aCtx->NbCurrents() > 0
-   && !toShowAll)
+  if (!aCtx->HasOpenedContext() && aCtx->NbSelected() > 0 && !toShowAll)
   {
-    for (aCtx->InitCurrent(); aCtx->MoreCurrent(); aCtx->NextCurrent())
+    NCollection_DataMap<Handle(SelectMgr_EntityOwner), TopoDS_Shape> anOwnerShapeMap;
+    for (aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected())
     {
-      Handle(AIS_InteractiveObject) anObj = aCtx->Current();
-      TCollection_AsciiString aName = GetMapOfAIS().Find1 (anObj);
-      aName.LeftJustify (20, ' ');
-      theDI << aName << " ";
-      objInfo (aDetected, anObj, theDI);
-      theDI << "\n";
+      const Handle(SelectMgr_EntityOwner) anOwner = aCtx->SelectedOwner();
+      const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
+      // handle whole object selection
+      if (anOwner == anObj->GlobalSelOwner())
+      {
+        TCollection_AsciiString aName = GetMapOfAIS().Find1 (anObj);
+        aName.LeftJustify (20, ' ');
+        theDI << aName << " ";
+        objInfo (aDetected, anObj, theDI);
+        theDI << "\n";
+      }
     }
+
+    // process selected sub-shapes
+    printLocalSelectionInfo (aCtx, theDI);
+
     return 0;
   }
 
@@ -4370,7 +4595,11 @@ static Standard_Integer VState (Draw_Interpretor& theDI,
     objInfo (aDetected, anObj, theDI);
     theDI << "\n";
   }
-  localCtxInfo (theDI);
+  printLocalSelectionInfo (aCtx, theDI);
+  Standard_DISABLE_DEPRECATION_WARNINGS
+  if (aCtx->HasOpenedContext())
+    printLocalSelectionInfo (aCtx->LocalContext(), theDI);
+  Standard_ENABLE_DEPRECATION_WARNINGS
   return 0;
 }
 
@@ -4384,7 +4613,9 @@ Standard_Boolean  ViewerTest::PickObjects(Handle(TColStd_HArray1OfTransient)& ar
                                          const Standard_Integer MaxPick)
 {
   Handle(AIS_InteractiveObject) IO;
+  Standard_DISABLE_DEPRECATION_WARNINGS
   Standard_Integer curindex = (TheType == AIS_KOI_None) ? 0 : TheAISContext()->OpenLocalContext();
+  Standard_ENABLE_DEPRECATION_WARNINGS
 
   // step 1: prepare the data
   if(curindex !=0){
@@ -4393,9 +4624,7 @@ Standard_Boolean  ViewerTest::PickObjects(Handle(TColStd_HArray1OfTransient)& ar
   }
 
   // step 2 : wait for the selection...
-//  Standard_Boolean IsGood (Standard_False);
-//  Standard_Integer NbPick(0);
-  Standard_Boolean NbPickGood (0),NbToReach(arr->Length());
+  Standard_Integer NbPickGood (0),NbToReach(arr->Length());
   Standard_Integer NbPickFail(0);
   Standard_Integer argccc = 5;
   const char *bufff[] = { "A", "B", "C","D", "E" };
@@ -4405,7 +4634,7 @@ Standard_Boolean  ViewerTest::PickObjects(Handle(TColStd_HArray1OfTransient)& ar
   while(NbPickGood<NbToReach && NbPickFail <= MaxPick){
     while(ViewerMainLoop(argccc,argvvv)){}
     Standard_Integer NbStored = TheAISContext()->NbSelected();
-    if((unsigned int ) NbStored != NbPickGood)
+    if(NbStored != NbPickGood)
       NbPickGood= NbStored;
     else
       NbPickFail++;
@@ -4414,7 +4643,8 @@ Standard_Boolean  ViewerTest::PickObjects(Handle(TColStd_HArray1OfTransient)& ar
 
   // step3 get result.
 
-  if((unsigned int ) NbPickFail >= NbToReach) return Standard_False;
+  if (NbPickFail >= NbToReach)
+    return Standard_False;
 
   Standard_Integer i(0);
   for(TheAISContext()->InitSelected();
@@ -4425,9 +4655,12 @@ Standard_Boolean  ViewerTest::PickObjects(Handle(TColStd_HArray1OfTransient)& ar
     arr->SetValue(i,IO2);
   }
 
-
-  if(curindex>0)
+  Standard_DISABLE_DEPRECATION_WARNINGS
+  if (curindex > 0)
+  {
     TheAISContext()->CloseLocalContext(curindex);
+  }
+  Standard_ENABLE_DEPRECATION_WARNINGS
 
   return Standard_True;
 }
@@ -4442,7 +4675,9 @@ Handle(AIS_InteractiveObject) ViewerTest::PickObject(const AIS_KindOfInteractive
                                                     const Standard_Integer MaxPick)
 {
   Handle(AIS_InteractiveObject) IO;
+  Standard_DISABLE_DEPRECATION_WARNINGS
   Standard_Integer curindex = (TheType == AIS_KOI_None) ? 0 : TheAISContext()->OpenLocalContext();
+  Standard_ENABLE_DEPRECATION_WARNINGS
 
   // step 1: prepare the data
 
@@ -4473,8 +4708,12 @@ Handle(AIS_InteractiveObject) ViewerTest::PickObject(const AIS_KindOfInteractive
     IO = TheAISContext()->SelectedInteractive();
   }
 
-  if(curindex!=0)
+  Standard_DISABLE_DEPRECATION_WARNINGS
+  if (curindex != 0)
+  {
     TheAISContext()->CloseLocalContext(curindex);
+  }
+  Standard_ENABLE_DEPRECATION_WARNINGS
   return IO;
 }
 
@@ -4489,8 +4728,9 @@ TopoDS_Shape ViewerTest::PickShape(const TopAbs_ShapeEnum TheType,
 {
 
   // step 1: prepare the data
-
+  Standard_DISABLE_DEPRECATION_WARNINGS
   Standard_Integer curindex = TheAISContext()->OpenLocalContext();
+  Standard_ENABLE_DEPRECATION_WARNINGS
   TopoDS_Shape result;
 
   if(TheType==TopAbs_SHAPE){
@@ -4500,8 +4740,9 @@ TopoDS_Shape ViewerTest::PickShape(const TopAbs_ShapeEnum TheType,
   else{
     Handle(StdSelect_ShapeTypeFilter) TF = new StdSelect_ShapeTypeFilter(TheType);
     TheAISContext()->AddFilter(TF);
+    Standard_DISABLE_DEPRECATION_WARNINGS
     TheAISContext()->ActivateStandardMode(TheType);
-
+    Standard_ENABLE_DEPRECATION_WARNINGS
   }
 
 
@@ -4529,12 +4770,16 @@ TopoDS_Shape ViewerTest::PickShape(const TopAbs_ShapeEnum TheType,
       result = TheAISContext()->SelectedShape();
     else{
       Handle(AIS_InteractiveObject) IO = TheAISContext()->SelectedInteractive();
-      result = (*((Handle(AIS_Shape)*) &IO))->Shape();
+      result = Handle(AIS_Shape)::DownCast (IO)->Shape();
     }
   }
 
-  if(curindex>0)
+  Standard_DISABLE_DEPRECATION_WARNINGS
+  if (curindex > 0)
+  {
     TheAISContext()->CloseLocalContext(curindex);
+  }
+  Standard_ENABLE_DEPRECATION_WARNINGS
 
   return result;
 }
@@ -4551,10 +4796,12 @@ Standard_Boolean ViewerTest::PickShapes (const TopAbs_ShapeEnum TheType,
 
   Standard_Integer Taille = thearr->Length();
   if(Taille>1)
-    cout<<" WARNING : Pick with Shift+ MB1 for Selection of more than 1 object"<<"\n";
+    cout<<" WARNING : Pick with Shift+ MB1 for Selection of more than 1 object\n";
 
   // step 1: prepare the data
+  Standard_DISABLE_DEPRECATION_WARNINGS
   Standard_Integer curindex = TheAISContext()->OpenLocalContext();
+  Standard_ENABLE_DEPRECATION_WARNINGS
   if(TheType==TopAbs_SHAPE){
     Handle(AIS_TypeFilter) F1 = new AIS_TypeFilter(AIS_KOI_Shape);
     TheAISContext()->AddFilter(F1);
@@ -4562,13 +4809,13 @@ Standard_Boolean ViewerTest::PickShapes (const TopAbs_ShapeEnum TheType,
   else{
     Handle(StdSelect_ShapeTypeFilter) TF = new StdSelect_ShapeTypeFilter(TheType);
     TheAISContext()->AddFilter(TF);
+    Standard_DISABLE_DEPRECATION_WARNINGS
     TheAISContext()->ActivateStandardMode(TheType);
-
+    Standard_ENABLE_DEPRECATION_WARNINGS
   }
 
   // step 2 : wait for the selection...
-
-  Standard_Boolean NbPickGood (0),NbToReach(thearr->Length());
+  Standard_Integer NbPickGood (0),NbToReach(thearr->Length());
   Standard_Integer NbPickFail(0);
   Standard_Integer argccc = 5;
   const char *bufff[] = { "A", "B", "C","D", "E" };
@@ -4578,7 +4825,7 @@ Standard_Boolean ViewerTest::PickShapes (const TopAbs_ShapeEnum TheType,
   while(NbPickGood<NbToReach && NbPickFail <= MaxPick){
     while(ViewerMainLoop(argccc,argvvv)){}
     Standard_Integer NbStored = TheAISContext()->NbSelected();
-    if((unsigned int ) NbStored != NbPickGood)
+    if (NbStored != NbPickGood)
       NbPickGood= NbStored;
     else
       NbPickFail++;
@@ -4587,7 +4834,8 @@ Standard_Boolean ViewerTest::PickShapes (const TopAbs_ShapeEnum TheType,
 
   // step3 get result.
 
-  if((unsigned int ) NbPickFail >= NbToReach) return Standard_False;
+  if (NbPickFail >= NbToReach)
+    return Standard_False;
 
   Standard_Integer i(0);
   for(TheAISContext()->InitSelected();TheAISContext()->MoreSelected();TheAISContext()->NextSelected()){
@@ -4596,11 +4844,13 @@ Standard_Boolean ViewerTest::PickShapes (const TopAbs_ShapeEnum TheType,
       thearr->SetValue(i,TheAISContext()->SelectedShape());
     else{
       Handle(AIS_InteractiveObject) IO = TheAISContext()->SelectedInteractive();
-      thearr->SetValue(i,(*((Handle(AIS_Shape)*) &IO))->Shape());
+      thearr->SetValue(i,Handle(AIS_Shape)::DownCast (IO)->Shape());
     }
   }
 
+  Standard_DISABLE_DEPRECATION_WARNINGS
   TheAISContext()->CloseLocalContext(curindex);
+  Standard_ENABLE_DEPRECATION_WARNINGS
   return Standard_True;
 }
 
@@ -4658,7 +4908,7 @@ static int VPickShape( Draw_Interpretor& di, Standard_Integer argc, const char**
 
     Handle(AIS_Shape) newsh = new AIS_Shape(PickSh);
     GetMapOfAIS().Bind(newsh, name);
-    TheAISContext()->Display(newsh);
+    TheAISContext()->Display (newsh, Standard_True);
     di<<"Nom de la shape pickee : "<<name.ToCString()<<"\n";
   }
 
@@ -4688,9 +4938,10 @@ static int VPickShape( Draw_Interpretor& di, Standard_Integer argc, const char**
        Handle(AIS_Shape) newsh = new AIS_Shape(PickSh);
        GetMapOfAIS().Bind(newsh, name);
        di<<"display of picke shape #"<<i<<" - nom : "<<name.ToCString()<<"\n";
-       TheAISContext()->Display(newsh);
+       TheAISContext()->Display (newsh, Standard_False);
 
       }
+      TheAISContext()->UpdateCurrentViewer();
     }
   }
   return 0;
@@ -4725,7 +4976,7 @@ static int VPickSelected (Draw_Interpretor& , Standard_Integer theArgNb, const c
     else
     {
       Handle(AIS_InteractiveObject) IO = TheAISContext()->SelectedInteractive();
-      aShape = (*((Handle(AIS_Shape)*) &IO))->Shape();
+      aShape = Handle(AIS_Shape)::DownCast (IO)->Shape();
     }
 
     TCollection_AsciiString aCurrentName = aName;
@@ -4738,9 +4989,11 @@ static int VPickSelected (Draw_Interpretor& , Standard_Integer theArgNb, const c
 
     Handle(AIS_Shape) aNewShape = new AIS_Shape (aShape);
     GetMapOfAIS().Bind (aNewShape, aCurrentName);
-    TheAISContext()->Display (aNewShape);
+    TheAISContext()->Display (aNewShape, Standard_False);
   }
 
+  TheAISContext()->UpdateCurrentViewer();
+
   return 0;
 }
 
@@ -4761,7 +5014,7 @@ static int VIOTypes( Draw_Interpretor& di, Standard_Integer , const char** )
     Colum[i].Center(20,' ');
   for(i=0;i<=2;i++)
     di<<"|"<<Colum[i].ToCString();
-  di<<"|"<<"\n";
+  di<<"|\n";
 
   di<<BlankLine.ToCString()<<"\n";
 
@@ -4785,7 +5038,7 @@ static int VIOTypes( Draw_Interpretor& di, Standard_Integer , const char** )
       curcolum[j].Center(20,' ');
       di<<"|"<<curcolum[j].ToCString();
     }
-    di<<"|"<<"\n";
+    di<<"|\n";
   }
   di<<BlankLine.ToCString()<<"\n";
 
@@ -4804,7 +5057,7 @@ static int VIOTypes( Draw_Interpretor& di, Standard_Integer , const char** )
       curcolum[j].Center(20,' ');
       di<<"|"<<curcolum[j].ToCString();
     }
-    di<<"|"<<"\n";
+    di<<"|\n";
   }
   di<<BlankLine.ToCString()<<"\n";
   // les IO de type objet...
@@ -4821,7 +5074,7 @@ static int VIOTypes( Draw_Interpretor& di, Standard_Integer , const char** )
       curcolum[j].Center(20,' ');
       di<<"|"<<curcolum[j].ToCString();
     }
-    di<<"|"<<"\n";
+    di<<"|\n";
   }
   di<<BlankLine.ToCString()<<"\n";
   // les contraintes et dimensions.
@@ -4840,7 +5093,7 @@ static int VIOTypes( Draw_Interpretor& di, Standard_Integer , const char** )
       curcolum[j].Center(20,' ');
       di<<"|"<<curcolum[j].ToCString();
     }
-    di<<"|"<<"\n";
+    di<<"|\n";
   }
   di<<BlankLine.ToCString()<<"\n";
 
@@ -4876,7 +5129,7 @@ static int VEraseType( Draw_Interpretor& , Standard_Integer argc, const char** a
     if(dimension_status == -1)
       TheAISContext()->Erase(curio,Standard_False);
     else {
-      AIS_KindOfDimension KOD = (*((Handle(AIS_Relation)*)&curio))->KindOfDimension();
+      AIS_KindOfDimension KOD = Handle(AIS_Relation)::DownCast (curio)->KindOfDimension();
       if ((dimension_status==0 && KOD == AIS_KOD_NONE)||
          (dimension_status==1 && KOD != AIS_KOD_NONE))
        TheAISContext()->Erase(curio,Standard_False);
@@ -4909,7 +5162,7 @@ static int VDisplayType(Draw_Interpretor& , Standard_Integer argc, const char**
     if(dimension_status == -1)
       TheAISContext()->Display(curio,Standard_False);
     else {
-      AIS_KindOfDimension KOD = (*((Handle(AIS_Relation)*)&curio))->KindOfDimension();
+      AIS_KindOfDimension KOD = Handle(AIS_Relation)::DownCast (curio)->KindOfDimension();
       if ((dimension_status==0 && KOD == AIS_KOD_NONE)||
          (dimension_status==1 && KOD != AIS_KOD_NONE))
        TheAISContext()->Display(curio,Standard_False);
@@ -4930,7 +5183,240 @@ static Standard_Integer vr(Draw_Interpretor& , Standard_Integer , const char** a
   DBRep::Set(a[1], shape);
   Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
   Handle(AIS_Shape) ais = new AIS_Shape(shape);
-  Ctx->Display(ais);
+  Ctx->Display (ais, Standard_True);
+  return 0;
+}
+
+//===============================================================================================
+//function : VBsdf
+//purpose  :
+//===============================================================================================
+static int VBsdf (Draw_Interpretor& theDi,
+                  Standard_Integer  theArgsNb,
+                  const char**      theArgVec)
+{
+  Handle(V3d_View)   aView   = ViewerTest::CurrentView();
+  Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
+  if (aView.IsNull()
+   || aViewer.IsNull())
+  {
+    std::cerr << "No active viewer!\n";
+    return 1;
+  }
+
+  ViewerTest_CmdParser aCmd;
+
+  aCmd.AddDescription ("Adjusts parameters of material BSDF:");
+  aCmd.AddOption ("print|echo|p", "Print BSDF");
+
+  aCmd.AddOption ("kd", "Weight of the Lambertian BRDF");
+  aCmd.AddOption ("kr", "Weight of the reflection BRDF");
+  aCmd.AddOption ("kt", "Weight of the transmission BTDF");
+  aCmd.AddOption ("ks", "Weight of the glossy Blinn BRDF");
+  aCmd.AddOption ("le", "Self-emitted radiance");
+
+  aCmd.AddOption ("fresnel|f", "Fresnel coefficients; Allowed fresnel formats are: Constant x, Schlick x y z, Dielectric x, Conductor x y");
+
+  aCmd.AddOption ("roughness|r",    "Roughness of material (Blinn's exponent)");
+  aCmd.AddOption ("absorpCoeff|af", "Absorption coeff (only for transparent material)");
+  aCmd.AddOption ("absorpColor|ac", "Absorption color (only for transparent material)");
+
+  aCmd.AddOption ("normalize|n", "Normalize BSDF coefficients");
+
+  aCmd.Parse (theArgsNb, theArgVec);
+
+  if (aCmd.HasOption ("help"))
+  {
+    theDi.PrintHelp (theArgVec[0]);
+    return 0;
+  }
+
+  TCollection_AsciiString aName (aCmd.Arg ("", 0).c_str());
+
+  // find object
+  ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
+  if (!aMap.IsBound2 (aName) )
+  {
+    std::cerr << "Use 'vdisplay' before\n";
+    return 1;
+  }
+
+  Handle(AIS_InteractiveObject) anIObj = Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (aName));
+  Graphic3d_MaterialAspect aMaterial = anIObj->Attributes()->ShadingAspect()->Material();
+  Graphic3d_BSDF aBSDF = aMaterial.BSDF();
+
+  if (aCmd.HasOption ("print"))
+  {
+    Graphic3d_Vec4 aFresnel = aBSDF.Fresnel.Serialize();
+
+    std::cout << "\n"
+      << "Kd:               " << aBSDF.Kd.r() << ", " << aBSDF.Kd.g() << ", " << aBSDF.Kd.b() << "\n"
+      << "Kr:               " << aBSDF.Kr.r() << ", " << aBSDF.Kr.g() << ", " << aBSDF.Kr.b() << "\n"
+      << "Kt:               " << aBSDF.Kt.r() << ", " << aBSDF.Kt.g() << ", " << aBSDF.Kt.b() << "\n"
+      << "Ks:               " << aBSDF.Ks.r() << ", " << aBSDF.Ks.g() << ", " << aBSDF.Ks.b() << "\n"
+      << "Le:               " << aBSDF.Le.r() << ", " << aBSDF.Le.g() << ", " << aBSDF.Le.b() << "\n"
+      << "Fresnel:          ";
+
+    if (aFresnel.x() >= 0.f)
+    {
+      std::cout
+        << "|Schlick| " << aFresnel.x() << ", " << aFresnel.y() << ", " << aFresnel.z() << "\n";
+    }
+    else if (aFresnel.x() >= -1.5f)
+    {
+      std::cout
+        << "|Constant| " << aFresnel.z() << "\n";
+    }
+    else if (aFresnel.x() >= -2.5f)
+    {
+      std::cout
+        << "|Conductor| " << aFresnel.y() << ", " << aFresnel.z() << "\n";
+    }
+    else
+    {
+      std::cout
+        << "|Dielectric| " << aFresnel.y() << "\n";
+    }
+
+
+    std::cout 
+      << "Roughness:        " << aBSDF.Roughness           << "\n"
+      << "Absorption coeff: " << aBSDF.AbsorptionCoeff     << "\n"
+      << "Absorption color: " << aBSDF.AbsorptionColor.r() << ", "
+                              << aBSDF.AbsorptionColor.g() << ", "
+                              << aBSDF.AbsorptionColor.b() << "\n";
+
+    return 0;
+  }
+
+  if (aCmd.HasOption ("roughness", 1, Standard_True))
+  {
+    aCmd.Arg ("roughness", 0);
+    aBSDF.Roughness = aCmd.ArgFloat ("roughness");
+  }
+
+  if (aCmd.HasOption ("absorpCoeff", 1, Standard_True))
+  {
+    aBSDF.AbsorptionCoeff = aCmd.ArgFloat ("absorpCoeff");
+  }
+
+  if (aCmd.HasOption ("absorpColor", 3, Standard_True))
+  {
+    aBSDF.AbsorptionColor = aCmd.ArgVec3f ("absorpColor");
+  }
+
+  if (aCmd.HasOption ("kd", 3))
+  {
+    aBSDF.Kd = aCmd.ArgVec3f ("kd");
+  }
+  else if (aCmd.HasOption ("kd", 1, Standard_True))
+  {
+    aBSDF.Kd = Graphic3d_Vec3 (aCmd.ArgFloat ("kd"));
+  }
+
+  if (aCmd.HasOption ("kr", 3))
+  {
+    aBSDF.Kr = aCmd.ArgVec3f ("kr");
+  }
+  else if (aCmd.HasOption ("kr", 1, Standard_True))
+  {
+    aBSDF.Kr = Graphic3d_Vec3 (aCmd.ArgFloat ("kr"));
+  }
+
+  if (aCmd.HasOption ("kt", 3))
+  {
+    aBSDF.Kt = aCmd.ArgVec3f ("kt");
+  }
+  else if (aCmd.HasOption ("kt", 1, Standard_True))
+  {
+    aBSDF.Kt = Graphic3d_Vec3 (aCmd.ArgFloat ("kt"));
+  }
+
+  if (aCmd.HasOption ("ks", 3))
+  {
+    aBSDF.Ks = aCmd.ArgVec3f ("ks");
+  }
+  else if (aCmd.HasOption ("ks", 1, Standard_True))
+  {
+    aBSDF.Ks = Graphic3d_Vec3 (aCmd.ArgFloat ("ks"));
+  }
+
+  if (aCmd.HasOption ("le", 3))
+  {
+    aBSDF.Le = aCmd.ArgVec3f ("le");
+  }
+  else if (aCmd.HasOption ("le", 1, Standard_True))
+  {
+    aBSDF.Le = Graphic3d_Vec3 (aCmd.ArgFloat ("le"));
+  }
+
+  const std::string aFresnelErrorMessage =
+    "Error! Wrong Fresnel type. Allowed types are: Constant x, Schlick x y z, Dielectric x, Conductor x y.\n";
+
+  if (aCmd.HasOption ("fresnel", 4)) // Schlick: type, x, y ,z
+  {
+    std::string aFresnelType = aCmd.Arg ("fresnel", 0);
+    std::transform (aFresnelType.begin(), aFresnelType.end(), aFresnelType.begin(), ::tolower);
+
+    if (aFresnelType == "schlick")
+    {
+      aBSDF.Fresnel = Graphic3d_Fresnel::CreateSchlick (
+        Graphic3d_Vec3 (static_cast<Standard_ShortReal> (Draw::Atof (aCmd.Arg ("fresnel", 1).c_str())),
+                        static_cast<Standard_ShortReal> (Draw::Atof (aCmd.Arg ("fresnel", 2).c_str())),
+                        static_cast<Standard_ShortReal> (Draw::Atof (aCmd.Arg ("fresnel", 3).c_str()))));
+    }
+    else
+    {
+      std::cout << aFresnelErrorMessage;
+    }
+  }
+  else if (aCmd.HasOption ("fresnel", 3)) // Conductor: type, x, y
+  {
+    std::string aFresnelType = aCmd.Arg ("fresnel", 0);
+    std::transform (aFresnelType.begin(), aFresnelType.end(), aFresnelType.begin(), ::tolower);
+
+    if (aFresnelType == "conductor")
+    {
+      aBSDF.Fresnel = Graphic3d_Fresnel::CreateConductor (
+        static_cast<Standard_ShortReal> (Draw::Atof (aCmd.Arg ("fresnel", 1).c_str())),
+        static_cast<Standard_ShortReal> (Draw::Atof (aCmd.Arg ("fresnel", 2).c_str())));
+    }
+    else
+    {
+      std::cout << aFresnelErrorMessage;
+    }
+  }
+  else if (aCmd.HasOption ("fresnel", 2)) // Dielectric, Constant: type, x
+  {
+    std::string aFresnelType = aCmd.Arg ("fresnel", 0);
+    std::transform (aFresnelType.begin(), aFresnelType.end(), aFresnelType.begin(), ::tolower);
+
+    if (aFresnelType == "dielectric")
+    {
+      aBSDF.Fresnel = Graphic3d_Fresnel::CreateDielectric (
+        static_cast<Standard_ShortReal> (Draw::Atof (aCmd.Arg ("fresnel", 1).c_str())));
+    }
+    else if (aFresnelType == "constant")
+    {
+      aBSDF.Fresnel = Graphic3d_Fresnel::CreateConstant (
+        static_cast<Standard_ShortReal> (Draw::Atof (aCmd.Arg ("fresnel", 1).c_str())));
+    }
+    else
+    {
+      std::cout << aFresnelErrorMessage;
+    }
+  }
+
+  if (aCmd.HasOption ("normalize"))
+  {
+    aBSDF.Normalize();
+  }
+
+  aMaterial.SetBSDF (aBSDF);
+  anIObj->SetMaterial (aMaterial);
+
+  aView->Redraw();
+
   return 0;
 }
 
@@ -4980,6 +5466,7 @@ static Standard_Integer VLoadSelection (Draw_Interpretor& /*theDi*/,
   }
 
   // Prepare context
+  Standard_DISABLE_DEPRECATION_WARNINGS
   if (isLocal && !aCtx->HasOpenedContext())
   {
     aCtx->OpenLocalContext (Standard_False);
@@ -4988,14 +5475,18 @@ static Standard_Integer VLoadSelection (Draw_Interpretor& /*theDi*/,
   {
     aCtx->CloseAllContexts (Standard_False);
   }
+  Standard_ENABLE_DEPRECATION_WARNINGS
 
   // Load selection of interactive objects
   for (Standard_Integer anIter = 1; anIter <= aNamesOfIO.Length(); ++anIter)
   {
     const TCollection_AsciiString& aName = aNamesOfIO.Value (anIter);
 
-    const Handle(AIS_InteractiveObject)& aShape = GetMapOfAIS().IsBound2 (aName) ?
-      Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aName)) : GetAISShapeFromName (aName.ToCString());
+    Handle(AIS_InteractiveObject) aShape;
+    if (GetMapOfAIS().IsBound2 (aName))
+      aShape = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aName));
+    else
+      aShape = GetAISShapeFromName (aName.ToCString());
 
     if (!aShape.IsNull())
     {
@@ -5005,53 +5496,8 @@ static Standard_Integer VLoadSelection (Draw_Interpretor& /*theDi*/,
       }
 
       aCtx->Load (aShape, -1, Standard_False);
-      aCtx->Activate (aShape, aShape->SelectionMode(), Standard_True);
-    }
-  }
-
-  return 0;
-}
-
-//==============================================================================
-//function : VAutoActivateSelection
-//purpose  : Activates or deactivates auto computation of selection
-//==============================================================================
-static int VAutoActivateSelection (Draw_Interpretor& theDi,
-                                   Standard_Integer theArgNb,
-                                   const char** theArgVec)
-{
-
-  if (theArgNb > 2)
-  {
-    std::cerr << theArgVec[0] << "Error: wrong number of arguments.\n";
-    return 1;
-  }
-
-  Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
-  if (aCtx.IsNull())
-  {
-    ViewerTest::ViewerInit();
-    aCtx = ViewerTest::GetAISContext();
-  }
-
-  if (theArgNb == 1)
-  {
-    TCollection_AsciiString aSelActivationString;
-    if (aCtx->GetAutoActivateSelection())
-    {
-      aSelActivationString.Copy ("ON");
+      aCtx->Activate (aShape, aShape->GlobalSelectionMode(), Standard_True);
     }
-    else
-    {
-      aSelActivationString.Copy ("OFF");
-    }
-
-    theDi << "Auto activation of selection is: " << aSelActivationString << "\n";
-  }
-  else
-  {
-    Standard_Boolean toActivate = Draw::Atoi (theArgVec[1]);
-    aCtx->SetAutoActivateSelection (toActivate);
   }
 
   return 0;
@@ -5068,7 +5514,6 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
   ViewerTest::RelationCommands(theCommands);
   ViewerTest::ObjectCommands(theCommands);
   ViewerTest::FilletCommands(theCommands);
-  ViewerTest::VoxelCommands(theCommands);
   ViewerTest::OpenGlCommands(theCommands);
 
   const char *group = "AIS_Display";
@@ -5080,22 +5525,42 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
       __FILE__, visos, group);
 
   theCommands.Add("vdisplay",
-              "vdisplay [-noupdate|-update] [-local] [-mutable] [-overlay|-underlay]"
-      "\n\t\t:          [-trsfPers flags] [-trsfPersPos X Y [Z]] [-3d|-2d|-2dTopDown]"
+              "vdisplay [-noupdate|-update] [-local] [-mutable] [-neutral]"
+      "\n\t\t:          [-trsfPers {zoom|rotate|zoomRotate|none}=none]"
+      "\n\t\t:                            [-trsfPersPos X Y [Z]] [-3d]"
+      "\n\t\t:          [-2d|-trihedron [{top|bottom|left|right|topLeft"
+      "\n\t\t:                           |topRight|bottomLeft|bottomRight}"
+      "\n\t\t:                                         [offsetX offsetY]]]"
       "\n\t\t:          [-dispMode mode] [-highMode mode]"
+      "\n\t\t:          [-layer index] [-top|-topmost|-overlay|-underlay]"
+      "\n\t\t:          [-redisplay]"
       "\n\t\t:          name1 [name2] ... [name n]"
       "\n\t\t: Displays named objects."
       "\n\t\t: Option -local enables displaying of objects in local"
       "\n\t\t: selection context. Local selection context will be opened"
       "\n\t\t: if there is not any."
-      "\n\t\t:  -noupdate    suppresses viewer redraw call."
-      "\n\t\t:  -mutable     enables optimizations for mutable objects."
-      "\n\t\t:  -overlay     draws objects in overlay."
-      "\n\t\t:  -underlay    draws objects in underlay."
-      "\n\t\t:  -selectable|-noselect controls selection of objects."
-      "\n\t\t:  -trsfPers    sets a transform persistence flags."
-      "\n\t\t:  -trsfPersPos sets an anchor point for transform persistence."
-      "\n\t\t:  -2d|-2dTopDown displays object in screen coordinates.",
+      "\n\t\t:  -noupdate    Suppresses viewer redraw call."
+      "\n\t\t:  -mutable     Enables optimizations for mutable objects."
+      "\n\t\t:  -neutral     Draws objects in main viewer."
+      "\n\t\t:  -layer       Sets z-layer for objects."
+      "\n\t\t:               Alternatively -overlay|-underlay|-top|-topmost"
+      "\n\t\t:               options can be used for the default z-layers."
+      "\n\t\t:  -top         Draws object on top of main presentations"
+      "\n\t\t:               but below topmost."
+      "\n\t\t:  -topmost     Draws in overlay for 3D presentations."
+      "\n\t\t:               with independent Depth."
+      "\n\t\t:  -overlay     Draws objects in overlay for 2D presentations."
+      "\n\t\t:               (On-Screen-Display)"
+      "\n\t\t:  -underlay    Draws objects in underlay for 2D presentations."
+      "\n\t\t:               (On-Screen-Display)"
+      "\n\t\t:  -selectable|-noselect Controls selection of objects."
+      "\n\t\t:  -trsfPers    Sets a transform persistence flags."
+      "\n\t\t:  -trsfPersPos Sets an anchor point for transform persistence."
+      "\n\t\t:  -2d          Displays object in screen coordinates."
+      "\n\t\t:               (DY looks up)"
+      "\n\t\t:  -dispmode    Sets display mode for objects."
+      "\n\t\t:  -highmode    Sets hilight mode for objects."
+      "\n\t\t:  -redisplay   Recomputes presentation of objects.",
       __FILE__, VDisplay2, group);
 
   theCommands.Add ("vupdate",
@@ -5159,14 +5624,6 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
                  "vdisplaytype        : vdisplaytype <Type> <Signature> \n\t display all the objects of one given kind (see vtypes) which are stored the AISContext ",
                  __FILE__,VDisplayType,group);
 
-  theCommands.Add("vdisplaymode",
-                 "vdispmode       : vdispmode  [name] mode(1,2,..) : no name -> on selected objects ",
-                 __FILE__,VDispMode,group);
-
-  theCommands.Add("verasemode",
-                 "verasemode      : verasemode [name] mode(1,2,..) : no name -> on selected objects",
-                 __FILE__,VDispMode,group);
-
   theCommands.Add("vsetdispmode",
                  "vsetdispmode [name] mode(1,2,..)"
       "\n\t\t: Sets display mode for all, selected or named objects.",
@@ -5181,16 +5638,17 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
                  "Lists all objects displayed in 3D viewer",
                  __FILE__,VDir,group);
 
+#ifdef HAVE_FREEIMAGE
+  #define DUMP_FORMATS "{png|bmp|jpg|gif}"
+#else
+  #define DUMP_FORMATS "{ppm}"
+#endif
   theCommands.Add("vdump",
-    #ifdef HAVE_FREEIMAGE
-              "vdump <filename>.{png|bmp|jpg|gif} [rgb|rgba|depth=rgb] [mono|left|right=mono]"
-      "\n\t\t:                                    [width Width=0 height Height=0]"
-      "\n\t\t: Dumps content of the active view into PNG, BMP, JPEG or GIF file",
-    #else
-              "vdump <filename>.{ppm} [rgb|rgba|depth=rgb] [mono|left|right=mono]"
-      "\n\t\t:                        [width Width=0 height Height=0]"
-      "\n\t\t: Dumps content of the active view into PPM image file",
-    #endif
+              "vdump <filename>." DUMP_FORMATS " [-width Width -height Height]"
+      "\n\t\t:       [-buffer rgb|rgba|depth=rgb]"
+      "\n\t\t:       [-stereo mono|left|right|blend|sideBySide|overUnder=mono]"
+      "\n\t\t:       [-tileSize Size=0]"
+      "\n\t\t: Dumps content of the active view into image file",
                  __FILE__,VDump,group);
 
   theCommands.Add("vsub",      "vsub 0/1 (off/on) [obj]        : Subintensity(on/off) of selected objects",
@@ -5198,15 +5656,20 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
 
   theCommands.Add("vaspects",
               "vaspects [-noupdate|-update] [name1 [name2 [...]] | -defaults]"
-      "\n\t\t:          [-setvisibility 0|1]"
-      "\n\t\t:          [-setcolor ColorName] [-setcolor R G B] [-unsetcolor]"
-      "\n\t\t:          [-setmaterial MatName] [-unsetmaterial]"
-      "\n\t\t:          [-settransparency Transp] [-unsettransparency]"
-      "\n\t\t:          [-setwidth LineWidth] [-unsetwidth]"
+      "\n\t\t:          [-setVisibility 0|1]"
+      "\n\t\t:          [-setColor ColorName] [-setcolor R G B] [-unsetColor]"
+      "\n\t\t:          [-setMaterial MatName] [-unsetMaterial]"
+      "\n\t\t:          [-setTransparency Transp] [-unsetTransparency]"
+      "\n\t\t:          [-setWidth LineWidth] [-unsetWidth]"
+      "\n\t\t:          [-setLineType {solid|dash|dot|dotDash}] [-unsetLineType]"
       "\n\t\t:          [-freeBoundary {off/on | 0/1}]"
       "\n\t\t:          [-setFreeBoundaryWidth Width] [-unsetFreeBoundaryWidth]"
       "\n\t\t:          [-setFreeBoundaryColor {ColorName | R G B}] [-unsetFreeBoundaryColor]"
       "\n\t\t:          [-subshapes subname1 [subname2 [...]]]"
+      "\n\t\t:          [-isoontriangulation 0|1]"
+      "\n\t\t:          [-setMaxParamValue {value}]"
+      "\n\t\t:          [-setSensitivity {selection_mode} {value}]"
+      "\n\t\t:          [-setHatch HatchStyle]"
       "\n\t\t: Manage presentation properties of all, selected or named objects."
       "\n\t\t: When -subshapes is specified than following properties will be"
       "\n\t\t: assigned to specified sub-shapes."
@@ -5267,31 +5730,32 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
                  __FILE__,VSetInteriorStyle,group);
 
   theCommands.Add("vsensdis",
-                 "vardisp           : display active entities",
-                 __FILE__,VDispSensi,group);
-  theCommands.Add("vsensera",
-                 "vardisp           : erase  active entities",
-                 __FILE__,VClearSensi,group);
-
-  theCommands.Add("vselprecision",
-                 "vselprecision : vselprecision [tolerance_value]",
-                 __FILE__,VSelPrecision,group);
+      "vsensdis : Display active entities (sensitive entities of one of the standard types corresponding to active selection modes)."
+      "\n\t\t: Standard entity types are those defined in Select3D package:"
+      "\n\t\t: - sensitive box"
+      "\n\t\t: - sensitive face"
+      "\n\t\t: - sensitive curve"
+      "\n\t\t: - sensitive segment"
+      "\n\t\t: - sensitive circle"
+      "\n\t\t: - sensitive point"
+      "\n\t\t: - sensitive triangulation"
+      "\n\t\t: - sensitive triangle"
+      "\n\t\t: Custom(application - defined) sensitive entity types are not processed by this command.",
+      __FILE__,VDispSensi,group);
 
-  theCommands.Add("vperf",
-                 "vperf: vperf  ShapeName 1/0(Transfo/Location) 1/0(Primitives sensibles ON/OFF)",
-                 __FILE__,VPerf,group);
-
-  theCommands.Add("vanimation",
-                 "vanimation CrankArmFile CylinderHeadFile PropellerFile EngineBlockFile",
-                 __FILE__,VAnimation,group);
+  theCommands.Add("vsensera",
+      "vsensera : erase active entities",
+      __FILE__,VClearSensi,group);
 
   theCommands.Add("vsetshading",
-                 "vsetshading  : vsetshading name Quality(default=0.0008) ",
-                 __FILE__,VShading,group);
+      "vsetshading  : vsetshading name Quality(default=0.0008) "
+      "\n\t\t: Sets deflection coefficient that defines the quality of the shape representation in the shading mode.",
+      __FILE__,VShading,group);
 
   theCommands.Add("vunsetshading",
-                 "vunsetshading :vunsetshading name ",
-                 __FILE__,VShading,group);
+      "vunsetshading :vunsetshading name "
+      "\n\t\t: Sets default deflection coefficient (0.0008) that defines the quality of the shape representation in the shading mode.",
+      __FILE__,VShading,group);
 
   theCommands.Add ("vtexture",
                    "\n'vtexture NameOfShape [TextureFile | IdOfTexture]\n"
@@ -5338,12 +5802,22 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
                  VTexture,group);
 
   theCommands.Add("vsetam",
-                 "vsetActivatedModes: vsetam mode(1->7)  ",
-                 __FILE__,VActivatedMode,group);
+      "vsetam [shapename] mode"
+      "\n\t\t: Activates selection mode for all selected or named shapes."
+      "\n\t\t: Mod can be:"
+      "\n\t\t:   0 - for shape itself" 
+      "\n\t\t:   1 - vertices"
+      "\n\t\t:   2 - edges"
+      "\n\t\t:   3 - wires"
+      "\n\t\t:   4 - faces"
+      "\n\t\t:   5 - shells"
+      "\n\t\t:   6 - solids"
+      "\n\t\t:   7 - compounds"
+      __FILE__,VActivatedMode,group);
 
   theCommands.Add("vunsetam",
-                 "vunsetActivatedModes:   vunsetam  ",
-                 __FILE__,VActivatedMode,group);
+      "vunsetam : Deactivates all selection modes for all shapes.",
+      __FILE__,VActivatedMode,group);
 
   theCommands.Add("vstate",
       "vstate [-entities] [-hasSelected] [name1] ... [nameN]"
@@ -5360,7 +5834,9 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
                  "vtypes : list of known types and signatures in AIS - To be Used in vpickobject command for selection with filters",
                  VIOTypes,group);
 
-  theCommands.Add("vr", "vr : reading of the shape",
+  theCommands.Add("vr",
+      "vr filename"
+      "\n\t\t: Reads shape from BREP-format file and displays it in the viewer. ",
                  __FILE__,vr, group);
 
   theCommands.Add("vpickselected", "vpickselected [name]: extract selected shape.",
@@ -5372,11 +5848,22 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
     "\n\t\t:   -local - open local context before selection computation",
     __FILE__, VLoadSelection, group);
 
-  theCommands.Add ("vautoactivatesel",
-    "vautoactivatesel [0|1] : manage or display the option to automatically"
-    "\n\t\t: activate selection for newly displayed objects"
-    "\n\t\t:   [0|1] - turn off | on auto activation of selection",
-    __FILE__, VAutoActivateSelection, group);
+  theCommands.Add("vbsdf", "vbsdf [name] [options]"
+    "\nAdjusts parameters of material BSDF:"
+    "\n    -help : Shows this message"
+    "\n    -print : Print BSDF"
+    "\n    -kd : Weight of the Lambertian BRDF"
+    "\n    -kr : Weight of the reflection BRDF"
+    "\n    -kt : Weight of the transmission BTDF"
+    "\n    -ks : Weight of the glossy Blinn BRDF"
+    "\n    -le : Self-emitted radiance"
+    "\n    -fresnel : Fresnel coefficients; Allowed fresnel formats are: Constant x,"
+    "\n               Schlick x y z, Dielectric x, Conductor x y"
+    "\n    -roughness : Roughness of material (Blinn's exponent)"
+    "\n    -absorpcoeff : Absorption coefficient (only for transparent material)"
+    "\n    -absorpcolor : Absorption color (only for transparent material)"
+    "\n    -normalize : Normalize BSDF coefficients",
+    __FILE__, VBsdf, group);
 
 }
 
@@ -5420,7 +5907,7 @@ static Standard_Boolean IsValid(const TopTools_ListOfShape& theArgs,
     }
   } else {
 #ifdef OCCT_DEBUG
-    cout <<"DONT_SWITCH_IS_VALID non positionne"<<"\n";
+    cout <<"DONT_SWITCH_IS_VALID non positionne\n";
 #endif
   }
   Standard_Boolean IsValid = Standard_True;
@@ -5452,7 +5939,7 @@ static Standard_Integer TDraft(Draw_Interpretor& di, Standard_Integer argc, cons
   TopoDS_Face Face    = TopoDS::Face(face);
   TopoDS_Shape Plane  = GetShapeFromName(argv[3]);
   if (Plane.IsNull ()) {
-    di << "TEST : Plane is NULL" << "\n";
+    di << "TEST : Plane is NULL\n";
     return 1;
   }
   anAngle = Draw::Atof(argv[4]);
@@ -5470,7 +5957,7 @@ static Standard_Integer TDraft(Draw_Interpretor& di, Standard_Integer argc, cons
   TopoDS_Face face2 = TopoDS::Face(Plane);
   if(!AIS::GetPlaneFromFace(face2, aPln, aSurf, aSurfType, Offset))
     {
-      di << "TEST : Can't find plane" << "\n";
+      di << "TEST : Can't find plane\n";
       return 1;
     }
 
@@ -5484,20 +5971,20 @@ static Standard_Integer TDraft(Draw_Interpretor& di, Standard_Integer argc, cons
   BRepOffsetAPI_DraftAngle Draft (Solid);
 
   if(Abs(anAngle)< Precision::Angular()) {
-    di << "TEST : NULL angle" << "\n";
+    di << "TEST : NULL angle\n";
     return 1;}
 
   if(Rev) anAngle = - anAngle;
   Draft.Add (Face, aDir, anAngle, aPln);
   Draft.Build ();
   if (!Draft.IsDone())  {
-    di << "TEST : Draft Not DONE " << "\n";
+    di << "TEST : Draft Not DONE \n";
     return 1;
   }
   TopTools_ListOfShape Larg;
   Larg.Append(Solid);
   if (!IsValid(Larg,Draft.Shape(),Standard_True,Standard_False)) {
-    di << "TEST : DesignAlgo returns Not valid" << "\n";
+    di << "TEST : DesignAlgo returns Not valid\n";
     return 1;
   }
 
@@ -5575,10 +6062,9 @@ void ViewerTest::Factory(Draw_Interpretor& theDI)
 {
   // definition of Viewer Command
   ViewerTest::Commands(theDI);
-  ViewerTest::AviCommands(theDI);
 
 #ifdef OCCT_DEBUG
-      theDI << "Draw Plugin : OCC V2d & V3d commands are loaded" << "\n";
+      theDI << "Draw Plugin : OCC V2d & V3d commands are loaded\n";
 #endif
 }