0031221: Visualization - selection filter in context
[occt.git] / src / ViewerTest / ViewerTest.cxx
index 109f9d4..dc613f9 100644 (file)
 #include <TopExp_Explorer.hxx>
 #include <BRepAdaptor_Curve.hxx>
 #include <StdSelect_ShapeTypeFilter.hxx>
-#include <AIS.hxx>
 #include <AIS_ColoredShape.hxx>
 #include <AIS_InteractiveObject.hxx>
 #include <AIS_Trihedron.hxx>
 #include <AIS_Axis.hxx>
-#include <AIS_Relation.hxx>
+#include <PrsDim.hxx>
+#include <PrsDim_Relation.hxx>
 #include <AIS_TypeFilter.hxx>
 #include <AIS_SignatureFilter.hxx>
 #include <AIS_ListOfInteractive.hxx>
@@ -50,7 +50,9 @@
 #include <Graphic3d_CStructure.hxx>
 #include <Graphic3d_Texture2Dmanual.hxx>
 #include <Graphic3d_GraphicDriver.hxx>
+#include <Graphic3d_MediaTextureSet.hxx>
 #include <Image_AlienPixMap.hxx>
+#include <Message.hxx>
 #include <OSD_File.hxx>
 #include <Prs3d_Drawer.hxx>
 #include <Prs3d_ShadingAspect.hxx>
@@ -63,6 +65,7 @@
 #include <StdSelect_ViewerSelector3d.hxx>
 #include <TopTools_MapOfShape.hxx>
 #include <ViewerTest_AutoUpdater.hxx>
+#include <Aspect_XRSession.hxx>
 
 #include <stdio.h>
 
@@ -82,8 +85,8 @@ extern int ViewerMainLoop(Standard_Integer argc, const char** argv);
 #define DEFAULT_MATERIAL           Graphic3d_NOM_BRASS
 
 //=======================================================================
-//function : GetColorFromName
-//purpose  : get the Quantity_NameOfColor from a string
+// function : GetColorFromName
+// purpose  : get the Quantity_NameOfColor from a string
 //=======================================================================
 
 Quantity_NameOfColor ViewerTest::GetColorFromName (const Standard_CString theName)
@@ -94,53 +97,25 @@ Quantity_NameOfColor ViewerTest::GetColorFromName (const Standard_CString theNam
 }
 
 //=======================================================================
-//function : ParseColor
-//purpose  :
+// function : ParseColor
+// purpose  :
 //=======================================================================
-
-Standard_Integer ViewerTest::ParseColor (Standard_Integer  theArgNb,
-                                         const char**      theArgVec,
-                                         Quantity_Color&   theColor)
+Standard_Integer ViewerTest::ParseColor (const Standard_Integer   theArgNb,
+                                         const char* const* const theArgVec,
+                                         Quantity_ColorRGBA&      theColor)
 {
-  Quantity_NameOfColor aColor = Quantity_NOC_BLACK;
-  if (theArgNb >= 1
-   && Quantity_Color::ColorFromName (theArgVec[0], aColor))
-  {
-    theColor = aColor;
-    return 1;
-  }
-  else if (theArgNb >= 3)
-  {
-    const TCollection_AsciiString anRgbStr[3] =
-    {
-      theArgVec[0],
-      theArgVec[1],
-      theArgVec[2]
-    };
-    if (!anRgbStr[0].IsRealValue()
-     || !anRgbStr[1].IsRealValue()
-     || !anRgbStr[2].IsRealValue())
-    {
-      return 0;
-    }
-
-    Graphic3d_Vec4d anRgb;
-    anRgb.x() = anRgbStr[0].RealValue();
-    anRgb.y() = anRgbStr[1].RealValue();
-    anRgb.z() = anRgbStr[2].RealValue();
-    if (anRgb.x() < 0.0 || anRgb.x() > 1.0
-     || anRgb.y() < 0.0 || anRgb.y() > 1.0
-     || anRgb.z() < 0.0 || anRgb.z() > 1.0)
-    {
-      std::cout << "Error: RGB color values should be within range 0..1!\n";
-      return 0;
-    }
-
-    theColor.SetValues (anRgb.x(), anRgb.y(), anRgb.z(), Quantity_TOC_RGB);
-    return 3;
-  }
+  return Draw::ParseColor (theArgNb, theArgVec, theColor);
+}
 
-  return 0;
+//=======================================================================
+// function : ParseColor
+// purpose  :
+//=======================================================================
+Standard_Integer ViewerTest::ParseColor (const Standard_Integer   theArgNb,
+                                         const char* const* const theArgVec,
+                                         Quantity_Color&          theColor)
+{
+  return Draw::ParseColor (theArgNb, theArgVec, theColor);
 }
 
 //=======================================================================
@@ -150,21 +125,7 @@ Standard_Integer ViewerTest::ParseColor (Standard_Integer  theArgNb,
 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;
+  return Draw::ParseOnOff (theArg, theIsOn);
 }
 
 //=======================================================================
@@ -187,39 +148,74 @@ void ViewerTest::GetSelectedShapes (TopTools_ListOfShape& theSelectedShapes)
 //function : ParseLineType
 //purpose  :
 //=======================================================================
-Standard_Boolean ViewerTest::ParseLineType (Standard_CString   theArg,
-                                            Aspect_TypeOfLine& theType)
+Standard_Boolean ViewerTest::ParseLineType (Standard_CString theArg,
+                                            Aspect_TypeOfLine& theType,
+                                            uint16_t& thePattern)
 {
   TCollection_AsciiString aTypeStr (theArg);
   aTypeStr.LowerCase();
-  if (aTypeStr == "empty")
+  if (aTypeStr == "empty"
+   || aTypeStr == "-1")
   {
     theType = Aspect_TOL_EMPTY;
+    thePattern = Graphic3d_Aspects::DefaultLinePatternForType (theType);
   }
-  else if (aTypeStr == "solid")
+  else if (aTypeStr == "solid"
+        || aTypeStr == "0")
   {
     theType = Aspect_TOL_SOLID;
+    thePattern = Graphic3d_Aspects::DefaultLinePatternForType (theType);
   }
-  else if (aTypeStr == "dot")
+  else if (aTypeStr == "dot"
+        || aTypeStr == "2")
   {
     theType = Aspect_TOL_DOT;
+    thePattern = Graphic3d_Aspects::DefaultLinePatternForType (theType);
   }
-  else if (aTypeStr == "dash")
+  else if (aTypeStr == "dash"
+        || aTypeStr == "1")
   {
     theType = Aspect_TOL_DASH;
+    thePattern = Graphic3d_Aspects::DefaultLinePatternForType (theType);
   }
-  else if (aTypeStr == "dotdash")
+  else if (aTypeStr == "dotdash"
+        || aTypeStr == "3")
   {
     theType = Aspect_TOL_DOTDASH;
+    thePattern = Graphic3d_Aspects::DefaultLinePatternForType (theType);
   }
   else
   {
-    const int aTypeInt = Draw::Atoi (theArg);
-    if (aTypeInt < -1 || aTypeInt >= Aspect_TOL_USERDEFINED)
+    if (aTypeStr.StartsWith ("0x"))
+    {
+      aTypeStr = aTypeStr.SubString (3, aTypeStr.Length());
+    }
+
+    if (aTypeStr.Length() != 4
+    || !std::isxdigit (static_cast<unsigned char> (aTypeStr.Value (1)))
+    || !std::isxdigit (static_cast<unsigned char> (aTypeStr.Value (2)))
+    || !std::isxdigit (static_cast<unsigned char> (aTypeStr.Value (3)))
+    || !std::isxdigit (static_cast<unsigned char> (aTypeStr.Value (4))))
+    {
+      return Standard_False;
+    }
+
+    std::stringstream aStream;
+    aStream << std::setbase (16) << aTypeStr.ToCString();
+    if (aStream.fail())
+    {
+      return Standard_False;
+    }
+
+    Standard_Integer aNumber = -1;
+    aStream >> aNumber;
+    if (aStream.fail())
     {
       return Standard_False;
     }
-    theType = (Aspect_TypeOfLine )aTypeInt;
+
+    thePattern = (uint16_t )aNumber;
+    theType = Graphic3d_Aspects::DefaultLineTypeForPattern (thePattern);
   }
   return Standard_True;
 }
@@ -362,6 +358,14 @@ Standard_Boolean ViewerTest::ParseShadingModel (Standard_CString              th
   {
     theModel = Graphic3d_TOSM_FRAGMENT;
   }
+  else if (aTypeStr == "pbr")
+  {
+    theModel = Graphic3d_TOSM_PBR;
+  }
+  else if (aTypeStr == "pbr_facet")
+  {
+    theModel = Graphic3d_TOSM_PBR_FACET;
+  }
   else if (aTypeStr == "default"
         || aTypeStr == "def")
   {
@@ -383,6 +387,75 @@ Standard_Boolean ViewerTest::ParseShadingModel (Standard_CString              th
   return Standard_True;
 }
 
+//=======================================================================
+//function : parseZLayer
+//purpose  :
+//=======================================================================
+Standard_Boolean ViewerTest::parseZLayer (Standard_CString theArg,
+                                          Standard_Boolean theToAllowInteger,
+                                          Graphic3d_ZLayerId& theLayer)
+{
+  TCollection_AsciiString aName (theArg);
+  aName.LowerCase();
+  if (aName == "default"
+   || aName == "def")
+  {
+    theLayer = Graphic3d_ZLayerId_Default;
+  }
+  else if (aName == "top")
+  {
+    theLayer = Graphic3d_ZLayerId_Top;
+  }
+  else if (aName == "topmost")
+  {
+    theLayer = Graphic3d_ZLayerId_Topmost;
+  }
+  else if (aName == "overlay"
+        || aName == "toposd")
+  {
+    theLayer = Graphic3d_ZLayerId_TopOSD;
+  }
+  else if (aName == "underlay"
+        || aName == "botosd")
+  {
+    theLayer = Graphic3d_ZLayerId_BotOSD;
+  }
+  else if (aName == "undefined")
+  {
+    theLayer = Graphic3d_ZLayerId_UNKNOWN;
+  }
+  else if (!GetAISContext().IsNull())
+  {
+    const Handle(V3d_Viewer)& aViewer = ViewerTest::GetAISContext()->CurrentViewer();
+    TColStd_SequenceOfInteger aLayers;
+    aViewer->GetAllZLayers (aLayers);
+    for (TColStd_SequenceOfInteger::Iterator aLayeriter (aLayers); aLayeriter.More(); aLayeriter.Next())
+    {
+      Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (aLayeriter.Value());
+      if (TCollection_AsciiString::IsSameString (aSettings.Name(), aName, Standard_False))
+      {
+        theLayer = aLayeriter.Value();
+        return true;
+      }
+    }
+
+    if (!theToAllowInteger
+     || !aName.IsIntegerValue())
+    {
+      return false;
+    }
+    Graphic3d_ZLayerId aLayer = aName.IntegerValue();
+    if (aLayer == Graphic3d_ZLayerId_UNKNOWN
+     || std::find (aLayers.begin(), aLayers.end(), aLayer) != aLayers.end())
+    {
+      theLayer = aLayer;
+      return true;
+    }
+    return false;
+  }
+  return true;
+}
+
 //=======================================================================
 //function : GetTypeNames
 //purpose  :
@@ -495,7 +568,7 @@ Standard_Boolean ViewerTest::Display (const TCollection_AsciiString&       theNa
   Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
   if (aCtx.IsNull())
   {
-    std::cout << "Error: AIS context is not available.\n";
+    Message::SendFail ("Error: AIS context is not available.");
     return Standard_False;
   }
 
@@ -503,13 +576,12 @@ Standard_Boolean ViewerTest::Display (const TCollection_AsciiString&       theNa
   {
     if (!theReplaceIfExists)
     {
-      std::cout << "Error: other interactive object has been already registered with name: " << theName << ".\n"
-                << "Please use another name.\n";
+      Message::SendFail() << "Error: other interactive object has been already registered with name: " << theName << ".\n"
+                          << "Please use another name.";
       return Standard_False;
     }
 
-    Handle(AIS_InteractiveObject) anOldObj = Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (theName));
-    if (!anOldObj.IsNull())
+    if (Handle(AIS_InteractiveObject) anOldObj = aMap.Find2 (theName))
     {
       aCtx->Remove (anOldObj, theObject.IsNull() && theToUpdate);
     }
@@ -539,15 +611,7 @@ Standard_EXPORT Standard_Boolean VDisplayAISObject (const TCollection_AsciiStrin
   return ViewerTest::Display (theName, theObject, Standard_True, theReplaceIfExists);
 }
 
-static TColStd_MapOfInteger theactivatedmodes(8);
-static TColStd_ListOfTransient theEventMgrs;
-
-static void VwrTst_InitEventMgr(const Handle(V3d_View)& aView,
-                                const Handle(AIS_InteractiveContext)& Ctx)
-{
-  theEventMgrs.Clear();
-  theEventMgrs.Prepend(new ViewerTest_EventManager(aView, Ctx));
-}
+static NCollection_List<Handle(ViewerTest_EventManager)> theEventMgrs;
 
 static Handle(V3d_View)&  a3DView()
 {
@@ -604,17 +668,15 @@ void ViewerTest::UnsetEventManager()
 
 void ViewerTest::ResetEventManager()
 {
-  const Handle(V3d_View) aView = ViewerTest::CurrentView();
-  VwrTst_InitEventMgr(aView, ViewerTest::GetAISContext());
+  theEventMgrs.Clear();
+  theEventMgrs.Prepend (new ViewerTest_EventManager (ViewerTest::CurrentView(), ViewerTest::GetAISContext()));
 }
 
 Handle(ViewerTest_EventManager) ViewerTest::CurrentEventManager()
 {
-  Handle(ViewerTest_EventManager) EM;
-  if(theEventMgrs.IsEmpty()) return EM;
-  Handle(Standard_Transient) Tr =  theEventMgrs.First();
-  EM = Handle(ViewerTest_EventManager)::DownCast (Tr);
-  return EM;
+  return !theEventMgrs.IsEmpty()
+        ? theEventMgrs.First()
+        : Handle(ViewerTest_EventManager)();
 }
 
 //=======================================================================
@@ -629,62 +691,12 @@ static Standard_Boolean getCtxAndView (Handle(AIS_InteractiveContext)& theCtx,
   if (theCtx.IsNull()
    || theView.IsNull())
   {
-    std::cout << "Error: cannot find an active view!\n";
+    Message::SendFail ("Error: cannot find an active view!");
     return Standard_False;
   }
   return Standard_True;
 }
 
-//==============================================================================
-//function : GetShapeFromName
-//purpose  : Compute an Shape from a draw variable or a file name
-//==============================================================================
-
-static TopoDS_Shape GetShapeFromName(const char* name)
-{
-  TopoDS_Shape S = DBRep::Get(name);
-
-  if ( S.IsNull() ) {
-       BRep_Builder aBuilder;
-       BRepTools::Read( S, name, aBuilder);
-  }
-
-  return S;
-}
-
-//==============================================================================
-//function : GetAISShapeFromName
-//purpose  : Compute an AIS_Shape from a draw variable or a file name
-//==============================================================================
-Handle(AIS_Shape) GetAISShapeFromName(const char* name)
-{
-  Handle(AIS_Shape) retsh;
-
-  if(GetMapOfAIS().IsBound2(name)){
-    const Handle(AIS_InteractiveObject) IO =
-      Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
-    if (!IO.IsNull()) {
-      if(IO->Type()==AIS_KOI_Shape) {
-        if(IO->Signature()==0){
-          retsh = Handle(AIS_Shape)::DownCast (IO);
-        }
-        else
-          cout << "an Object which is not an AIS_Shape "
-            "already has this name!!!"<<endl;
-      }
-    }
-    return retsh;
-  }
-
-
-  TopoDS_Shape S = GetShapeFromName(name);
-  if ( !S.IsNull() ) {
-    retsh = new AIS_Shape(S);
-  }
-  return retsh;
-}
-
-
 //==============================================================================
 //function : Clear
 //purpose  : Remove all the object from the viewer
@@ -699,13 +711,13 @@ void ViewerTest::Clear()
   NCollection_Sequence<Handle(AIS_InteractiveObject)> aListRemoved;
   for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anObjIter (GetMapOfAIS()); anObjIter.More(); anObjIter.Next())
   {
-    const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anObjIter.Key1());
+    const Handle(AIS_InteractiveObject) anObj = anObjIter.Key1();
     if (anObj->GetContext() != TheAISContext())
     {
       continue;
     }
 
-    std::cout << "Remove " << anObjIter.Key2() << std::endl;
+    Message::SendInfo() << "Remove " << anObjIter.Key2();
     TheAISContext()->Remove (anObj, Standard_False);
     aListRemoved.Append (anObj);
   }
@@ -802,34 +814,31 @@ static int visos (Draw_Interpretor& di, Standard_Integer argc, const char** argv
 
   Standard_Integer i;
 
-  for (i = 1; i <= aLastInd; i++) {
+  for (i = 1; i <= aLastInd; i++)
+  {
     TCollection_AsciiString name(argv[i]);
-    Standard_Boolean IsBound = GetMapOfAIS().IsBound2(name);
-
-    if (IsBound) {
-      const Handle(Standard_Transient) anObj = GetMapOfAIS().Find2(name);
-      if (anObj->IsKind(STANDARD_TYPE(AIS_InteractiveObject))) {
-        const Handle(AIS_InteractiveObject) aShape =
-        Handle(AIS_InteractiveObject)::DownCast (anObj);
-        Handle(Prs3d_Drawer) CurDrawer = aShape->Attributes();
-        Handle(Prs3d_IsoAspect) aUIso = CurDrawer->UIsoAspect();
-        Handle(Prs3d_IsoAspect) aVIso = CurDrawer->VIsoAspect();
-
-        if (isChanged) {
-          CurDrawer->SetUIsoAspect(CopyIsoAspect(aUIso, aNbUIsos));
-          CurDrawer->SetVIsoAspect(CopyIsoAspect(aVIso, aNbVIsos));
-          TheAISContext()->SetLocalAttributes
-                  (aShape, CurDrawer, Standard_False);
-          TheAISContext()->Redisplay (aShape, Standard_False);
-        } else {
-          di << "Number of isos for " << argv[i] << " : "
-             << aUIso->Number() << " " << aVIso->Number() << "\n";
-        }
-      } else {
-        di << argv[i] << ": Not an AIS interactive object!\n";
-      }
-    } else {
-      di << argv[i] << ": Use 'vdisplay' before\n";
+    Handle(AIS_InteractiveObject) aShape;
+    GetMapOfAIS().Find2(name, aShape);
+    if (aShape.IsNull())
+    {
+      Message::SendFail() << "Syntax error: object '" << name << "' is not found";
+      return 1;
+    }
+
+    Handle(Prs3d_Drawer) CurDrawer = aShape->Attributes();
+    Handle(Prs3d_IsoAspect) aUIso = CurDrawer->UIsoAspect();
+    Handle(Prs3d_IsoAspect) aVIso = CurDrawer->VIsoAspect();
+    if (isChanged)
+    {
+      CurDrawer->SetUIsoAspect(CopyIsoAspect(aUIso, aNbUIsos));
+      CurDrawer->SetVIsoAspect(CopyIsoAspect(aVIso, aNbVIsos));
+      TheAISContext()->SetLocalAttributes (aShape, CurDrawer, Standard_False);
+      TheAISContext()->Redisplay (aShape, Standard_False);
+    }
+    else
+    {
+      di << "Number of isos for " << argv[i] << " : "
+          << aUIso->Number() << " " << aVIso->Number() << "\n";
     }
   }
 
@@ -846,7 +855,7 @@ static Standard_Integer VDispSensi (Draw_Interpretor& ,
 {
   if (theArgNb > 1)
   {
-    std::cout << "Error: wrong syntax!\n";
+    Message::SendFail ("Error: wrong syntax!");
     return 1;
   }
 
@@ -868,7 +877,7 @@ static Standard_Integer VClearSensi (Draw_Interpretor& ,
 {
   if (theArgNb > 1)
   {
-    std::cout << "Error: wrong syntax!\n";
+    Message::SendFail ("Error: wrong syntax!");
     return 1;
   }
 
@@ -887,19 +896,55 @@ static Standard_Integer VClearSensi (Draw_Interpretor& ,
 //purpose  : To list the displayed object with their attributes
 //==============================================================================
 static int VDir (Draw_Interpretor& theDI,
-                 Standard_Integer ,
-                 const char** )
+                 Standard_Integer theNbArgs,
+                 const char** theArgVec)
 {
-  if (!a3DView().IsNull())
+  TCollection_AsciiString aMatch;
+  Standard_Boolean toFormat = Standard_False;
+  for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
   {
-    return 0;
+    TCollection_AsciiString anArgCase (theArgVec[anArgIter]);
+    anArgCase.LowerCase();
+    if (anArgCase == "-list"
+     || anArgCase == "-format")
+    {
+      toFormat = Standard_True;
+    }
+    else if (aMatch.IsEmpty())
+    {
+      aMatch = theArgVec[anArgIter];
+    }
+    else
+    {
+      Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'";
+      return 1;
+    }
   }
 
-  for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
-       anIter.More(); anIter.Next())
+  TCollection_AsciiString aRes;
+  for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS()); anIter.More(); anIter.Next())
   {
-    theDI << "\t" << anIter.Key2().ToCString() << "\n";
+    if (!aMatch.IsEmpty())
+    {
+      const TCollection_AsciiString aCheck = TCollection_AsciiString ("string match '") + aMatch + "' '" + anIter.Key2() + "'";
+      if (theDI.Eval (aCheck.ToCString()) == 0
+      && *theDI.Result() != '1')
+      {
+        continue;
+      }
+    }
+
+    if (toFormat)
+    {
+      aRes += TCollection_AsciiString("\t") + anIter.Key2() + "\n";
+    }
+    else
+    {
+      aRes += anIter.Key2() + " ";
+    }
   }
+  theDI.Reset();
+  theDI << aRes;
   return 0;
 }
 
@@ -919,9 +964,15 @@ static Standard_Integer VDump (Draw_Interpretor& theDI,
                                Standard_Integer  theArgNb,
                                Standard_CString* theArgVec)
 {
+  Handle(V3d_View) aView = ViewerTest::CurrentView();
   if (theArgNb < 2)
   {
-    std::cout << "Error: wrong number of arguments! Image file name should be specified at least.\n";
+    Message::SendFail ("Error: wrong number of arguments! Image file name should be specified at least.");
+    return 1;
+  }
+  if (aView.IsNull())
+  {
+    Message::SendFail() << "Error: cannot find an active view!";
     return 1;
   }
 
@@ -929,6 +980,7 @@ static Standard_Integer VDump (Draw_Interpretor& theDI,
   Standard_CString      aFilePath   = theArgVec[anArgIter++];
   ViewerTest_StereoPair aStereoPair = ViewerTest_SP_Single;
   V3d_ImageDumpOptions  aParams;
+  Handle(Graphic3d_Camera) aCustomCam;
   aParams.BufferType    = Graphic3d_BT_RGB;
   aParams.StereoOptions = V3d_SDO_MONO;
   for (; anArgIter < theArgNb; ++anArgIter)
@@ -939,7 +991,7 @@ static Standard_Integer VDump (Draw_Interpretor& theDI,
     {
       if (++anArgIter >= theArgNb)
       {
-        std::cout << "Error: wrong syntax at '" << anArg << "'\n";
+        Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
         return 1;
       }
 
@@ -953,21 +1005,60 @@ static Standard_Integer VDump (Draw_Interpretor& theDI,
       {
         aParams.BufferType = Graphic3d_BT_RGB;
       }
+      else if (aBufArg == "red")
+      {
+        aParams.BufferType = Graphic3d_BT_Red;
+      }
       else if (aBufArg == "depth")
       {
         aParams.BufferType = Graphic3d_BT_Depth;
       }
       else
       {
-        std::cout << "Error: unknown buffer '" << aBufArg << "'\n";
+        Message::SendFail() << "Error: unknown buffer '" << aBufArg << "'";
+        return 1;
+      }
+    }
+    else if (anArgIter + 1 < theArgNb
+          && anArg == "-xrpose")
+    {
+      TCollection_AsciiString anXRArg (theArgVec[++anArgIter]);
+      anXRArg.LowerCase();
+      if (anXRArg == "base")
+      {
+        aCustomCam = aView->View()->BaseXRCamera();
+      }
+      else if (anXRArg == "head")
+      {
+        aCustomCam = aView->View()->PosedXRCamera();
+      }
+      else if (anXRArg == "handleft"
+            || anXRArg == "handright")
+      {
+        if (aView->View()->IsActiveXR())
+        {
+          aCustomCam = new Graphic3d_Camera();
+          aView->View()->ComputeXRPosedCameraFromBase (*aCustomCam, anXRArg == "handleft"
+                                                     ? aView->View()->XRSession()->LeftHandPose()
+                                                     : aView->View()->XRSession()->RightHandPose());
+        }
+      }
+      else
+      {
+        Message::SendFail() << "Syntax error: unknown XR pose '" << anXRArg << "'";
         return 1;
       }
+      if (aCustomCam.IsNull())
+      {
+        Message::SendFail() << "Error: undefined XR pose";
+        return 0;
+      }
     }
     else if (anArg == "-stereo")
     {
       if (++anArgIter >= theArgNb)
       {
-        std::cout << "Error: wrong syntax at '" << anArg << "'\n";
+        Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
         return 1;
       }
 
@@ -1005,7 +1096,7 @@ static Standard_Integer VDump (Draw_Interpretor& theDI,
       }
       else
       {
-        std::cout << "Error: unknown stereo format '" << aStereoArg << "'\n";
+        Message::SendFail() << "Error: unknown stereo format '" << aStereoArg << "'";
         return 1;
       }
     }
@@ -1019,6 +1110,11 @@ static Standard_Integer VDump (Draw_Interpretor& theDI,
     {
       aParams.BufferType = Graphic3d_BT_RGB;
     }
+    else if (anArg == "-red"
+          || anArg ==  "red")
+    {
+      aParams.BufferType = Graphic3d_BT_Red;
+    }
     else if (anArg == "-depth"
           || anArg ==  "depth")
     {
@@ -1030,12 +1126,12 @@ static Standard_Integer VDump (Draw_Interpretor& theDI,
     {
       if (aParams.Width != 0)
       {
-        std::cout << "Error: wrong syntax at " << theArgVec[anArgIter] << "\n";
+        Message::SendFail() << "Error: wrong syntax at " << theArgVec[anArgIter];
         return 1;
       }
       else if (++anArgIter >= theArgNb)
       {
-        std::cout << "Error: integer value is expected right after 'width'\n";
+        Message::SendFail() << "Error: integer value is expected right after 'width'";
         return 1;
       }
       aParams.Width = Draw::Atoi (theArgVec[anArgIter]);
@@ -1046,12 +1142,12 @@ static Standard_Integer VDump (Draw_Interpretor& theDI,
     {
       if (aParams.Height != 0)
       {
-        std::cout << "Error: wrong syntax at " << theArgVec[anArgIter] << "\n";
+        Message::SendFail() << "Error: wrong syntax at " << theArgVec[anArgIter];
         return 1;
       }
       else if (++anArgIter >= theArgNb)
       {
-        std::cout << "Error: integer value is expected right after 'height'\n";
+        Message::SendFail() << "Error: integer value is expected right after 'height'";
         return 1;
       }
       aParams.Height = Draw::Atoi (theArgVec[anArgIter]);
@@ -1061,28 +1157,21 @@ static Standard_Integer VDump (Draw_Interpretor& theDI,
     {
       if (++anArgIter >= theArgNb)
       {
-        std::cout << "Error: integer value is expected right after 'tileSize'\n";
+        Message::SendFail() << "Error: integer value is expected right after 'tileSize'";
         return 1;
       }
       aParams.TileSize = Draw::Atoi (theArgVec[anArgIter]);
     }
     else
     {
-      std::cout << "Error: unknown argument '" << theArgVec[anArgIter] << "'\n";
+      Message::SendFail() << "Error: unknown argument '" << theArgVec[anArgIter] << "'";
       return 1;
     }
   }
   if ((aParams.Width <= 0 && aParams.Height >  0)
    || (aParams.Width >  0 && aParams.Height <= 0))
   {
-    std::cout << "Error: dimensions " << aParams.Width << "x" << aParams.Height << " are incorrect\n";
-    return 1;
-  }
-
-  Handle(V3d_View) aView = ViewerTest::CurrentView();
-  if (aView.IsNull())
-  {
-    std::cout << "Error: cannot find an active view!\n";
+    Message::SendFail() << "Error: dimensions " << aParams.Width << "x" << aParams.Height << " are incorrect";
     return 1;
   }
 
@@ -1099,8 +1188,15 @@ static Standard_Integer VDump (Draw_Interpretor& theDI,
     case Graphic3d_BT_RGBA:                aFormat = Image_Format_RGBA;  break;
     case Graphic3d_BT_Depth:               aFormat = Image_Format_GrayF; break;
     case Graphic3d_BT_RGB_RayTraceHdrLeft: aFormat = Image_Format_RGBF;  break;
+    case Graphic3d_BT_Red:                 aFormat = Image_Format_Gray;  break;
   }
 
+  const bool wasImmUpdate = aView->SetImmediateUpdate (false);
+  Handle(Graphic3d_Camera) aCamBack = aView->Camera();
+  if (!aCustomCam.IsNull())
+  {
+    aView->SetCamera (aCustomCam);
+  }
   switch (aStereoPair)
   {
     case ViewerTest_SP_Single:
@@ -1169,6 +1265,11 @@ static Standard_Integer VDump (Draw_Interpretor& theDI,
       break;
     }
   }
+  if (!aCustomCam.IsNull())
+  {
+    aView->SetCamera (aCamBack);
+  }
+  aView->SetImmediateUpdate (wasImmUpdate);
 
   if (!aPixMap.Save (aFilePath))
   {
@@ -1228,7 +1329,7 @@ static int VDispMode (Draw_Interpretor& , Standard_Integer argc, const char** ar
   if (argc < 1
    || argc > 3)
   {
-    std::cout << "Syntax error: wrong number of arguments\n";
+    Message::SendFail() << "Syntax error: wrong number of arguments";
     return 1;
   }
 
@@ -1256,13 +1357,11 @@ static int VDispMode (Draw_Interpretor& , Standard_Integer argc, const char** ar
     else
     {
       TCollection_AsciiString aName = argv[1];
-      if (GetMapOfAIS().IsBound2 (aName))
+      Handle(AIS_InteractiveObject) aPrs;
+      if (GetMapOfAIS().Find2 (aName, aPrs)
+      && !aPrs.IsNull())
       {
-        Handle(AIS_InteractiveObject) aPrs = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2 (aName));
-        if (!aPrs.IsNull())
-        {
-          VwrTst_DispErase (aPrs, -1, TypeOfDispOperation_UnsetDispMode, Standard_True);
-        }
+        VwrTst_DispErase (aPrs, -1, TypeOfDispOperation_UnsetDispMode, Standard_True);
       }
     }
   }
@@ -1284,11 +1383,8 @@ static int VDispMode (Draw_Interpretor& , Standard_Integer argc, const char** ar
   {
     Handle(AIS_InteractiveObject) aPrs;
     TCollection_AsciiString aName (argv[1]);
-    if (GetMapOfAIS().IsBound2 (aName))
-    {
-      aPrs = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2 (aName));
-    }
-    if (!aPrs.IsNull())
+    if (GetMapOfAIS().Find2 (aName, aPrs)
+     && !aPrs.IsNull())
     {
       VwrTst_DispErase (aPrs, Draw::Atoi(argv[2]), aType, Standard_True);
     }
@@ -1328,14 +1424,13 @@ static int VSubInt(Draw_Interpretor& di, Standard_Integer argc, const char** arg
   else {
     Handle(AIS_InteractiveObject) IO;
     TCollection_AsciiString name = argv[2];
-    if(GetMapOfAIS().IsBound2(name)){
-      IO = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
-      if (!IO.IsNull()) {
-        if(On==1)
-          Ctx->SubIntensityOn(IO, Standard_True);
-        else
-          Ctx->SubIntensityOff(IO, Standard_True);
-      }
+    if (GetMapOfAIS().Find2 (name, IO)
+    && !IO.IsNull())
+    {
+      if(On==1)
+        Ctx->SubIntensityOn(IO, Standard_True);
+      else
+        Ctx->SubIntensityOff(IO, Standard_True);
     }
     else return 1;
   }
@@ -1467,7 +1562,7 @@ private:
         {
           if (!GetMapOfAIS().IsBound2 (mySeqIter.Value()))
           {
-            std::cout << "Error: object " << mySeqIter.Value() << " is not displayed!\n";
+            Message::SendFail() << "Error: object " << mySeqIter.Value() << " is not displayed!";
             return;
           }
           myCurrentName = mySeqIter.Value();
@@ -1512,106 +1607,52 @@ private:
 
 };
 
-//==============================================================================
-//function : VInteriorStyle
-//purpose  : sets interior style of the a selected or named or displayed shape
-//==============================================================================
-static int VSetInteriorStyle (Draw_Interpretor& theDI,
-                              Standard_Integer  theArgNb,
-                              const char**      theArgVec)
+//! Parse interior style name.
+static bool parseInteriorStyle (const TCollection_AsciiString& theArg,
+                                Aspect_InteriorStyle& theStyle)
 {
-  const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
-  ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
-  if (aCtx.IsNull())
-  {
-    std::cerr << "Error: no active view!\n";
-    return 1;
-  }
-
-  Standard_Integer anArgIter = 1;
-  for (; anArgIter < theArgNb; ++anArgIter)
-  {
-    if (!anUpdateTool.parseRedrawMode (theArgVec[anArgIter]))
-    {
-      break;
-    }
-  }
-  TCollection_AsciiString aName;
-  if (theArgNb - anArgIter == 2)
-  {
-    aName = theArgVec[anArgIter++];
-  }
-  else if (theArgNb - anArgIter != 1)
-  {
-    std::cout << "Error: wrong number of arguments! See usage:\n";
-    theDI.PrintHelp (theArgVec[0]);
-    return 1;
-  }
-  Aspect_InteriorStyle    anInterStyle = Aspect_IS_SOLID;
-  TCollection_AsciiString aStyleArg (theArgVec[anArgIter++]);
-  aStyleArg.LowerCase();
-  if (aStyleArg == "empty")
+  TCollection_AsciiString anArg (theArg);
+  anArg.LowerCase();
+  if (anArg == "empty")
   {
-    anInterStyle = Aspect_IS_EMPTY;
+    theStyle = Aspect_IS_EMPTY;
   }
-  else if (aStyleArg == "hollow")
+  else if (anArg == "hollow")
   {
-    anInterStyle = Aspect_IS_HOLLOW;
+    theStyle = Aspect_IS_HOLLOW;
   }
-  else if (aStyleArg == "hatch")
+  else if (anArg == "solid")
   {
-    anInterStyle = Aspect_IS_HATCH;
+    theStyle = Aspect_IS_SOLID;
   }
-  else if (aStyleArg == "solid")
+  else if (anArg == "hatch")
   {
-    anInterStyle = Aspect_IS_SOLID;
+    theStyle = Aspect_IS_HATCH;
   }
-  else if (aStyleArg == "hiddenline")
+  else if (anArg == "hiddenline"
+        || anArg == "hidden-line"
+        || anArg == "hidden_line")
   {
-    anInterStyle = Aspect_IS_HIDDENLINE;
+    theStyle = Aspect_IS_HIDDENLINE;
   }
-  else if (aStyleArg == "point")
+  else if (anArg == "point")
   {
-    anInterStyle = Aspect_IS_POINT;
+    theStyle = Aspect_IS_POINT;
   }
-  else
+  else if (theArg.IsIntegerValue())
   {
-    const Standard_Integer anIntStyle = aStyleArg.IntegerValue();
-    if (anIntStyle < Aspect_IS_EMPTY
-     || anIntStyle > Aspect_IS_POINT)
+    const Standard_Integer anIntStyle = theArg.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;
+      return false;
     }
-    anInterStyle = (Aspect_InteriorStyle )anIntStyle;
-  }
-
-  if (!aName.IsEmpty()
-   && !GetMapOfAIS().IsBound2 (aName))
-  {
-    std::cout << "Error: object " << aName << " is not displayed!\n";
-    return 1;
+    theStyle = (Aspect_InteriorStyle)anIntStyle;
   }
-
-  for (ViewTest_PrsIter anIter (aName); anIter.More(); anIter.Next())
+  else
   {
-    const Handle(AIS_InteractiveObject)& anIO = anIter.Current();
-    if (!anIO.IsNull())
-    {
-      const Handle(Prs3d_Drawer)& aDrawer        = anIO->Attributes();
-      Handle(Prs3d_ShadingAspect) aShadingAspect = aDrawer->ShadingAspect();
-      Handle(Graphic3d_AspectFillArea3d) aFillAspect = aShadingAspect->Aspect();
-      aFillAspect->SetInteriorStyle (anInterStyle);
-      if (anInterStyle == Aspect_IS_HATCH
-       && aFillAspect->HatchStyle().IsNull())
-      {
-        aFillAspect->SetHatchStyle (Aspect_HS_VERTICAL);
-      }
-      aCtx->RecomputePrsOnly (anIO, Standard_False, Standard_True);
-    }
+    return false;
   }
-  return 0;
+  return true;
 }
 
 //! Auxiliary structure for VAspects
@@ -1622,12 +1663,15 @@ struct ViewerTest_AspectsChangeSet
 
   Standard_Integer             ToSetColor;
   Quantity_Color               Color;
+  Standard_Integer             ToSetBackFaceColor;
+  Quantity_Color               BackFaceColor;
 
   Standard_Integer             ToSetLineWidth;
   Standard_Real                LineWidth;
 
   Standard_Integer             ToSetTypeOfLine;
-  Aspect_TypeOfLine            TypeOfLine;
+  uint16_t                     StippleLinePattern;
+  uint16_t                     StippleLineFactor;
 
   Standard_Integer             ToSetTypeOfMarker;
   Aspect_TypeOfMarker          TypeOfMarker;
@@ -1657,6 +1701,19 @@ struct ViewerTest_AspectsChangeSet
 
   Standard_Integer             ToEnableIsoOnTriangulation;
 
+  Standard_Integer             ToSetFaceBoundaryDraw;
+  Standard_Integer             ToSetFaceBoundaryUpperContinuity;
+  GeomAbs_Shape                FaceBoundaryUpperContinuity;
+
+  Standard_Integer             ToSetFaceBoundaryColor;
+  Quantity_Color               FaceBoundaryColor;
+
+  Standard_Integer             ToSetFaceBoundaryWidth;
+  Standard_Real                FaceBoundaryWidth;
+
+  Standard_Integer             ToSetTypeOfFaceBoundaryLine;
+  Aspect_TypeOfLine            TypeOfFaceBoundaryLine;
+
   Standard_Integer             ToSetMaxParamValue;
   Standard_Real                MaxParamValue;
 
@@ -1672,16 +1729,36 @@ struct ViewerTest_AspectsChangeSet
   Graphic3d_TypeOfShadingModel ShadingModel;
   TCollection_AsciiString      ShadingModelName;
 
+  Standard_Integer             ToSetInterior;
+  Aspect_InteriorStyle         InteriorStyle;
+
+  Standard_Integer             ToSetDrawSilhouette;
+
+  Standard_Integer             ToSetDrawEdges;
+  Standard_Integer             ToSetQuadEdges;
+
+  Standard_Integer             ToSetEdgeColor;
+  Quantity_ColorRGBA           EdgeColor;
+
+  Standard_Integer             ToSetEdgeWidth;
+  Standard_Real                EdgeWidth;
+
+  Standard_Integer             ToSetTypeOfEdge;
+  Aspect_TypeOfLine            TypeOfEdge;
+
   //! Empty constructor
   ViewerTest_AspectsChangeSet()
   : ToSetVisibility   (0),
     Visibility        (1),
     ToSetColor        (0),
     Color             (DEFAULT_COLOR),
+    ToSetBackFaceColor(0),
+    BackFaceColor     (DEFAULT_COLOR),
     ToSetLineWidth    (0),
     LineWidth         (1.0),
     ToSetTypeOfLine   (0),
-    TypeOfLine        (Aspect_TOL_SOLID),
+    StippleLinePattern(0xFFFF),
+    StippleLineFactor (1),
     ToSetTypeOfMarker (0),
     TypeOfMarker      (Aspect_TOM_PLUS),
     ToSetMarkerSize   (0),
@@ -1698,7 +1775,18 @@ struct ViewerTest_AspectsChangeSet
     FreeBoundaryWidth          (1.0),
     ToSetFreeBoundaryColor     (0),
     FreeBoundaryColor          (DEFAULT_FREEBOUNDARY_COLOR),
-    ToEnableIsoOnTriangulation (-1),
+    ToEnableIsoOnTriangulation (0),
+    //
+    ToSetFaceBoundaryDraw      (0),
+    ToSetFaceBoundaryUpperContinuity (0),
+    FaceBoundaryUpperContinuity(GeomAbs_CN),
+    ToSetFaceBoundaryColor     (0),
+    FaceBoundaryColor          (Quantity_NOC_BLACK),
+    ToSetFaceBoundaryWidth     (0),
+    FaceBoundaryWidth          (1.0f),
+    ToSetTypeOfFaceBoundaryLine(0),
+    TypeOfFaceBoundaryLine     (Aspect_TOL_SOLID),
+    //
     ToSetMaxParamValue         (0),
     MaxParamValue              (500000),
     ToSetSensitivity           (0),
@@ -1707,7 +1795,17 @@ struct ViewerTest_AspectsChangeSet
     ToSetHatch                 (0),
     StdHatchStyle              (-1),
     ToSetShadingModel          (0),
-    ShadingModel               (Graphic3d_TOSM_DEFAULT)
+    ShadingModel               (Graphic3d_TOSM_DEFAULT),
+    ToSetInterior              (0),
+    InteriorStyle              (Aspect_IS_SOLID),
+    ToSetDrawSilhouette (0),
+    ToSetDrawEdges    (0),
+    ToSetQuadEdges    (0),
+    ToSetEdgeColor    (0),
+    ToSetEdgeWidth    (0),
+    EdgeWidth         (1.0),
+    ToSetTypeOfEdge   (0),
+    TypeOfEdge        (Aspect_TOL_SOLID)
     {}
 
   //! @return true if no changes have been requested
@@ -1718,108 +1816,397 @@ struct ViewerTest_AspectsChangeSet
         && ToSetTransparency      == 0
         && ToSetAlphaMode         == 0
         && ToSetColor             == 0
+        && ToSetBackFaceColor     == 0
         && ToSetMaterial          == 0
         && ToSetShowFreeBoundary  == 0
         && ToSetFreeBoundaryColor == 0
         && ToSetFreeBoundaryWidth == 0
+        && ToEnableIsoOnTriangulation == 0
+        && ToSetFaceBoundaryDraw == 0
+        && ToSetFaceBoundaryUpperContinuity == 0
+        && ToSetFaceBoundaryColor == 0
+        && ToSetFaceBoundaryWidth == 0
+        && ToSetTypeOfFaceBoundaryLine == 0
         && ToSetMaxParamValue     == 0
         && ToSetSensitivity       == 0
         && ToSetHatch             == 0
-        && ToSetShadingModel      == 0;
+        && ToSetShadingModel      == 0
+        && ToSetInterior          == 0
+        && ToSetDrawSilhouette    == 0
+        && ToSetDrawEdges         == 0
+        && ToSetQuadEdges         == 0
+        && ToSetEdgeColor         == 0
+        && ToSetEdgeWidth         == 0
+        && ToSetTypeOfEdge        == 0;
   }
 
   //! @return true if properties are valid
-  Standard_Boolean Validate (const Standard_Boolean theIsSubPart) const
+  Standard_Boolean Validate() const
   {
     Standard_Boolean isOk = Standard_True;
     if (Visibility != 0 && Visibility != 1)
     {
-      std::cout << "Error: the visibility should be equal to 0 or 1 (0 - invisible; 1 - visible) (specified " << Visibility << ")\n";
+      Message::SendFail() << "Error: the visibility should be equal to 0 or 1 (0 - invisible; 1 - visible) (specified " << Visibility << ")";
       isOk = Standard_False;
     }
     if (LineWidth <= 0.0
      || LineWidth >  10.0)
     {
-      std::cout << "Error: the width should be within [1; 10] range (specified " << LineWidth << ")\n";
+      Message::SendFail() << "Error: the width should be within [1; 10] range (specified " << LineWidth << ")";
       isOk = Standard_False;
     }
     if (Transparency < 0.0
      || Transparency > 1.0)
     {
-      std::cout << "Error: the transparency should be within [0; 1] range (specified " << Transparency << ")\n";
-      isOk = Standard_False;
-    }
-    if (theIsSubPart
-     && ToSetTransparency != 0)
-    {
-      std::cout << "Error: the transparency can not be defined for sub-part of object!\n";
+      Message::SendFail() << "Error: the transparency should be within [0; 1] range (specified " << Transparency << ")";
       isOk = Standard_False;
     }
     if (ToSetAlphaMode == 1
      && (AlphaCutoff <= 0.0f || AlphaCutoff >= 1.0f))
     {
-      std::cout << "Error: alpha cutoff value should be within (0; 1) range (specified " << AlphaCutoff << ")\n";
-      isOk = Standard_False;
-    }
-    if (ToSetMaterial == 1
-     && Material == Graphic3d_NOM_DEFAULT)
-    {
-      std::cout << "Error: unknown material " << MatName << ".\n";
+      Message::SendFail() << "Error: alpha cutoff value should be within (0; 1) range (specified " << AlphaCutoff << ")";
       isOk = Standard_False;
     }
     if (FreeBoundaryWidth <= 0.0
      || FreeBoundaryWidth >  10.0)
     {
-      std::cout << "Error: the free boundary width should be within [1; 10] range (specified " << FreeBoundaryWidth << ")\n";
+      Message::SendFail() << "Error: the free boundary width should be within [1; 10] range (specified " << FreeBoundaryWidth << ")";
       isOk = Standard_False;
     }
     if (MaxParamValue < 0.0)
     {
-      std::cout << "Error: the max parameter value should be greater than zero (specified " << MaxParamValue << ")\n";
+      Message::SendFail() << "Error: the max parameter value should be greater than zero (specified " << MaxParamValue << ")";
       isOk = Standard_False;
     }
     if (Sensitivity <= 0 && ToSetSensitivity)
     {
-      std::cout << "Error: sensitivity parameter value should be positive (specified " << Sensitivity << ")\n";
+      Message::SendFail() << "Error: sensitivity parameter value should be positive (specified " << Sensitivity << ")";
       isOk = Standard_False;
     }
     if (ToSetHatch == 1 && StdHatchStyle < 0 && PathToHatchPattern == "")
     {
-      std::cout << "Error: hatch style must be specified\n";
+      Message::SendFail ("Error: hatch style must be specified");
       isOk = Standard_False;
     }
     if (ToSetShadingModel == 1
-    && (ShadingModel < Graphic3d_TOSM_DEFAULT || ShadingModel > Graphic3d_TOSM_FRAGMENT))
+    && (ShadingModel < Graphic3d_TOSM_DEFAULT || ShadingModel > Graphic3d_TOSM_PBR_FACET))
     {
-      std::cout << "Error: unknown shading model " << ShadingModelName << ".\n";
+      Message::SendFail() << "Error: unknown shading model " << ShadingModelName << ".";
       isOk = Standard_False;
     }
     return isOk;
   }
 
-};
-
-//==============================================================================
-//function : VAspects
-//purpose  :
-//==============================================================================
-static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
-                                  Standard_Integer  theArgNb,
-                                  const char**      theArgVec)
-{
-  TCollection_AsciiString aCmdName (theArgVec[0]);
-  const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
-  ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
-  if (aCtx.IsNull())
+  //! Apply aspects to specified drawer.
+  bool Apply (const Handle(Prs3d_Drawer)& theDrawer)
   {
-    std::cerr << "Error: no active view!\n";
-    return 1;
-  }
-
-  Standard_Integer anArgIter = 1;
-  Standard_Boolean isDefaults = Standard_False;
-  NCollection_Sequence<TCollection_AsciiString> aNames;
-  for (; anArgIter < theArgNb; ++anArgIter)
+    bool toRecompute = false;
+    const Handle(Prs3d_Drawer)& aDefDrawer = ViewerTest::GetAISContext()->DefaultDrawer();
+    if (ToSetShowFreeBoundary != 0)
+    {
+      theDrawer->SetFreeBoundaryDraw (ToSetShowFreeBoundary == 1);
+      toRecompute = true;
+    }
+    if (ToSetFreeBoundaryWidth != 0)
+    {
+      if (ToSetFreeBoundaryWidth != -1
+       || theDrawer->HasOwnFreeBoundaryAspect())
+      {
+        if (!theDrawer->HasOwnFreeBoundaryAspect())
+        {
+          Handle(Prs3d_LineAspect) aBoundaryAspect = new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0);
+          *aBoundaryAspect->Aspect() = *theDrawer->FreeBoundaryAspect()->Aspect();
+          theDrawer->SetFreeBoundaryAspect (aBoundaryAspect);
+          toRecompute = true;
+        }
+        theDrawer->FreeBoundaryAspect()->SetWidth (FreeBoundaryWidth);
+      }
+    }
+    if (ToSetFreeBoundaryColor != 0)
+    {
+      Handle(Prs3d_LineAspect) aBoundaryAspect = new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0);
+      *aBoundaryAspect->Aspect() = *theDrawer->FreeBoundaryAspect()->Aspect();
+      aBoundaryAspect->SetColor (FreeBoundaryColor);
+      theDrawer->SetFreeBoundaryAspect (aBoundaryAspect);
+      toRecompute = true;
+    }
+    if (ToSetTypeOfLine != 0)
+    {
+      if (ToSetTypeOfLine != -1
+       || theDrawer->HasOwnLineAspect()
+       || theDrawer->HasOwnWireAspect()
+       || theDrawer->HasOwnFreeBoundaryAspect()
+       || theDrawer->HasOwnUnFreeBoundaryAspect()
+       || theDrawer->HasOwnSeenLineAspect())
+      {
+        toRecompute = theDrawer->SetOwnLineAspects() || toRecompute;
+        theDrawer->LineAspect()->Aspect()->SetLinePattern (StippleLinePattern);
+        theDrawer->LineAspect()->Aspect()->SetLineStippleFactor (StippleLineFactor);
+        theDrawer->WireAspect()->Aspect()->SetLinePattern (StippleLinePattern);
+        theDrawer->WireAspect()->Aspect()->SetLineStippleFactor (StippleLineFactor);
+        theDrawer->FreeBoundaryAspect()->Aspect()->SetLinePattern (StippleLinePattern);
+        theDrawer->FreeBoundaryAspect()->Aspect()->SetLineStippleFactor (StippleLineFactor);
+        theDrawer->UnFreeBoundaryAspect()->Aspect()->SetLinePattern (StippleLinePattern);
+        theDrawer->UnFreeBoundaryAspect()->Aspect()->SetLineStippleFactor (StippleLineFactor);
+        theDrawer->SeenLineAspect()->Aspect()->SetLinePattern (StippleLinePattern);
+        theDrawer->SeenLineAspect()->Aspect()->SetLineStippleFactor (StippleLineFactor);
+      }
+    }
+    if (ToSetTypeOfMarker != 0)
+    {
+      if (ToSetTypeOfMarker != -1
+       || theDrawer->HasOwnPointAspect())
+      {
+        toRecompute = theDrawer->SetupOwnPointAspect (aDefDrawer) || toRecompute;
+        theDrawer->PointAspect()->SetTypeOfMarker (TypeOfMarker);
+        theDrawer->PointAspect()->Aspect()->SetMarkerImage (MarkerImage.IsNull() ? Handle(Graphic3d_MarkerImage)() : new Graphic3d_MarkerImage (MarkerImage));
+      }
+    }
+    if (ToSetMarkerSize != 0)
+    {
+      if (ToSetMarkerSize != -1
+       || theDrawer->HasOwnPointAspect())
+      {
+        toRecompute = theDrawer->SetupOwnPointAspect (aDefDrawer) || toRecompute;
+        theDrawer->PointAspect()->SetScale (MarkerSize);
+        toRecompute = true;
+      }
+    }
+    if (ToSetMaxParamValue != 0)
+    {
+      if (ToSetMaxParamValue != -1
+       || theDrawer->HasOwnMaximalParameterValue())
+      {
+        theDrawer->SetMaximalParameterValue (MaxParamValue);
+        toRecompute = true;
+      }
+    }
+    if (ToSetFaceBoundaryDraw != 0)
+    {
+      if (ToSetFaceBoundaryDraw != -1
+       || theDrawer->HasOwnFaceBoundaryDraw())
+      {
+        toRecompute = true;
+        theDrawer->SetFaceBoundaryDraw (ToSetFaceBoundaryDraw == 1);
+      }
+    }
+    if (ToSetFaceBoundaryUpperContinuity != 0)
+    {
+      if (ToSetFaceBoundaryUpperContinuity != -1
+       || theDrawer->HasOwnFaceBoundaryUpperContinuity())
+      {
+        toRecompute = true;
+        if (ToSetFaceBoundaryUpperContinuity == -1)
+        {
+          theDrawer->UnsetFaceBoundaryUpperContinuity();
+        }
+        else
+        {
+          theDrawer->SetFaceBoundaryUpperContinuity (FaceBoundaryUpperContinuity);
+        }
+      }
+    }
+    if (ToSetFaceBoundaryColor != 0)
+    {
+      if (ToSetFaceBoundaryColor != -1
+       || theDrawer->HasOwnFaceBoundaryAspect())
+      {
+        if (ToSetFaceBoundaryColor == -1)
+        {
+          toRecompute = true;
+          theDrawer->SetFaceBoundaryAspect (Handle(Prs3d_LineAspect)());
+        }
+        else
+        {
+          toRecompute = theDrawer->SetupOwnFaceBoundaryAspect (aDefDrawer) || toRecompute;
+          theDrawer->FaceBoundaryAspect()->SetColor (FaceBoundaryColor);
+        }
+      }
+    }
+    if (ToSetFaceBoundaryWidth != 0)
+    {
+      if (ToSetFaceBoundaryWidth != -1
+       || theDrawer->HasOwnFaceBoundaryAspect())
+      {
+        toRecompute = theDrawer->SetupOwnFaceBoundaryAspect (aDefDrawer) || toRecompute;
+        theDrawer->FaceBoundaryAspect()->SetWidth (FaceBoundaryWidth);
+      }
+    }
+    if (ToSetTypeOfFaceBoundaryLine != 0)
+    {
+      if (ToSetTypeOfFaceBoundaryLine != -1
+       || theDrawer->HasOwnFaceBoundaryAspect())
+      {
+        toRecompute = theDrawer->SetupOwnFaceBoundaryAspect (aDefDrawer) || toRecompute;
+        theDrawer->FaceBoundaryAspect()->SetTypeOfLine (TypeOfFaceBoundaryLine);
+      }
+    }
+    if (ToSetShadingModel != 0)
+    {
+      if (ToSetShadingModel != -1
+       || theDrawer->HasOwnShadingAspect())
+      {
+        toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+        theDrawer->ShadingAspect()->Aspect()->SetShadingModel (ShadingModel);
+      }
+    }
+    if (ToSetBackFaceColor != 0)
+    {
+      if (ToSetBackFaceColor != -1
+       || theDrawer->HasOwnShadingAspect())
+      {
+        toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+        theDrawer->ShadingAspect()->SetColor (BackFaceColor, Aspect_TOFM_BACK_SIDE);
+      }
+    }
+    if (ToSetAlphaMode != 0)
+    {
+      if (ToSetAlphaMode != -1
+       || theDrawer->HasOwnShadingAspect())
+      {
+        toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+        theDrawer->ShadingAspect()->Aspect()->SetAlphaMode (AlphaMode, AlphaCutoff);
+      }
+    }
+    if (ToSetHatch != 0)
+    {
+      if (ToSetHatch != -1
+      ||  theDrawer->HasOwnShadingAspect())
+      {
+        theDrawer->SetupOwnShadingAspect (aDefDrawer);
+        Handle(Graphic3d_AspectFillArea3d) anAsp = theDrawer->ShadingAspect()->Aspect();
+        if (ToSetHatch == -1)
+        {
+          anAsp->SetInteriorStyle (Aspect_IS_SOLID);
+        }
+        else
+        {
+          anAsp->SetInteriorStyle (Aspect_IS_HATCH);
+          if (!PathToHatchPattern.IsEmpty())
+          {
+            Handle(Image_AlienPixMap) anImage = new Image_AlienPixMap();
+            if (anImage->Load (TCollection_AsciiString (PathToHatchPattern.ToCString())))
+            {
+              anAsp->SetHatchStyle (new Graphic3d_HatchStyle (anImage));
+            }
+            else
+            {
+              Message::SendFail() << "Error: cannot load the following image: " << PathToHatchPattern;
+            }
+          }
+          else if (StdHatchStyle != -1)
+          {
+            anAsp->SetHatchStyle (new Graphic3d_HatchStyle ((Aspect_HatchStyle)StdHatchStyle));
+          }
+        }
+        toRecompute = true;
+      }
+    }
+    if (ToSetInterior != 0)
+    {
+      if (ToSetInterior != -1
+       || theDrawer->HasOwnShadingAspect())
+      {
+        toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+        theDrawer->ShadingAspect()->Aspect()->SetInteriorStyle (InteriorStyle);
+        if (InteriorStyle == Aspect_IS_HATCH
+         && theDrawer->ShadingAspect()->Aspect()->HatchStyle().IsNull())
+        {
+          theDrawer->ShadingAspect()->Aspect()->SetHatchStyle (Aspect_HS_VERTICAL);
+        }
+      }
+    }
+    if (ToSetDrawSilhouette != 0)
+    {
+      if (ToSetDrawSilhouette != -1
+       || theDrawer->HasOwnShadingAspect())
+      {
+        toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+        theDrawer->ShadingAspect()->Aspect()->SetDrawSilhouette (ToSetDrawSilhouette == 1);
+      }
+    }
+    if (ToSetDrawEdges != 0)
+    {
+      if (ToSetDrawEdges != -1
+       || theDrawer->HasOwnShadingAspect())
+      {
+        toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+        theDrawer->ShadingAspect()->Aspect()->SetDrawEdges (ToSetDrawEdges == 1);
+      }
+    }
+    if (ToSetQuadEdges != 0)
+    {
+      if (ToSetQuadEdges != -1
+          || theDrawer->HasOwnShadingAspect())
+      {
+        toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+        theDrawer->ShadingAspect()->Aspect()->SetSkipFirstEdge (ToSetQuadEdges == 1);
+      }
+    }
+    if (ToSetEdgeWidth != 0)
+    {
+      if (ToSetEdgeWidth != -1
+       || theDrawer->HasOwnShadingAspect())
+      {
+        toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+        theDrawer->ShadingAspect()->Aspect()->SetEdgeWidth (EdgeWidth);
+      }
+    }
+    if (ToSetTypeOfEdge != 0)
+    {
+      if (ToSetTypeOfEdge != -1
+       || theDrawer->HasOwnShadingAspect())
+      {
+        toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+        theDrawer->ShadingAspect()->Aspect()->SetEdgeLineType (TypeOfEdge);
+        if (ToSetInterior == 0)
+        {
+          theDrawer->ShadingAspect()->Aspect()->SetDrawEdges (ToSetTypeOfEdge == 1
+                                                           && TypeOfEdge != Aspect_TOL_EMPTY);
+        }
+      }
+    }
+    if (ToSetEdgeColor != 0)
+    {
+      if (ToSetEdgeColor != -1
+       || theDrawer->HasOwnShadingAspect())
+      {
+        toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+        if (ToSetEdgeColor == -1)
+        {
+          theDrawer->ShadingAspect()->Aspect()->SetEdgeColor (theDrawer->ShadingAspect()->Aspect()->InteriorColor());
+        }
+        else
+        {
+          theDrawer->ShadingAspect()->Aspect()->SetEdgeColor (EdgeColor);
+        }
+      }
+    }
+    return toRecompute;
+  }
+};
+
+//==============================================================================
+//function : VAspects
+//purpose  :
+//==============================================================================
+static Standard_Integer VAspects (Draw_Interpretor& theDI,
+                                  Standard_Integer  theArgNb,
+                                  const char**      theArgVec)
+{
+  TCollection_AsciiString aCmdName (theArgVec[0]);
+  const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
+  ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
+  if (aCtx.IsNull())
+  {
+    Message::SendFail ("Error: no active view!");
+    return 1;
+  }
+
+  Standard_Integer anArgIter = 1;
+  Standard_Boolean isDefaults = Standard_False;
+  NCollection_Sequence<TCollection_AsciiString> aNames;
+  for (; anArgIter < theArgNb; ++anArgIter)
   {
     TCollection_AsciiString anArg = theArgVec[anArgIter];
     if (anUpdateTool.parseRedrawMode (anArg))
@@ -1844,7 +2231,7 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
 
   if (!aNames.IsEmpty() && isDefaults)
   {
-    std::cout << "Error: wrong syntax. If -defaults is used there should not be any objects' names!\n";
+    Message::SendFail ("Error: wrong syntax. If -defaults is used there should not be any objects' names!");
     return 1;
   }
 
@@ -1853,12 +2240,16 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
   ViewerTest_AspectsChangeSet* aChangeSet = &aChanges.ChangeLast();
 
   // parse syntax of legacy commands
+  bool toParseAliasArgs = false;
+  Standard_Boolean toDump = 0;
+  Standard_Boolean toCompactDump = 0;
+  Standard_Integer aDumpDepth = -1;
   if (aCmdName == "vsetwidth")
   {
     if (aNames.IsEmpty()
     || !aNames.Last().IsRealValue())
     {
-      std::cout << "Error: not enough arguments!\n";
+      Message::SendFail ("Error: not enough arguments!");
       return 1;
     }
     aChangeSet->ToSetLineWidth = 1;
@@ -1873,7 +2264,7 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
   {
     if (aNames.IsEmpty())
     {
-      std::cout << "Error: not enough arguments!\n";
+      Message::SendFail ("Error: not enough arguments!");
       return 1;
     }
     aChangeSet->ToSetColor = 1;
@@ -1886,39 +2277,29 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       aNames.Remove (aNames.Length());
       isOk = Standard_True;
     }
+    else if (Quantity_Color::ColorFromHex (aNames.Last().ToCString(), aChangeSet->Color))
+    {
+      aNames.Remove (aNames.Length());
+      isOk = Standard_True;
+    }
     else if (aNames.Length() >= 3)
     {
-      const TCollection_AsciiString anRgbStr[3] =
+      const char* anArgVec[3] =
       {
-        aNames.Value (aNames.Upper() - 2),
-        aNames.Value (aNames.Upper() - 1),
-        aNames.Value (aNames.Upper() - 0)
+        aNames.Value (aNames.Upper() - 2).ToCString(),
+        aNames.Value (aNames.Upper() - 1).ToCString(),
+        aNames.Value (aNames.Upper() - 0).ToCString(),
       };
-      isOk = anRgbStr[0].IsRealValue()
-          && anRgbStr[1].IsRealValue()
-          && anRgbStr[2].IsRealValue();
-      if (isOk)
-      {
-        Graphic3d_Vec4d anRgb;
-        anRgb.x() = anRgbStr[0].RealValue();
-        anRgb.y() = anRgbStr[1].RealValue();
-        anRgb.z() = anRgbStr[2].RealValue();
-        if (anRgb.x() < 0.0 || anRgb.x() > 1.0
-         || anRgb.y() < 0.0 || anRgb.y() > 1.0
-         || anRgb.z() < 0.0 || anRgb.z() > 1.0)
-        {
-          std::cout << "Error: RGB color values should be within range 0..1!\n";
-          return 1;
-        }
-        aChangeSet->Color.SetValues (anRgb.x(), anRgb.y(), anRgb.z(), Quantity_TOC_RGB);
-        aNames.Remove (aNames.Length());
-        aNames.Remove (aNames.Length());
-        aNames.Remove (aNames.Length());
-      }
+
+      Standard_Integer aNbParsed = Draw::ParseColor (3, anArgVec, aChangeSet->Color);
+      isOk = aNbParsed == 3;
+      aNames.Remove (aNames.Length());
+      aNames.Remove (aNames.Length());
+      aNames.Remove (aNames.Length());
     }
     if (!isOk)
     {
-      std::cout << "Error: not enough arguments!\n";
+      Message::SendFail ("Error: not enough arguments!");
       return 1;
     }
   }
@@ -1931,7 +2312,7 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
     if (aNames.IsEmpty()
     || !aNames.Last().IsRealValue())
     {
-      std::cout << "Error: not enough arguments!\n";
+      Message::SendFail ("Error: not enough arguments!");
       return 1;
     }
     aChangeSet->ToSetTransparency = 1;
@@ -1946,25 +2327,102 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
   {
     if (aNames.IsEmpty())
     {
-      std::cout << "Error: not enough arguments!\n";
+      Message::SendFail ("Error: not enough arguments!");
       return 1;
     }
     aChangeSet->ToSetMaterial = 1;
-    aChangeSet->MatName  = aNames.Last();
-    aChangeSet->Material = Graphic3d_MaterialAspect::MaterialFromName (aChangeSet->MatName.ToCString());
+    aChangeSet->MatName = aNames.Last();
     aNames.Remove (aNames.Length());
+    if (!Graphic3d_MaterialAspect::MaterialFromName (aChangeSet->MatName.ToCString(), aChangeSet->Material))
+    {
+      Message::SendFail() << "Syntax error: unknown material '" << aChangeSet->MatName << "'.";
+      return 1;
+    }
   }
   else if (aCmdName == "vunsetmaterial")
   {
     aChangeSet->ToSetMaterial = -1;
   }
+  else if (aCmdName == "vsetinteriorstyle")
+  {
+    if (aNames.IsEmpty()
+    || !aNames.Last().IsRealValue())
+    {
+      Message::SendFail ("Error: not enough arguments!");
+      return 1;
+    }
+    aChangeSet->ToSetInterior = 1;
+    if (!parseInteriorStyle (aNames.Last(), aChangeSet->InteriorStyle))
+    {
+      Message::SendFail() << "Error: wrong syntax at " << aNames.Last();
+      return 1;
+    }
+    aNames.Remove (aNames.Length());
+  }
+  else if (aCmdName == "vsetedgetype")
+  {
+    aChangeSet->ToSetDrawEdges = 1;
+    toParseAliasArgs = true;
+  }
+  else if (aCmdName == "vunsetedgetype")
+  {
+    aChangeSet->ToSetDrawEdges  = -1;
+    aChangeSet->ToSetEdgeColor  = -1;
+    aChangeSet->ToSetTypeOfEdge = -1;
+    aChangeSet->TypeOfEdge = Aspect_TOL_SOLID;
+  }
+  else if (aCmdName == "vshowfaceboundary")
+  {
+    aChangeSet->ToSetFaceBoundaryDraw = 1;
+    toParseAliasArgs = true;
+    if (aNames.Size() >= 2
+     && aNames.Value (2).IsIntegerValue())
+    {
+      if (aNames.Size() == 7)
+      {
+        if (ViewerTest::ParseLineType (aNames.Value (7).ToCString(), aChangeSet->TypeOfFaceBoundaryLine))
+        {
+          aChangeSet->ToSetTypeOfFaceBoundaryLine = 1;
+          aNames.Remove (7);
+        }
+      }
+      if (aNames.Size() == 6
+       && aNames.Value (6).IsRealValue())
+      {
+        aChangeSet->ToSetFaceBoundaryWidth = 1;
+        aChangeSet->FaceBoundaryWidth = aNames.Value (6).RealValue();
+        aNames.Remove (6);
+      }
+      if (aNames.Size() == 5
+       && aNames.Value (3).IsIntegerValue()
+       && aNames.Value (4).IsIntegerValue()
+       && aNames.Value (5).IsIntegerValue())
+      {
+        aChangeSet->ToSetFaceBoundaryColor = 1;
+        aChangeSet->FaceBoundaryColor = Quantity_Color (aNames.Value (3).IntegerValue() / 255.0,
+                                                        aNames.Value (4).IntegerValue() / 255.0,
+                                                        aNames.Value (5).IntegerValue() / 255.0,
+                                                        Quantity_TOC_sRGB);
+        aNames.Remove (5);
+        aNames.Remove (4);
+        aNames.Remove (3);
+      }
+      if (aNames.Size() == 2)
+      {
+        toParseAliasArgs = false;
+        aChangeSet->ToSetFaceBoundaryDraw = aNames.Value (2).IntegerValue() == 1 ? 1 : -1;
+        aNames.Remove (2);
+      }
+    }
+  }
   else if (anArgIter >= theArgNb)
   {
-    std::cout << "Error: not enough arguments!\n";
+    Message::SendFail ("Error: not enough arguments!");
     return 1;
   }
 
-  if (!aChangeSet->IsEmpty())
+  if (!aChangeSet->IsEmpty()
+   && !toParseAliasArgs)
   {
     anArgIter = theArgNb;
   }
@@ -1973,28 +2431,72 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
     TCollection_AsciiString anArg = theArgVec[anArgIter];
     anArg.LowerCase();
     if (anArg == "-setwidth"
-     || anArg == "-setlinewidth")
+     || anArg == "-width"
+     || anArg == "-setlinewidth"
+     || anArg == "-linewidth"
+     || anArg == "-setedgewidth"
+     || anArg == "-setedgeswidth"
+     || anArg == "-edgewidth"
+     || anArg == "-edgeswidth"
+     || anArg == "-setfaceboundarywidth"
+     || anArg == "-setboundarywidth"
+     || anArg == "-faceboundarywidth"
+     || anArg == "-boundarywidth")
     {
       if (++anArgIter >= theArgNb)
       {
-        std::cout << "Error: wrong syntax at " << anArg << "\n";
+        Message::SendFail() << "Error: wrong syntax at " << anArg;
         return 1;
       }
-      aChangeSet->ToSetLineWidth = 1;
-      aChangeSet->LineWidth = Draw::Atof (theArgVec[anArgIter]);
+
+      const Standard_Real aWidth = Draw::Atof (theArgVec[anArgIter]);
+      if (anArg == "-setedgewidth"
+       || anArg == "-setedgeswidth"
+       || anArg == "-edgewidth"
+       || anArg == "-edgeswidth"
+       || aCmdName == "vsetedgetype")
+      {
+        aChangeSet->ToSetEdgeWidth = 1;
+        aChangeSet->EdgeWidth = aWidth;
+      }
+      else if (anArg == "-setfaceboundarywidth"
+            || anArg == "-setboundarywidth"
+            || anArg == "-faceboundarywidth"
+            || anArg == "-boundarywidth"
+            || aCmdName == "vshowfaceboundary")
+      {
+        aChangeSet->ToSetFaceBoundaryWidth = 1;
+        aChangeSet->FaceBoundaryWidth = aWidth;
+      }
+      else
+      {
+        aChangeSet->ToSetLineWidth = 1;
+        aChangeSet->LineWidth = aWidth;
+      }
     }
     else if (anArg == "-unsetwidth"
-          || anArg == "-unsetlinewidth")
+          || anArg == "-unsetlinewidth"
+          || anArg == "-unsetedgewidth")
     {
-      aChangeSet->ToSetLineWidth = -1;
-      aChangeSet->LineWidth = 1.0;
+      if (anArg == "-unsetedgewidth")
+      {
+        aChangeSet->ToSetEdgeWidth = -1;
+        aChangeSet->EdgeWidth = 1.0;
+      }
+      else
+      {
+        aChangeSet->ToSetLineWidth = -1;
+        aChangeSet->LineWidth = 1.0;
+      }
     }
     else if (anArg == "-settransp"
-          || anArg == "-settransparency")
+          || anArg == "-settransparency"
+          || anArg == "-transparency"
+          || anArg == "-transp")
     {
       if (++anArgIter >= theArgNb)
       {
-        std::cout << "Error: wrong syntax at " << anArg << "\n";
+        Message::SendFail() << "Error: wrong syntax at " << anArg;
         return 1;
       }
       aChangeSet->ToSetTransparency = 1;
@@ -2006,11 +2508,12 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
         aChangeSet->Transparency = 0.0;
       }
     }
-    else if (anArg == "-setalphamode")
+    else if (anArg == "-setalphamode"
+          || anArg == "-alphamode")
     {
       if (++anArgIter >= theArgNb)
       {
-        std::cout << "Error: wrong syntax at " << anArg << "\n";
+        Message::SendFail() << "Error: wrong syntax at " << anArg;
         return 1;
       }
       aChangeSet->ToSetAlphaMode = 1;
@@ -2037,7 +2540,7 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
         }
         else
         {
-          std::cout << "Error: wrong syntax at " << aParam << "\n";
+          Message::SendFail() << "Error: wrong syntax at " << aParam;
           return 1;
         }
       }
@@ -2054,22 +2557,24 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       }
     }
     else if (anArg == "-setvis"
-          || anArg == "-setvisibility")
+          || anArg == "-setvisibility"
+          || anArg == "-visibility")
     {
       if (++anArgIter >= theArgNb)
       {
-        std::cout << "Error: wrong syntax at " << anArg << "\n";
+        Message::SendFail() << "Error: wrong syntax at " << anArg;
         return 1;
       }
 
       aChangeSet->ToSetVisibility = 1;
       aChangeSet->Visibility = Draw::Atoi (theArgVec[anArgIter]);
     }
-    else if (anArg == "-setalpha")
+    else if (anArg == "-setalpha"
+          || anArg == "-alpha")
     {
       if (++anArgIter >= theArgNb)
       {
-        std::cout << "Error: wrong syntax at " << anArg << "\n";
+        Message::SendFail() << "Error: wrong syntax at " << anArg;
         return 1;
       }
       aChangeSet->ToSetTransparency = 1;
@@ -2077,7 +2582,7 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       if (aChangeSet->Transparency < 0.0
        || aChangeSet->Transparency > 1.0)
       {
-        std::cout << "Error: the transparency should be within [0; 1] range (specified " << aChangeSet->Transparency << ")\n";
+        Message::SendFail() << "Error: the transparency should be within [0; 1] range (specified " << aChangeSet->Transparency << ")";
         return 1;
       }
       aChangeSet->Transparency = 1.0 - aChangeSet->Transparency;
@@ -2096,86 +2601,156 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       aChangeSet->ToSetTransparency = -1;
       aChangeSet->Transparency = 0.0;
     }
-    else if (anArg == "-setcolor")
-    {
-      Standard_Integer aNbComps  = 0;
-      Standard_Integer aCompIter = anArgIter + 1;
-      for (; aCompIter < theArgNb; ++aCompIter, ++aNbComps)
+    else if (anArg == "-setcolor"
+          || anArg == "-color"
+          || anArg == "-setbackfacecolor"
+          || anArg == "-backfacecolor"
+          || anArg == "-setbackcolor"
+          || anArg == "-backcolor"
+          || anArg == "-setfaceboundarycolor"
+          || anArg == "-setboundarycolor"
+          || anArg == "-faceboundarycolor"
+          || anArg == "-boundarycolor")
+    {
+      Quantity_Color aColor;
+      Standard_Integer aNbParsed = Draw::ParseColor (theArgNb  - anArgIter - 1,
+                                                     theArgVec + anArgIter + 1,
+                                                     aColor);
+      if (aNbParsed == 0)
+      {
+        Message::SendFail() << "Syntax error at '" << anArg << "'";
+        return 1;
+      }
+      anArgIter += aNbParsed;
+      if (aCmdName == "vsetedgetype")
       {
-        if (theArgVec[aCompIter][0] == '-')
-        {
-          break;
-        }
+        aChangeSet->ToSetEdgeColor = 1;
+        aChangeSet->EdgeColor = Quantity_ColorRGBA (aColor);
       }
-      switch (aNbComps)
+      else if (aCmdName == "vshowfaceboundary"
+            || anArg == "-setfaceboundarycolor"
+            || anArg == "-setboundarycolor"
+            || anArg == "-faceboundarycolor"
+            || anArg == "-boundarycolor")
       {
-        case 1:
-        {
-          Quantity_NameOfColor aColor = Quantity_NOC_BLACK;
-          Standard_CString     aName  = theArgVec[anArgIter + 1];
-          if (!Quantity_Color::ColorFromName (aName, aColor))
-          {
-            std::cout << "Error: unknown color name '" << aName << "'\n";
-            return 1;
-          }
-          aChangeSet->Color = aColor;
-          break;
-        }
-        case 3:
-        {
-          Graphic3d_Vec3d anRgb;
-          anRgb.x() = Draw::Atof (theArgVec[anArgIter + 1]);
-          anRgb.y() = Draw::Atof (theArgVec[anArgIter + 2]);
-          anRgb.z() = Draw::Atof (theArgVec[anArgIter + 3]);
-          if (anRgb.x() < 0.0 || anRgb.x() > 1.0
-           || anRgb.y() < 0.0 || anRgb.y() > 1.0
-           || anRgb.z() < 0.0 || anRgb.z() > 1.0)
-          {
-            std::cout << "Error: RGB color values should be within range 0..1!\n";
-            return 1;
-          }
-          aChangeSet->Color.SetValues (anRgb.x(), anRgb.y(), anRgb.z(), Quantity_TOC_RGB);
-          break;
-        }
-        default:
-        {
-          std::cout << "Error: wrong syntax at " << anArg << "\n";
-          return 1;
-        }
+        aChangeSet->ToSetFaceBoundaryColor = 1;
+        aChangeSet->FaceBoundaryColor = aColor;
       }
-      aChangeSet->ToSetColor = 1;
-      anArgIter += aNbComps;
-    }
-    else if (anArg == "-setlinetype")
+      else if (anArg == "-setbackfacecolor"
+            || anArg == "-backfacecolor"
+            || anArg == "-setbackcolor"
+            || anArg == "-backcolor")
+      {
+        aChangeSet->ToSetBackFaceColor = 1;
+        aChangeSet->BackFaceColor = aColor;
+      }
+      else
+      {
+        aChangeSet->ToSetColor = 1;
+        aChangeSet->Color = aColor;
+      }
+    }
+    else if (anArg == "-setlinetype"
+          || anArg == "-linetype"
+          || anArg == "-setedgetype"
+          || anArg == "-setedgestype"
+          || anArg == "-edgetype"
+          || anArg == "-edgestype"
+          || anArg == "-setfaceboundarystyle"
+          || anArg == "-faceboundarystyle"
+          || anArg == "-boundarystyle"
+          || anArg == "-setfaceboundarytype"
+          || anArg == "-faceboundarytype"
+          || anArg == "-setboundarytype"
+          || anArg == "-boundarytype"
+          || anArg == "-type")
     {
       if (++anArgIter >= theArgNb)
       {
-        std::cout << "Error: wrong syntax at " << anArg << "\n";
+        Message::SendFail() << "Error: wrong syntax at " << anArg;
         return 1;
       }
-      if (!ViewerTest::ParseLineType (theArgVec[anArgIter], aChangeSet->TypeOfLine))
+      Aspect_TypeOfLine aLineType = Aspect_TOL_EMPTY;
+      uint16_t aLinePattern = 0xFFFF;
+      if (!ViewerTest::ParseLineType (theArgVec[anArgIter], aLineType, aLinePattern))
       {
-        std::cout << "Error: wrong syntax at " << anArg << "\n";
+        Message::SendFail() << "Error: wrong syntax at " << anArg;
         return 1;
       }
 
-      aChangeSet->ToSetTypeOfLine = 1;
+      if (anArg == "-setedgetype"
+       || anArg == "-setedgestype"
+       || anArg == "-edgetype"
+       || anArg == "-edgestype"
+       || aCmdName == "vsetedgetype")
+      {
+        aChangeSet->TypeOfEdge = Graphic3d_Aspects::DefaultLineTypeForPattern (aLinePattern);
+        aChangeSet->ToSetTypeOfEdge = 1;
+      }
+      else if (anArg == "-setfaceboundarystyle"
+            || anArg == "-faceboundarystyle"
+            || anArg == "-boundarystyle"
+            || anArg == "-setfaceboundarytype"
+            || anArg == "-faceboundarytype"
+            || anArg == "-setboundarytype"
+            || anArg == "-boundarytype"
+            || aCmdName == "vshowfaceboundary")
+      {
+        aChangeSet->TypeOfFaceBoundaryLine = Graphic3d_Aspects::DefaultLineTypeForPattern (aLinePattern);
+        aChangeSet->ToSetTypeOfFaceBoundaryLine = 1;
+      }
+      else
+      {
+        aChangeSet->StippleLinePattern = aLinePattern;
+        aChangeSet->ToSetTypeOfLine = 1;
+      }
     }
-    else if (anArg == "-unsetlinetype")
+    else if (anArg == "-unsetlinetype"
+          || anArg == "-unsetedgetype"
+          || anArg == "-unsetedgestype")
     {
-      aChangeSet->ToSetTypeOfLine = -1;
+      if (anArg == "-unsetedgetype"
+       || anArg == "-unsetedgestype")
+      {
+        aChangeSet->ToSetTypeOfEdge = -1;
+      }
+      else
+      {
+        aChangeSet->ToSetTypeOfLine = -1;
+      }
+    }
+    else if (anArg == "-setstipplelinefactor"
+          || anArg == "-setstipplefactor"
+          || anArg == "-setlinefactor"
+          || anArg == "-stipplelinefactor"
+          || anArg == "-stipplefactor"
+          || anArg == "-linefactor")
+    {
+      if (aChangeSet->ToSetTypeOfLine == -1)
+      {
+        Message::SendFail() << "Error: -setStippleLineFactor requires -setLineType";
+        return 1;
+      }
+      if (++anArgIter >= theArgNb)
+      {
+        Message::SendFail() << "Error: wrong syntax at " << anArg;
+        return 1;
+      }
+      aChangeSet->StippleLineFactor = (uint16_t )Draw::Atoi (theArgVec[anArgIter]);
     }
     else if (anArg == "-setmarkertype"
-          || anArg == "-setpointtype")
+          || anArg == "-markertype"
+          || anArg == "-setpointtype"
+          || anArg == "-pointtype")
     {
       if (++anArgIter >= theArgNb)
       {
-        std::cout << "Error: wrong syntax at " << anArg << "\n";
+        Message::SendFail() << "Error: wrong syntax at " << anArg;
         return 1;
       }
       if (!ViewerTest::ParseMarkerType (theArgVec[anArgIter], aChangeSet->TypeOfMarker, aChangeSet->MarkerImage))
       {
-        std::cout << "Error: wrong syntax at " << anArg << "\n";
+        Message::SendFail() << "Error: wrong syntax at " << anArg;
         return 1;
       }
 
@@ -2187,11 +2762,13 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       aChangeSet->ToSetTypeOfMarker = -1;
     }
     else if (anArg == "-setmarkersize"
-          || anArg == "-setpointsize")
+          || anArg == "-markersize"
+          || anArg == "-setpointsize"
+          || anArg == "-pointsize")
     {
       if (++anArgIter >= theArgNb)
       {
-        std::cout << "Error: wrong syntax at " << anArg << "\n";
+        Message::SendFail() << "Error: wrong syntax at " << anArg;
         return 1;
       }
       aChangeSet->ToSetMarkerSize = 1;
@@ -2209,16 +2786,22 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       aChangeSet->Color = DEFAULT_COLOR;
     }
     else if (anArg == "-setmat"
-          || anArg == "-setmaterial")
+          || anArg == "-mat"
+          || anArg == "-setmaterial"
+          || anArg == "-material")
     {
       if (++anArgIter >= theArgNb)
       {
-        std::cout << "Error: wrong syntax at " << anArg << "\n";
+        Message::SendFail() << "Error: wrong syntax at " << anArg;
         return 1;
       }
       aChangeSet->ToSetMaterial = 1;
-      aChangeSet->MatName  = theArgVec[anArgIter];
-      aChangeSet->Material = Graphic3d_MaterialAspect::MaterialFromName (aChangeSet->MatName.ToCString());
+      aChangeSet->MatName = theArgVec[anArgIter];
+      if (!Graphic3d_MaterialAspect::MaterialFromName (aChangeSet->MatName.ToCString(), aChangeSet->Material))
+      {
+        Message::SendFail() << "Syntax error: unknown material '" << aChangeSet->MatName << "'.";
+        return 1;
+      }
     }
     else if (anArg == "-unsetmat"
           || anArg == "-unsetmaterial")
@@ -2231,13 +2814,13 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
     {
       if (isDefaults)
       {
-        std::cout << "Error: wrong syntax. -subshapes can not be used together with -defaults call!\n";
+        Message::SendFail() << "Error: wrong syntax. -subshapes can not be used together with -defaults call!";
         return 1;
       }
 
       if (aNames.IsEmpty())
       {
-        std::cout << "Error: main objects should specified explicitly when -subshapes is used!\n";
+        Message::SendFail() << "Error: main objects should specified explicitly when -subshapes is used!";
         return 1;
       }
 
@@ -2256,7 +2839,7 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
         TopoDS_Shape aSubShape = DBRep::Get (aSubShapeName);
         if (aSubShape.IsNull())
         {
-          std::cerr << "Error: shape " << aSubShapeName << " doesn't found!\n";
+          Message::SendFail() << "Error: shape " << aSubShapeName << " doesn't found!";
           return 1;
         }
         aChangeSet->SubShapes.Append (aSubShape);
@@ -2264,42 +2847,32 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
 
       if (aChangeSet->SubShapes.IsEmpty())
       {
-        std::cerr << "Error: empty list is specified after -subshapes!\n";
+        Message::SendFail() << "Error: empty list is specified after -subshapes!";
         return 1;
       }
     }
-    else if (anArg == "-freeboundary"
+    else if (anArg == "-setfreeboundary"
+          || anArg == "-freeboundary"
+          || anArg == "-setfb"
           || anArg == "-fb")
     {
-      if (++anArgIter >= theArgNb)
+      bool toEnable = true;
+      if (!Draw::ParseOnOff (anArgIter + 1 < theArgNb ? theArgVec[anArgIter + 1] : "", toEnable))
       {
-        std::cout << "Error: wrong syntax at " << anArg << "\n";
-        return 1;
-      }
-      TCollection_AsciiString aValue (theArgVec[anArgIter]);
-      aValue.LowerCase();
-      if (aValue == "on"
-       || aValue == "1")
-      {
-        aChangeSet->ToSetShowFreeBoundary = 1;
-      }
-      else if (aValue == "off"
-            || aValue == "0")
-      {
-        aChangeSet->ToSetShowFreeBoundary = -1;
-      }
-      else
-      {
-        std::cout << "Error: wrong syntax at " << anArg << "\n";
+        Message::SendFail() << "Error: wrong syntax at " << anArg;
         return 1;
       }
+      ++anArgIter;
+      aChangeSet->ToSetShowFreeBoundary = toEnable ? 1 : -1;
     }
     else if (anArg == "-setfreeboundarywidth"
-          || anArg == "-setfbwidth")
+          || anArg == "-freeboundarywidth"
+          || anArg == "-setfbwidth"
+          || anArg == "-fbwidth")
     {
       if (++anArgIter >= theArgNb)
       {
-        std::cout << "Error: wrong syntax at " << anArg << "\n";
+        Message::SendFail() << "Error: wrong syntax at " << anArg;
         return 1;
       }
       aChangeSet->ToSetFreeBoundaryWidth = 1;
@@ -2312,55 +2885,20 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       aChangeSet->FreeBoundaryWidth = 1.0;
     }
     else if (anArg == "-setfreeboundarycolor"
-          || anArg == "-setfbcolor")
+          || anArg == "-freeboundarycolor"
+          || anArg == "-setfbcolor"
+          || anArg == "-fbcolor")
     {
-      Standard_Integer aNbComps  = 0;
-      Standard_Integer aCompIter = anArgIter + 1;
-      for (; aCompIter < theArgNb; ++aCompIter, ++aNbComps)
+      Standard_Integer aNbParsed = Draw::ParseColor (theArgNb  - anArgIter - 1,
+                                                     theArgVec + anArgIter + 1,
+                                                     aChangeSet->FreeBoundaryColor);
+      if (aNbParsed == 0)
       {
-        if (theArgVec[aCompIter][0] == '-')
-        {
-          break;
-        }
-      }
-      switch (aNbComps)
-      {
-        case 1:
-        {
-          Quantity_NameOfColor aColor = Quantity_NOC_BLACK;
-          Standard_CString     aName  = theArgVec[anArgIter + 1];
-          if (!Quantity_Color::ColorFromName (aName, aColor))
-          {
-            std::cout << "Error: unknown free boundary color name '" << aName << "'\n";
-            return 1;
-          }
-          aChangeSet->FreeBoundaryColor = aColor;
-          break;
-        }
-        case 3:
-        {
-          Graphic3d_Vec3d anRgb;
-          anRgb.x() = Draw::Atof (theArgVec[anArgIter + 1]);
-          anRgb.y() = Draw::Atof (theArgVec[anArgIter + 2]);
-          anRgb.z() = Draw::Atof (theArgVec[anArgIter + 3]);
-          if (anRgb.x() < 0.0 || anRgb.x() > 1.0
-           || anRgb.y() < 0.0 || anRgb.y() > 1.0
-           || anRgb.z() < 0.0 || anRgb.z() > 1.0)
-          {
-            std::cout << "Error: free boundary RGB color values should be within range 0..1!\n";
-            return 1;
-          }
-          aChangeSet->FreeBoundaryColor.SetValues (anRgb.x(), anRgb.y(), anRgb.z(), Quantity_TOC_RGB);
-          break;
-        }
-        default:
-        {
-          std::cout << "Error: wrong syntax at " << anArg << "\n";
-          return 1;
-        }
+        Message::SendFail() << "Syntax error at '" << anArg << "'";
+        return 1;
       }
+      anArgIter += aNbParsed;
       aChangeSet->ToSetFreeBoundaryColor = 1;
-      anArgIter += aNbComps;
     }
     else if (anArg == "-unsetfreeboundarycolor"
           || anArg == "-unsetfbcolor")
@@ -2368,108 +2906,139 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       aChangeSet->ToSetFreeBoundaryColor = -1;
       aChangeSet->FreeBoundaryColor = DEFAULT_FREEBOUNDARY_COLOR;
     }
-    else if (anArg == "-unset")
-    {
-      aChangeSet->ToSetVisibility = 1;
-      aChangeSet->Visibility = 1;
-      aChangeSet->ToSetLineWidth = -1;
-      aChangeSet->LineWidth = 1.0;
-      aChangeSet->ToSetTypeOfLine = -1;
-      aChangeSet->TypeOfLine = Aspect_TOL_SOLID;
-      aChangeSet->ToSetTypeOfMarker = -1;
-      aChangeSet->TypeOfMarker = Aspect_TOM_PLUS;
-      aChangeSet->ToSetMarkerSize = -1;
-      aChangeSet->MarkerSize = 1.0;
-      aChangeSet->ToSetTransparency = -1;
-      aChangeSet->Transparency = 0.0;
-      aChangeSet->ToSetAlphaMode = -1;
-      aChangeSet->AlphaMode = Graphic3d_AlphaMode_BlendAuto;
-      aChangeSet->AlphaCutoff = 0.5f;
-      aChangeSet->ToSetColor = -1;
-      aChangeSet->Color = DEFAULT_COLOR;
-      aChangeSet->ToSetMaterial = -1;
-      aChangeSet->Material = Graphic3d_NOM_DEFAULT;
-      aChangeSet->ToSetShowFreeBoundary = -1;
-      aChangeSet->ToSetFreeBoundaryColor = -1;
-      aChangeSet->FreeBoundaryColor = DEFAULT_FREEBOUNDARY_COLOR;
-      aChangeSet->ToSetFreeBoundaryWidth = -1;
-      aChangeSet->FreeBoundaryWidth = 1.0;
-      aChangeSet->ToSetHatch = -1;
-      aChangeSet->StdHatchStyle = -1;
-      aChangeSet->PathToHatchPattern.Clear();
-      aChangeSet->ToSetShadingModel = -1;
-      aChangeSet->ShadingModel = Graphic3d_TOSM_DEFAULT;
-    }
-    else if (anArg == "-isoontriangulation"
+    else if (anArg == "-setisoontriangulation"
+          || anArg == "-isoontriangulation"
+          || anArg == "-setisoontriang"
           || anArg == "-isoontriang")
     {
-      if (++anArgIter >= theArgNb)
+      bool toEnable = true;
+      if (!Draw::ParseOnOff (anArgIter + 1 < theArgNb ? theArgVec[anArgIter + 1] : "", toEnable))
       {
-        std::cout << "Error: wrong syntax at " << anArg << "\n";
+        Message::SendFail() << "Error: wrong syntax at " << anArg;
         return 1;
       }
-      TCollection_AsciiString aValue (theArgVec[anArgIter]);
-      aValue.LowerCase();
-      if (aValue == "on"
-        || aValue == "1")
+      ++anArgIter;
+      aChangeSet->ToEnableIsoOnTriangulation = toEnable ? 1 : -1;
+    }
+    else if (anArg == "-setfaceboundarydraw"
+          || anArg == "-setdrawfaceboundary"
+          || anArg == "-setdrawfaceboundaries"
+          || anArg == "-setshowfaceboundary"
+          || anArg == "-setshowfaceboundaries"
+          || anArg == "-setdrawfaceedges"
+          || anArg == "-faceboundarydraw"
+          || anArg == "-drawfaceboundary"
+          || anArg == "-drawfaceboundaries"
+          || anArg == "-showfaceboundary"
+          || anArg == "-showfaceboundaries"
+          || anArg == "-drawfaceedges"
+          || anArg == "-faceboundary"
+          || anArg == "-faceboundaries"
+          || anArg == "-faceedges")
+    {
+      bool toEnable = true;
+      if (!Draw::ParseOnOff (anArgIter + 1 < theArgNb ? theArgVec[anArgIter + 1] : "", toEnable))
+      {
+        Message::SendFail() << "Error: wrong syntax at " << anArg;
+        return 1;
+      }
+      ++anArgIter;
+      aChangeSet->ToSetFaceBoundaryDraw = toEnable ? 1 : -1;
+    }
+    else if (anArg == "-unsetfaceboundary"
+          || anArg == "-unsetboundary")
+    {
+      aChangeSet->ToSetFaceBoundaryDraw  = -1;
+      aChangeSet->ToSetFaceBoundaryColor = -1;
+    }
+    else if (anArg == "-setmostcontinuity"
+          || anArg == "-mostcontinuity")
+    {
+      TCollection_AsciiString aClassArg (anArgIter + 1 < theArgNb ? theArgVec[anArgIter + 1] : "");
+      aClassArg.LowerCase();
+      GeomAbs_Shape aClass = GeomAbs_CN;
+      if (aClassArg == "c0"
+       || aClassArg == "0")
       {
-        aChangeSet->ToEnableIsoOnTriangulation = 1;
+        aClass = GeomAbs_C0;
       }
-      else if (aValue == "off"
-        || aValue == "0")
+      else if (aClassArg == "c1"
+            || aClassArg == "1")
       {
-        aChangeSet->ToEnableIsoOnTriangulation = 0;
+        aClass = GeomAbs_C1;
+      }
+      else if (aClassArg == "c2"
+            || aClassArg == "2")
+      {
+        aClass = GeomAbs_C2;
+      }
+      else if (aClassArg == "c3"
+            || aClassArg == "3")
+      {
+        aClass = GeomAbs_C3;
+      }
+      else if (aClassArg == "cn"
+            || aClassArg == "n")
+      {
+        aClass = GeomAbs_CN;
       }
       else
       {
-        std::cout << "Error: wrong syntax at " << anArg << "\n";
+        Message::SendFail() << "Syntax error at '" << anArg << "'";
         return 1;
       }
+
+      ++anArgIter;
+      aChangeSet->ToSetFaceBoundaryUpperContinuity = 1;
+      aChangeSet->FaceBoundaryUpperContinuity = aClass;
     }
-    else if (anArg == "-setmaxparamvalue")
+    else if (anArg == "-setmaxparamvalue"
+          || anArg == "-maxparamvalue")
     {
       if (++anArgIter >= theArgNb)
       {
-        std::cout << "Error: wrong syntax at " << anArg << "\n";
+        Message::SendFail() << "Error: wrong syntax at " << anArg;
         return 1;
       }
       aChangeSet->ToSetMaxParamValue = 1;
       aChangeSet->MaxParamValue = Draw::Atof (theArgVec[anArgIter]);
     }
-    else if (anArg == "-setsensitivity")
+    else if (anArg == "-setsensitivity"
+          || anArg == "-sensitivity")
     {
       if (isDefaults)
       {
-        std::cout << "Error: wrong syntax. -setSensitivity can not be used together with -defaults call!\n";
+        Message::SendFail() << "Error: wrong syntax. -setSensitivity can not be used together with -defaults call!";
         return 1;
       }
 
       if (aNames.IsEmpty())
       {
-        std::cout << "Error: object and selection mode should specified explicitly when -setSensitivity is used!\n";
+        Message::SendFail() << "Error: object and selection mode should specified explicitly when -setSensitivity is used!";
         return 1;
       }
 
       if (anArgIter + 2 >= theArgNb)
       {
-        std::cout << "Error: wrong syntax at " << anArg << "\n";
+        Message::SendFail() << "Error: wrong syntax at " << anArg;
         return 1;
       }
       aChangeSet->ToSetSensitivity = 1;
       aChangeSet->SelectionMode = Draw::Atoi (theArgVec[++anArgIter]);
       aChangeSet->Sensitivity = Draw::Atoi (theArgVec[++anArgIter]);
     }
-    else if (anArg == "-sethatch")
+    else if (anArg == "-sethatch"
+          || anArg == "-hatch")
     {
       if (isDefaults)
       {
-        std::cout << "Error: wrong syntax. -setHatch can not be used together with -defaults call!\n";
+        Message::SendFail() << "Error: wrong syntax. -setHatch can not be used together with -defaults call!";
         return 1;
       }
 
       if (aNames.IsEmpty())
       {
-        std::cout << "Error: object should be specified explicitly when -setHatch is used!\n";
+        Message::SendFail() << "Error: object should be specified explicitly when -setHatch is used!";
         return 1;
       }
 
@@ -2481,7 +3050,7 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
         if (anIntStyle < 0
          || anIntStyle >= Aspect_HS_NB)
         {
-          std::cout << "Error: hatch style is out of range [0, " << (Aspect_HS_NB - 1) << "]!\n";
+          Message::SendFail() << "Error: hatch style is out of range [0, " << (Aspect_HS_NB - 1) << "]!";
           return 1;
         }
         aChangeSet->StdHatchStyle = anIntStyle;
@@ -2491,18 +3060,21 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
         aChangeSet->PathToHatchPattern = anArgHatch;
       }
     }
-    else if (anArg == "-setshadingmodel")
+    else if (anArg == "-setshadingmodel"
+          || anArg == "-setshading"
+          || anArg == "-shadingmodel"
+          || anArg == "-shading")
     {
       if (++anArgIter >= theArgNb)
       {
-        std::cout << "Error: wrong syntax at " << anArg << "\n";
+        Message::SendFail() << "Error: wrong syntax at " << anArg;
         return 1;
       }
       aChangeSet->ToSetShadingModel = 1;
       aChangeSet->ShadingModelName  = theArgVec[anArgIter];
       if (!ViewerTest::ParseShadingModel (theArgVec[anArgIter], aChangeSet->ShadingModel))
       {
-        std::cout << "Error: wrong syntax at " << anArg << "\n";
+        Message::SendFail() << "Error: wrong syntax at " << anArg;
         return 1;
       }
     }
@@ -2511,22 +3083,178 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       aChangeSet->ToSetShadingModel = -1;
       aChangeSet->ShadingModel = Graphic3d_TOSM_DEFAULT;
     }
+    else if (anArg == "-setinterior"
+          || anArg == "-setinteriorstyle"
+          || anArg == "-interior"
+          || anArg == "-interiorstyle")
+    {
+      if (++anArgIter >= theArgNb)
+      {
+        Message::SendFail() << "Error: wrong syntax at " << anArg;
+        return 1;
+      }
+      aChangeSet->ToSetInterior = 1;
+      if (!parseInteriorStyle (theArgVec[anArgIter], aChangeSet->InteriorStyle))
+      {
+        Message::SendFail() << "Error: wrong syntax at " << anArg;
+        return 1;
+      }
+    }
+    else if (anArg == "-unsetinterior")
+    {
+      aChangeSet->ToSetInterior = -1;
+      aChangeSet->InteriorStyle = Aspect_IS_SOLID;
+    }
+    else if (anArg == "-setdrawoutline"
+          || anArg == "-setdrawsilhouette"
+          || anArg == "-setoutline"
+          || anArg == "-setsilhouette"
+          || anArg == "-outline"
+          || anArg == "-outlined"
+          || anArg == "-silhouette")
+    {
+      bool toDrawOutline = true;
+      if (anArgIter + 1 < theArgNb
+       && Draw::ParseOnOff (theArgVec[anArgIter + 1], toDrawOutline))
+      {
+        ++anArgIter;
+      }
+      aChangeSet->ToSetDrawSilhouette = toDrawOutline ? 1 : -1;
+    }
+    else if (anArg == "-setdrawedges"
+          || anArg == "-setdrawedge"
+          || anArg == "-drawedges"
+          || anArg == "-drawedge"
+          || anArg == "-edges")
+    {
+      bool toDrawEdges = true;
+      if (anArgIter + 1 < theArgNb
+       && Draw::ParseOnOff (theArgVec[anArgIter + 1], toDrawEdges))
+      {
+        ++anArgIter;
+      }
+      aChangeSet->ToSetDrawEdges = toDrawEdges ? 1 : -1;
+    }
+    else if (anArg == "-setquadedges"
+          || anArg == "-setquads"
+          || anArg == "-quads"
+          || anArg == "-skipfirstedge")
+    {
+      bool isQuadMode = true;
+      if (anArgIter + 1 < theArgNb
+       && Draw::ParseOnOff (theArgVec[anArgIter + 1], isQuadMode))
+      {
+        ++anArgIter;
+      }
+      aChangeSet->ToSetQuadEdges = isQuadMode ? 1 : -1;
+    }
+    else if (anArg == "-setedgecolor"
+          || anArg == "-setedgescolor"
+          || anArg == "-edgecolor"
+          || anArg == "-edgescolor")
+    {
+      Standard_Integer aNbParsed = Draw::ParseColor (theArgNb  - anArgIter - 1,
+                                                     theArgVec + anArgIter + 1,
+                                                     aChangeSet->EdgeColor);
+      if (aNbParsed == 0)
+      {
+        Message::SendFail() << "Syntax error at '" << anArg << "'";
+        return 1;
+      }
+      anArgIter += aNbParsed;
+      aChangeSet->ToSetEdgeColor = 1;
+    }
+    else if (anArg == "-unset")
+    {
+      aChangeSet->ToSetVisibility = 1;
+      aChangeSet->Visibility = 1;
+      aChangeSet->ToSetLineWidth = -1;
+      aChangeSet->LineWidth = 1.0;
+      aChangeSet->ToSetTypeOfLine = -1;
+      aChangeSet->StippleLinePattern = 0xFFFF;
+      aChangeSet->StippleLineFactor = 1;
+      aChangeSet->ToSetTypeOfMarker = -1;
+      aChangeSet->TypeOfMarker = Aspect_TOM_PLUS;
+      aChangeSet->ToSetMarkerSize = -1;
+      aChangeSet->MarkerSize = 1.0;
+      aChangeSet->ToSetTransparency = -1;
+      aChangeSet->Transparency = 0.0;
+      aChangeSet->ToSetAlphaMode = -1;
+      aChangeSet->AlphaMode = Graphic3d_AlphaMode_BlendAuto;
+      aChangeSet->AlphaCutoff = 0.5f;
+      aChangeSet->ToSetColor = -1;
+      aChangeSet->Color = DEFAULT_COLOR;
+      //aChangeSet->ToSetBackFaceColor = -1; // should be reset by ToSetColor
+      //aChangeSet->BackFaceColor = DEFAULT_COLOR;
+      aChangeSet->ToSetMaterial = -1;
+      aChangeSet->Material = Graphic3d_NOM_DEFAULT;
+      aChangeSet->ToSetShowFreeBoundary = -1;
+      aChangeSet->ToSetFreeBoundaryColor = -1;
+      aChangeSet->FreeBoundaryColor = DEFAULT_FREEBOUNDARY_COLOR;
+      aChangeSet->ToSetFreeBoundaryWidth = -1;
+      aChangeSet->FreeBoundaryWidth = 1.0;
+      aChangeSet->ToEnableIsoOnTriangulation = -1;
+      //
+      aChangeSet->ToSetFaceBoundaryDraw = -1;
+      aChangeSet->ToSetFaceBoundaryUpperContinuity = -1;
+      aChangeSet->FaceBoundaryUpperContinuity = GeomAbs_CN;
+      aChangeSet->ToSetFaceBoundaryColor = -1;
+      aChangeSet->FaceBoundaryColor = Quantity_NOC_BLACK;
+      aChangeSet->ToSetFaceBoundaryWidth = -1;
+      aChangeSet->FaceBoundaryWidth = 1.0f;
+      aChangeSet->ToSetTypeOfFaceBoundaryLine = -1;
+      aChangeSet->TypeOfFaceBoundaryLine = Aspect_TOL_SOLID;
+      //
+      aChangeSet->ToSetHatch = -1;
+      aChangeSet->StdHatchStyle = -1;
+      aChangeSet->PathToHatchPattern.Clear();
+      aChangeSet->ToSetShadingModel = -1;
+      aChangeSet->ShadingModel = Graphic3d_TOSM_DEFAULT;
+      aChangeSet->ToSetInterior = -1;
+      aChangeSet->InteriorStyle = Aspect_IS_SOLID;
+      aChangeSet->ToSetDrawSilhouette = -1;
+      aChangeSet->ToSetDrawEdges = -1;
+      aChangeSet->ToSetQuadEdges = -1;
+      aChangeSet->ToSetEdgeColor = -1;
+      aChangeSet->EdgeColor = Quantity_ColorRGBA (DEFAULT_COLOR);
+      aChangeSet->ToSetEdgeWidth = -1;
+      aChangeSet->EdgeWidth = 1.0;
+      aChangeSet->ToSetTypeOfEdge = -1;
+      aChangeSet->TypeOfEdge = Aspect_TOL_SOLID;
+    }
+    else if (anArg == "-dumpjson")
+    {
+      toDump = Standard_True;
+    }
+    else if (anArg == "-dumpcompact")
+    {
+      toCompactDump = Standard_False;
+      if (++anArgIter >= theArgNb && Draw::ParseOnOff (theArgVec[anArgIter + 1], toCompactDump))
+        ++anArgIter;
+    }
+    else if (anArg == "-dumpdepth")
+    {
+      if (++anArgIter >= theArgNb)
+      {
+        Message::SendFail() << "Error: wrong syntax at " << anArg;
+        return 1;
+      }
+      aDumpDepth = Draw::Atoi (theArgVec[anArgIter]);
+    }
     else
     {
-      std::cout << "Error: wrong syntax at " << anArg << "\n";
+      Message::SendFail() << "Error: wrong syntax at " << anArg;
       return 1;
     }
   }
 
-  Standard_Boolean isFirst = Standard_True;
   for (NCollection_Sequence<ViewerTest_AspectsChangeSet>::Iterator aChangesIter (aChanges);
        aChangesIter.More(); aChangesIter.Next())
   {
-    if (!aChangesIter.Value().Validate (!isFirst))
+    if (!aChangesIter.Value().Validate())
     {
       return 1;
     }
-    isFirst = Standard_False;
   }
 
   // special case for -defaults parameter.
@@ -2534,7 +3262,7 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
   if (isDefaults)
   {
     const Handle(Prs3d_Drawer)& aDrawer = aCtx->DefaultDrawer();
-
+    aChangeSet->Apply (aDrawer);
     if (aChangeSet->ToSetLineWidth != 0)
     {
       aDrawer->LineAspect()->SetWidth (aChangeSet->LineWidth);
@@ -2551,65 +3279,18 @@ 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->ToSetTypeOfMarker != 0)
-    {
-      aDrawer->PointAspect()->SetTypeOfMarker (aChangeSet->TypeOfMarker);
-      aDrawer->PointAspect()->Aspect()->SetMarkerImage (aChangeSet->MarkerImage.IsNull()
-                                                      ? Handle(Graphic3d_MarkerImage)()
-                                                      : new Graphic3d_MarkerImage (aChangeSet->MarkerImage));
-    }
-    if (aChangeSet->ToSetMarkerSize != 0)
-    {
-      aDrawer->PointAspect()->SetScale (aChangeSet->MarkerSize);
-    }
     if (aChangeSet->ToSetTransparency != 0)
     {
       aDrawer->ShadingAspect()->SetTransparency (aChangeSet->Transparency);
     }
-    if (aChangeSet->ToSetAlphaMode != 0)
-    {
-      aDrawer->ShadingAspect()->Aspect()->SetAlphaMode (aChangeSet->AlphaMode, aChangeSet->AlphaCutoff);
-    }
     if (aChangeSet->ToSetMaterial != 0)
     {
       aDrawer->ShadingAspect()->SetMaterial (aChangeSet->Material);
     }
-    if (aChangeSet->ToSetShowFreeBoundary == 1)
-    {
-      aDrawer->SetFreeBoundaryDraw (Standard_True);
-    }
-    else if (aChangeSet->ToSetShowFreeBoundary == -1)
-    {
-      aDrawer->SetFreeBoundaryDraw (Standard_False);
-    }
-    if (aChangeSet->ToSetFreeBoundaryWidth != 0)
-    {
-      aDrawer->FreeBoundaryAspect()->SetWidth (aChangeSet->FreeBoundaryWidth);
-    }
-    if (aChangeSet->ToSetFreeBoundaryColor != 0)
-    {
-      aDrawer->FreeBoundaryAspect()->SetColor (aChangeSet->FreeBoundaryColor);
-    }
-    if (aChangeSet->ToEnableIsoOnTriangulation != -1)
+    if (aChangeSet->ToEnableIsoOnTriangulation != 0)
     {
       aDrawer->SetIsoOnTriangulation (aChangeSet->ToEnableIsoOnTriangulation == 1);
     }
-    if (aChangeSet->ToSetMaxParamValue != 0)
-    {
-      aDrawer->SetMaximalParameterValue (aChangeSet->MaxParamValue);
-    }
-    if (aChangeSet->ToSetShadingModel == 1)
-    {
-      aDrawer->ShadingAspect()->Aspect()->SetShadingModel (aChangeSet->ShadingModel);
-    }
 
     // redisplay all objects in context
     for (ViewTest_PrsIter aPrsIter (aNames); aPrsIter.More(); aPrsIter.Next())
@@ -2620,6 +3301,16 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
         aCtx->Redisplay (aPrs, Standard_False);
       }
     }
+    if (toDump)
+    {
+      Standard_SStream aStream;
+      aDrawer->DumpJson (aStream, aDumpDepth);
+
+      if (toCompactDump)
+        theDI << Standard_Dump::Text (aStream);
+      else
+        theDI << Standard_Dump::FormatJson (aStream);
+    }
     return 0;
   }
 
@@ -2641,7 +3332,7 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast (aPrs);
       if (aShapePrs.IsNull())
       {
-        std::cout << "Error: an object " << aName << " is not an AIS_Shape presentation!\n";
+        Message::SendFail() << "Error: an object " << aName << " is not an AIS_Shape presentation!";
         return 1;
       }
       aColoredPrs = Handle(AIS_ColoredShape)::DownCast (aShapePrs);
@@ -2703,7 +3394,7 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       {
         aCtx->UnsetWidth (aPrs, Standard_False);
       }
-      else if (aChangeSet->ToEnableIsoOnTriangulation != -1)
+      else if (aChangeSet->ToEnableIsoOnTriangulation != 0)
       {
         aCtx->IsoOnTriangulation (aChangeSet->ToEnableIsoOnTriangulation == 1, aPrs);
         toRedisplay = Standard_True;
@@ -2714,117 +3405,7 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       }
       if (!aDrawer.IsNull())
       {
-        if (aChangeSet->ToSetShowFreeBoundary == 1)
-        {
-          aDrawer->SetFreeBoundaryDraw (Standard_True);
-          toRedisplay = Standard_True;
-        }
-        else if (aChangeSet->ToSetShowFreeBoundary == -1)
-        {
-          aDrawer->SetFreeBoundaryDraw (Standard_False);
-          toRedisplay = Standard_True;
-        }
-        if (aChangeSet->ToSetFreeBoundaryWidth != 0)
-        {
-          Handle(Prs3d_LineAspect) aBoundaryAspect =
-              new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0);
-          *aBoundaryAspect->Aspect() = *aDrawer->FreeBoundaryAspect()->Aspect();
-          aBoundaryAspect->SetWidth (aChangeSet->FreeBoundaryWidth);
-          aDrawer->SetFreeBoundaryAspect (aBoundaryAspect);
-          toRedisplay = Standard_True;
-        }
-        if (aChangeSet->ToSetFreeBoundaryColor != 0)
-        {
-          Handle(Prs3d_LineAspect) aBoundaryAspect =
-              new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0);
-          *aBoundaryAspect->Aspect() = *aDrawer->FreeBoundaryAspect()->Aspect();
-          aBoundaryAspect->SetColor (aChangeSet->FreeBoundaryColor);
-          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->ToSetTypeOfMarker != 0)
-        {
-          Handle(Prs3d_PointAspect) aMarkerAspect = new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_YELLOW, 1.0);
-          *aMarkerAspect->Aspect() = *aDrawer->PointAspect()->Aspect();
-          aMarkerAspect->SetTypeOfMarker (aChangeSet->TypeOfMarker);
-          aMarkerAspect->Aspect()->SetMarkerImage (aChangeSet->MarkerImage.IsNull()
-                                                 ? Handle(Graphic3d_MarkerImage)()
-                                                 : new Graphic3d_MarkerImage (aChangeSet->MarkerImage));
-          aDrawer->SetPointAspect (aMarkerAspect);
-          toRedisplay = Standard_True;
-        }
-        if (aChangeSet->ToSetMarkerSize != 0)
-        {
-          Handle(Prs3d_PointAspect) aMarkerAspect = new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_YELLOW, 1.0);
-          *aMarkerAspect->Aspect() = *aDrawer->PointAspect()->Aspect();
-          aMarkerAspect->SetScale (aChangeSet->MarkerSize);
-          aDrawer->SetPointAspect (aMarkerAspect);
-          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;
-        }
-        if (aChangeSet->ToSetShadingModel != 0)
-        {
-          aDrawer->SetShadingModel ((aChangeSet->ToSetShadingModel == -1) ? Graphic3d_TOSM_DEFAULT : aChangeSet->ShadingModel, aChangeSet->ToSetShadingModel != -1);
-          toRedisplay = Standard_True;
-        }
-        if (aChangeSet->ToSetAlphaMode != 0)
-        {
-          if (!aDrawer->HasOwnShadingAspect())
-          {
-            aDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
-            *aDrawer->ShadingAspect()->Aspect() = *aCtx->DefaultDrawer()->ShadingAspect()->Aspect();
-          }
-          aDrawer->ShadingAspect()->Aspect()->SetAlphaMode (aChangeSet->AlphaMode, aChangeSet->AlphaCutoff);
-          toRedisplay = Standard_True;
-        }
+        toRedisplay = aChangeSet->Apply (aDrawer) || toRedisplay;
       }
 
       for (aChangesIter.Next(); aChangesIter.More(); aChangesIter.Next())
@@ -2834,6 +3415,11 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
              aSubShapeIter.More(); aSubShapeIter.Next())
         {
           const TopoDS_Shape& aSubShape = aSubShapeIter.Value();
+          if (!aChangeSet->IsEmpty())
+          {
+            Handle(AIS_ColoredDrawer) aCurColDrawer = aColoredPrs->CustomAspects (aSubShape);
+            aChangeSet->Apply (aCurColDrawer);
+          }
           if (aChangeSet->ToSetVisibility == 1)
           {
             Handle(AIS_ColoredDrawer) aCurColDrawer = aColoredPrs->CustomAspects (aSubShape);
@@ -2843,6 +3429,10 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
           {
             aColoredPrs->SetCustomColor (aSubShape, aChangeSet->Color);
           }
+          if (aChangeSet->ToSetTransparency == 1)
+          {
+            aColoredPrs->SetCustomTransparency (aSubShape, aChangeSet->Transparency);
+          }
           if (aChangeSet->ToSetLineWidth == 1)
           {
             aColoredPrs->SetCustomWidth (aSubShape, aChangeSet->LineWidth);
@@ -2852,20 +3442,10 @@ 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 (aChangeSet->ToSetShadingModel != 0)
-          {
-            Handle(AIS_ColoredDrawer) aCurColDrawer = aColoredPrs->CustomAspects (aSubShape);
-            aCurColDrawer->SetShadingModel ((aChangeSet->ToSetShadingModel == -1) ? Graphic3d_TOSM_DEFAULT : aChangeSet->ShadingModel, aChangeSet->ToSetShadingModel != -1);
-          }
         }
       }
       if (toDisplay)
@@ -2880,6 +3460,20 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       {
         aCtx->Redisplay (aColoredPrs, Standard_False);
       }
+      else
+      {
+        aPrs->SynchronizeAspects();
+      }
+
+      if (toDump)
+      {
+        Standard_SStream aStream;
+        aDrawer->DumpJson (aStream);
+
+        theDI << aName << ": \n";
+        theDI << Standard_Dump::FormatJson (aStream);
+        theDI << "\n";
+      }
     }
   }
   return 0;
@@ -2899,7 +3493,7 @@ static int VDonly2 (Draw_Interpretor& ,
   ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
   if (aCtx.IsNull())
   {
-    std::cerr << "Error: no active view!\n";
+    Message::SendFail ("Error: no active view!");
     return 1;
   }
 
@@ -2932,14 +3526,12 @@ static int VDonly2 (Draw_Interpretor& ,
     for (; anArgIter < theArgNb; ++anArgIter)
     {
       TCollection_AsciiString aName = theArgVec[anArgIter];
-      if (GetMapOfAIS().IsBound2 (aName))
+      Handle(AIS_InteractiveObject) aShape;
+      if (GetMapOfAIS().Find2 (aName, aShape)
+      && !aShape.IsNull())
       {
-        const Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aName));
-        if (!aShape.IsNull())
-        {
-          aCtx->Display (aShape, Standard_False);
-          aDispSet.Add (aShape);
-        }
+        aCtx->Display (aShape, Standard_False);
+        aDispSet.Add (aShape);
       }
     }
   }
@@ -2952,8 +3544,7 @@ static int VDonly2 (Draw_Interpretor& ,
       continue;
     }
 
-    const Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
-    if (!aShape.IsNull())
+    if (Handle(AIS_InteractiveObject) aShape = anIter.Key1())
     {
       aCtx->Erase (aShape, Standard_False);
     }
@@ -2977,13 +3568,14 @@ int VRemove (Draw_Interpretor& theDI,
   ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
   if (aCtx.IsNull())
   {
-    std::cerr << "Error: no active view!\n";
+    Message::SendFail ("Error: no active view!");
     return 1;
   }
 
   Standard_Boolean isContextOnly = Standard_False;
   Standard_Boolean toRemoveAll   = Standard_False;
   Standard_Boolean toPrintInfo   = Standard_True;
+  Standard_Boolean toFailOnError = Standard_True;
 
   Standard_Integer anArgIter = 1;
   for (; anArgIter < theArgNb; ++anArgIter)
@@ -3002,6 +3594,11 @@ int VRemove (Draw_Interpretor& theDI,
     {
       toPrintInfo = Standard_False;
     }
+    else if (anArg == "-noerror"
+          || anArg == "-nofail")
+    {
+      toFailOnError = Standard_False;
+    }
     else if (anUpdateTool.parseRedrawMode (anArg))
     {
       continue;
@@ -3014,7 +3611,7 @@ int VRemove (Draw_Interpretor& theDI,
   if (toRemoveAll
    && anArgIter < theArgNb)
   {
-    std::cerr << "Error: wrong syntax!\n";
+    Message::SendFail ("Error: wrong syntax!");
     return 1;
   }
 
@@ -3031,23 +3628,48 @@ int VRemove (Draw_Interpretor& theDI,
   {
     for (; anArgIter < theArgNb; ++anArgIter)
     {
-      TCollection_AsciiString aName = theArgVec[anArgIter];
-      if (!GetMapOfAIS().IsBound2 (aName))
+      const TCollection_AsciiString aName (theArgVec[anArgIter]);
+      if (aName.Search ("*") != -1)
       {
-        theDI << aName.ToCString() << " was not bound to some object.\n";
+        for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName aPrsIter (GetMapOfAIS()); aPrsIter.More(); aPrsIter.Next())
+        {
+          if (aPrsIter.Key1()->GetContext() != aCtx)
+          {
+            continue;
+          }
+          const TCollection_AsciiString aCheck = TCollection_AsciiString ("string match '") + aName + "' '" + aPrsIter.Key2() + "'";
+          if (theDI.Eval (aCheck.ToCString()) == 0
+          && *theDI.Result() == '1')
+          {
+            anIONameList.Append (aPrsIter.Key2());
+          }
+        }
+        theDI.Reset();
         continue;
       }
 
-      const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aName));
-      if (anIO->GetContext() != aCtx)
+      Handle(AIS_InteractiveObject) anIO;
+      if (!GetMapOfAIS().Find2 (aName, anIO))
       {
-        theDI << aName.ToCString() << " was not displayed in current context.\n";
-        theDI << "Please activate view with this object displayed and try again.\n";
-        continue;
+        if (toFailOnError)
+        {
+          Message::SendFail() << "Syntax error: '" << aName << "' was not bound to some object.";
+          return 1;
+        }
+      }
+      else if (anIO->GetContext() != aCtx)
+      {
+        if (toFailOnError)
+        {
+          Message::SendFail() << "Syntax error: '" << aName << "' was not displayed in current context.\n"
+                              << "Please activate view with this object displayed and try again.";
+          return 1;
+        }
+      }
+      else
+      {
+        anIONameList.Append (aName);
       }
-
-      anIONameList.Append (aName);
-      continue;
     }
   }
   else if (aCtx->NbSelected() > 0)
@@ -3055,8 +3677,7 @@ int VRemove (Draw_Interpretor& theDI,
     for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
          anIter.More(); anIter.Next())
     {
-      const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
-      if (!aCtx->IsSelected (anIO))
+      if (!aCtx->IsSelected (anIter.Key1()))
       {
         continue;
       }
@@ -3070,11 +3691,11 @@ int VRemove (Draw_Interpretor& theDI,
   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()));
+    const Handle(AIS_InteractiveObject) anIO = GetMapOfAIS().Find2 (anIter.Value());
     aCtx->Remove (anIO, Standard_False);
     if (toPrintInfo)
     {
-      theDI << anIter.Value().ToCString() << " was removed\n";
+      theDI << anIter.Value() << " ";
     }
     if (!isContextOnly)
     {
@@ -3098,7 +3719,7 @@ int VErase (Draw_Interpretor& theDI,
   ViewerTest_AutoUpdater anUpdateTool (aCtx, aView);
   if (aCtx.IsNull())
   {
-    std::cerr << "Error: no active view!\n";
+    Message::SendFail ("Error: no active view!");
     return 1;
   }
 
@@ -3106,6 +3727,7 @@ int VErase (Draw_Interpretor& theDI,
 
   Standard_Integer anArgIter = 1;
   Standard_Boolean toEraseInView = Standard_False;
+  Standard_Boolean toFailOnError = Standard_True;
   TColStd_SequenceOfAsciiString aNamesOfEraseIO;
   for (; anArgIter < theArgNb; ++anArgIter)
   {
@@ -3120,6 +3742,11 @@ int VErase (Draw_Interpretor& theDI,
     {
       toEraseInView = Standard_True;
     }
+    else if (anArgCase == "-noerror"
+          || anArgCase == "-nofail")
+    {
+      toFailOnError = Standard_False;
+    }
     else
     {
       aNamesOfEraseIO.Append (theArgVec[anArgIter]);
@@ -3128,36 +3755,60 @@ int VErase (Draw_Interpretor& theDI,
 
   if (!aNamesOfEraseIO.IsEmpty() && toEraseAll)
   {
-    std::cerr << "Error: wrong syntax, " << theArgVec[0] << " too much arguments.\n";
+    Message::SendFail() << "Error: wrong syntax, " << theArgVec[0] << " too much arguments.";
     return 1;
   }
 
   if (!aNamesOfEraseIO.IsEmpty())
   {
     // Erase named objects
-    for (Standard_Integer anIter = 1; anIter <= aNamesOfEraseIO.Length(); ++anIter)
+    NCollection_IndexedDataMap<Handle(AIS_InteractiveObject), TCollection_AsciiString> aPrsList;
+    for (TColStd_SequenceOfAsciiString::Iterator anIter (aNamesOfEraseIO); anIter.More(); anIter.Next())
     {
-      TCollection_AsciiString aName = aNamesOfEraseIO.Value (anIter);
-      if (!GetMapOfAIS().IsBound2 (aName))
+      const TCollection_AsciiString& aName = anIter.Value();
+      if (aName.Search ("*") != -1)
       {
-        continue;
+        for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName aPrsIter (GetMapOfAIS()); aPrsIter.More(); aPrsIter.Next())
+        {
+          const TCollection_AsciiString aCheck = TCollection_AsciiString ("string match '") + aName + "' '" + aPrsIter.Key2() + "'";
+          if (theDI.Eval (aCheck.ToCString()) == 0
+          && *theDI.Result() == '1')
+          {
+            aPrsList.Add (aPrsIter.Key1(), aPrsIter.Key2());
+          }
+        }
+        theDI.Reset();
       }
-
-      const Handle(Standard_Transient)    anObj = GetMapOfAIS().Find2 (aName);
-      const Handle(AIS_InteractiveObject) anIO  = Handle(AIS_InteractiveObject)::DownCast (anObj);
-      theDI << aName.ToCString() << " ";
-      if (!anIO.IsNull())
+      else
       {
-        if (toEraseInView)
+        Handle(AIS_InteractiveObject) anIO;
+        if (!GetMapOfAIS().Find2 (aName, anIO))
         {
-          aCtx->SetViewAffinity (anIO, aView, Standard_False);
+          if (toFailOnError)
+          {
+            Message::SendFail() << "Syntax error: '" << aName << "' is not found";
+            return 1;
+          }
         }
         else
         {
-          aCtx->Erase (anIO, Standard_False);
+          aPrsList.Add (anIO, aName);
         }
       }
     }
+
+    for (NCollection_IndexedDataMap<Handle(AIS_InteractiveObject), TCollection_AsciiString>::Iterator anIter (aPrsList); anIter.More(); anIter.Next())
+    {
+      theDI << anIter.Value() << " ";
+      if (toEraseInView)
+      {
+        aCtx->SetViewAffinity (anIter.Key(), aView, Standard_False);
+      }
+      else
+      {
+        aCtx->Erase (anIter.Key(), Standard_False);
+      }
+    }
   }
   else if (!toEraseAll && aCtx->NbSelected() > 0)
   {
@@ -3165,11 +3816,11 @@ int VErase (Draw_Interpretor& theDI,
     for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
          anIter.More(); anIter.Next())
     {
-      const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
+      const Handle(AIS_InteractiveObject) anIO = anIter.Key1();
       if (!anIO.IsNull()
        && aCtx->IsSelected (anIO))
       {
-        theDI << anIter.Key2().ToCString() << " ";
+        theDI << anIter.Key2() << " ";
         if (toEraseInView)
         {
           aCtx->SetViewAffinity (anIO, aView, Standard_False);
@@ -3188,7 +3839,7 @@ int VErase (Draw_Interpretor& theDI,
     for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
          anIter.More(); anIter.Next())
     {
-      const Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
+      Handle(AIS_InteractiveObject) anIO = anIter.Key1();
       if (!anIO.IsNull())
       {
         if (toEraseInView)
@@ -3219,7 +3870,7 @@ static int VDisplayAll (Draw_Interpretor& ,
   ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
   if (aCtx.IsNull())
   {
-    std::cerr << "Error: no active view!\n";
+    Message::SendFail ("Error: no active view!");
     return 1;
   }
 
@@ -3239,22 +3890,20 @@ static int VDisplayAll (Draw_Interpretor& ,
   }
   if (anArgIter < theArgNb)
   {
-    std::cout << theArgVec[0] << "Error: wrong syntax\n";
+    Message::SendFail() << theArgVec[0] << "Error: wrong syntax";
     return 1;
   }
 
   for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
        anIter.More(); anIter.Next())
   {
-    const Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
-    aCtx->Erase (aShape, Standard_False);
+    aCtx->Erase (anIter.Key1(), Standard_False);
   }
 
   for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
        anIter.More(); anIter.Next())
   {
-    const Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
-    aCtx->Display (aShape, Standard_False);
+    aCtx->Display (anIter.Key1(), Standard_False);
   }
   return 0;
 }
@@ -3321,10 +3970,10 @@ inline void bndPresentation (Draw_Interpretor&                         theDI,
       Bnd_Box aBox;
       for (PrsMgr_Presentations::Iterator aPrsIter (theObj->Presentations()); aPrsIter.More(); aPrsIter.Next())
       {
-        if (aPrsIter.Value().Mode() != theDispMode)
+        if (aPrsIter.Value()->Mode() != theDispMode)
           continue;
 
-        aBox = aPrsIter.Value().Presentation()->Presentation()->MinMaxValues();
+        aBox = aPrsIter.Value()->MinMaxValues();
       }
       gp_Pnt aMin = aBox.CornerMin();
       gp_Pnt aMax = aBox.CornerMax();
@@ -3348,7 +3997,7 @@ int VBounding (Draw_Interpretor& theDI,
   ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
   if (aCtx.IsNull())
   {
-    std::cout << "Error: no active view!\n";
+    Message::SendFail ("Error: no active view!");
     return 1;
   }
 
@@ -3378,7 +4027,7 @@ int VBounding (Draw_Interpretor& theDI,
     {
       if (++anArgIter >= theArgNb)
       {
-        std::cout << "Error: wrong syntax at " << anArg << "\n";
+        Message::SendFail() << "Error: wrong syntax at " << anArg;
         return 1;
       }
       aMode = Draw::Atoi (theArgVec[anArgIter]);
@@ -3403,17 +4052,17 @@ int VBounding (Draw_Interpretor& theDI,
     for (; anArgIter < theArgNb; ++anArgIter)
     {
       TCollection_AsciiString aName = theArgVec[anArgIter];
-      if (!GetMapOfAIS().IsBound2 (aName))
+      Handle(AIS_InteractiveObject) anIO;
+      if (!GetMapOfAIS().Find2 (aName, anIO))
       {
-        std::cout << "Error: presentation " << aName << " does not exist\n";
+        Message::SendFail() << "Error: presentation " << aName << " does not exist";
         return 1;
       }
 
-      Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aName));
       aHighlightedMode = checkMode (aCtx, anIO, aMode);
       if (aHighlightedMode == -1)
       {
-        std::cout << "Error: object " << aName << " has no presentation with mode " << aMode << std::endl;
+        Message::SendFail() << "Error: object " << aName << " has no presentation with mode " << aMode;
         return 1;
       }
       bndPresentation (theDI, aCtx->MainPrsMgr(), anIO, aHighlightedMode, aName, anAction, aStyle);
@@ -3439,7 +4088,7 @@ int VBounding (Draw_Interpretor& theDI,
     for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
          anIter.More(); anIter.Next())
     {
-      Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
+      Handle(AIS_InteractiveObject) anIO = anIter.Key1();
       aHighlightedMode = checkMode (aCtx, anIO, aMode);
       if (aHighlightedMode != -1)
       {
@@ -3459,7 +4108,7 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
   const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
   if (aCtx.IsNull())
   {
-    std::cout << "Error: no active view!\n";
+    Message::SendFail() << "Error: no active view!";
     return 1;
   }
 
@@ -3475,7 +4124,8 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
   Graphic3d_TypeOfTextureFilter      aFilter       = Graphic3d_TOTF_NEAREST;
   Graphic3d_LevelOfTextureAnisotropy anAnisoFilter = Graphic3d_LOTA_OFF;
 
-  Handle(AIS_Shape) aTexturedIO;
+  Handle(AIS_InteractiveObject) aTexturedIO;
+  Handle(AIS_Shape) aTexturedShape;
   Handle(Graphic3d_TextureSet) aTextureSetOld;
   NCollection_Vector<Handle(Graphic3d_Texture2Dmanual)> aTextureVecNew;
   bool toSetGenRepeat = false;
@@ -3502,11 +4152,12 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
       const ViewerTest_DoubleMapOfInteractiveAndName& aMapOfIO = GetMapOfAIS();
       if (aMapOfIO.IsBound2 (aName))
       {
-        aTexturedIO = Handle(AIS_Shape)::DownCast (aMapOfIO.Find2 (aName));
+        aTexturedIO = aMapOfIO.Find2 (aName);
+        aTexturedShape = Handle(AIS_Shape)::DownCast (aTexturedIO);
       }
       if (aTexturedIO.IsNull())
       {
-        std::cout << "Syntax error: shape " << aName << " does not exists in the viewer.\n";
+        Message::SendFail() << "Syntax error: shape " << aName << " does not exists in the viewer.";
         return 1;
       }
 
@@ -3515,9 +4166,10 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
         aTextureSetOld = aTexturedIO->Attributes()->ShadingAspect()->Aspect()->TextureSet();
       }
     }
-    else if (aNameCase == "-scale"
-          || aNameCase == "-setscale"
-          || aCommandName == "vtexscale")
+    else if (!aTexturedShape.IsNull()
+          && (aNameCase == "-scale"
+           || aNameCase == "-setscale"
+           || aCommandName == "vtexscale"))
     {
       if (aCommandName != "vtexscale")
       {
@@ -3531,7 +4183,7 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
         toSetGenScale = true;
         if (aValUCase == "off")
         {
-          aTexturedIO->SetTextureScaleUV (gp_Pnt2d (1.0, 1.0));
+          aTexturedShape->SetTextureScaleUV (gp_Pnt2d (1.0, 1.0));
           continue;
         }
         else if (anArgIter + 1 < theArgsNb)
@@ -3540,18 +4192,19 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
           if (aValU.IsRealValue()
            && aValV.IsRealValue())
           {
-            aTexturedIO->SetTextureScaleUV (gp_Pnt2d (aValU.RealValue(), aValV.RealValue()));
+            aTexturedShape->SetTextureScaleUV (gp_Pnt2d (aValU.RealValue(), aValV.RealValue()));
             ++anArgIter;
             continue;
           }
         }
       }
-      std::cout << "Syntax error: unexpected argument '" << aName << "'\n";
+      Message::SendFail() << "Syntax error: unexpected argument '" << aName << "'";
       return 1;
     }
-    else if (aNameCase == "-origin"
-          || aNameCase == "-setorigin"
-          || aCommandName == "vtexorigin")
+    else if (!aTexturedShape.IsNull()
+          && (aNameCase == "-origin"
+           || aNameCase == "-setorigin"
+           || aCommandName == "vtexorigin"))
     {
       if (aCommandName != "vtexorigin")
       {
@@ -3565,7 +4218,7 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
         toSetGenOrigin = true;
         if (aValUCase == "off")
         {
-          aTexturedIO->SetTextureOriginUV (gp_Pnt2d (0.0, 0.0));
+          aTexturedShape->SetTextureOriginUV (gp_Pnt2d (0.0, 0.0));
           continue;
         }
         else if (anArgIter + 1 < theArgsNb)
@@ -3574,18 +4227,19 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
           if (aValU.IsRealValue()
            && aValV.IsRealValue())
           {
-            aTexturedIO->SetTextureOriginUV (gp_Pnt2d (aValU.RealValue(), aValV.RealValue()));
+            aTexturedShape->SetTextureOriginUV (gp_Pnt2d (aValU.RealValue(), aValV.RealValue()));
             ++anArgIter;
             continue;
           }
         }
       }
-      std::cout << "Syntax error: unexpected argument '" << aName << "'\n";
+      Message::SendFail() << "Syntax error: unexpected argument '" << aName << "'";
       return 1;
     }
-    else if (aNameCase == "-repeat"
-          || aNameCase == "-setrepeat"
-          || aCommandName == "vtexrepeat")
+    else if (!aTexturedShape.IsNull()
+          && (aNameCase == "-repeat"
+           || aNameCase == "-setrepeat"
+           || aCommandName == "vtexrepeat"))
     {
       if (aCommandName != "vtexrepeat")
       {
@@ -3599,7 +4253,7 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
         toSetGenRepeat = true;
         if (aValUCase == "off")
         {
-          aTexturedIO->SetTextureRepeatUV (gp_Pnt2d (1.0, 1.0));
+          aTexturedShape->SetTextureRepeatUV (gp_Pnt2d (1.0, 1.0));
           continue;
         }
         else if (anArgIter + 1 < theArgsNb)
@@ -3608,20 +4262,20 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
           if (aValU.IsRealValue()
            && aValV.IsRealValue())
           {
-            aTexturedIO->SetTextureRepeatUV (gp_Pnt2d (aValU.RealValue(), aValV.RealValue()));
+            aTexturedShape->SetTextureRepeatUV (gp_Pnt2d (aValU.RealValue(), aValV.RealValue()));
             ++anArgIter;
             continue;
           }
         }
       }
-      std::cout << "Syntax error: unexpected argument '" << aName << "'\n";
+      Message::SendFail() << "Syntax error: unexpected argument '" << aName << "'";
       return 1;
     }
     else if (aNameCase == "-modulate")
     {
       bool toModulateBool = true;
       if (anArgIter + 1 < theArgsNb
-       && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toModulateBool))
+       && Draw::ParseOnOff (theArgVec[anArgIter + 1], toModulateBool))
       {
         ++anArgIter;
       }
@@ -3649,7 +4303,7 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
       }
       else
       {
-        std::cout << "Syntax error: unexpected argument '" << aValue << "'\n";
+        Message::SendFail() << "Syntax error: unexpected argument '" << aValue << "'";
         return 1;
       }
     }
@@ -3682,7 +4336,7 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
       }
       else
       {
-        std::cout << "Syntax error: unexpected argument '" << aValue << "'\n";
+        Message::SendFail() << "Syntax error: unexpected argument '" << aValue << "'";
         return 1;
       }
     }
@@ -3721,6 +4375,38 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
     {
       toSetDefaults = true;
     }
+    else if ((aNameCase == "-video")
+           && anArgIter + 1 < theArgsNb)
+    {
+      const TCollection_AsciiString anInput (theArgVec[++anArgIter]);
+      Handle(Graphic3d_MediaTextureSet) aMedia = Handle(Graphic3d_MediaTextureSet)::DownCast (aTextureSetOld);
+      if (aMedia.IsNull())
+      {
+        aMedia = new Graphic3d_MediaTextureSet();
+      }
+      if (aMedia->Input() != anInput)
+      {
+        aMedia->OpenInput (anInput, false);
+      }
+      else
+      {
+        if (aMedia->SwapFrames()
+        && !aCtx->CurrentViewer()->ZLayerSettings (aTexturedIO->ZLayer()).IsImmediate())
+        {
+          ViewerTest::CurrentView()->Invalidate();
+        }
+      }
+      if (aTexturedIO->Attributes()->SetupOwnShadingAspect (aCtx->DefaultDrawer())
+       && aTexturedShape.IsNull())
+      {
+        aTexturedIO->SetToUpdate();
+      }
+
+      toComputeUV = aTextureSetOld.IsNull();
+      aTexturedIO->Attributes()->ShadingAspect()->Aspect()->SetTextureMapOn (true);
+      aTexturedIO->Attributes()->ShadingAspect()->Aspect()->SetTextureSet (aMedia);
+      aTextureSetOld.Nullify();
+    }
     else if (aCommandName == "vtexture"
           && (aTextureVecNew.IsEmpty()
            || aNameCase.StartsWith ("-tex")))
@@ -3732,14 +4418,14 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
         if (anArgIter + 1 >= theArgsNb
          || aNameCase.Length() < 5)
         {
-          std::cout << "Syntax error: invalid argument '" << theArgVec[anArgIter] << "'\n";
+          Message::SendFail() << "Syntax error: invalid argument '" << theArgVec[anArgIter] << "'";
           return 1;
         }
 
         TCollection_AsciiString aTexIndexStr = aNameCase.SubString (5, aNameCase.Length());
         if (!aTexIndexStr.IsIntegerValue())
         {
-          std::cout << "Syntax error: invalid argument '" << theArgVec[anArgIter] << "'\n";
+          Message::SendFail() << "Syntax error: invalid argument '" << theArgVec[anArgIter] << "'";
           return 1;
         }
 
@@ -3750,7 +4436,7 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
       if (aTexIndex >= Graphic3d_TextureUnit_NB
        || aTexIndex >= aCtx->CurrentViewer()->Driver()->InquireLimit (Graphic3d_TypeOfLimit_MaxCombinedTextureUnits))
       {
-        std::cout << "Error: too many textures specified\n";
+        Message::SendFail ("Error: too many textures specified");
         return 1;
       }
 
@@ -3760,7 +4446,7 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
         const Standard_Integer aValue = aTexName.IntegerValue();
         if (aValue < 0 || aValue >= Graphic3d_Texture2D::NumberOfTextures())
         {
-          std::cout << "Syntax error: texture with ID " << aValue << " is undefined!\n";
+          Message::SendFail() << "Syntax error: texture with ID " << aValue << " is undefined!";
           return 1;
         }
         aTextureVecNew.SetValue (aTexIndex, new Graphic3d_Texture2Dmanual (Graphic3d_NameOfTexture2D (aValue)));
@@ -3784,7 +4470,7 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
       {
         if (!OSD_File (aTexName).Exists())
         {
-          std::cout << "Syntax error: non-existing image file has been specified '" << aTexName << "'.\n";
+          Message::SendFail() << "Syntax error: non-existing image file has been specified '" << aTexName << "'.";
           return 1;
         }
         aTextureVecNew.SetValue (aTexIndex, new Graphic3d_Texture2Dmanual (aTexName));
@@ -3801,7 +4487,7 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
     }
     else
     {
-      std::cout << "Syntax error: invalid argument '" << theArgVec[anArgIter] << "'\n";
+      Message::SendFail() << "Syntax error: invalid argument '" << theArgVec[anArgIter] << "'";
       return 1;
     }
   }
@@ -3853,10 +4539,10 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
       aTextureSetNew = aTextureSetOld;
     }
 
-    if (!aTexturedIO->Attributes()->HasOwnShadingAspect())
+    if (aTexturedIO->Attributes()->SetupOwnShadingAspect (aCtx->DefaultDrawer())
+     && aTexturedShape.IsNull())
     {
-      aTexturedIO->Attributes()->SetShadingAspect (new Prs3d_ShadingAspect());
-      *aTexturedIO->Attributes()->ShadingAspect()->Aspect() = *aCtx->DefaultDrawer()->ShadingAspect()->Aspect();
+      aTexturedIO->SetToUpdate();
     }
 
     toComputeUV = !aTextureSetNew.IsNull() && aTextureSetOld.IsNull();
@@ -3944,33 +4630,45 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
    && (aCommandName == "vtexrepeat"
     || toSetDefaults))
   {
-    aTexturedIO->SetTextureRepeatUV (gp_Pnt2d (1.0, 1.0));
+    if (!aTexturedShape.IsNull())
+    {
+      aTexturedShape->SetTextureRepeatUV (gp_Pnt2d (1.0, 1.0));
+    }
     toSetGenRepeat = true;
   }
   if (!toSetGenOrigin
    && (aCommandName == "vtexorigin"
     || toSetDefaults))
   {
-    aTexturedIO->SetTextureOriginUV (gp_Pnt2d (0.0, 0.0));
+    if (!aTexturedShape.IsNull())
+    {
+      aTexturedShape->SetTextureOriginUV (gp_Pnt2d (0.0, 0.0));
+    }
     toSetGenOrigin = true;
   }
   if (!toSetGenScale
    && (aCommandName == "vtexscale"
     || toSetDefaults))
   {
-    aTexturedIO->SetTextureScaleUV  (gp_Pnt2d (1.0, 1.0));
+    if (!aTexturedShape.IsNull())
+    {
+      aTexturedShape->SetTextureScaleUV  (gp_Pnt2d (1.0, 1.0));
+    }
     toSetGenScale = true;
   }
 
   if (toSetGenRepeat || toSetGenOrigin || toSetGenScale || toComputeUV)
   {
-    aTexturedIO->SetToUpdate (AIS_Shaded);
-    if (toSetImage)
+    if (!aTexturedShape.IsNull())
     {
-      if ((aTexturedIO->HasDisplayMode() && aTexturedIO->DisplayMode() != AIS_Shaded)
-       || aCtx->DisplayMode() != AIS_Shaded)
+      aTexturedShape->SetToUpdate (AIS_Shaded);
+      if (toSetImage)
       {
-        aCtx->SetDisplayMode (aTexturedIO, AIS_Shaded, false);
+        if ((aTexturedIO->HasDisplayMode() && aTexturedIO->DisplayMode() != AIS_Shaded)
+         || aCtx->DisplayMode() != AIS_Shaded)
+        {
+          aCtx->SetDisplayMode (aTexturedIO, AIS_Shaded, false);
+        }
       }
     }
   }
@@ -4083,9 +4781,15 @@ static int VDisplay2 (Draw_Interpretor& theDI,
 {
   if (theArgNb < 2)
   {
-    std::cerr << theArgVec[0] << "Error: wrong number of arguments.\n";
+    Message::SendFail ("Syntax error: wrong number of arguments.");
     return 1;
   }
+  if (theArgNb == 2
+   && TCollection_AsciiString (theArgVec[1]) == "*")
+  {
+    // alias
+    return VDisplayAll (theDI, 1, theArgVec);
+  }
 
   Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
   if (aCtx.IsNull())
@@ -4159,18 +4863,19 @@ static int VDisplay2 (Draw_Interpretor& theDI,
     {
       if (++anArgIter >= theArgNb)
       {
-        std::cerr << "Error: wrong syntax at " << aName << ".\n";
+        Message::SendFail() << "Error: wrong syntax at " << aName << ".";
         return 1;
       }
 
       anObjDispMode = Draw::Atoi (theArgVec [anArgIter]);
     }
-    else if (aNameCase == "-highmode"
+    else if (aNameCase == "-himode"
+          || aNameCase == "-highmode"
           || aNameCase == "-highlightmode")
     {
       if (++anArgIter >= theArgNb)
       {
-        std::cerr << "Error: wrong syntax at " << aName << ".\n";
+        Message::SendFail() << "Error: wrong syntax at " << aName << ".";
         return 1;
       }
 
@@ -4216,7 +4921,7 @@ static int VDisplay2 (Draw_Interpretor& theDI,
       if (++anArgIter >= theArgNb
        || !aTrsfPers.IsNull())
       {
-        std::cerr << "Error: wrong syntax at " << aName << ".\n";
+        Message::SendFail() << "Error: wrong syntax at " << aName << ".";
         return 1;
       }
 
@@ -4226,7 +4931,7 @@ static int VDisplay2 (Draw_Interpretor& theDI,
       aPersFlags.LowerCase();
       if (!parseTrsfPersFlag (aPersFlags, aTrsfPersFlags))
       {
-        std::cerr << "Error: wrong transform persistence flags " << theArgVec [anArgIter] << ".\n";
+        Message::SendFail() << "Error: wrong transform persistence flags " << theArgVec [anArgIter] << ".";
         return 1;
       }
 
@@ -4245,7 +4950,7 @@ static int VDisplay2 (Draw_Interpretor& theDI,
       if (anArgIter + 2 >= theArgNb
        || aTrsfPers.IsNull())
       {
-        std::cerr << "Error: wrong syntax at " << aName << ".\n";
+        Message::SendFail() << "Error: wrong syntax at " << aName << ".";
         return 1;
       }
 
@@ -4255,7 +4960,7 @@ static int VDisplay2 (Draw_Interpretor& theDI,
       if (!aX.IsRealValue()
        || !aY.IsRealValue())
       {
-        std::cerr << "Error: wrong syntax at " << aName << ".\n";
+        Message::SendFail() << "Error: wrong syntax at " << aName << ".";
         return 1;
       }
       if (anArgIter + 1 < theArgNb)
@@ -4278,22 +4983,17 @@ static int VDisplay2 (Draw_Interpretor& theDI,
         aTrsfPers = Graphic3d_TransformPers::FromDeprecatedParams (aTrsfPers->Mode(), aPnt);
       }
     }
-    else if (aNameCase == "-layer")
+    else if (aNameCase == "-layer"
+          || aNameCase == "-zlayer")
     {
-      if (++anArgIter >= theArgNb)
-      {
-        std::cerr << "Error: wrong syntax at " << aName << ".\n";
-        return 1;
-      }
-
-      TCollection_AsciiString aValue (theArgVec[anArgIter]);
-      if (!aValue.IsIntegerValue())
+      ++anArgIter;
+      if (anArgIter >= theArgNb
+      || !ViewerTest::ParseZLayer (theArgVec[anArgIter], aZLayer)
+      ||  aZLayer == Graphic3d_ZLayerId_UNKNOWN)
       {
-        std::cerr << "Error: wrong syntax at " << aName << ".\n";
+        Message::SendFail() << "Error: wrong syntax at " << aName << ".";
         return 1;
       }
-
-      aZLayer = aValue.IntegerValue();
     }
     else if (aNameCase == "-view"
           || aNameCase == "-inview")
@@ -4317,21 +5017,22 @@ static int VDisplay2 (Draw_Interpretor& theDI,
 
   if (aNamesOfDisplayIO.IsEmpty())
   {
-    std::cerr << theArgVec[0] << "Error: wrong number of arguments.\n";
+    Message::SendFail ("Syntax error: wrong number of arguments.");
     return 1;
   }
 
   // Display interactive objects
   for (Standard_Integer anIter = 1; anIter <= aNamesOfDisplayIO.Length(); ++anIter)
   {
-    const TCollection_AsciiString& aName = aNamesOfDisplayIO.Value(anIter);
-
-    if (!GetMapOfAIS().IsBound2 (aName))
+    const TCollection_AsciiString& aName = aNamesOfDisplayIO.Value (anIter);
+    Handle(AIS_InteractiveObject) aShape;
+    if (!GetMapOfAIS().Find2 (aName, aShape))
     {
       // create the AIS_Shape from a name
-      const Handle(AIS_InteractiveObject) aShape = GetAISShapeFromName (aName.ToCString());
-      if (!aShape.IsNull())
+      TopoDS_Shape aDrawShape = DBRep::GetExisting (aName);
+      if (!aDrawShape.IsNull())
       {
+        aShape = new AIS_Shape (aDrawShape);
         if (isMutable != -1)
         {
           aShape->SetMutable (isMutable == 1);
@@ -4346,10 +5047,28 @@ static int VDisplay2 (Draw_Interpretor& theDI,
         }
         if (anObjDispMode != -2)
         {
-          aShape->SetDisplayMode (anObjDispMode);
+          if (anObjDispMode == -1)
+          {
+            aShape->UnsetDisplayMode();
+          }
+          if (!aShape->AcceptDisplayMode (anObjDispMode))
+          {
+            Message::SendFail() << "Syntax error: " << aShape->DynamicType()->Name() << " rejects " << anObjDispMode << " display mode";
+            return 1;
+          }
+          else
+          {
+            aShape->SetDisplayMode (anObjDispMode);
+          }
         }
         if (anObjHighMode != -2)
         {
+          if (anObjHighMode != -1
+          && !aShape->AcceptDisplayMode (anObjHighMode))
+          {
+            Message::SendFail() << "Syntax error: " << aShape->DynamicType()->Name() << " rejects " << anObjHighMode << " display mode";
+            return 1;
+          }
           aShape->SetHilightMode (anObjHighMode);
         }
 
@@ -4377,12 +5096,11 @@ static int VDisplay2 (Draw_Interpretor& theDI,
       }
       else
       {
-        std::cerr << "Error: object with name '" << aName << "' does not exist!\n";
+        Message::SendFail() << "Error: object with name '" << aName << "' does not exist!";
       }
       continue;
     }
 
-    Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aName));
     if (isMutable != -1)
     {
       aShape->SetMutable (isMutable == 1);
@@ -4420,10 +5138,10 @@ static int VDisplay2 (Draw_Interpretor& theDI,
     }
     else
     {
-      theDI << "Display " << aName.ToCString() << "\n";
+      theDI << "Display " << aName << "\n";
 
       // update the Shape in the AIS_Shape
-      TopoDS_Shape      aNewShape = GetShapeFromName (aName.ToCString());
+      TopoDS_Shape      aNewShape = DBRep::GetExisting (aName);
       Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(aShape);
       if (!aShapePrs.IsNull())
       {
@@ -4470,7 +5188,7 @@ static Standard_Integer VNbDisplayed (Draw_Interpretor& theDi,
   Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
   if (aContextAIS.IsNull())
   {
-    std::cout << theArgVec[0] << "AIS context is not available.\n";
+    Message::SendFail ("Syntax error: AIS context is not available.");
     return 1;
   }
 
@@ -4497,33 +5215,26 @@ static int VUpdate (Draw_Interpretor& /*theDi*/, Standard_Integer theArgsNb, con
   Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
   if (aContextAIS.IsNull())
   {
-    std::cout << theArgVec[0] << "AIS context is not available.\n";
+    Message::SendFail ("Syntax error: AIS context is not available.");
     return 1;
   }
 
   if (theArgsNb < 2)
   {
-    std::cout << theArgVec[0] << ": insufficient arguments. Type help for more information.\n";
+    Message::SendFail ("Syntax error: insufficient arguments. Type help for more information.");
     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))
-    {
-      anAISObj = Handle(AIS_InteractiveObject)::DownCast (anAISMap.Find2 (aName));
-    }
-
+    GetMapOfAIS().Find2 (aName, anAISObj);
     if (anAISObj.IsNull())
     {
-      std::cout << theArgVec[0] << ": no AIS interactive object named \"" << aName << "\".\n";
+      Message::SendFail() << theArgVec[0] << ": no AIS interactive object named \"" << aName << "\".";
       return 1;
     }
 
@@ -4560,10 +5271,15 @@ static int VShading(Draw_Interpretor& ,Standard_Integer argc, const char** argv)
   }
 
   TCollection_AsciiString name=argv[1];
-  if (GetMapOfAIS().IsBound2(name ))
-    TheAisIO = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
+  GetMapOfAIS().Find2(name, TheAisIO);
   if (TheAisIO.IsNull())
-    TheAisIO=GetAISShapeFromName((const char *)name.ToCString());
+  {
+    TopoDS_Shape aDrawShape = DBRep::GetExisting (name);
+    if (!aDrawShape.IsNull())
+    {
+      TheAisIO = new AIS_Shape (aDrawShape);
+    }
+  }
 
   if (HaveToSet)
     TheAISContext()->SetDeviationCoefficient(TheAisIO,myDevCoef,Standard_True);
@@ -4576,50 +5292,49 @@ static int VShading(Draw_Interpretor& ,Standard_Integer argc, const char** argv)
 
 //! Auxiliary method to print Interactive Object information
 static void objInfo (const NCollection_Map<Handle(AIS_InteractiveObject)>& theDetected,
-                     const Handle(Standard_Transient)&                     theObject,
+                     const Handle(AIS_InteractiveObject)&                  theObj,
                      Draw_Interpretor&                                     theDI)
 {
-  const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theObject);
-  if (anObj.IsNull())
+  if (theObj.IsNull())
   {
-    theDI << theObject->DynamicType()->Name() << " is not AIS presentation\n";
+    theDI << "NULL presentation\n";
     return;
   }
 
-  theDI << (TheAISContext()->IsDisplayed  (anObj) ? "Displayed"  : "Hidden   ")
-        << (TheAISContext()->IsSelected   (anObj) ? " Selected" : "         ")
-        << (theDetected.Contains (anObj)          ? " Detected" : "         ")
+  theDI << (TheAISContext()->IsDisplayed (theObj) ? "Displayed"  : "Hidden   ")
+        << (TheAISContext()->IsSelected  (theObj) ? " Selected" : "         ")
+        << (theDetected.Contains (theObj)         ? " Detected" : "         ")
         << " Type: ";
-  if (anObj->Type() == AIS_KOI_Datum)
+  if (theObj->Type() == AIS_KOI_Datum)
   {
     // AIS_Datum
-    if      (anObj->Signature() == 3) { theDI << " AIS_Trihedron"; }
-    else if (anObj->Signature() == 2) { theDI << " AIS_Axis"; }
-    else if (anObj->Signature() == 6) { theDI << " AIS_Circle"; }
-    else if (anObj->Signature() == 5) { theDI << " AIS_Line"; }
-    else if (anObj->Signature() == 7) { theDI << " AIS_Plane"; }
-    else if (anObj->Signature() == 1) { theDI << " AIS_Point"; }
-    else if (anObj->Signature() == 4) { theDI << " AIS_PlaneTrihedron"; }
+    if      (theObj->Signature() == 3) { theDI << " AIS_Trihedron"; }
+    else if (theObj->Signature() == 2) { theDI << " AIS_Axis"; }
+    else if (theObj->Signature() == 6) { theDI << " AIS_Circle"; }
+    else if (theObj->Signature() == 5) { theDI << " AIS_Line"; }
+    else if (theObj->Signature() == 7) { theDI << " AIS_Plane"; }
+    else if (theObj->Signature() == 1) { theDI << " AIS_Point"; }
+    else if (theObj->Signature() == 4) { theDI << " AIS_PlaneTrihedron"; }
   }
   // AIS_Shape
-  else if (anObj->Type()      == AIS_KOI_Shape
-        && anObj->Signature() == 0)
+  else if (theObj->Type()      == AIS_KOI_Shape
+        && theObj->Signature() == 0)
   {
     theDI << " AIS_Shape";
   }
-  else if (anObj->Type() == AIS_KOI_Relation)
+  else if (theObj->Type() == AIS_KOI_Relation)
   {
-    // AIS_Dimention and AIS_Relation
-    Handle(AIS_Relation) aRelation = Handle(AIS_Relation)::DownCast (anObj);
+    // PrsDim_Dimention and AIS_Relation
+    Handle(PrsDim_Relation) aRelation = Handle(PrsDim_Relation)::DownCast (theObj);
     switch (aRelation->KindOfDimension())
     {
-      case AIS_KOD_PLANEANGLE:     theDI << " AIS_AngleDimension"; break;
-      case AIS_KOD_LENGTH:         theDI << " AIS_Chamf2/3dDimension/AIS_LengthDimension"; break;
-      case AIS_KOD_DIAMETER:       theDI << " AIS_DiameterDimension"; break;
-      case AIS_KOD_ELLIPSERADIUS:  theDI << " AIS_EllipseRadiusDimension"; break;
-      //case AIS_KOD_FILLETRADIUS:   theDI << " AIS_FilletRadiusDimension "; break;
-      case AIS_KOD_OFFSET:         theDI << " AIS_OffsetDimension"; break;
-      case AIS_KOD_RADIUS:         theDI << " AIS_RadiusDimension"; break;
+      case PrsDim_KOD_PLANEANGLE:     theDI << " PrsDim_AngleDimension"; break;
+      case PrsDim_KOD_LENGTH:         theDI << " PrsDim_Chamf2/3dDimension/PrsDim_LengthDimension"; break;
+      case PrsDim_KOD_DIAMETER:       theDI << " PrsDim_DiameterDimension"; break;
+      case PrsDim_KOD_ELLIPSERADIUS:  theDI << " PrsDim_EllipseRadiusDimension"; break;
+      //case PrsDim_KOD_FILLETRADIUS:   theDI << " PrsDim_FilletRadiusDimension "; break;
+      case PrsDim_KOD_OFFSET:         theDI << " PrsDim_OffsetDimension"; break;
+      case PrsDim_KOD_RADIUS:         theDI << " PrsDim_RadiusDimension"; break;
       default:                     theDI << " UNKNOWN dimension"; break;
     }
   }
@@ -4627,7 +5342,7 @@ static void objInfo (const NCollection_Map<Handle(AIS_InteractiveObject)>& theDe
   {
     theDI << " UserPrs";
   }
-  theDI << " (" << theObject->DynamicType()->Name() << ")";
+  theDI << " (" << theObj->DynamicType()->Name() << ")";
 }
 
 //! Print information about locally selected sub-shapes
@@ -4710,7 +5425,7 @@ static Standard_Integer VState (Draw_Interpretor& theDI,
   Handle(AIS_InteractiveContext) aCtx = TheAISContext();
   if (aCtx.IsNull())
   {
-    std::cerr << "Error: No opened viewer!\n";
+    Message::SendFail ("Error: No opened viewer!");
     return 1;
   }
 
@@ -4749,18 +5464,32 @@ static Standard_Integer VState (Draw_Interpretor& theDI,
     SelectMgr_SelectingVolumeManager aMgr = aSelector->GetManager();
     for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter)
     {
-      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());
-      TCollection_AsciiString aName = GetMapOfAIS().Find1 (anObj);
+      const SelectMgr_SortCriterion&         aPickData = aSelector->PickedData (aPickIter);
+      const Handle(Select3D_SensitiveEntity)& anEntity = aSelector->PickedEntity (aPickIter);
+      const Handle(SelectMgr_EntityOwner)& anOwner = anEntity->OwnerId();
+      Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
+
+      TCollection_AsciiString aName;
+      GetMapOfAIS().Find1 (anObj, aName);
       aName.LeftJustify (20, ' ');
       char anInfoStr[512];
-      Sprintf (anInfoStr,
-               " Depth: %g Distance: %g Point: %g %g %g",
-               aPickData.Depth,
-               aPickData.MinDist,
-               aPickData.Point.X(), aPickData.Point.Y(), aPickData.Point.Z());
+      if (aPickData.Normal.SquareModulus() > ShortRealEpsilon())
+      {
+        Sprintf (anInfoStr,
+                 " Depth: %g Distance: %g Point: %g %g %g Normal: %g %g %g",
+                 aPickData.Depth,
+                 aPickData.MinDist,
+                 aPickData.Point.X(), aPickData.Point.Y(), aPickData.Point.Z(),
+                 aPickData.Normal.x(), aPickData.Normal.y(), aPickData.Normal.z());
+      }
+      else
+      {
+        Sprintf (anInfoStr,
+                 " 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() << ")"
@@ -4807,17 +5536,17 @@ static Standard_Integer VState (Draw_Interpretor& theDI,
     for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
     {
       const TCollection_AsciiString anObjName = theArgVec[anArgIter];
-      if (!GetMapOfAIS().IsBound2 (anObjName))
+      Handle(AIS_InteractiveObject) anObj;
+      if (!GetMapOfAIS().Find2 (anObjName, anObj))
       {
         theDI << anObjName << " doesn't exist!\n";
         continue;
       }
 
-      const Handle(Standard_Transient) anObjTrans = GetMapOfAIS().Find2 (anObjName);
       TCollection_AsciiString aName = anObjName;
       aName.LeftJustify (20, ' ');
       theDI << "  " << aName << " ";
-      objInfo (aDetected, anObjTrans, theDI);
+      objInfo (aDetected, anObj, theDI);
       theDI << "\n";
     }
     return 0;
@@ -4833,7 +5562,8 @@ static Standard_Integer VState (Draw_Interpretor& theDI,
       // handle whole object selection
       if (anOwner == anObj->GlobalSelOwner())
       {
-        TCollection_AsciiString aName = GetMapOfAIS().Find1 (anObj);
+        TCollection_AsciiString aName;
+        GetMapOfAIS().Find1 (anObj, aName);
         aName.LeftJustify (20, ' ');
         theDI << aName << " ";
         objInfo (aDetected, anObj, theDI);
@@ -4851,8 +5581,7 @@ static Standard_Integer VState (Draw_Interpretor& theDI,
   for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anObjIter (GetMapOfAIS());
        anObjIter.More(); anObjIter.Next())
   {
-    Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anObjIter.Key1());
-    if (anObj.IsNull())
+    if (anObjIter.Key1().IsNull())
     {
       continue;
     }
@@ -4860,7 +5589,7 @@ static Standard_Integer VState (Draw_Interpretor& theDI,
     TCollection_AsciiString aName = anObjIter.Key2();
     aName.LeftJustify (20, ' ');
     theDI << "  " << aName << " ";
-    objInfo (aDetected, anObj, theDI);
+    objInfo (aDetected, anObjIter.Key1(), theDI);
     theDI << "\n";
   }
   printLocalSelectionInfo (aCtx, theDI);
@@ -4892,7 +5621,7 @@ Standard_Boolean ViewerTest::PickShapes (const TopAbs_ShapeEnum theShapeType,
   const Standard_Integer aNbToReach = theResArray->Length();
   if (aNbToReach > 1)
   {
-    std::cout << " WARNING : Pick with Shift+ MB1 for Selection of more than 1 object\n";
+    Message::SendWarning ("WARNING : Pick with Shift+ MB1 for Selection of more than 1 object");
   }
 
   // step 1: prepare the data
@@ -4935,7 +5664,7 @@ Standard_Boolean ViewerTest::PickShapes (const TopAbs_ShapeEnum theShapeType,
     {
       ++aNbPickFail;
     }
-    std::cout << "NbPicked =  " << aNbPickGood << " |  Nb Pick Fail :" << aNbPickFail << "\n";
+    Message::SendInfo() << "NbPicked =  " << aNbPickGood << " |  Nb Pick Fail :" << aNbPickFail;
   }
 
   // step3 get result.
@@ -4997,7 +5726,7 @@ static int VPickShape( Draw_Interpretor& di, Standard_Integer argc, const char**
     else if (aShapeArg == "solid")  aShapeType = TopAbs_SOLID;
     else
     {
-      std::cout << "Syntax error at '" << argv[1] << "'\n";
+      Message::SendFail() << "Syntax error at '" << argv[1] << "'";
       return 1;
     }
   }
@@ -5074,7 +5803,7 @@ static int VSelFilter(Draw_Interpretor& , Standard_Integer theArgc,
   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
   if (aContext.IsNull())
   {
-    std::cout << "Error: AIS context is not available.\n";
+    Message::SendFail ("Error: AIS context is not available.");
     return 1;
   }
 
@@ -5086,6 +5815,24 @@ static int VSelFilter(Draw_Interpretor& , Standard_Integer theArgc,
     {
       aContext->RemoveFilters();
     }
+    else if (anArg == "-contextfilter" && anArgIter + 1 < theArgc)
+    {
+      TCollection_AsciiString aVal (theArgv[++anArgIter]);
+      aVal.LowerCase();
+      if (aVal == "and")
+      {
+        aContext->SetFilterType (SelectMgr_FilterType_AND);
+      }
+      else if (aVal == "or")
+      {
+        aContext->SetFilterType (SelectMgr_FilterType_OR);
+      }
+      else
+      {
+        Message::SendFail() << "Syntax error: wrong command attribute value '" << aVal << "'";
+        return 1;
+      }
+    }
     else if (anArg == "-type"
           && anArgIter + 1 < theArgc)
     {
@@ -5093,7 +5840,29 @@ static int VSelFilter(Draw_Interpretor& , Standard_Integer theArgc,
       TopAbs_ShapeEnum aShapeType = TopAbs_COMPOUND;
       if (!TopAbs::ShapeTypeFromString (aVal.ToCString(), aShapeType))
       {
-        std::cout << "Syntax error: wrong command attribute value '" << aVal << "'\n";
+        Message::SendFail() << "Syntax error: wrong command attribute value '" << aVal << "'";
+        return 1;
+      }
+
+      Handle(SelectMgr_Filter) aFilter;
+      if (aShapeType == TopAbs_SHAPE)
+      {
+        aFilter = new AIS_TypeFilter (AIS_KOI_Shape);
+      }
+      else
+      {
+        aFilter = new StdSelect_ShapeTypeFilter (aShapeType);
+      }
+      aContext->AddFilter (aFilter);
+    }
+    else if (anArg == "-secondtype"
+          && anArgIter + 1 < theArgc)
+    {
+      TCollection_AsciiString aVal (theArgv[++anArgIter]);
+      TopAbs_ShapeEnum aShapeType = TopAbs_COMPOUND;
+      if (!TopAbs::ShapeTypeFromString (aVal.ToCString(), aShapeType))
+      {
+        Message::SendFail() << "Syntax error: wrong command attribute value '" << aVal << "'";
         return 1;
       }
 
@@ -5110,7 +5879,7 @@ static int VSelFilter(Draw_Interpretor& , Standard_Integer theArgc,
     }
     else
     {
-      std::cout << "Syntax error: unknown argument '" << theArgv[anArgIter] << "'\n";
+      Message::SendFail() << "Syntax error: unknown argument '" << theArgv[anArgIter] << "'";
       return 1;
     }
   }
@@ -5299,9 +6068,9 @@ 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)::DownCast (curio)->KindOfDimension();
-      if ((dimension_status==0 && KOD == AIS_KOD_NONE)||
-         (dimension_status==1 && KOD != AIS_KOD_NONE))
+      PrsDim_KindOfDimension KOD = Handle(PrsDim_Relation)::DownCast (curio)->KindOfDimension();
+      if ((dimension_status==0 && KOD == PrsDim_KOD_NONE)||
+         (dimension_status==1 && KOD != PrsDim_KOD_NONE))
        TheAISContext()->Erase(curio,Standard_False);
     }
   }
@@ -5332,9 +6101,9 @@ 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)::DownCast (curio)->KindOfDimension();
-      if ((dimension_status==0 && KOD == AIS_KOD_NONE)||
-         (dimension_status==1 && KOD != AIS_KOD_NONE))
+      PrsDim_KindOfDimension KOD = Handle(PrsDim_Relation)::DownCast (curio)->KindOfDimension();
+      if ((dimension_status==0 && KOD == PrsDim_KOD_NONE)||
+         (dimension_status==1 && KOD != PrsDim_KOD_NONE))
        TheAISContext()->Display(curio,Standard_False);
     }
 
@@ -5346,7 +6115,7 @@ static int VDisplayType(Draw_Interpretor& , Standard_Integer argc, const char**
 
 static Standard_Integer vr(Draw_Interpretor& , Standard_Integer , const char** a)
 {
-  ifstream s(a[1]);
+  std::ifstream s(a[1]);
   BRep_Builder builder;
   TopoDS_Shape shape;
   BRepTools::Read(shape, s, builder);
@@ -5370,13 +6139,13 @@ static int VBsdf (Draw_Interpretor& theDI,
   if (aView.IsNull()
    || aViewer.IsNull())
   {
-    std::cerr << "No active viewer!\n";
+    Message::SendFail ("Error: No active viewer!");
     return 1;
   }
 
   ViewerTest_CmdParser aCmd;
 
-  aCmd.AddDescription ("Adjusts parameters of material BSDF:");
+  aCmd.SetDescription ("Adjusts parameters of material BSDF:");
 
   aCmd.AddOption ("print|echo|p", "Prints BSDF");
 
@@ -5409,7 +6178,6 @@ static int VBsdf (Draw_Interpretor& theDI,
 
   // check viewer update mode
   ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), ViewerTest::CurrentView());
-
   for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter)
   {
     if (anUpdateTool.parseRedrawMode (theArgVec[anArgIter]))
@@ -5418,17 +6186,15 @@ static int VBsdf (Draw_Interpretor& theDI,
     }
   }
 
-  TCollection_AsciiString aName (aCmd.Arg ("", 0).c_str());
-
   // find object
-  ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
-  if (!aMap.IsBound2 (aName) )
+  TCollection_AsciiString aName (aCmd.Arg (ViewerTest_CmdParser::THE_UNNAMED_COMMAND_OPTION_KEY, 0).c_str());
+  Handle(AIS_InteractiveObject) anIObj;
+  if (!GetMapOfAIS().Find2 (aName, anIObj))
   {
-    std::cerr << "Use 'vdisplay' before\n";
+    Message::SendFail ("Error: no active viewer");
     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();
 
@@ -5659,7 +6425,7 @@ static Standard_Integer VLoadSelection (Draw_Interpretor& /*theDi*/,
 {
   if (theArgNb < 2)
   {
-    std::cerr << theArgVec[0] << "Error: wrong number of arguments.\n";
+    Message::SendFail ("Syntax error: wrong number of arguments.");
     return 1;
   }
 
@@ -5671,42 +6437,28 @@ static Standard_Integer VLoadSelection (Draw_Interpretor& /*theDi*/,
   }
 
   // Parse input arguments
-  TColStd_SequenceOfAsciiString aNamesOfIO;
   for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
   {
     const TCollection_AsciiString aName = theArgVec[anArgIter];
-    aNamesOfIO.Append (aName);
-  }
-
-  if (aNamesOfIO.IsEmpty())
-  {
-    std::cerr << theArgVec[0] << "Error: wrong number of arguments.\n";
-    return 1;
-  }
-
-  // Load selection of interactive objects
-  for (Standard_Integer anIter = 1; anIter <= aNamesOfIO.Length(); ++anIter)
-  {
-    const TCollection_AsciiString& aName = aNamesOfIO.Value (anIter);
-
     Handle(AIS_InteractiveObject) aShape;
-    if (GetMapOfAIS().IsBound2 (aName))
-      aShape = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aName));
-    else
-      aShape = GetAISShapeFromName (aName.ToCString());
-
-    if (!aShape.IsNull())
+    if (!GetMapOfAIS().Find2 (aName, aShape))
     {
-      if (!GetMapOfAIS().IsBound2 (aName))
+      TopoDS_Shape aDrawShape = DBRep::GetExisting (aName);
+      if (!aDrawShape.IsNull())
       {
+        aShape = new AIS_Shape (aDrawShape);
         GetMapOfAIS().Bind (aShape, aName);
       }
-
-      aCtx->Load (aShape, -1);
-      aCtx->Activate (aShape, aShape->GlobalSelectionMode(), Standard_True);
     }
-  }
+    if (aShape.IsNull())
+    {
+      Message::SendFail() << "Syntax error: presentation '" << aName << "' not found";
+      return 1;
+    }
 
+    aCtx->Load (aShape, -1);
+    aCtx->Activate (aShape, aShape->GlobalSelectionMode(), Standard_True);
+  }
   return 0;
 }
 
@@ -5782,15 +6534,16 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
       __FILE__, VUpdate, group);
 
   theCommands.Add("verase",
-      "verase [-noupdate|-update] [-local] [name1] ...  [name n]"
+      "verase [-noupdate|-update] [-local] [name1] ...  [name n] [-noerror]"
       "\n\t\t: Erases selected or named objects."
       "\n\t\t: If there are no selected or named objects the whole viewer is erased."
       "\n\t\t: Option -local enables erasing of selected or named objects without"
-      "\n\t\t: closing local selection context.",
+      "\n\t\t: closing local selection context."
+      "\n\t\t: Option -noerror prevents exception on non-existing objects.",
       __FILE__, VErase, group);
 
   theCommands.Add("vremove",
-      "vremove [-noupdate|-update] [-context] [-all] [-noinfo] [name1] ...  [name n]"
+      "vremove [-noupdate|-update] [-context] [-all] [-noinfo] [name1] ...  [name n] [-noerror]"
       "or vremove [-context] -all to remove all objects"
       "\n\t\t: Removes selected or named objects."
       "\n\t\t  If -context is in arguments, the objects are not deleted"
@@ -5799,7 +6552,8 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
       "\n\t\t: closing local selection context. Empty local selection context will be"
       "\n\t\t: closed."
       "\n\t\t: Option -noupdate suppresses viewer redraw call."
-      "\n\t\t: Option -noinfo suppresses displaying the list of removed objects.",
+      "\n\t\t: Option -noinfo suppresses displaying the list of removed objects."
+      "\n\t\t: Option -noerror prevents exception on non-existing objects.",
       __FILE__, VRemove, group);
 
   theCommands.Add("vdonly",
@@ -5844,7 +6598,10 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
                  __FILE__,VDispMode,group);
 
   theCommands.Add("vdir",
-                 "Lists all objects displayed in 3D viewer",
+              "vdir [mask] [-list]"
+      "\n\t\t: Lists all objects displayed in 3D viewer"
+      "\n\t\t:    mask - name filter like prefix*"
+      "\n\t\t:   -list - format list with new-line per name; OFF by default",
                  __FILE__,VDir,group);
 
 #ifdef HAVE_FREEIMAGE
@@ -5856,6 +6613,7 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
               "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:       [-xrPose base|head|handLeft|handRight=base]"
       "\n\t\t:       [-tileSize Size=0]"
       "\n\t\t: Dumps content of the active view into image file",
                  __FILE__,VDump,group);
@@ -5864,34 +6622,44 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
                  __FILE__,VSubInt,group);
 
   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:          [-setLineType {solid|dash|dot|dotDash}] [-unsetLineType]"
-      "\n\t\t:          [-setMarkerType {.|+|x|O|xcircle|pointcircle|ring1|ring2|ring3|ball|ImagePath}]"
+              "vaspects [-noupdate|-update] [name1 [name2 [...]] | -defaults] [-subshapes subname1 [subname2 [...]]]"
+      "\n\t\t:          [-visibility {0|1}]"
+      "\n\t\t:          [-color {ColorName | R G B}] [-unsetColor]"
+      "\n\t\t:          [-backfaceColor Color]"
+      "\n\t\t:          [-material MatName] [-unsetMaterial]"
+      "\n\t\t:          [-transparency Transp] [-unsetTransparency]"
+      "\n\t\t:          [-width LineWidth] [-unsetWidth]"
+      "\n\t\t:          [-lineType {solid|dash|dot|dotDash|0xHexPattern} [-stippleFactor factor]]"
+      "\n\t\t:          [-unsetLineType]"
+      "\n\t\t:          [-markerType {.|+|x|O|xcircle|pointcircle|ring1|ring2|ring3|ball|ImagePath}]"
       "\n\t\t:          [-unsetMarkerType]"
-      "\n\t\t:          [-setMarkerSize Scale] [-unsetMarkerSize]"
-      "\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:          [-setShadingModel {color|flat|gouraud|phong}]"
+      "\n\t\t:          [-markerSize Scale] [-unsetMarkerSize]"
+      "\n\t\t:          [-freeBoundary {0|1}]"
+      "\n\t\t:          [-freeBoundaryWidth Width] [-unsetFreeBoundaryWidth]"
+      "\n\t\t:          [-freeBoundaryColor {ColorName | R G B}] [-unsetFreeBoundaryColor]"
+      "\n\t\t:          [-isoOnTriangulation 0|1]"
+      "\n\t\t:          [-maxParamValue {value}]"
+      "\n\t\t:          [-sensitivity {selection_mode} {value}]"
+      "\n\t\t:          [-shadingModel {unlit|flat|gouraud|phong|pbr|pbr_facet}]"
       "\n\t\t:          [-unsetShadingModel]"
-      "\n\t\t:          [-setAlphaMode {opaque|mask|blend|blendauto} [alphaCutOff=0.5]]"
+      "\n\t\t:          [-interior {solid|hatch|hidenline|point}] [-setHatch HatchStyle]"
+      "\n\t\t:          [-unsetInterior]"
+      "\n\t\t:          [-faceBoundaryDraw {0|1}] [-mostContinuity {c0|c1|c2|c3|cn}]"
+      "\n\t\t:          [-faceBoundaryWidth LineWidth] [-faceBoundaryColor R G B] [-faceBoundaryType LineType]"
+      "\n\t\t:          [-drawEdges {0|1}] [-edgeType LineType] [-edgeColor R G B] [-quadEdges {0|1}]"
+      "\n\t\t:          [-drawSilhouette {0|1}]"
+      "\n\t\t:          [-alphaMode {opaque|mask|blend|blendauto} [alphaCutOff=0.5]]"
+      "\n\t\t:          [-dumpJson]"
+      "\n\t\t:          [-dumpCompact {0|1}]"
+      "\n\t\t:          [-dumpDepth depth]"
       "\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."
+      "\n\t\t: When -subshapes is specified than following properties will be assigned to specified sub-shapes."
       "\n\t\t: When -defaults is specified than presentation properties will be"
       "\n\t\t: assigned to all objects that have not their own specified properties"
       "\n\t\t: and to all objects to be displayed in the future."
-      "\n\t\t: If -defaults is used there should not be any objects' names and -subshapes specifier.",
+      "\n\t\t: If -defaults is used there should not be any objects' names nor -subshapes specifier."
+      "\n\t\t: See also vlistcolors and vlistmaterials to list named colors and materials"
+      "\n\t\t: accepted by arguments -material and -color",
                  __FILE__,VAspects,group);
 
   theCommands.Add("vsetcolor",
@@ -5936,13 +6704,28 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
 
   theCommands.Add("vunsetwidth",
                  "vunsetwidth [-noupdate|-update] [name]"
-      "\n\t\t: Alias for vaspects -unsetwidth [name] width.",
+      "\n\t\t: Alias for vaspects -unsetwidth [name].",
                  __FILE__,VAspects,group);
 
   theCommands.Add("vsetinteriorstyle",
-                 "vsetinteriorstyle [-noupdate|-update] [name] style"
-      "\n\t\t: Where style is: 0 = EMPTY, 1 = HOLLOW, 2 = HATCH, 3 = SOLID, 4 = HIDDENLINE.",
-                 __FILE__,VSetInteriorStyle,group);
+    "vsetinteriorstyle [-noupdate|-update] [name] Style"
+    "\n\t\t: Alias for vaspects -setInterior [name] Style.",
+                 __FILE__,VAspects,group);
+
+  theCommands.Add ("vsetedgetype",
+    "vsetedgetype [name] [-type {solid, dash, dot}] [-color R G B] [-width value]"
+    "\n\t\t: Alias for vaspects [name] -setEdgeType Type.",
+      __FILE__, VAspects, group);
+
+  theCommands.Add ("vunsetedgetype",
+    "vunsetedgetype [name]"
+    "\n\t\t: Alias for vaspects [name] -unsetEdgeType.",
+      __FILE__, VAspects, group);
+
+  theCommands.Add ("vshowfaceboundary",
+    "vshowfaceboundary [name]"
+    "\n\t\t: Alias for vaspects [name] -setFaceBoundaryDraw on",
+      __FILE__, VAspects, group);
 
   theCommands.Add("vsensdis",
       "vsensdis : Display active entities (sensitive entities of one of the standard types corresponding to active selection modes)."
@@ -6039,8 +6822,13 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
                  __FILE__,vr, group);
 
   theCommands.Add("vselfilter",
-                  "vselfilter [-type {VERTEX|EDGE|WIRE|FACE|SHAPE|SHELL|SOLID}] [-clear]"
+    "vselfilter [-contextfilter {AND|OR}]"
+    "\n         [-type {VERTEX|EDGE|WIRE|FACE|SHAPE|SHELL|SOLID}]"
+    "\n         [-secondtype {VERTEX|EDGE|WIRE|FACE|SHAPE|SHELL|SOLID}]"
+    "\n         [-clear]"
     "\nSets selection shape type filter in context or remove all filters."
+    "\n    : Option -contextfilter : To define a selection filter for two or more types of entity,"
+    "\n                              use value AND (OR by default)."
     "\n    : Option -type set type of selection filter. Filters are applyed with Or combination."
     "\n    : Option -clear remove all filters in context",
                  __FILE__,VSelFilter,group);
@@ -6079,17 +6867,11 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
 #include <DBRep.hxx>
 #include <TopoDS_Face.hxx>
 #include <gp_Pln.hxx>
-#include <AIS_KindOfSurface.hxx>
 #include <BRepOffsetAPI_DraftAngle.hxx>
 #include <Precision.hxx>
 #include <BRepAlgo.hxx>
 #include <OSD_Environment.hxx>
 #include <DrawTrSurf.hxx>
-//#include <DbgTools.hxx>
-//#include <FeatAlgo_MakeLinearForm.hxx>
-
-
-
 
 //=======================================================================
 //function : IsValid
@@ -6105,14 +6887,14 @@ static Standard_Boolean IsValid(const TopTools_ListOfShape& theArgs,
   Standard_Boolean ToCheck = Standard_True;
   if (!checkValid.IsEmpty()) {
 #ifdef OCCT_DEBUG
-    cout <<"DONT_SWITCH_IS_VALID positionnee a :"<<checkValid.ToCString()<<"\n";
+    std::cout <<"DONT_SWITCH_IS_VALID positionnee a :"<<checkValid.ToCString()<<"\n";
 #endif
     if ( checkValid=="true" || checkValid=="TRUE" ) {
       ToCheck= Standard_False;
     }
   } else {
 #ifdef OCCT_DEBUG
-    cout <<"DONT_SWITCH_IS_VALID non positionne\n";
+    std::cout <<"DONT_SWITCH_IS_VALID non positionne\n";
 #endif
   }
   Standard_Boolean IsValid = Standard_True;
@@ -6139,10 +6921,10 @@ static Standard_Integer TDraft(Draw_Interpretor& di, Standard_Integer argc, cons
   Standard_Real anAngle = 0;
   Standard_Boolean Rev = Standard_False;
   Standard_Integer rev = 0;
-  TopoDS_Shape Solid  = GetShapeFromName(argv[1]);
-  TopoDS_Shape face   = GetShapeFromName(argv[2]);
+  TopoDS_Shape Solid  = DBRep::Get (argv[1]);
+  TopoDS_Shape face   = DBRep::Get (argv[2]);
   TopoDS_Face Face    = TopoDS::Face(face);
-  TopoDS_Shape Plane  = GetShapeFromName(argv[3]);
+  TopoDS_Shape Plane  = DBRep::Get (argv[3]);
   if (Plane.IsNull ()) {
     di << "TEST : Plane is NULL\n";
     return 1;
@@ -6151,7 +6933,7 @@ static Standard_Integer TDraft(Draw_Interpretor& di, Standard_Integer argc, cons
   anAngle = 2*M_PI * anAngle / 360.0;
   gp_Pln aPln;
   Handle( Geom_Surface )aSurf;
-  AIS_KindOfSurface aSurfType;
+  PrsDim_KindOfSurface aSurfType;
   Standard_Real Offset;
   gp_Dir aDir;
   if(argc > 4) { // == 5
@@ -6160,7 +6942,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))
+  if(!PrsDim::GetPlaneFromFace(face2, aPln, aSurf, aSurfType, Offset))
     {
       di << "TEST : Can't find plane\n";
       return 1;
@@ -6203,15 +6985,14 @@ static Standard_Integer TDraft(Draw_Interpretor& di, Standard_Integer argc, cons
     Ctx->Display(ais, Standard_False);
 
     const char *Name = "draft1";
-    Standard_Boolean IsBound = GetMapOfAIS().IsBound2(Name);
-    if (IsBound) {
-      Handle(AIS_InteractiveObject) an_object =
-       Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(Name));
-      if (!an_object.IsNull()) {
-        Ctx->Remove(an_object,
-                    Standard_True) ;
-        GetMapOfAIS().UnBind2(Name) ;
+    Handle(AIS_InteractiveObject) an_object;
+    if (GetMapOfAIS().Find2(Name, an_object))
+    {
+      if (!an_object.IsNull())
+      {
+        Ctx->Remove (an_object, Standard_True);
       }
+      GetMapOfAIS().UnBind2 (Name);
     }
     GetMapOfAIS().Bind(ais, Name);
 //  DBRep::Set("draft", ais->Shape());