0024351: Test cases for AIS dimension presentations to check arrow orientation, text...
[occt.git] / src / ViewerTest / ViewerTest_ViewerCommands.cxx
index f25c460..febef29 100755 (executable)
 // purpose or non-infringement. Please see the License for the specific terms
 // and conditions governing the rights and limitations under the License.
 
-
-// Robert Boehne 30 May 2000 : Dec Osf
-
 #ifdef HAVE_CONFIG_H
-include <config.h>
+  #include <config.h>
 #endif
 
 #include <OpenGl_GlCore20.hxx>
 #include <Graphic3d_TextureEnv.hxx>
 #include <Graphic3d_TextureParams.hxx>
 #include <Graphic3d_TypeOfTextureFilter.hxx>
+#include <Graphic3d_AspectFillArea3d.hxx>
 #include <ViewerTest.hxx>
 #include <ViewerTest_EventManager.hxx>
 #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
+#include <ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName.hxx>
 #include <Visual3d_View.hxx>
 #include <Visual3d_ViewManager.hxx>
+#include <V3d_AmbientLight.hxx>
+#include <V3d_DirectionalLight.hxx>
 #include <V3d_LayerMgr.hxx>
+#include <V3d_LayerMgrPointer.hxx>
+#include <V3d_PositionalLight.hxx>
+#include <V3d_SpotLight.hxx>
 #include <NCollection_DoubleMap.hxx>
 #include <NCollection_List.hxx>
 #include <NCollection_Vector.hxx>
 #include <TColStd_HSequenceOfReal.hxx>
 #include <TColgp_Array1OfPnt2d.hxx>
 #include <Visual3d_LayerItem.hxx>
-#include <V3d_LayerMgr.hxx>
-#include <V3d_LayerMgrPointer.hxx>
 #include <Aspect_TypeOfLine.hxx>
 #include <Image_Diff.hxx>
 #include <Aspect_DisplayConnection.hxx>
 #include <Graphic3d.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Pln.hxx>
+#include <PrsMgr_PresentableObject.hxx>
+#include <Graphic3d_ClipPlane.hxx>
+#include <NCollection_DataMap.hxx>
+#include <Graphic3d_Texture2Dmanual.hxx>
+#include <Prs3d_ShadingAspect.hxx>
 
 #ifdef WNT
 #undef DrawText
@@ -86,7 +96,6 @@
   #endif
 #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
   #include <Cocoa_Window.hxx>
-  #include <tk.h>
 #else
   #include <Xw_Window.hxx>
   #include <X11/Xlib.h> /* contains some dangerous #defines such as Status, True etc. */
   #include <tk.h>
 #endif
 
-//==============================================================================
+// Auxiliary definitions
+static const char THE_KEY_DELETE = 127;
 
 //==============================================================================
 //  VIEWER GLOBAL VARIABLES
 //==============================================================================
 
 Standard_IMPORT Standard_Boolean Draw_VirtualWindows;
+Standard_IMPORT Standard_Boolean Draw_Interprete (const char* theCommand);
 
 Standard_EXPORT int ViewerMainLoop(Standard_Integer , const char** argv);
 extern const Handle(NIS_InteractiveContext)& TheNISContext();
 extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
 
+extern int VErase (Draw_Interpretor& theDI,
+                   Standard_Integer  theArgNb,
+                   const char**      theArgVec);
+
 #if defined(_WIN32)
 static Handle(WNT_Window)& VT_GetWindow() {
   static Handle(WNT_Window) WNTWin;
@@ -144,7 +159,7 @@ static void SetDisplayConnection (const Handle(Aspect_DisplayConnection)& theDis
 #if defined(_WIN32) || (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
 Aspect_Handle GetWindowHandle(const Handle(Aspect_Window)& theWindow)
 {
-  Aspect_Handle aWindowHandle = NULL;
+  Aspect_Handle aWindowHandle = (Aspect_Handle)NULL;
 #if defined(_WIN32)
   const Handle (WNT_Window) aWindow = Handle(WNT_Window)::DownCast (theWindow);
   if (!aWindow.IsNull())
@@ -504,24 +519,23 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft
     aPxWidth = thePxWidth;
   if (thePxHeight != 0)
     aPxHeight = thePxHeight;
+
   // Get graphic driver (create it or get from another view)
   if (!ViewerTest_myDrivers.IsBound1 (aViewNames.GetDriverName()))
   {
     // Get connection string
   #if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
     TCollection_AsciiString aDisplayName(theDisplayName);
-    if (aDisplayName.IsEmpty())
+    if (!aDisplayName.IsEmpty())
       SetDisplayConnection (new Aspect_DisplayConnection ());
     else
       SetDisplayConnection (new Aspect_DisplayConnection (aDisplayName));
-
   #else
+    (void)theDisplayName; // avoid warning on unused argument
     SetDisplayConnection (new Aspect_DisplayConnection ());
   #endif
-    aGraphicDriver = new OpenGl_GraphicDriver();
+    aGraphicDriver = new OpenGl_GraphicDriver (GetDisplayConnection());
     aGraphicDriver->ChangeOptions() = ViewerTest_myDefaultCaps;
-    aGraphicDriver->Begin (GetDisplayConnection());
     ViewerTest_myDrivers.Bind (aViewNames.GetDriverName(), aGraphicDriver);
     toCreateViewer = Standard_True;
   }
@@ -591,7 +605,7 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft
   }
 
   // Create viewer
-  Handle(V3d_Viewer) a3DViewer, a3DCollector;
+  Handle(V3d_Viewer) a3DViewer;
   // If it's the single view, we first look for empty context
   if (ViewerTest_myViews.IsEmpty() && !ViewerTest_myContexts.IsEmpty())
   {
@@ -600,63 +614,60 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft
     if (anIter.More())
       ViewerTest::SetAISContext (anIter.Value());
     a3DViewer = ViewerTest::GetAISContext()->CurrentViewer();
-    a3DCollector= ViewerTest::GetAISContext()->Collector();
   }
   else if (ViewerTest_myContexts.IsBound1(aViewNames.GetViewerName()))
   {
     ViewerTest::SetAISContext(ViewerTest_myContexts.Find1(aViewNames.GetViewerName()));
     a3DViewer = ViewerTest::GetAISContext()->CurrentViewer();
-    a3DCollector= ViewerTest::GetAISContext()->Collector();
   }
-  else if (a3DViewer.IsNull() || a3DCollector.IsNull())
+  else if (a3DViewer.IsNull())
   {
     toCreateViewer = Standard_True;
     TCollection_ExtendedString NameOfWindow("Viewer3D");
     a3DViewer = new V3d_Viewer(aGraphicDriver, NameOfWindow.ToExtString());
 
     NameOfWindow = TCollection_ExtendedString("Collector");
-    a3DCollector = new V3d_Viewer(aGraphicDriver, NameOfWindow.ToExtString());
 
     a3DViewer->SetDefaultBackgroundColor(Quantity_NOC_BLACK);
-    a3DCollector->SetDefaultBackgroundColor(Quantity_NOC_STEELBLUE);
   }
 
   // AIS context setup
   if (ViewerTest::GetAISContext().IsNull() ||
       !(ViewerTest_myContexts.IsBound1(aViewNames.GetViewerName())))
   {
-    Handle(AIS_InteractiveContext) aContext =
-      new AIS_InteractiveContext(a3DViewer, a3DCollector);
+    Handle(AIS_InteractiveContext) aContext = new AIS_InteractiveContext (a3DViewer);
     ViewerTest::SetAISContext (aContext);
     ViewerTest_myContexts.Bind (aViewNames.GetViewerName(), ViewerTest::GetAISContext());
   }
   else
+  {
     ViewerTest::ResetEventManager();
+  }
 
   // Create window
-#if defined(_WIN32) || defined(__WIN32__)
-      VT_GetWindow() = new WNT_Window (aTitle.ToCString(),
-                                       Handle(WNT_WClass)::DownCast (WClass()),
-                                       WS_OVERLAPPEDWINDOW,
-                                       aPxLeft, aPxTop,
-                                       aPxWidth, aPxHeight,
-                                       Quantity_NOC_BLACK);
+#if defined(_WIN32)
+  VT_GetWindow() = new WNT_Window (aTitle.ToCString(),
+                                    Handle(WNT_WClass)::DownCast (WClass()),
+                                    Draw_VirtualWindows ? WS_POPUPWINDOW : WS_OVERLAPPEDWINDOW,
+                                    aPxLeft, aPxTop,
+                                    aPxWidth, aPxHeight,
+                                    Quantity_NOC_BLACK);
 #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
-      VT_GetWindow() = new Cocoa_Window (aTitle.ToCString(),
-                                         aPxLeft, aPxTop,
-                                         aPxWidth, aPxHeight);
-      ViewerTest_SetCocoaEventManagerView (VT_GetWindow());
+  VT_GetWindow() = new Cocoa_Window (aTitle.ToCString(),
+                                     aPxLeft, aPxTop,
+                                     aPxWidth, aPxHeight);
+  ViewerTest_SetCocoaEventManagerView (VT_GetWindow());
 #else
-      VT_GetWindow() = new Xw_Window (aGraphicDriver->GetDisplayConnection(),
-                                      aTitle.ToCString(),
-                                      aPxLeft, aPxTop,
-                                      aPxWidth, aPxHeight);
+  VT_GetWindow() = new Xw_Window (aGraphicDriver->GetDisplayConnection(),
+                                  aTitle.ToCString(),
+                                  aPxLeft, aPxTop,
+                                  aPxWidth, aPxHeight);
 #endif
   VT_GetWindow()->SetVirtual (Draw_VirtualWindows);
 
   // NIS setup
   Handle(NIS_View) aView = new NIS_View (a3DViewer, VT_GetWindow());
-  
+
   ViewerTest::CurrentView(aView);
   ViewerTest_myViews.Bind (aViewNames.GetViewName(), aView);
   TheNISContext()->AttachView (aView);
@@ -678,7 +689,7 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft
     a3DViewer->SetLightOn();
   }
 
-  #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
+  #if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
   #if TCL_MAJOR_VERSION  < 8
   Tk_CreateFileHandler((void*)XConnectionNumber(GetDisplayConnection()->GetDisplay()),
       TK_READABLE, VProcessEvents, (ClientData) VT_GetWindow()->XWindow() );
@@ -689,7 +700,7 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft
   #endif
 
   VT_GetWindow()->Map();
-  
+
   // Set the handle of created view in the event manager
   ViewerTest::ResetEventManager();
 
@@ -697,99 +708,108 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft
 
   aView.Nullify();
   a3DViewer.Nullify();
-  a3DCollector.Nullify();
 
   return aViewNames.GetViewName();
 }
 
 //==============================================================================
-//function : SplitParameter
-//purpose  : Split parameter string to parameter name an patameter value
+//function : RedrawAllViews
+//purpose  : Redraw all created views
 //==============================================================================
-Standard_Boolean SplitParameter (const TCollection_AsciiString& theString,
-                                      TCollection_AsciiString& theName,
-                                      TCollection_AsciiString& theValue)
+void ViewerTest::RedrawAllViews()
 {
-  Standard_Integer aParamNameEnd = theString.FirstLocationInSet("=",1, theString.Length());
-  if (aParamNameEnd == 0)
-    return Standard_False;
-  TCollection_AsciiString aString(theString);
-  if (aParamNameEnd != 0)
+  NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator aViewIt(ViewerTest_myViews);
+  for (; aViewIt.More(); aViewIt.Next())
   {
-    theValue = aString.Split(aParamNameEnd);
-    aString.Split(aString.Length()-1);
-    theName = aString;
+    const Handle(V3d_View)& aView = aViewIt.Key2();
+    aView->Redraw();
   }
-  return Standard_True;
 }
 
 //==============================================================================
 //function : Vinit
 //purpose  : Create the window viewer and initialize all the global variable
-//    Use Tk_CreateFileHandler on UNIX to cath the X11 Viewer event
+//    Use Tk_CreateFileHandler on UNIX to catch the X11 Viewer event
 //==============================================================================
 
 static int VInit (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
 {
-if (theArgsNb > 9)
+  if (theArgsNb > 9)
   {
-    theDi << theArgVec[0] << ": incorrect number of command arguments.\n"
-      << "Type help for more information.\n";
+    std::cerr << theArgVec[0] << ": incorrect number of command arguments.\n"
+              << "Type help for more information.\n";
     return 1;
   }
-  TCollection_AsciiString aViewName (""),
-                          aDisplayName ("");
-  Standard_Integer aPxLeft = 0,
-                  aPxTop = 0,
-                  aPxWidth = 0,
-                  aPxHeight = 0;
 
-  for (Standard_Integer i = 1; i < theArgsNb; ++i)
+  TCollection_AsciiString aViewName, aDisplayName;
+  Standard_Integer aPxLeft = 0, aPxTop = 0, aPxWidth = 0, aPxHeight = 0;
+  TCollection_AsciiString aName, aValue;
+  for (Standard_Integer anArgIt = 1; anArgIt < theArgsNb; ++anArgIt)
   {
-    TCollection_AsciiString aName = "", aValue = "";
-    if(!SplitParameter (TCollection_AsciiString(theArgVec[i]),aName,aValue) && theArgsNb == 2)
-    {
-      // In case of syntax: vinit ViewName
-      aViewName = theArgVec[1];
-    }
-    else
+    const TCollection_AsciiString anArg = theArgVec[anArgIt];
+    TCollection_AsciiString anArgCase = anArg;
+    anArgCase.UpperCase();
+    if (ViewerTest::SplitParameter (anArg, aName, aValue))
     {
-      if (aName == "name")
+      aName.UpperCase();
+      if (aName.IsEqual ("NAME"))
       {
         aViewName = aValue;
       }
-      else if (aName == "l" || aName == "left")
+      else if (aName.IsEqual ("L")
+            || aName.IsEqual ("LEFT"))
+      {
         aPxLeft = aValue.IntegerValue();
-      else if (aName == "t" || aName == "top")
+      }
+      else if (aName.IsEqual ("T")
+            || aName.IsEqual ("TOP"))
+      {
         aPxTop = aValue.IntegerValue();
-#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
-      else if (aName == "display")
+      }
+    #if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
+      else if (aName.IsEqual ("DISP")
+            || aName.IsEqual ("DISPLAY"))
+      {
         aDisplayName = aValue;
-#endif
-      else if (aName == "w" || aName == "width")
+      }
+    #endif
+      else if (aName.IsEqual ("W")
+            || aName.IsEqual ("WIDTH"))
+      {
         aPxWidth = aValue.IntegerValue();
-      else if (aName == "h" || aName == "height")
+      }
+      else if (aName.IsEqual ("H")
+            || aName.IsEqual ("HEIGHT"))
+      {
         aPxHeight = aValue.IntegerValue();
+      }
       else
       {
-        theDi << theArgVec[0] << ": Warning: unknown parameter " << aName.ToCString() << ".\n";
+        std::cerr << theArgVec[0] << ": Warning: unknown argument " << anArg << ".\n";
       }
     }
+    else if (aViewName.IsEmpty())
+    {
+      aViewName = anArg;
+    }
+    else
+    {
+      std::cerr << theArgVec[0] << ": Warning: unknown argument " << anArg << ".\n";
+    }
   }
 
   ViewerTest_Names aViewNames (aViewName);
-  if (ViewerTest_myViews.IsBound1 (aViewNames.GetViewName ()))
+  if (ViewerTest_myViews.IsBound1 (aViewNames.GetViewName()))
   {
-    TCollection_AsciiString aCommand("vactivate ");
-    aCommand = aCommand + aViewNames.GetViewName();
-    theDi.Eval(aCommand.ToCString());
+    TCollection_AsciiString aCommand = TCollection_AsciiString ("vactivate ") + aViewNames.GetViewName();
+    theDi.Eval (aCommand.ToCString());
     return 0;
   }
 
   TCollection_AsciiString aViewId = ViewerTest::ViewerInit (aPxLeft, aPxTop, aPxWidth, aPxHeight,
                                                             aViewName.ToCString(),
                                                             aDisplayName.ToCString());
-  cout << theArgVec[0] << ": 3D View - " << aViewId << " was created.\n";
+  theDi << aViewId;
   return 0;
 }
 
@@ -1057,44 +1077,56 @@ void ViewerTest::RemoveView (const TCollection_AsciiString& theViewName, const S
 //purpose  : Remove the view defined by its name
 //==============================================================================
 
-static int VClose (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
+static int VClose (Draw_Interpretor& /*theDi*/,
+                   Standard_Integer  theArgsNb,
+                   const char**      theArgVec)
 {
-  if (theArgsNb < 2)
-  {
-    theDi << theArgVec[0] << ": incorrect number of command arguments.\n"
-      << "Type help " << theArgVec[0] << " for more information.\n";
-    return 1;
-  }
-
-  if (ViewerTest_myViews.IsEmpty())
-  {
-    theDi << theArgVec[0] <<": there is no views to close.\n";
-    return 0;
-  }
-
-  TCollection_AsciiString anInputString(theArgVec[1]);
-  
-  // Create list to iterate and remove views from the map of views
   NCollection_List<TCollection_AsciiString> aViewList;
-  if ( strcasecmp( anInputString.ToCString(), "ALL" ) == 0 )
+  if (theArgsNb > 1)
   {
-    for (NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator anIter(ViewerTest_myViews);
-         anIter.More(); anIter.Next())
+    TCollection_AsciiString anArg (theArgVec[1]);
+    anArg.UpperCase();
+    if (anArg.IsEqual ("ALL")
+     || anArg.IsEqual ("*"))
     {
-      aViewList.Append(anIter.Key1());
+      for (NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator anIter (ViewerTest_myViews);
+           anIter.More(); anIter.Next())
+      {
+        aViewList.Append (anIter.Key1());
+      }
+      if (aViewList.IsEmpty())
+      {
+        std::cout << "No view to close\n";
+        return 0;
+      }
+    }
+    else
+    {
+      ViewerTest_Names aViewName (theArgVec[1]);
+      if (!ViewerTest_myViews.IsBound1 (aViewName.GetViewName()))
+      {
+        std::cerr << "The view with name '" << theArgVec[1] << "' does not exist\n";
+        return 1;
+      }
+      aViewList.Append (aViewName.GetViewName());
     }
   }
   else
   {
-    ViewerTest_Names aViewNames(anInputString);
-    aViewList.Append(aViewNames.GetViewName());
+    // close active view
+    if (ViewerTest::CurrentView().IsNull())
+    {
+      std::cerr << "No active view!\n";
+      return 1;
+    }
+    aViewList.Append (ViewerTest_myViews.Find2 (ViewerTest::CurrentView()));
   }
 
-  Standard_Boolean isContextRemoved = (theArgsNb == 3 && atoi(theArgVec[2])==1) ? Standard_False : Standard_True;
+  Standard_Boolean toRemoveContext = (theArgsNb != 3 || Draw::Atoi (theArgVec[2]) != 1);
   for (NCollection_List<TCollection_AsciiString>::Iterator anIter(aViewList);
        anIter.More(); anIter.Next())
   {
-    ViewerTest::RemoveView(anIter.Value(), isContextRemoved);
+    ViewerTest::RemoveView (anIter.Value(), toRemoveContext);
   }
 
   return 0;
@@ -1236,28 +1268,33 @@ void VT_ProcessKeyPress (const char* buf_ret)
   const Handle(NIS_View) aNisView = Handle(NIS_View)::DownCast (aView);
   // Letter in alphabetic order
 
-  if ( !strcasecmp(buf_ret, "A") ) {
+  if (!strcasecmp (buf_ret, "A"))
+  {
     // AXO
     aView->SetProj(V3d_XposYnegZpos);
   }
-  else if ( !strcasecmp(buf_ret, "D") ) {
+  else if (!strcasecmp (buf_ret, "D"))
+  {
     // Reset
     aView->Reset();
   }
-  else if ( !strcasecmp(buf_ret, "F") ) {
+  else if (!strcasecmp (buf_ret, "F"))
+  {
     // FitAll
     if (aNisView.IsNull())
       aView->FitAll();
     else
       aNisView->FitAll3d();
   }
-  else if ( !strcasecmp(buf_ret, "H") ) {
+  else if (!strcasecmp (buf_ret, "H"))
+  {
     // HLR
     cout << "HLR" << endl;
     aView->SetComputedMode (!aView->ComputedMode());
     MyHLRIsOn = aView->ComputedMode();
   }
-  else if ( !strcasecmp(buf_ret, "P") ) {
+  else if (!strcasecmp (buf_ret, "P"))
+  {
     // Type of HLR
     Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
     if (aContext->DefaultDrawer()->TypeOfHLR() == Prs3d_TOH_Algo)
@@ -1297,11 +1334,11 @@ void VT_ProcessKeyPress (const char* buf_ret)
     }
 
     aContext->UpdateCurrentViewer();
-    
+
   }
-  else if ( !strcasecmp(buf_ret, "S") ) {
-    // SHADING
-    cout << "passage en mode 1 (shading pour les shapes)" << endl;
+  else if (!strcasecmp (buf_ret, "S"))
+  {
+    std::cout << "setup Shaded display mode" << std::endl;
 
     Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
     if(Ctx->NbCurrents()==0 ||
@@ -1319,9 +1356,10 @@ void VT_ProcessKeyPress (const char* buf_ret)
       Ctx->UpdateCurrentViewer();
     }
   }
-  else if ( !strcasecmp(buf_ret, "U") ) {
+  else if (!strcasecmp (buf_ret, "U"))
+  {
     // Unset display mode
-    cout<<"passage au mode par defaut"<<endl;
+    std::cout << "reset display mode to defaults" << std::endl;
 
     Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
     if(Ctx->NbCurrents()==0 ||
@@ -1340,26 +1378,29 @@ void VT_ProcessKeyPress (const char* buf_ret)
     }
 
   }
-  else if ( !strcasecmp(buf_ret, "T") ) {
+  else if (!strcasecmp (buf_ret, "T"))
+  {
     // Top
     aView->SetProj(V3d_Zpos);
   }
-  else if ( !strcasecmp(buf_ret, "B") ) {
+  else if (!strcasecmp (buf_ret, "B"))
+  {
     // Bottom
     aView->SetProj(V3d_Zneg);
   }
-  else if ( !strcasecmp(buf_ret, "L") ) {
+  else if (!strcasecmp (buf_ret, "L"))
+  {
     // Left
     aView->SetProj(V3d_Xneg);
   }
-  else if ( !strcasecmp(buf_ret, "R") ) {
+  else if (!strcasecmp (buf_ret, "R"))
+  {
     // Right
     aView->SetProj(V3d_Xpos);
   }
-
-  else if ( !strcasecmp(buf_ret, "W") ) {
-    // WIREFRAME
-    cout << "passage en mode 0 (filaire pour les shapes)" << endl;
+  else if (!strcasecmp (buf_ret, "W"))
+  {
+    std::cout << "setup WireFrame display mode" << std::endl;
     Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
     if(Ctx->NbCurrents()==0 ||
       Ctx->NbSelected()==0)
@@ -1376,9 +1417,9 @@ void VT_ProcessKeyPress (const char* buf_ret)
       Ctx->UpdateCurrentViewer();
     }
   }
-  else if ( !strcasecmp(buf_ret, "Z") ) {
+  else if (!strcasecmp (buf_ret, "Z"))
+  {
     // ZCLIP
-
     if ( ZClipIsOn ) {
       cout << "ZClipping OFF" << endl;
       ZClipIsOn = 0;
@@ -1394,16 +1435,27 @@ void VT_ProcessKeyPress (const char* buf_ret)
       aView->Redraw();
     }
   }
-  else if ( !strcasecmp(buf_ret, ",") ) {
+  else if (!strcasecmp (buf_ret, ","))
+  {
     ViewerTest::GetAISContext()->HilightNextDetected(ViewerTest::CurrentView());
-
-
   }
-  else if ( !strcasecmp(buf_ret, ".") ) {
+  else if (!strcasecmp (buf_ret, "."))
+  {
     ViewerTest::GetAISContext()->HilightPreviousDetected(ViewerTest::CurrentView());
   }
-  // Number
-  else{
+  else if (*buf_ret == THE_KEY_DELETE)
+  {
+    Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
+    if (!aCtx.IsNull()
+     && aCtx->NbCurrents() > 0
+     && aCtx->NbSelected() > 0)
+    {
+      Draw_Interprete ("verase");
+    }
+  }
+  else
+  {
+    // Number
     Standard_Integer Num = Draw::Atoi(buf_ret);
     if(Num>=0 && Num<=7)
       ViewerTest::StandardModeActivation(Num);
@@ -1444,29 +1496,31 @@ void VT_ProcessConfigure()
 //function : VT_ProcessButton1Press
 //purpose  : Picking
 //==============================================================================
-Standard_Boolean VT_ProcessButton1Press(
-  Standard_Integer ,
-  const char**     argv,
-  Standard_Boolean pick,
-  Standard_Boolean shift)
+Standard_Boolean VT_ProcessButton1Press (Standard_Integer ,
+                                         const char**     theArgVec,
+                                         Standard_Boolean theToPick,
+                                         Standard_Boolean theIsShift)
 {
-  Handle(ViewerTest_EventManager) EM = ViewerTest::CurrentEventManager();
-  if ( pick ) {
+  if (theToPick)
+  {
     Standard_Real X, Y, Z;
+    ViewerTest::CurrentView()->Convert (X_Motion, Y_Motion, X, Y, Z);
 
-    ViewerTest::CurrentView()->Convert(X_Motion, Y_Motion, X, Y, Z);
-
-    Draw::Set(argv[1], X);
-    Draw::Set(argv[2], Y);
-    Draw::Set(argv[3], Z);}
+    Draw::Set (theArgVec[1], X);
+    Draw::Set (theArgVec[2], Y);
+    Draw::Set (theArgVec[3], Z);
+  }
 
-  if(shift)
-    EM->ShiftSelect();
+  if (theIsShift)
+  {
+    ViewerTest::CurrentEventManager()->ShiftSelect();
+  }
   else
-    EM->Select();
+  {
+    ViewerTest::CurrentEventManager()->Select();
+  }
 
-  pick = 0;
-  return pick;
+  return Standard_False;
 }
 
 //==============================================================================
@@ -1741,6 +1795,7 @@ static int VHelp(Draw_Interpretor& di, Standard_Integer , const char** )
   di << "W : Wireframe" << "\n";
   di << "H : HidelLineRemoval" << "\n";
   di << "U : Unset display mode" << "\n";
+  di << "Delete : Remove selection from viewer" << "\n";
 
   di << "========================="<<"\n";
   di << "Selection mode "<<"\n";
@@ -1891,6 +1946,10 @@ static LRESULT WINAPI ViewerWindowProc( HWND hwnd,
         char c[2];
         c[0] = (char) wParam;
         c[1] = '\0';
+        if (wParam == VK_DELETE)
+        {
+          c[0] = THE_KEY_DELETE;
+        }
         VT_ProcessKeyPress (c);
       }
       break;
@@ -2053,7 +2112,7 @@ int max( int a, int b )
 
 int ViewerMainLoop(Standard_Integer argc, const char** argv)
 
-{ 
+{
   static XEvent aReport;
   Standard_Boolean pick = argc > 0;
   Display *aDisplay = GetDisplayConnection()->GetDisplay();
@@ -2275,13 +2334,13 @@ static void VProcessEvents(ClientData,int)
        anIter (ViewerTest_myDrivers); anIter.More(); anIter.Next())
   {
     anEventNumbers.Append(XPending (anIter.Key2()->GetDisplayConnection()->GetDisplay()));
-  } 
+  }
     // Handle events for every display
   int anEventIter = 0;
   for (NCollection_DoubleMap <TCollection_AsciiString, Handle(Graphic3d_GraphicDriver)>::Iterator
        anIter (ViewerTest_myDrivers); anIter.More(); anIter.Next(), anEventIter++)
   {
-    for (int i = 0; i < anEventNumbers.Value(anEventIter) && 
+    for (int i = 0; i < anEventNumbers.Value(anEventIter) &&
          XPending (anIter.Key2()->GetDisplayConnection()->GetDisplay()) > 0; ++i)
     {
       SetDisplayConnection (anIter.Key2()->GetDisplayConnection());
@@ -2291,9 +2350,9 @@ static void VProcessEvents(ClientData,int)
        return;
     }
   }
-  
+
   SetDisplayConnection (ViewerTest::GetAISContext()->CurrentViewer()->Driver()->GetDisplayConnection());
-  
+
 }
 #endif
 
@@ -3319,14 +3378,13 @@ private:
 
   Standard_Real            myX1;
   Standard_Real            myY1;
-  Standard_Real            myHeight;
   TCollection_AsciiString  myText;
-  TCollection_AsciiString  myFontName;
+  Standard_Real            myHeight;
+  Handle(Visual3d_Layer)   myLayer;
   Quantity_Color           myColor;
   Quantity_Color           mySubtitleColor;
   Aspect_TypeOfDisplayText myType;
-  Handle(Visual3d_Layer)   myLayer;
-
+  TCollection_AsciiString  myFontName;
 };
 
 IMPLEMENT_STANDARD_HANDLE(V3d_TextItem, Visual3d_LayerItem)
@@ -3391,10 +3449,10 @@ public:
 private:
 
   Standard_Real       myX1, myY1, myX2, myY2;
+  V3d_LayerMgrPointer myLayerMgr;
+  Aspect_TypeOfLine   myType;
   Standard_Real       myWidth;
   Standard_Real       myTransparency;
-  Aspect_TypeOfLine   myType;
-  V3d_LayerMgrPointer myLayerMgr;
 };
 
 IMPLEMENT_STANDARD_HANDLE(V3d_LineItem, Visual3d_LayerItem)
@@ -3548,7 +3606,7 @@ static int VOverlayText (Draw_Interpretor& di, Standard_Integer argc, const char
     di << "  height - pixel height of the text (default=10.0)\n";
     di << "  font_name - name of font (default=courier)\n";
     di << "  text_color - R G B values of text color (default=255.0 255.0 255.0)\n";
-    di << "  display_type = {normal/subtitle/decal/blend}, (default=normal)\n";
+    di << "  display_type = {normal/subtitle/decal/blend/dimension}, (default=normal)\n";
     di << "  background_color- R G B values used for subtitle and decal text\n";
     di << "(default=255.0 255.0 255.0)\n";
     return 1;
@@ -3587,6 +3645,8 @@ static int VOverlayText (Draw_Interpretor& di, Standard_Integer argc, const char
     aTextType = Aspect_TODT_DEKALE;
   else if (aDispStr.IsEqual ("blend"))
     aTextType = Aspect_TODT_BLEND;
+  else if (aDispStr.IsEqual ("dimension"))
+    aTextType = Aspect_TODT_DIMENSION;
 
   // subtitle color
   Quantity_Parameter aSubRed   = 1.0;
@@ -3872,6 +3932,7 @@ static int VCaps (Draw_Interpretor& theDI,
   {
     theDI << "VBO:     " << (aCaps->vboDisable        ? "0" : "1") << "\n";
     theDI << "Sprites: " << (aCaps->pntSpritesDisable ? "0" : "1") << "\n";
+    theDI << "SoftMode:" << (aCaps->contextNoAccel    ? "1" : "0") << "\n";
     return 0;
   }
 
@@ -3886,6 +3947,10 @@ static int VCaps (Draw_Interpretor& theDI,
     {
       aCaps->pntSpritesDisable = anArg.Token ("=", 2).IntegerValue() == 0;
     }
+    else if (anArg.Search ("soft=") > -1)
+    {
+      aCaps->contextNoAccel = anArg.Token ("=", 2).IntegerValue() != 0;
+    }
     else
     {
       std::cerr << "Unknown argument: " << anArg << "\n";
@@ -4036,11 +4101,11 @@ static int VReadPixel (Draw_Interpretor& theDI,
   {
     if (aBufferType == Graphic3d_BT_RGBA)
     {
-      theDI << Quantity_Color::StringName (aColor.Name()) << " " << anAlpha << "\n";
+      theDI << Quantity_Color::StringName (aColor.Name()) << " " << anAlpha;
     }
     else
     {
-      theDI << Quantity_Color::StringName (aColor.Name()) << "\n";
+      theDI << Quantity_Color::StringName (aColor.Name());
     }
   }
   else
@@ -4052,22 +4117,22 @@ static int VReadPixel (Draw_Interpretor& theDI,
       {
         if (toShowHls)
         {
-          theDI << aColor.Hue() << " " << aColor.Light() << " " << aColor.Saturation() << "\n";
+          theDI << aColor.Hue() << " " << aColor.Light() << " " << aColor.Saturation();
         }
         else
         {
-          theDI << aColor.Red() << " " << aColor.Green() << " " << aColor.Blue() << "\n";
+          theDI << aColor.Red() << " " << aColor.Green() << " " << aColor.Blue();
         }
         break;
       }
       case Graphic3d_BT_RGBA:
       {
-        theDI << aColor.Red() << " " << aColor.Green() << " " << aColor.Blue() << " " << anAlpha << "\n";
+        theDI << aColor.Red() << " " << aColor.Green() << " " << aColor.Blue() << " " << anAlpha;
         break;
       }
       case Graphic3d_BT_Depth:
       {
-        theDI << aColor.Red() << "\n";
+        theDI << aColor.Red();
         break;
       }
     }
@@ -4498,16 +4563,11 @@ static Standard_Integer VPurgeDisplay (Draw_Interpretor& di,
                                 Standard_Integer argc,
                                 const char ** argv)
 {
-  if (argc > 2)
+  if (argc > 1)
   {
-    di << "Usage : " << argv[0] << " [CollectorToo = 0|1]" << "\n";
+    di << "Usage : " << argv[0] << "\n";
     return 1;
   }
-  Standard_Boolean isCollectorToo = Standard_False;
-  if (argc == 2)
-  {
-      isCollectorToo = (atoi(argv [1]) != 0);
-  }
   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
   if (aContext.IsNull())
   {
@@ -4515,7 +4575,7 @@ static Standard_Integer VPurgeDisplay (Draw_Interpretor& di,
     return 1;
   }
   aContext->CloseAllContexts(Standard_False);
-  di << aContext->PurgeDisplay(isCollectorToo) << "\n";
+  di << aContext->PurgeDisplay() << "\n";
   return 0;
 }
 
@@ -4790,6 +4850,1107 @@ static int VTextureEnv (Draw_Interpretor& /*theDI*/, Standard_Integer theArgNb,
   return 0;
 }
 
+//===============================================================================================
+//function : VClipPlane
+//purpose  :
+//===============================================================================================
+static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
+{
+  // use short-cut for created clip planes map of created (or "registered by name") clip planes
+  typedef NCollection_DataMap<TCollection_AsciiString, Handle(Graphic3d_ClipPlane)> MapOfPlanes;
+  static MapOfPlanes aRegPlanes;
+
+  if (theArgsNb < 2)
+  {
+    theDi << theArgVec[0] << ": command argument is required. Type help for more information.\n";
+    return 1;
+  }
+
+  TCollection_AsciiString aCommand (theArgVec[1]);
+
+  // print maximum number of planes for current viewer
+  if (aCommand == "maxplanes")
+  {
+    if (theArgsNb < 3)
+    {
+      theDi << theArgVec[0] << ": view name is required. Type help for more information.\n";
+      return 1;
+    }
+
+    TCollection_AsciiString aViewName (theArgVec[2]);
+
+    if (!ViewerTest_myViews.IsBound1 (aViewName))
+    {
+      theDi << theArgVec[0] << ": view is not found.\n";
+      return 1;
+    }
+
+    const Handle(V3d_View)& aView = ViewerTest_myViews.Find1 (aViewName);
+
+    theDi << theArgVec[0] << ": "
+                          << aView->Viewer()->Driver()->InquirePlaneLimit()
+                          << " plane slots provided by driver."
+                          << " Note that 2 more planes might be used (reserved for z-clipping).\n";
+
+    return 0;
+  }
+
+  // create / delete plane instance
+  if (aCommand == "create" || aCommand == "delete" || aCommand == "clone")
+  {
+    if (theArgsNb < 3)
+    {
+      theDi << theArgVec[0] << ": plane name is required. Type help for more information.\n";
+      return 1;
+    }
+
+    Standard_Boolean toCreate = (aCommand == "create");
+    Standard_Boolean toClone  = (aCommand == "clone");
+    TCollection_AsciiString aPlane (theArgVec[2]);
+
+    if (toCreate)
+    {
+      if (aRegPlanes.IsBound (aPlane))
+      {
+        theDi << theArgVec[0] << ": plane name is in use.\n";
+        return 1;
+      }
+
+      aRegPlanes.Bind (aPlane, new Graphic3d_ClipPlane());
+    }
+    else if (toClone) // toClone
+    {
+      if (!aRegPlanes.IsBound (aPlane))
+      {
+        theDi << theArgVec[0] << ": no such plane.\n";
+        return 1;
+      }
+
+      if (theArgsNb < 4)
+      {
+        theDi << theArgVec[0] << ": enter name for new plane. Type help for more information.\n";
+        return 1;
+      }
+
+      TCollection_AsciiString aClone (theArgVec[3]);
+      if (aRegPlanes.IsBound (aClone))
+      {
+        theDi << theArgVec[0] << ": plane name is in use.\n";
+        return 1;
+      }
+
+      const Handle(Graphic3d_ClipPlane)& aClipPlane = aRegPlanes.Find (aPlane);
+
+      aRegPlanes.Bind (aClone, aClipPlane->Clone());
+    }
+    else// toDelete
+    {
+      if (!aRegPlanes.IsBound (aPlane))
+      {
+        theDi << theArgVec[0] << ": no such plane.\n";
+        return 1;
+      }
+
+      Handle(Graphic3d_ClipPlane) aClipPlane = aRegPlanes.Find (aPlane);
+      aRegPlanes.UnBind (aPlane);
+
+      ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIObjIt (GetMapOfAIS());
+      for (; anIObjIt.More(); anIObjIt.Next())
+      {
+        Handle(PrsMgr_PresentableObject) aPrs = Handle(PrsMgr_PresentableObject)::DownCast (anIObjIt.Key1());
+        aPrs->RemoveClipPlane(aClipPlane);
+      }
+
+      NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator aViewIt(ViewerTest_myViews);
+      for (; aViewIt.More(); aViewIt.Next())
+      {
+        const Handle(V3d_View)& aView = aViewIt.Key2();
+        aView->RemoveClipPlane(aClipPlane);
+      }
+
+      ViewerTest::RedrawAllViews();
+    }
+
+    return 0;
+  }
+
+  // set / unset plane command
+  if (aCommand == "set" || aCommand == "unset")
+  {
+    if (theArgsNb < 4)
+    {
+      theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
+      return 1;
+    }
+
+    Standard_Boolean toSet = (aCommand == "set");
+    TCollection_AsciiString aPlane (theArgVec [2]);
+    if (!aRegPlanes.IsBound (aPlane))
+    {
+      theDi << theArgVec[0] << ": no such plane.\n";
+      return 1;
+    }
+
+    const Handle(Graphic3d_ClipPlane)& aClipPlane = aRegPlanes.Find (aPlane);
+
+    TCollection_AsciiString aTarget (theArgVec [3]);
+    if (aTarget != "object" && aTarget != "view")
+    {
+      theDi << theArgVec[0] << ": invalid target.\n";
+      return 1;
+    }
+
+    if (aTarget == "object" || aTarget == "view")
+    {
+      if (theArgsNb < 5)
+      {
+        theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
+        return 1;
+      }
+
+      Standard_Boolean isObject = (aTarget == "object");
+
+      for (Standard_Integer anIt = 4; anIt < theArgsNb; ++anIt)
+      {
+        TCollection_AsciiString anEntityName (theArgVec[anIt]);
+        if (isObject) // to object
+        {
+          if (!GetMapOfAIS().IsBound2 (anEntityName))
+          {
+            theDi << theArgVec[0] << ": can not find IO with name " << anEntityName << ".\n";
+            continue;
+          }
+
+          Handle(AIS_InteractiveObject) aIObj =
+            Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (anEntityName));
+
+          if (toSet)
+            aIObj->AddClipPlane (aClipPlane);
+          else
+            aIObj->RemoveClipPlane (aClipPlane);
+        }
+        else // to view
+        {
+          if (!ViewerTest_myViews.IsBound1 (anEntityName))
+          {
+            theDi << theArgVec[0] << ": can not find View with name " << anEntityName << ".\n";
+            continue;
+          }
+
+          Handle(V3d_View) aView = ViewerTest_myViews.Find1(anEntityName);
+          if (toSet)
+            aView->AddClipPlane (aClipPlane);
+          else
+            aView->RemoveClipPlane (aClipPlane);
+        }
+      }
+
+      ViewerTest::RedrawAllViews();
+    }
+
+    return 0;
+  }
+
+  // change plane command
+  if (aCommand == "change")
+  {
+    if (theArgsNb < 4)
+    {
+      theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
+      return 1;
+    }
+
+    TCollection_AsciiString aPlane (theArgVec [2]);
+    if (!aRegPlanes.IsBound (aPlane))
+    {
+      theDi << theArgVec[0] << ": no such plane.\n";
+      return 1;
+    }
+
+    const Handle(Graphic3d_ClipPlane)& aClipPlane = aRegPlanes.Find (aPlane);
+
+    TCollection_AsciiString aChangeArg (theArgVec [3]);
+    if (aChangeArg != "on" && aChangeArg != "off" && aChangeArg != "capping" && aChangeArg != "equation")
+    {
+      theDi << theArgVec[0] << ": invalid arguments. Type help for more information.\n";
+      return 1;
+    }
+
+    if (aChangeArg == "on" || aChangeArg == "off") // on / off
+    {
+      aClipPlane->SetOn (aChangeArg == "on");
+    }
+    else if (aChangeArg == "equation") // change equation
+    {
+      if (theArgsNb < 8)
+      {
+        theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
+        return 1;
+      }
+
+      Standard_Real aCoeffA = atof (theArgVec [4]);
+      Standard_Real aCoeffB = atof (theArgVec [5]);
+      Standard_Real aCoeffC = atof (theArgVec [6]);
+      Standard_Real aCoeffD = atof (theArgVec [7]);
+      aClipPlane->SetEquation (gp_Pln (aCoeffA, aCoeffB, aCoeffC, aCoeffD));
+    }
+    else if (aChangeArg == "capping") // change capping aspects
+    {
+      if (theArgsNb < 5)
+      {
+        theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
+        return 1;
+      }
+
+      TCollection_AsciiString aCappingArg (theArgVec [4]);
+      if (aCappingArg != "on" && aCappingArg != "off" &&
+          aCappingArg != "color" && aCappingArg != "texname" &&
+          aCappingArg != "texscale" && aCappingArg != "texorigin" &&
+          aCappingArg != "texrotate" && aCappingArg != "hatch")
+      {
+        theDi << theArgVec[0] << ": invalid arguments. Type help for more information.\n";
+        return 1;
+      }
+
+      if (aCappingArg == "on" || aCappingArg == "off") // on / off capping
+      {
+        aClipPlane->SetCapping (aCappingArg == "on");
+      }
+      else if (aCappingArg == "color") // color aspect for capping
+      {
+        if (theArgsNb < 8)
+        {
+          theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
+          return 1;
+        }
+
+        Standard_Real aRed = atof (theArgVec [5]);
+        Standard_Real aGrn = atof (theArgVec [6]);
+        Standard_Real aBlu = atof (theArgVec [7]);
+
+        Graphic3d_MaterialAspect aMat = aClipPlane->CappingMaterial();
+        aMat.SetColor (Quantity_Color (aRed, aGrn, aBlu, Quantity_TOC_RGB));
+        aClipPlane->SetCappingMaterial (aMat);
+      }
+      else if (aCappingArg == "texname") // texture name
+      {
+        if (theArgsNb < 6)
+        {
+          theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
+          return 1;
+        }
+
+        TCollection_AsciiString aTextureName (theArgVec [5]);
+
+        Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual(aTextureName);
+        if (!aTexture->IsDone ())
+        {
+          aClipPlane->SetCappingTexture (NULL);
+        }
+        else
+        {
+          aTexture->EnableModulate();
+          aTexture->EnableRepeat();
+          aClipPlane->SetCappingTexture (aTexture);
+        }
+      }
+      else if (aCappingArg == "texscale") // texture scale
+      {
+        if (aClipPlane->CappingTexture().IsNull())
+        {
+          theDi << theArgVec[0] << ": no texture is set.\n";
+          return 1;
+        }
+
+        if (theArgsNb < 7)
+        {
+          theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
+          return 1;
+        }
+
+        Standard_ShortReal aSx = (Standard_ShortReal)atof (theArgVec [5]);
+        Standard_ShortReal aSy = (Standard_ShortReal)atof (theArgVec [6]);
+
+        aClipPlane->CappingTexture()->GetParams()->SetScale (Graphic3d_Vec2 (aSx, aSy));
+      }
+      else if (aCappingArg == "texorigin") // texture origin
+      {
+        if (aClipPlane->CappingTexture().IsNull())
+        {
+          theDi << theArgVec[0] << ": no texture is set.\n";
+          return 1;
+        }
+
+        if (theArgsNb < 7)
+        {
+          theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
+          return 1;
+        }
+
+        Standard_ShortReal aTx = (Standard_ShortReal)atof (theArgVec [5]);
+        Standard_ShortReal aTy = (Standard_ShortReal)atof (theArgVec [6]);
+
+        aClipPlane->CappingTexture()->GetParams()->SetTranslation (Graphic3d_Vec2 (aTx, aTy));
+      }
+      else if (aCappingArg == "texrotate") // texture rotation
+      {
+        if (aClipPlane->CappingTexture().IsNull())
+        {
+          theDi << theArgVec[0] << ": no texture is set.\n";
+          return 1;
+        }
+
+        if (theArgsNb < 6)
+        {
+          theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
+          return 1;
+        }
+
+        Standard_ShortReal aRot = (Standard_ShortReal)atof (theArgVec[5]);
+
+        aClipPlane->CappingTexture()->GetParams()->SetRotation (aRot);
+      }
+      else if (aCappingArg == "hatch") // hatch style
+      {
+        if (theArgsNb < 6)
+        {
+          theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
+          return 1;
+        }
+
+        TCollection_AsciiString aHatchStr (theArgVec [5]);
+        if (aHatchStr == "on")
+        {
+          aClipPlane->SetCappingHatchOn();
+        }
+        else if (aHatchStr == "off")
+        {
+          aClipPlane->SetCappingHatchOff();
+        }
+        else
+        {
+          aClipPlane->SetCappingHatch ((Aspect_HatchStyle)atoi (theArgVec[5]));
+        }
+      }
+    }
+
+    ViewerTest::RedrawAllViews();
+
+    return 0;
+  }
+
+  theDi << theArgVec[0] << ": invalid command. Type help for more information.\n";
+  return 1;
+}
+
+//===============================================================================================
+//function : VSetTextureMode
+//purpose  :
+//===============================================================================================
+static int VSetTextureMode (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
+{
+  if (theArgsNb < 3)
+  {
+    theDi << theArgVec[0] << ": insufficient command arguments. Type help for more information.\n";
+    return 1;
+  }
+
+  TCollection_AsciiString aViewName (theArgVec[1]);
+  if (!ViewerTest_myViews.IsBound1 (aViewName))
+  {
+    theDi << theArgVec[0] << ": view is not found.\n";
+    return 1;
+  }
+
+  const Handle(V3d_View)& aView = ViewerTest_myViews.Find1 (aViewName);
+  switch (atoi (theArgVec[2]))
+  {
+    case 0: aView->SetSurfaceDetail (V3d_TEX_NONE); break;
+    case 1: aView->SetSurfaceDetail (V3d_TEX_ENVIRONMENT); break;
+    case 2: aView->SetSurfaceDetail (V3d_TEX_ALL); break;
+    default:
+      theDi << theArgVec[0] << ": invalid mode.\n";
+      return 1;
+  }
+
+  aView->Redraw();
+  return 0;
+}
+
+//===============================================================================================
+//function : VDefaults
+//purpose  :
+//===============================================================================================
+static int VDefaults (Draw_Interpretor& theDi,
+                      Standard_Integer  theArgsNb,
+                      const char**      theArgVec)
+{
+  const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
+  if (aCtx.IsNull())
+  {
+    std::cerr << "No active viewer!\n";
+    return 1;
+  }
+
+  Handle(Prs3d_Drawer) aDefParams = aCtx->DefaultDrawer();
+  if (theArgsNb < 2)
+  {
+    if (aDefParams->TypeOfDeflection() == Aspect_TOD_RELATIVE)
+    {
+      theDi << "DeflType:           relative\n"
+            << "DeviationCoeff:     " << aDefParams->DeviationCoefficient() << "\n";
+    }
+    else
+    {
+      theDi << "DeflType:           absolute\n"
+            << "AbsoluteDeflection: " << aDefParams->MaximalChordialDeviation() << "\n";
+    }
+    theDi << "AngularDeflection:  " << (180.0 * aDefParams->HLRAngle() / M_PI) << "\n";
+    return 0;
+  }
+
+  for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter)
+  {
+    TCollection_AsciiString anArg (theArgVec[anArgIter]);
+    TCollection_AsciiString aKey, aValue;
+    if (!ViewerTest::SplitParameter (anArg, aKey, aValue)
+     || aValue.IsEmpty())
+    {
+      std::cerr << "Error, wrong syntax at: '" << anArg.ToCString() << "'!\n";
+      return 1;
+    }
+
+    aKey.UpperCase();
+    if (aKey == "ABSDEFL"
+     || aKey == "ABSOLUTEDEFLECTION"
+     || aKey == "DEFL"
+     || aKey == "DEFLECTION")
+    {
+      aDefParams->SetTypeOfDeflection         (Aspect_TOD_ABSOLUTE);
+      aDefParams->SetMaximalChordialDeviation (aValue.RealValue());
+    }
+    else if (aKey == "RELDEFL"
+          || aKey == "RELATIVEDEFLECTION"
+          || aKey == "DEVCOEFF"
+          || aKey == "DEVIATIONCOEFF"
+          || aKey == "DEVIATIONCOEFFICIENT")
+    {
+      aDefParams->SetTypeOfDeflection     (Aspect_TOD_RELATIVE);
+      aDefParams->SetDeviationCoefficient (aValue.RealValue());
+    }
+    else if (aKey == "ANGDEFL"
+          || aKey == "ANGULARDEFL"
+          || aKey == "ANGULARDEFLECTION")
+    {
+      // currently HLRDeviationAngle is used instead of DeviationAngle in most places
+      aDefParams->SetHLRAngle (M_PI * aValue.RealValue() / 180.0);
+    }
+    else
+    {
+      std::cerr << "Warning, unknown argument '" << anArg.ToCString() << "'\n";
+    }
+  }
+
+  return 0;
+}
+
+//! Auxiliary method
+inline void addLight (const Handle(V3d_Light)& theLightNew,
+                      const Standard_Boolean   theIsGlobal)
+{
+  if (theLightNew.IsNull())
+  {
+    return;
+  }
+
+  if (theIsGlobal)
+  {
+    ViewerTest::GetViewerFromContext()->SetLightOn (theLightNew);
+  }
+  else
+  {
+    ViewerTest::CurrentView()->SetLightOn (theLightNew);
+  }
+}
+
+//! Auxiliary method
+inline Standard_Integer getLightId (const TCollection_AsciiString& theArgNext)
+{
+  TCollection_AsciiString anArgNextCase (theArgNext);
+  anArgNextCase.UpperCase();
+  if (anArgNextCase.Length() > 5
+   && anArgNextCase.SubString (1, 5).IsEqual ("LIGHT"))
+  {
+    return theArgNext.SubString (6, theArgNext.Length()).IntegerValue();
+  }
+  else
+  {
+    return theArgNext.IntegerValue();
+  }
+}
+
+//===============================================================================================
+//function : VLight
+//purpose  :
+//===============================================================================================
+static int VLight (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;
+  }
+
+  Standard_Real        anXYZ[3];
+  Quantity_Coefficient anAtten[2];
+  if (theArgsNb < 2)
+  {
+    // print lights info
+    Standard_Integer aLightId = 0;
+    for (aView->InitActiveLights(); aView->MoreActiveLights(); aView->NextActiveLights(), ++aLightId)
+    {
+      Handle(V3d_Light) aLight = aView->ActiveLight();
+      const Quantity_Color aColor = aLight->Color();
+      theDi << "Light" << aLightId << "\n";
+      switch (aLight->Type())
+      {
+        case V3d_AMBIENT:
+        {
+          theDi << "  Type:      Ambient\n";
+          break;
+        }
+        case V3d_DIRECTIONAL:
+        {
+          Handle(V3d_DirectionalLight) aLightDir = Handle(V3d_DirectionalLight)::DownCast (aLight);
+          theDi << "  Type:      Directional\n";
+          theDi << "  Headlight: " << (aLight->Headlight() ? "TRUE" : "FALSE") << "\n";
+          if (!aLightDir.IsNull())
+          {
+            aLightDir->Position  (anXYZ[0], anXYZ[1], anXYZ[2]);
+            theDi << "  Position:  " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
+            aLightDir->Direction (anXYZ[0], anXYZ[1], anXYZ[2]);
+            theDi << "  Direction: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
+          }
+          break;
+        }
+        case V3d_POSITIONAL:
+        {
+          Handle(V3d_PositionalLight) aLightPos = Handle(V3d_PositionalLight)::DownCast (aLight);
+          theDi << "  Type:      Positional\n";
+          theDi << "  Headlight: " << (aLight->Headlight() ? "TRUE" : "FALSE") << "\n";
+          if (!aLightPos.IsNull())
+          {
+            aLightPos->Position  (anXYZ[0], anXYZ[1], anXYZ[2]);
+            theDi << "  Position:  " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
+            aLightPos->Attenuation (anAtten[0], anAtten[1]);
+            theDi << "  Atten.:    " << anAtten[0] << " " << anAtten[1] << "\n";
+          }
+          break;
+        }
+        case V3d_SPOT:
+        {
+          Handle(V3d_SpotLight) aLightSpot = Handle(V3d_SpotLight)::DownCast (aLight);
+          theDi << "  Type:      Spot\n";
+          theDi << "  Headlight: " << (aLight->Headlight() ? "TRUE" : "FALSE") << "\n";
+          if (!aLightSpot.IsNull())
+          {
+            aLightSpot->Position  (anXYZ[0], anXYZ[1], anXYZ[2]);
+            theDi << "  Position:  " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
+            aLightSpot->Direction (anXYZ[0], anXYZ[1], anXYZ[2]);
+            theDi << "  Direction: " << anXYZ[0] << ", " << anXYZ[1] << ", " << anXYZ[2] << "\n";
+            aLightSpot->Attenuation (anAtten[0], anAtten[1]);
+            theDi << "  Atten.:    " << anAtten[0] << " " << anAtten[1] << "\n";
+            theDi << "  Angle:     " << (aLightSpot->Angle() * 180.0 / M_PI) << "\n";
+            theDi << "  Exponent:  " << aLightSpot->Concentration() << "\n";
+          }
+          break;
+        }
+        default:
+        {
+          theDi << "  Type:      UNKNOWN\n";
+          break;
+        }
+      }
+      theDi << "  Color:     " << aColor.Red() << ", " << aColor.Green() << ", " << aColor.Blue() << "\n";
+    }
+  }
+
+  Handle(V3d_Light) aLightNew;
+  Handle(V3d_Light) aLightOld;
+  Standard_Boolean  isGlobal = Standard_True;
+  Standard_Boolean  toCreate = Standard_False;
+  for (Standard_Integer anArgIt = 1; anArgIt < theArgsNb; ++anArgIt)
+  {
+    Handle(V3d_Light)            aLightCurr = aLightNew.IsNull() ? aLightOld : aLightNew;
+    Handle(V3d_AmbientLight)     aLightAmb  = Handle(V3d_AmbientLight)    ::DownCast (aLightCurr);
+    Handle(V3d_DirectionalLight) aLightDir  = Handle(V3d_DirectionalLight)::DownCast (aLightCurr);
+    Handle(V3d_PositionalLight)  aLightPos  = Handle(V3d_PositionalLight) ::DownCast (aLightCurr);
+    Handle(V3d_SpotLight)        aLightSpot = Handle(V3d_SpotLight)       ::DownCast (aLightCurr);
+
+    TCollection_AsciiString aName, aValue;
+    const TCollection_AsciiString anArg (theArgVec[anArgIt]);
+    TCollection_AsciiString anArgCase (anArg);
+    anArgCase.UpperCase();
+    if (anArgCase.IsEqual ("NEW")
+     || anArgCase.IsEqual ("ADD")
+     || anArgCase.IsEqual ("CREATE"))
+    {
+      toCreate = Standard_True;
+    }
+    else if (anArgCase.IsEqual ("GLOB")
+          || anArgCase.IsEqual ("GLOBAL"))
+    {
+      isGlobal = Standard_True;
+    }
+    else if (anArgCase.IsEqual ("LOC")
+          || anArgCase.IsEqual ("LOCAL"))
+    {
+      isGlobal = Standard_False;
+    }
+    else if (anArgCase.IsEqual ("DEF")
+          || anArgCase.IsEqual ("DEFAULTS"))
+    {
+      toCreate = Standard_False;
+      aViewer->SetDefaultLights();
+    }
+    else if (anArgCase.IsEqual ("CLR")
+          || anArgCase.IsEqual ("CLEAR"))
+    {
+      toCreate = Standard_False;
+      aView->InitActiveLights();
+      while (aView->MoreActiveLights())
+      {
+        aViewer->DelLight (aView->ActiveLight());
+        aView->InitActiveLights();
+      }
+    }
+    else if (anArgCase.IsEqual ("AMB")
+          || anArgCase.IsEqual ("AMBIENT")
+          || anArgCase.IsEqual ("AMBLIGHT"))
+    {
+      addLight (aLightNew, isGlobal);
+      if (!toCreate)
+      {
+        std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
+        return 1;
+      }
+      toCreate  = Standard_False;
+      aLightNew = new V3d_AmbientLight (aViewer);
+    }
+    else if (anArgCase.IsEqual ("DIRECTIONAL")
+          || anArgCase.IsEqual ("DIRLIGHT"))
+    {
+      addLight (aLightNew, isGlobal);
+      if (!toCreate)
+      {
+        std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
+        return 1;
+      }
+      toCreate  = Standard_False;
+      aLightNew = new V3d_DirectionalLight (aViewer);
+    }
+    else if (anArgCase.IsEqual ("SPOT")
+          || anArgCase.IsEqual ("SPOTLIGHT"))
+    {
+      addLight (aLightNew, isGlobal);
+      if (!toCreate)
+      {
+        std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
+        return 1;
+      }
+      toCreate  = Standard_False;
+      aLightNew = new V3d_SpotLight (aViewer, 0.0, 0.0, 0.0);
+    }
+    else if (anArgCase.IsEqual ("POSLIGHT")
+          || anArgCase.IsEqual ("POSITIONAL"))
+    {
+      addLight (aLightNew, isGlobal);
+      if (!toCreate)
+      {
+        std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
+        return 1;
+      }
+      toCreate  = Standard_False;
+      aLightNew = new V3d_PositionalLight (aViewer, 0.0, 0.0, 0.0);
+    }
+    else if (anArgCase.IsEqual ("CHANGE"))
+    {
+      addLight (aLightNew, isGlobal);
+      aLightNew.Nullify();
+      if (++anArgIt >= theArgsNb)
+      {
+        std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
+        return 1;
+      }
+
+      const Standard_Integer aLightId = getLightId (theArgVec[anArgIt]);
+      Standard_Integer aLightIt = 0;
+      for (aView->InitActiveLights(); aView->MoreActiveLights(); aView->NextActiveLights(), ++aLightIt)
+      {
+        if (aLightIt == aLightId)
+        {
+          aLightOld = aView->ActiveLight();
+          break;
+        }
+      }
+
+      if (aLightOld.IsNull())
+      {
+        std::cerr << "Light " << theArgVec[anArgIt] << " is undefined!\n";
+        return 1;
+      }
+    }
+    else if (anArgCase.IsEqual ("DEL")
+          || anArgCase.IsEqual ("DELETE"))
+    {
+      Handle(V3d_Light) aLightDel;
+      if (++anArgIt >= theArgsNb)
+      {
+        std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
+        return 1;
+      }
+
+      const TCollection_AsciiString anArgNext (theArgVec[anArgIt]);
+      const Standard_Integer aLightDelId = getLightId (theArgVec[anArgIt]);
+      Standard_Integer aLightIt = 0;
+      for (aView->InitActiveLights(); aView->MoreActiveLights(); aView->NextActiveLights(), ++aLightIt)
+      {
+        aLightDel = aView->ActiveLight();
+        if (aLightIt == aLightDelId)
+        {
+          break;
+        }
+      }
+      if (!aLightDel.IsNull())
+      {
+        aViewer->DelLight (aLightDel);
+      }
+    }
+    else if (anArgCase.IsEqual ("COLOR")
+          || anArgCase.IsEqual ("COLOUR"))
+    {
+      if (++anArgIt >= theArgsNb)
+      {
+        std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
+        return 1;
+      }
+
+      TCollection_AsciiString anArgNext (theArgVec[anArgIt]);
+      anArgNext.UpperCase();
+      const Quantity_Color aColor = ViewerTest::GetColorFromName (anArgNext.ToCString());
+      if (!aLightCurr.IsNull())
+      {
+        aLightCurr->SetColor (aColor);
+      }
+    }
+    else if (anArgCase.IsEqual ("POS")
+          || anArgCase.IsEqual ("POSITION"))
+    {
+      if ((anArgIt + 3) >= theArgsNb)
+      {
+        std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
+        return 1;
+      }
+
+      anXYZ[0] = Atof (theArgVec[++anArgIt]);
+      anXYZ[1] = Atof (theArgVec[++anArgIt]);
+      anXYZ[2] = Atof (theArgVec[++anArgIt]);
+      if (!aLightDir.IsNull())
+      {
+        aLightDir->SetPosition (anXYZ[0], anXYZ[1], anXYZ[2]);
+      }
+      else if (!aLightPos.IsNull())
+      {
+        aLightPos->SetPosition (anXYZ[0], anXYZ[1], anXYZ[2]);
+      }
+      else if (!aLightSpot.IsNull())
+      {
+        aLightSpot->SetPosition (anXYZ[0], anXYZ[1], anXYZ[2]);
+      }
+      else
+      {
+        std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
+        return 1;
+      }
+    }
+    else if (anArgCase.IsEqual ("DIR")
+          || anArgCase.IsEqual ("DIRECTION"))
+    {
+      if ((anArgIt + 3) >= theArgsNb)
+      {
+        std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
+        return 1;
+      }
+
+      anXYZ[0] = Atof (theArgVec[++anArgIt]);
+      anXYZ[1] = Atof (theArgVec[++anArgIt]);
+      anXYZ[2] = Atof (theArgVec[++anArgIt]);
+      if (!aLightDir.IsNull())
+      {
+        aLightDir->SetDirection (anXYZ[0], anXYZ[1], anXYZ[2]);
+      }
+      else if (!aLightSpot.IsNull())
+      {
+        aLightSpot->SetDirection (anXYZ[0], anXYZ[1], anXYZ[2]);
+      }
+      else
+      {
+        std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
+        return 1;
+      }
+    }
+    else if (anArgCase.IsEqual ("ANG")
+          || anArgCase.IsEqual ("ANGLE"))
+    {
+      if (++anArgIt >= theArgsNb)
+      {
+        std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
+        return 1;
+      }
+
+      Standard_Real anAngle = Atof (theArgVec[anArgIt]);
+
+      if (!aLightSpot.IsNull())
+      {
+        aLightSpot->SetAngle (anAngle / 180.0 * M_PI);
+      }
+    }
+    else if (anArgCase.IsEqual ("CONSTATTEN")
+          || anArgCase.IsEqual ("CONSTATTENUATION"))
+    {
+      if (++anArgIt >= theArgsNb)
+      {
+        std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
+        return 1;
+      }
+
+      if (!aLightPos.IsNull())
+      {
+        aLightPos->Attenuation (anAtten[0], anAtten[1]);
+        anAtten[0] = Atof (theArgVec[anArgIt]);
+        aLightPos->SetAttenuation (anAtten[0], anAtten[1]);
+      }
+      else if (!aLightSpot.IsNull())
+      {
+        aLightSpot->Attenuation (anAtten[0], anAtten[1]);
+        anAtten[0] = Atof (theArgVec[anArgIt]);
+        aLightSpot->SetAttenuation (anAtten[0], anAtten[1]);
+      }
+      else
+      {
+        std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
+        return 1;
+      }
+    }
+    else if (anArgCase.IsEqual ("LINATTEN")
+          || anArgCase.IsEqual ("LINEARATTEN")
+          || anArgCase.IsEqual ("LINEARATTENUATION"))
+    {
+      if (++anArgIt >= theArgsNb)
+      {
+        std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
+        return 1;
+      }
+
+      if (!aLightPos.IsNull())
+      {
+        aLightPos->Attenuation (anAtten[0], anAtten[1]);
+        anAtten[1] = Atof (theArgVec[anArgIt]);
+        aLightPos->SetAttenuation (anAtten[0], anAtten[1]);
+      }
+      else if (!aLightSpot.IsNull())
+      {
+        aLightSpot->Attenuation (anAtten[0], anAtten[1]);
+        anAtten[1] = Atof (theArgVec[anArgIt]);
+        aLightSpot->SetAttenuation (anAtten[0], anAtten[1]);
+      }
+      else
+      {
+        std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
+        return 1;
+      }
+    }
+    else if (anArgCase.IsEqual ("EXP")
+          || anArgCase.IsEqual ("EXPONENT")
+          || anArgCase.IsEqual ("SPOTEXP")
+          || anArgCase.IsEqual ("SPOTEXPONENT"))
+    {
+      if (++anArgIt >= theArgsNb)
+      {
+        std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
+        return 1;
+      }
+
+      if (!aLightSpot.IsNull())
+      {
+        aLightSpot->SetConcentration (Atof (theArgVec[anArgIt]));
+      }
+      else
+      {
+        std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
+        return 1;
+      }
+    }
+    else if (anArgCase.IsEqual ("HEAD")
+          || anArgCase.IsEqual ("HEADLIGHT"))
+    {
+      if (++anArgIt >= theArgsNb)
+      {
+        std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
+        return 1;
+      }
+
+      if (aLightAmb.IsNull()
+       && !aLightCurr.IsNull())
+      {
+        aLightCurr->SetHeadlight (Draw::Atoi (theArgVec[anArgIt]) != 0);
+      }
+      else
+      {
+        std::cerr << "Wrong syntax at argument '" << anArg << "'!\n";
+        return 1;
+      }
+    }
+    else
+    {
+      std::cerr << "Warning: unknown argument '" << anArg << "'\n";
+    }
+  }
+
+  addLight (aLightNew, isGlobal);
+  aViewer->UpdateLights();
+
+  return 0;
+}
+
+
+
+//==============================================================================
+//function : VClInfo
+//purpose  : Prints info about active OpenCL device
+//==============================================================================
+
+static Standard_Integer VClInfo (Draw_Interpretor& theDi,
+                                 Standard_Integer,
+                                 const char**)
+{
+  Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
+  if (aContextAIS.IsNull())
+  {
+    std::cerr << "Call vinit before!\n";
+    return 1;
+  }
+
+  Handle(OpenGl_GraphicDriver) aDrv = Handle(OpenGl_GraphicDriver)::DownCast (aContextAIS->CurrentViewer()->Driver());
+  Graphic3d_CView* aCView = static_cast<Graphic3d_CView*> (ViewerTest::CurrentView()->View()->CView());
+  NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString> anInfo;
+  if (aDrv.IsNull()
+   || aCView == NULL
+   || !aDrv->GetOpenClDeviceInfo (*aCView, anInfo))
+  {
+    theDi << "OpenCL device info is unavailable!\n";
+    return 0;
+  }
+
+  theDi << "OpenCL device info:\n";
+  for (NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString>::Iterator anIter (anInfo);
+       anIter.More(); anIter.Next())
+  {
+    theDi << anIter.Key() << ": \t" << anIter.Value() << "\n";
+  }
+  return 0;
+}
+
+//=======================================================================
+//function : VRaytrace
+//purpose  : Enables/disables OpenCL-based ray-tracing
+//=======================================================================
+
+static Standard_Integer VRaytrace (Draw_Interpretor& ,
+                                   Standard_Integer  theArgNb,
+                                   const char**      theArgVec)
+{
+  Handle(V3d_View) aView = ViewerTest::CurrentView();
+  if (aView.IsNull())
+  {
+    std::cerr << "Use 'vinit' command before " << theArgVec[0] << "\n";
+    return 1;
+  }
+
+  if (theArgNb < 2
+   || Draw::Atoi (theArgVec[1]))
+  {
+    aView->SetRaytracingMode();
+  }
+  else
+  {
+    aView->SetRasterizationMode();
+  }
+  aView->Redraw();
+  return 0;
+}
+
+//=======================================================================
+//function : VSetRaytraceMode
+//purpose  : Enables/disables features of OpenCL-based ray-tracing
+//=======================================================================
+
+static Standard_Integer VSetRaytraceMode (Draw_Interpretor&,
+                                          Standard_Integer theArgNb,
+                                          const char ** theArgVec)
+{
+  Handle(V3d_View) aView = ViewerTest::CurrentView();
+  if (aView.IsNull())
+  {
+    std::cerr << "Use 'vinit' command before " << theArgVec[0] << "\n";
+    return 1;
+  }
+  else if (theArgNb < 2)
+  {
+    std::cerr << "Usage : " << theArgVec[0] << " [shad=0|1] [refl=0|1] [aa=0|1]\n";
+    return 1;
+  }
+
+  for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
+  {
+    const TCollection_AsciiString anArg (theArgVec[anArgIter]);
+
+    if (anArg.Search ("shad=") > -1)
+    {
+      if (anArg.Token ("=", 2).IntegerValue() != 0)
+        aView->EnableRaytracedShadows();
+      else
+        aView->DisableRaytracedShadows();
+    }
+    else if (anArg.Search ("refl=") > -1)
+    {
+      if (anArg.Token ("=", 2).IntegerValue() != 0)
+        aView->EnableRaytracedReflections();
+      else
+        aView->DisableRaytracedReflections();
+    }
+    else if (anArg.Search ("aa=") > -1)
+    {
+      if (anArg.Token ("=", 2).IntegerValue() != 0)
+        aView->EnableRaytracedAntialiasing();
+      else
+        aView->DisableRaytracedAntialiasing();
+    }
+    else
+    {
+      std::cerr << "Unknown argument: " << anArg << "\n";
+    }
+  }
+
+  aView->Redraw();
+  return 0;
+}
+
 //=======================================================================
 //function : ViewerCommands
 //purpose  :
@@ -4820,7 +5981,7 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
     "Additional commands for operations with views: vclose, vactivate, vviewlist.\n",
     __FILE__,VInit,group);
   theCommands.Add("vclose" ,
-    "view_id [keep_context=0|1]\n"
+    "[view_id [keep_context=0|1]]\n"
     "or vclose ALL - to remove all created views\n"
     " - removes view(viewer window) defined by its view_id.\n"
     " - keep_context: by default 0; if 1 and the last view is deleted"
@@ -4952,7 +6113,7 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
     "vvbo [{0|1}] : turn VBO usage On/Off; affects only newly displayed objects",
     __FILE__, VVbo, group);
   theCommands.Add ("vcaps",
-    "vcaps [vbo={0|1}] [sprites={0|1}] : modify particular graphic driver options",
+    "vcaps [vbo={0|1}] [sprites={0|1}] [soft={0|1}] : modify particular graphic driver options",
     __FILE__, VCaps, group);
   theCommands.Add ("vmemgpu",
     "vmemgpu [f]: print system-dependent GPU memory information if available;"
@@ -4996,7 +6157,7 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
     "vantialiasing 1|0",
     __FILE__,VAntialiasing,group);
   theCommands.Add ("vpurgedisplay",
-    "vpurgedisplay [CollectorToo = 0|1]"
+    "vpurgedisplay"
     "- removes structures which don't belong to objects displayed in neutral point",
     __FILE__, VPurgeDisplay, group);
   theCommands.Add("vsetviewsize",
@@ -5038,4 +6199,49 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
     "If shapes are not given HLR algoithm of given type is applied"
     " to all shapes in the view\n",
     __FILE__,VHLRType,group);
+  theCommands.Add("vclipplane", "vclipplane usage: \n"
+    "  maxplanes <view_name> - get plane limit for view.\n"
+    "  create <plane_name> - create new plane.\n"
+    "  delete <plane_name> - delete plane.\n"
+    "  clone <source_plane> <plane_name> - clone the plane definition.\n"
+    "  set/unset <plane_name> object <object list> - set/unset plane for IO.\n"
+    "  set/unset <plane_name> view <view list> - set/unset plane for view.\n"
+    "  change <plane_name> on/off - turn clipping on/off.\n"
+    "  change <plane_name> equation <a> <b> <c> <d> - change plane equation.\n"
+    "  change <plane_name> capping on/off - turn capping on/off.\n"
+    "  change <plane_name> capping color <r> <g> <b> - set color.\n"
+    "  change <plane name> capping texname <texture> - set texture.\n"
+    "  change <plane_name> capping texscale <sx> <sy> - set tex scale.\n"
+    "  change <plane_name> capping texorigin <tx> <ty> - set tex origin.\n"
+    "  change <plane_name> capping texrotate <angle> - set tex rotation.\n"
+    "  change <plane_name> capping hatch on/off/<id> - set hatching mask.\n"
+    "  please use VSetTextureMode command to enable texture rendering in view.\n"
+    , __FILE__, VClipPlane, group);
+  theCommands.Add("vsettexturemode", "vsettexturemode view_name mode \n"
+    "  mode can be:\n"
+    "  0 - no textures enabled in view.\n"
+    "  1 - only environment textures enabled.\n"
+    "  2 - all textures enabled.\n"
+    "  this command sets texture details mode for the specified view.\n"
+    , __FILE__, VSetTextureMode, group);
+  theCommands.Add("vdefaults",
+    "vdefaults [absDefl=value] [devCoeff=value] [angDefl=value]",
+    __FILE__, VDefaults, group);
+  theCommands.Add("vlight",
+            "vlight [add|new {amb}ient|directional|{spot}light|positional]"
+    "\n\t\t:        [{def}aults] [clear]"
+    "\n\t\t:        [{del}ete|change lightId] [local|global]"
+    "\n\t\t:        [{pos}ition X Y Z] [color colorName] [{head}light 0|1]"
+    "\n\t\t:        [{constAtten}uation value] [{linearAtten}uation value]"
+    "\n\t\t:        [angle angleDeg] [{spotexp}onent value]",
+    __FILE__, VLight, group);
+  theCommands.Add("vraytrace",
+    "vraytrace 0|1",
+    __FILE__,VRaytrace,group);
+  theCommands.Add("vclinfo",
+    "vclinfo",
+    __FILE__,VClInfo,group);
+  theCommands.Add("vsetraytracemode",
+    "vsetraytracemode [shad=0|1] [refl=0|1] [aa=0|1]",
+    __FILE__,VSetRaytraceMode,group);
 }