0029993: Visualization - AIS_TextLabel computes selection primitive only for attachme...
[occt.git] / src / ViewerTest / ViewerTest_ObjectCommands.cxx
index 0ff7df4..3db6e67 100644 (file)
@@ -28,7 +28,7 @@
 #include <Font_BRepFont.hxx>
 #include <Font_BRepTextBuilder.hxx>
 #include <Font_FontMgr.hxx>
-
+#include <Message.hxx>
 #include <NCollection_List.hxx>
 
 #include <OSD_Chronometer.hxx>
 
 #include <Select3D_SensitiveSegment.hxx>
 #include <Select3D_SensitivePrimitiveArray.hxx>
-#include <Select3D_SensitiveTriangle.hxx>
-#include <Select3D_SensitiveCurve.hxx>
 #include <Select3D_SensitivePoint.hxx>
 #include <BRepAdaptor_Curve.hxx>
 #include <StdPrs_Curve.hxx>
@@ -309,7 +307,7 @@ namespace
     if ((aMapOfArgs.IsBound ("xaxis") && !aMapOfArgs.IsBound ("zaxis"))
     || (!aMapOfArgs.IsBound ("xaxis") &&  aMapOfArgs.IsBound ("zaxis")))
     {
-      std::cout << "Syntax error: -xaxis and -zaxis parameters are to set together.\n";
+      Message::SendFail ("Syntax error: -xaxis and -zaxis parameters are to set together");
       return Standard_False;
     }
 
@@ -334,7 +332,7 @@ namespace
 
       if (!aZDir.IsNormal (aXDir, M_PI / 180.0))
       {
-        std::cout << "Syntax error - parameters 'xaxis' and 'zaxis' are not applied as VectorX is not normal to VectorZ\n";
+        Message::SendFail ("Syntax error - parameters 'xaxis' and 'zaxis' are not applied as VectorX is not normal to VectorZ");
         return Standard_False;
       }
 
@@ -360,7 +358,7 @@ namespace
       }
       else if (aValues->Size() != 0)
       {
-        std::cout << "Syntax error: -hidelabels expects parameter 'on' or 'off' after.\n";
+        Message::SendFail ("Syntax error: -hidelabels expects parameter 'on' or 'off' after");
         return Standard_False;
       }
 
@@ -380,7 +378,7 @@ namespace
       }
       else if (aValues->Size() != 0)
       {
-        std::cout << "Syntax error: -hidearrows expects parameter 'on' or 'off' after.\n";
+        Message::SendFail ("Syntax error: -hidearrows expects parameter 'on' or 'off' after");
         return Standard_False;
       }
 
@@ -396,7 +394,7 @@ namespace
       NCollection_List<Prs3d_DatumParts> aParts;
       if (aValues->Size() < 2)
       {
-        std::cout << "Syntax error: -color wrong parameters.\n";
+        Message::SendFail ("Syntax error: -color wrong parameters");
         return Standard_False;
       }
 
@@ -405,7 +403,7 @@ namespace
       Quantity_Color aColor;
       if (!convertToColor (aValues, aColor))
       {
-        std::cout << "Syntax error: -color wrong parameters.\n";
+        Message::SendFail ("Syntax error: -color wrong parameters");
         return Standard_False;
       }
 
@@ -428,7 +426,7 @@ namespace
       Quantity_Color aColor;
       if (!convertToColor (aValues, aColor))
       {
-        std::cout << "Syntax error: -textcolor wrong parameters.\n";
+        Message::SendFail ("Syntax error: -textcolor wrong parameters");
         return Standard_False;
       }
       theTrihedron->SetTextColor (aColor);
@@ -439,7 +437,7 @@ namespace
       Quantity_Color aColor;
       if (!convertToColor (aValues, aColor))
       {
-        std::cout << "Syntax error: -arrowcolor wrong parameters.\n";
+        Message::SendFail ("Syntax error: -arrowcolor wrong parameters");
         return Standard_False;
       }
       theTrihedron->SetArrowColor (aColor);
@@ -450,7 +448,7 @@ namespace
       NCollection_List<Prs3d_DatumAttribute> anAttributes;
       if (aValues->Size() != 2)
       {
-        std::cout << "Syntax error: -attribute wrong parameters.\n";
+        Message::SendFail ("Syntax error: -attribute wrong parameters");
         return Standard_False;
       }
 
@@ -469,7 +467,7 @@ namespace
       if (aValues->Size() < 2
       || !convertToDatumPart (aValues->Value (1), aDatumPart))
       {
-        std::cout << "Syntax error: -priority wrong parameters.\n";
+        Message::SendFail ("Syntax error: -priority wrong parameters");
         return Standard_False;
       }
       theTrihedron->SetSelectionPriority (aDatumPart, aValues->Value (2).IntegerValue());
@@ -488,7 +486,7 @@ namespace
       }
       else
       {
-        std::cout << "Syntax error: -labels wrong parameters.\n";
+        Message::SendFail ("Syntax error: -labels wrong parameters");
         return Standard_False;
       }
     }
@@ -499,7 +497,7 @@ namespace
       if (aValues->Size() < 1
       || !convertToDatumAxes (aValues->Value (1), aDatumAxes))
       {
-        std::cout << "Syntax error: -drawaxes wrong parameters.\n";
+        Message::SendFail ("Syntax error: -drawaxes wrong parameters");
         return Standard_False;
       }
       if (!theTrihedron->Attributes()->HasOwnDatumAspect())
@@ -583,7 +581,7 @@ static int VTrihedron2D (Draw_Interpretor& /*theDI*/,
 {
   if (theArgsNum != 2)
   {
-    std::cerr << theArgVec[0]<< " error.\n";
+    Message::SendFail() << "Syntax error: wrong number of arguments.";
     return 1;
   }
 
@@ -592,7 +590,7 @@ static int VTrihedron2D (Draw_Interpretor& /*theDI*/,
 
   if (aShapes.Extent() != 1)
   {
-    std::cerr << "Error: wrong number of selected shapes.\n";
+    Message::SendFail ("Error: wrong number of selected shapes.");
     return 1;
   }
 
@@ -641,7 +639,7 @@ static int VTrihedron (Draw_Interpretor& ,
 {
   if (theArgsNb < 2)
   {
-    std::cout << "Syntax error: the wrong number of input parameters.\n";
+    Message::SendFail ("Syntax error: the wrong number of input parameters");
     return 1;
   }
 
@@ -659,7 +657,7 @@ static int VTrihedron (Draw_Interpretor& ,
     aTrihedron = Handle(AIS_Trihedron)::DownCast (anObject);
     if (aTrihedron.IsNull())
     {
-      std::cout << "Syntax error: no trihedron with this name.\n";
+      Message::SendFail ("Syntax error: no trihedron with this name");
       return 1;
     }
   }
@@ -855,7 +853,7 @@ static int VPlaneTrihedron (Draw_Interpretor& di, Standard_Integer argc, const c
 
   if (TheAISContext()->NbSelected() != 1)
   {
-    std::cerr << "Error: Wrong number of selected shapes.\n";
+    Message::SendFail ("Error: Wrong number of selected shapes.");
     return 1;
   }
 
@@ -864,7 +862,7 @@ static int VPlaneTrihedron (Draw_Interpretor& di, Standard_Integer argc, const c
   Handle(AIS_Plane) aPlane = Handle(AIS_Plane)::DownCast (aTest);
   if (aPlane.IsNull())
   {
-    std::cerr << "Error: Selected shape is not a plane.\n";
+    Message::SendFail ("Error: Selected shape is not a plane.");
     return 1;
   }
 
@@ -934,7 +932,7 @@ static int VAxisBuilder(Draw_Interpretor& di, Standard_Integer argc, const char*
     if ( !strcasecmp(argv[0], "vaxis")) {
       if (aShapes.Extent() != 2 && aShapes.Extent() != 1)
       {
-        std::cerr << "Error: Wrong number of selected shapes.\n";
+        Message::SendFail ("Error: Wrong number of selected shapes.");
         return 1;
       }
 
@@ -943,14 +941,14 @@ static int VAxisBuilder(Draw_Interpretor& di, Standard_Integer argc, const char*
       {
         if (aShapes.Extent() != 2)
         {
-          std::cerr << "Error: Wron number of selected shapes.\n";
+          Message::SendFail ("Error: Wrong number of selected shapes.");
           return 1;
         }
 
         const TopoDS_Shape& aShapeB = aShapes.Last();
         if (aShapeB.ShapeType() != TopAbs_VERTEX)
         {
-          std::cerr << "Syntax error: You should select two vertices or one edge.\n";
+          Message::SendFail ("Syntax error: You should select two vertices or one edge.");
           return 1;
         }
 
@@ -987,7 +985,7 @@ static int VAxisBuilder(Draw_Interpretor& di, Standard_Integer argc, const char*
     {
       if (aShapes.Extent() != 2)
       {
-        std::cerr << "Error: Wrong number of selected shapes.\n";
+        Message::SendFail ("Error: Wrong number of selected shapes.");
         return 1;
       }
 
@@ -996,7 +994,7 @@ static int VAxisBuilder(Draw_Interpretor& di, Standard_Integer argc, const char*
       if (!(aShapeA.ShapeType() == TopAbs_EDGE
          && aShapeB.ShapeType() == TopAbs_VERTEX))
       {
-        std::cerr << "Syntax error: You should select face and then vertex.\n";
+        Message::SendFail ("Syntax error: You should select face and then vertex.");
         return 1;
       }
 
@@ -1020,7 +1018,7 @@ static int VAxisBuilder(Draw_Interpretor& di, Standard_Integer argc, const char*
     {
       if (aShapes.Extent() != 2)
       {
-        std::cerr << "Error: Wrong number of selected shapes.\n";
+        Message::SendFail ("Error: Wrong number of selected shapes.");
         return 1;
       }
 
@@ -1029,7 +1027,7 @@ static int VAxisBuilder(Draw_Interpretor& di, Standard_Integer argc, const char*
       if (!(aShapeA.ShapeType() == TopAbs_EDGE
          && aShapeB.ShapeType() == TopAbs_VERTEX))
       {
-        std::cerr << "Syntax error: You should select face and then vertex.\n";
+        Message::SendFail ("Syntax error: You should select face and then vertex.");
         return 1;
       }
 
@@ -1064,8 +1062,7 @@ static int VAxisBuilder(Draw_Interpretor& di, Standard_Integer argc, const char*
 
 //==============================================================================
 //function : VPointBuilder
-//purpose  : Build an AIS_Point from coordinates or with a selected vertex or edge
-//Draw arg : vpoint PoinName [Xa] [Ya] [Za]
+//purpose  :
 //==============================================================================
 #include <TopoDS_Edge.hxx>
 #include <TopoDS_Vertex.hxx>
@@ -1073,70 +1070,105 @@ static int VAxisBuilder(Draw_Interpretor& di, Standard_Integer argc, const char*
 #include <AIS_Point.hxx>
 #include <Geom_CartesianPoint.hxx>
 
-static int VPointBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+static int VPointBuilder(Draw_Interpretor& ,
+                         Standard_Integer theArgNb,
+                         const char** theArgVec)
 {
-  // Declarations
-  Standard_Boolean HasArg;
-  TCollection_AsciiString name;
-
-  // Verification
-  if (argc<2 || argc>5 ) {di<<" Syntaxe error\n";return 1;}
-  if (argc==5) HasArg=Standard_True;
-  else HasArg=Standard_False;
-
-  name=argv[1];
-
-  // Il y a des arguments: teste l'unique constructeur AIS_Pnt::AIS_Pnt(Point from Geom)
-  if (HasArg) {
-    Standard_Real thecoord[3];
-    for(Standard_Integer i=0;i<=2;i++)
-      thecoord[i]=Draw::Atof(argv[2+i]);
-    Handle(Geom_CartesianPoint )  myGeomPoint= new Geom_CartesianPoint (thecoord[0],thecoord[1],thecoord[2]);
-    Handle(AIS_Point)  myAISPoint=new AIS_Point(myGeomPoint );
-    GetMapOfAIS().Bind (myAISPoint,name);
-    TheAISContext()->Display (myAISPoint, Standard_True);
-  }
-
-  // Il n'a pas d'arguments
-  else
+  TCollection_AsciiString aName;
+  gp_Pnt aPnt (RealLast(), 0.0, 0.0);
+  bool is2d = false, isNoSel = false;
+  for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
   {
-    TopTools_ListOfShape aShapes;
-    ViewerTest::GetSelectedShapes (aShapes);
-
-    if (aShapes.Extent() != 1)
+    TCollection_AsciiString anArg (theArgVec[anArgIter]);
+    anArg.LowerCase();
+    if (anArg == "-2d")
     {
-      std::cerr << "Error: Wrong number of selected shapes.\n";
-      std::cerr << "\tYou should select one edge or vertex.\n";
+      is2d = true;
+    }
+    else if (anArg == "-nosel"
+          || anArg == "-noselection")
+    {
+      isNoSel = true;
+    }
+    else if (aName.IsEmpty())
+    {
+      aName = theArgVec[anArgIter];
+    }
+    else if (aPnt.X() == RealLast()
+          && anArgIter + 1 < theArgNb
+          && Draw::ParseReal (theArgVec[anArgIter + 0], aPnt.ChangeCoord().ChangeCoord (1))
+          && Draw::ParseReal (theArgVec[anArgIter + 1], aPnt.ChangeCoord().ChangeCoord (2)))
+    {
+      if (anArgIter + 2 < theArgNb
+       && TCollection_AsciiString (theArgVec[anArgIter + 2]) != "-2d"
+       && Draw::ParseReal (theArgVec[anArgIter + 2], aPnt.ChangeCoord().ChangeCoord (3)))
+      {
+        anArgIter += 2;
+      }
+      else
+      {
+        anArgIter += 1;
+      }
+    }
+    else
+    {
+      Message::SendFail() << "Syntax error at argument '" << anArg << "'\n";
       return 1;
     }
+  }
 
-    const TopoDS_Shape& aShapeA = aShapes.First();
-
-    if (aShapeA.ShapeType()==TopAbs_VERTEX )
+  if (aPnt.X() == RealLast())
+  {
+    TopTools_ListOfShape aShapes;
+    ViewerTest::GetSelectedShapes (aShapes);
+    TopoDS_Shape aShapeA;
+    if (aShapes.Extent() == 1)
     {
-      gp_Pnt A=BRep_Tool::Pnt(TopoDS::Vertex(aShapeA ) );
-      Handle(Geom_CartesianPoint) myGeomPoint= new Geom_CartesianPoint (A );
-      Handle(AIS_Point)  myAISPoint = new AIS_Point  (myGeomPoint );
-      GetMapOfAIS().Bind(myAISPoint,name);
-      TheAISContext()->Display (myAISPoint, Standard_True);
+      aShapeA = aShapes.First();
     }
-    else
+    switch (!aShapeA.IsNull() ? aShapeA.ShapeType() : TopAbs_SHAPE)
     {
-      TopoDS_Edge myEdge=TopoDS::Edge(aShapeA);
-      TopoDS_Vertex myVertexA,myVertexB;
-      TopExp::Vertices (myEdge ,myVertexA ,myVertexB );
-      gp_Pnt A=BRep_Tool::Pnt(myVertexA );
-      gp_Pnt B=BRep_Tool::Pnt(myVertexB );
-      // M est le milieu de [AB]
-      Handle(Geom_CartesianPoint) myGeomPointM= new Geom_CartesianPoint ( (A.X()+B.X())/2  , (A.Y()+B.Y())/2  , (A.Z()+B.Z())/2  );
-      Handle(AIS_Point)  myAISPointM = new AIS_Point  (myGeomPointM );
-      GetMapOfAIS().Bind(myAISPointM,name);
-      TheAISContext()->Display (myAISPointM, Standard_True);
+      case TopAbs_VERTEX:
+      {
+        aPnt = BRep_Tool::Pnt (TopoDS::Vertex (aShapeA));
+        break;
+      }
+      case TopAbs_EDGE: // edge middle point
+      {
+        const TopoDS_Edge& anEdge = TopoDS::Edge (aShapeA);
+        TopoDS_Vertex aVertPair[2];
+        TopExp::Vertices (anEdge, aVertPair[0], aVertPair[1]);
+        const gp_Pnt A = BRep_Tool::Pnt (aVertPair[0]);
+        const gp_Pnt B = BRep_Tool::Pnt (aVertPair[1]);
+        aPnt = (A.XYZ() + B.XYZ()) / 2;
+        break;
+      }
+      default:
+      {
+        Message::SendFail() << "Error: Wrong number of selected shapes.\n"
+                            << "\tYou should select one edge or vertex.";
+        return 1;
+      }
     }
+  }
 
+  if (is2d)
+  {
+    aPnt.SetY (-aPnt.Y());
+  }
+  Handle(Geom_CartesianPoint ) aGeomPoint = new Geom_CartesianPoint (aPnt);
+  Handle(AIS_Point) aPointPrs = new AIS_Point (aGeomPoint);
+  if (is2d)
+  {
+    aPointPrs->SetTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_UPPER));
+    aPointPrs->SetZLayer (Graphic3d_ZLayerId_TopOSD);
+  }
+  ViewerTest::Display (aName, aPointPrs);
+  if (isNoSel)
+  {
+    ViewerTest::GetAISContext()->Deactivate (aPointPrs);
   }
   return 0;
-
 }
 
 //==============================================================================
@@ -1170,7 +1202,7 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
   // Verification
   if (argc<2 || argc>6 )
   {
-    std::cout<<" Syntax error\n";
+    Message::SendFail ("Syntax error: wrong number of arguments");
     return 1;
   }
   if (argc == 6 || argc==5 || argc==4)
@@ -1186,7 +1218,7 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
     Handle(AIS_InteractiveObject) aShapeA;
     if (!GetMapOfAIS().Find2 (argv[2], aShapeA))
     {
-      std::cout<<"vplane: error 1st name doesn't exist in the GetMapOfAIS()\n";
+      Message::SendFail ("Syntax error: 1st name is not displayed");
       return 1;
     }
 
@@ -1199,28 +1231,28 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
         Handle(AIS_InteractiveObject) aShapeB;
         if (argc<5 || !GetMapOfAIS().Find2 (argv[3], aShapeB))
         {
-          std::cout<<"vplane: error 2nd name doesn't exist in the GetMapOfAIS()\n";
+          Message::SendFail ("Syntax error: 2nd name is not displayed");
           return 1;
         }
         // If B is not an AIS_Point
         if (aShapeB.IsNull() ||
           (!(aShapeB->Type()==AIS_KOI_Datum && aShapeB->Signature()==1)))
         {
-          std::cout<<"vplane: error 2nd object is expected to be an AIS_Point.\n";
+          Message::SendFail ("Syntax error: 2nd object is expected to be an AIS_Point");
           return 1;
         }
         // The third object is an AIS_Point
         Handle(AIS_InteractiveObject) aShapeC;
         if (!GetMapOfAIS().Find2(argv[4], aShapeC)) 
         {
-          std::cout<<"vplane: error 3d name doesn't exist in the GetMapOfAIS().\n";
+          Message::SendFail ("Syntax error: 3d name is not displayed");
           return 1; 
         }
         // If C is not an AIS_Point
         if (aShapeC.IsNull() ||
           (!(aShapeC->Type()==AIS_KOI_Datum && aShapeC->Signature()==1)))
         {
-          std::cout<<"vplane: error 3d object is expected to be an AIS_Point.\n";
+          Message::SendFail ("Syntax error: 3d object is expected to be an AIS_Point");
           return 1;
         }
 
@@ -1245,21 +1277,24 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
            Abs(aCartPointB->Z()-aCartPointA->Z())<=Precision::Confusion())
         {
           // B=A
-          std::cout<<"vplane error: same points\n";return 1;
+          Message::SendFail ("Error: same points");
+          return 1;
         }
         if(Abs(aCartPointC->X()-aCartPointA->X())<=Precision::Confusion() &&
            Abs(aCartPointC->Y()-aCartPointA->Y())<=Precision::Confusion() &&
            Abs(aCartPointC->Z()-aCartPointA->Z())<=Precision::Confusion())
         {
           // C=A
-          std::cout<<"vplane error: same points\n";return 1;
+          Message::SendFail ("Error: same points");
+          return 1;
         }
         if(Abs(aCartPointC->X()-aCartPointB->X())<=Precision::Confusion() &&
            Abs(aCartPointC->Y()-aCartPointB->Y())<=Precision::Confusion() &&
            Abs(aCartPointC->Z()-aCartPointB->Z())<=Precision::Confusion())
         {
           // C=B
-          std::cout<<"vplane error: same points\n";return 1;
+          Message::SendFail ("Error: same points");
+          return 1;
         }
 
         gp_Pnt A = aCartPointA->Pnt();
@@ -1276,11 +1311,10 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
           Standard_Integer aType = Draw::Atoi (argv[5]);
           if (aType != 0 && aType != 1)
           {
-            std::cout << "vplane error: wrong type of sensitivity!\n"
-                      << "Should be one of the following values:\n"
-                      << "0 - Interior\n"
-                      << "1 - Boundary"
-                      << std::endl;
+            Message::SendFail("Syntax error: wrong type of sensitivity.\n"
+                              "Should be one of the following values:\n"
+                              "0 - Interior\n"
+                              "1 - Boundary");
             return 1;
           }
           else
@@ -1298,14 +1332,14 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
       Handle(AIS_InteractiveObject) aShapeB;
       if (argc!=4 || !GetMapOfAIS().Find2 (argv[3], aShapeB))
       {
-        std::cout<<"vplane: error 2d name doesn't exist in the GetMapOfAIS()\n";
+        Message::SendFail ("Syntax error: 2d name is not displayed");
         return 1;
       }
       // If B is not an AIS_Point
       if (aShapeB.IsNull() ||
         (!(aShapeB->Type()==AIS_KOI_Datum && aShapeB->Signature()==1)))
       {
-        std::cout<<"vplane: error 2d object is expected to be an AIS_Point\n";
+        Message::SendFail ("Syntax error: 2d object is expected to be an AIS_Point");
         return 1;
       }
 
@@ -1332,11 +1366,10 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
         Standard_Integer aType = Draw::Atoi (argv[4]);
         if (aType != 0 && aType != 1)
         {
-          std::cout << "vplane error: wrong type of sensitivity!\n"
-                    << "Should be one of the following values:\n"
-                    << "0 - Interior\n"
-                    << "1 - Boundary"
-                    << std::endl;
+          Message::SendFail ("Syntax error: wrong type of sensitivity!\n"
+                             "Should be one of the following values:\n"
+                             "0 - Interior\n"
+                             "1 - Boundary");
           return 1;
         }
         else
@@ -1355,14 +1388,14 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
       Handle(AIS_InteractiveObject) aShapeB;
       if (argc!=4 || !GetMapOfAIS().Find2 (argv[3], aShapeB))
       {
-        std::cout<<"vplane: error 2d name doesn't exist in the GetMapOfAIS()\n";
+        Message::SendFail ("Syntax error: 2d name is not displayed");
         return 1;
       }
       // B should be an AIS_Point
       if (aShapeB.IsNull() ||
          (!(aShapeB->Type()==AIS_KOI_Datum && aShapeB->Signature()==1)))
       {
-        std::cout<<"vplane: error 2d object is expected to be an AIS_Point\n";
+        Message::SendFail ("Syntax error: 2d object is expected to be an AIS_Point");
         return 1;
       }
 
@@ -1385,11 +1418,10 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
         Standard_Integer aType = Draw::Atoi (argv[4]);
         if (aType != 0 && aType != 1)
         {
-          std::cout << "vplane error: wrong type of sensitivity!\n"
-                    << "Should be one of the following values:\n"
-                    << "0 - Interior\n"
-                    << "1 - Boundary"
-                    << std::endl;
+          Message::SendFail ("Syntax error: wrong type of sensitivity!\n"
+                             "Should be one of the following values:\n"
+                             "0 - Interior\n"
+                             "1 - Boundary");
           return 1;
         }
         else
@@ -1402,7 +1434,7 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
     // Error
     else
     {
-      std::cout<<"vplane: error 1st object is not an AIS\n";
+      Message::SendFail ("Syntax error: 1st object is not an AIS");
       return 1;
     }
   }
@@ -1418,8 +1450,8 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
     {
       if (aShapes.Extent() < 1 || aShapes.Extent() > 3)
       {
-        std::cerr << "Error: Wront number of selected shapes.\n";
-        std::cerr << "\tYou should one of variant: face, edge and vertex or three vertices.\n";
+        Message::SendFail() << "Error: Wront number of selected shapes.\n"
+                            << "\tYou should one of variant: face, edge and vertex or three vertices.";
         return 1;
       }
 
@@ -1431,7 +1463,7 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
           const TopoDS_Shape& aShapeB = aShapes.Last();
           if (aShapeB.ShapeType() != TopAbs_EDGE)
           {
-            std::cerr << "Syntax error: Together with vertex should be edge.\n";
+            Message::SendFail ("Syntax error: Together with vertex should be edge.");
             return 1;
           }
 
@@ -1443,7 +1475,7 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
           if (OrthoProj.SquareDistance(1)<Precision::Approximation())
           {
             // The vertex is on the edge
-            std::cout<<" vplane: error point is on the edge\n";
+            Message::SendFail ("Error: point is on the edge");
             return 1;
           }
           else
@@ -1473,7 +1505,7 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
           if (!(aShapeB.ShapeType() == TopAbs_VERTEX
              && aShapeC.ShapeType() == TopAbs_VERTEX))
           {
-            std::cerr << "Syntax error: You should one of variant: face, edge and vertex or three vertices.\n";
+            Message::SendFail ("Syntax error: You should one of variant: face, edge and vertex or three vertices.");
             return 1;
           }
 
@@ -1488,7 +1520,7 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
         }
         else
         {
-          std::cerr << "Syntax error: You should one of variant: face, edge and vertex or three vertices.\n";
+          Message::SendFail ("Syntax error: You should one of variant: face, edge and vertex or three vertices.");
           return 1;
         }
       }
@@ -1496,14 +1528,14 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
       {
         if (aShapes.Extent() != 2)
         {
-          std::cerr << "Error: wrong number of selected shapes.\n";
+          Message::SendFail ("Error: wrong number of selected shapes.");
           return 1;
         }
 
         const TopoDS_Shape& aShapeB = aShapes.Last();
         if (aShapeB.ShapeType() != TopAbs_VERTEX)
         {
-          std::cerr << "Syntax error: Together with edge should be vertex.\n";
+          Message::SendFail ("Syntax error: Together with edge should be vertex.");
           return 1;
         }
 
@@ -1515,7 +1547,7 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
         if (OrthoProj.SquareDistance(1)<Precision::Approximation())
         {
           // The vertex is on the edge
-          std::cout<<" vplane: error point is on the edge\n";
+          Message::SendFail ("Error point is on the edge");
           return 1;
         }
 
@@ -1544,13 +1576,13 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
         }
         else
         {
-          std::cout<<" vplane: error\n";
+          Message::SendFail ("Error: surface is not Plane");
           return 1;
         }
       }
       else
       {
-        std::cerr << "Syntax error: You should one of variant: face, edge and vertex or three vertices.\n";
+        Message::SendFail ("Syntax error: You should one of variant: face, edge and vertex or three vertices");
         return 1;
       }
     }
@@ -1562,7 +1594,7 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
     {
       if (aShapes.Extent() != 2)
       {
-        std::cerr << "Error: Wrong number of selected shapes.\n";
+        Message::SendFail ("Error: Wrong number of selected shapes.");
         return 1;
       }
 
@@ -1576,7 +1608,7 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
       if (!(aShapeA->ShapeType() == TopAbs_VERTEX
          && aShapeB->ShapeType() == TopAbs_FACE))
       {
-        std::cerr << "Syntax error: you should select face and vertex.\n";
+        Message::SendFail ("Syntax error: you should select face and vertex.");
         return 1;
       }
 
@@ -1596,7 +1628,7 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
       }
       else
       {
-        std::cerr << "Error: Builded surface is not a plane.\n";
+        Message::SendFail ("Error: Builded surface is not a plane.");
         return 1;
       }
     }
@@ -1608,7 +1640,7 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
     {
       if (aShapes.Extent() != 2)
       {
-        std::cerr << "Error: wrong number of selected shapes.\n";
+        Message::SendFail ("Error: wrong number of selected shapes.");
         return 1;
       }
 
@@ -1623,7 +1655,7 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
       if (!(aShapeA->ShapeType() == TopAbs_EDGE
          && aShapeB->ShapeType() == TopAbs_FACE))
       {
-        std::cerr << "Error: you should select edge and face.\n";
+        Message::SendFail ("Error: you should select edge and face.");
         return 1;
       }
 
@@ -1648,7 +1680,7 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
           >Precision::Confusion())
       {
         // the edge is not parallel to the face
-        std::cout<<" vplaneortho error: the edge is not parallel to the face\n";
+        Message::SendFail ("Error: the edge is not parallel to the face");
         return 1;
       }
       // the edge is OK
@@ -1668,7 +1700,7 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
       }
       else
       {
-        std::cout<<" vplaneortho: error\n";
+        Message::SendFail ("Error: surface is not Plane");
         return 1;
       }
     }
@@ -1685,15 +1717,13 @@ static int VChangePlane (Draw_Interpretor& /*theDi*/, Standard_Integer theArgsNb
   Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
   if (aContextAIS.IsNull())
   {
-    std::cout << theArgVec[0] << "AIS context is not available.\n";
+    Message::SendFail ("Error: no active viewer.");
     return 1;
   }
 
   if (theArgsNb < 3 || theArgsNb > 11)
   {
-    std::cerr << theArgVec[0] 
-              << ": incorrect number of command arguments.\n"
-              << "Type help for more information.\n";
+    Message::SendFail ("Syntax error: wrong number of arguments.");
     return 1;
   }
 
@@ -1705,9 +1735,7 @@ static int VChangePlane (Draw_Interpretor& /*theDi*/, Standard_Integer theArgsNb
 
   if ( aPlane.IsNull() )
   {
-    std::cout << theArgVec[0] 
-              << ": there is no interactive plane with the given name."
-              << "Type help for more information.\n";
+    Message::SendFail() << "Syntax error: there is no interactive plane with the given name '" << aName << "'.";
     return 1;
   }
 
@@ -1877,7 +1905,7 @@ static int VLineBuilder(Draw_Interpretor& di, Standard_Integer argc, const char*
     ViewerTest::GetSelectedShapes (aShapes);
     if (aShapes.Extent() != 2)
     {
-      std::cerr << "Error: wrong number of selected shapes.\n";
+      Message::SendFail ("Error: wrong number of selected shapes.");
       return 1;
     }
 
@@ -1887,7 +1915,7 @@ static int VLineBuilder(Draw_Interpretor& di, Standard_Integer argc, const char*
     if (!(aShapeA.ShapeType() == TopAbs_VERTEX
        && aShapeB.ShapeType() == TopAbs_VERTEX))
     {
-      std::cerr << "Error: you should select two different vertex.\n";
+      Message::SendFail ("Error: you should select two different vertex.");
       return 1;
     }
 
@@ -1999,8 +2027,7 @@ void FilledCircle::ComputeSelection(const Handle(SelectMgr_Selection) &theSelect
                                     const Standard_Integer /*theMode*/)
 {
   Handle(SelectMgr_EntityOwner) anEntityOwner = new SelectMgr_EntityOwner(this);
-  Handle(Select3D_SensitiveCircle) aSensitiveCircle = new Select3D_SensitiveCircle(anEntityOwner, 
-      myCircle, myFilledStatus);
+  Handle(Select3D_SensitiveCircle) aSensitiveCircle = new Select3D_SensitiveCircle (anEntityOwner, myCircle->Circ(), myFilledStatus);
   theSelection->Add(aSensitiveCircle);
 }
 
@@ -2053,8 +2080,8 @@ static int VCircleBuilder(Draw_Interpretor& /*di*/, Standard_Integer argc, const
   // Verification of the arguments
   if (argc>6 || argc<2) 
   { 
-    std::cout << "vcircle error: expect 4 arguments.\n"; 
-    return 1; // TCL_ERROR 
+    Message::SendFail ("Syntax error: wrong number of arguments");
+    return 1;
   }
 
   // There are all arguments
@@ -2075,8 +2102,8 @@ static int VCircleBuilder(Draw_Interpretor& /*di*/, Standard_Integer argc, const
     {
       if (theShapeB->Type()!=AIS_KOI_Datum || theShapeB->Signature()!=1 ) 
       {
-        std::cout << "vcircle error: 2d argument is unexpected to be a point.\n";
-        return 1; // TCL_ERROR 
+        Message::SendFail ("Error: 2d argument is unexpected to be a point");
+        return 1;
       }
       // The third object must be a point
       Handle(AIS_InteractiveObject) theShapeC;
@@ -2084,8 +2111,8 @@ static int VCircleBuilder(Draw_Interpretor& /*di*/, Standard_Integer argc, const
       if (theShapeC.IsNull() ||
         theShapeC->Type()!=AIS_KOI_Datum || theShapeC->Signature()!=1 ) 
       {
-        std::cout << "vcircle error: 3d argument is unexpected to be a point.\n";
-        return 1; // TCL_ERROR 
+        Message::SendFail ("Error: 3d argument is unexpected to be a point");
+        return 1;
       }
         // tag
         // Verify that the three points are different
@@ -2110,24 +2137,24 @@ static int VCircleBuilder(Draw_Interpretor& /*di*/, Standard_Integer argc, const
             Abs(myCartPointA->Y()-myCartPointB->Y()) <= Precision::Confusion() && 
             Abs(myCartPointA->Z()-myCartPointB->Z()) <= Precision::Confusion() ) 
         {
-          std::cout << "vcircle error: Same points.\n"; 
-          return 1; // TCL_ERROR 
+          Message::SendFail ("Error: Same points");
+          return 1;
         }
         // Test A=C
         if (Abs(myCartPointA->X()-myCartPointC->X()) <= Precision::Confusion() &&
             Abs(myCartPointA->Y()-myCartPointC->Y()) <= Precision::Confusion() && 
             Abs(myCartPointA->Z()-myCartPointC->Z()) <= Precision::Confusion() ) 
         {
-          std::cout << "vcircle error: Same points.\n"; 
-          return 1; // TCL_ERROR 
+          Message::SendFail ("Error: Same points");
+          return 1;
         }
         // Test B=C
         if (Abs(myCartPointB->X()-myCartPointC->X()) <= Precision::Confusion() && 
             Abs(myCartPointB->Y()-myCartPointC->Y()) <= Precision::Confusion() && 
             Abs(myCartPointB->Z()-myCartPointC->Z()) <= Precision::Confusion() ) 
         {
-          std::cout << "vcircle error: Same points.\n"; 
-          return 1;// TCL_ERROR 
+          Message::SendFail ("Error: Same points");
+          return 1;
         }
         // Construction of the circle
         GC_MakeCircle Cir = GC_MakeCircle (myCartPointA->Pnt(), 
@@ -2139,10 +2166,10 @@ static int VCircleBuilder(Draw_Interpretor& /*di*/, Standard_Integer argc, const
         }
         catch (StdFail_NotDone const&)
         {
-          std::cout << "vcircle error: can't create circle\n";
-          return -1; // TCL_ERROR
+          Message::SendFail ("Error: can't create circle");
+          return -1;
         }
-        
+
         DisplayCircle(theGeomCircle, aName, isFilled);
     }
 
@@ -2154,14 +2181,14 @@ static int VCircleBuilder(Draw_Interpretor& /*di*/, Standard_Integer argc, const
       if (theShapeB->Type() != AIS_KOI_Datum || 
         theShapeB->Signature() != 1 ) 
       {
-        std::cout << "vcircle error: 2d element is a unexpected to be a point.\n"; 
-        return 1; // TCL_ERROR 
+        Message::SendFail ("Error: 2d element is a unexpected to be a point");
+        return 1;
       }
       // Check that the radius is >= 0
       if (Draw::Atof(argv[4]) <= 0 ) 
       {
-        std::cout << "vcircle error: the radius must be >=0.\n"; 
-        return 1; // TCL_ERROR 
+        Message::SendFail ("Syntax error: the radius must be >=0");
+        return 1;
       }
 
       // Recover the normal to the plane
@@ -2186,8 +2213,8 @@ static int VCircleBuilder(Draw_Interpretor& /*di*/, Standard_Integer argc, const
       }
       catch (StdFail_NotDone const&)
       {
-        std::cout << "vcircle error: can't create circle\n";
-        return -1; // TCL_ERROR
+        Message::SendFail ("Error: can't create circle");
+        return -1;
       }
 
       DisplayCircle(theGeomCircle, aName, isFilled);
@@ -2197,8 +2224,8 @@ static int VCircleBuilder(Draw_Interpretor& /*di*/, Standard_Integer argc, const
     // Error
     else
     {
-      std::cout << "vcircle error: 1st argument is a unexpected type.\n"; 
-      return 1; // TCL_ERROR 
+      Message::SendFail ("Error: 1st argument has an unexpected type");
+      return 1;
     }
 
   }
@@ -2213,7 +2240,7 @@ static int VCircleBuilder(Draw_Interpretor& /*di*/, Standard_Integer argc, const
     ViewerTest::GetSelectedShapes (aShapes);
     if (aShapes.Extent() != 3 && aShapes.Extent() != 2)
     {
-      std::cerr << "Error: Wrong number of selected shapes.\n";
+      Message::SendFail ("Error: Wrong number of selected shapes.");
       return 1;
     }
 
@@ -2222,7 +2249,7 @@ static int VCircleBuilder(Draw_Interpretor& /*di*/, Standard_Integer argc, const
     {
       if (aShapes.Extent() != 3)
       {
-        std::cerr << "Error: wrong number of selected shapes.\n";
+        Message::SendFail ("Error: wrong number of selected shapes.");
         return 1;
       }
 
@@ -2252,8 +2279,8 @@ static int VCircleBuilder(Draw_Interpretor& /*di*/, Standard_Integer argc, const
       }
       catch (StdFail_NotDone const&)
       {
-        std::cout << "vcircle error: can't create circle\n";
-        return -1; // TCL_ERROR
+        Message::SendFail ("Error: can't create circle");
+        return -1;
       }
 
       DisplayCircle(theGeomCircle, aName, isFilled);
@@ -2297,15 +2324,15 @@ static int VCircleBuilder(Draw_Interpretor& /*di*/, Standard_Integer argc, const
       }
       catch (StdFail_NotDone const&)
       {
-        std::cout << "vcircle error: can't create circle\n";
-        return -1; // TCL_ERROR
+        Message::SendFail ("Error: can't create circle");
+        return -1;
       }
 
       DisplayCircle(theGeomCircle, aName, isFilled);
     }
     else
     {
-      std::cerr << "Error: You should select face and vertex or three vertices.\n";
+      Message::SendFail ("Error: You should select face and vertex or three vertices.");
       return 1;
     }
   }
@@ -2324,13 +2351,13 @@ static int VDrawText (Draw_Interpretor& theDI,
   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
   if (theArgsNb < 3)
   {
-    std::cout << "Error: wrong number of arguments! See usage:\n";
+    Message::SendFail ("Syntax error: wrong number of arguments. See usage:");
     theDI.PrintHelp (theArgVec[0]);
     return 1;
   }
   else if (aContext.IsNull())
   {
-    std::cout << "Error: no active view!\n";
+    Message::SendFail ("Error: no active viewer");
     return 1;
   }
 
@@ -2377,7 +2404,7 @@ static int VDrawText (Draw_Interpretor& theDI,
     {
       if (anArgIt + 3 >= theArgsNb)
       {
-        std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        Message::SendFail() << "Error: wrong number of values for parameter '" << aParam << "'";
         return 1;
       }
 
@@ -2394,7 +2421,7 @@ static int VDrawText (Draw_Interpretor& theDI,
                                                            aColor);
       if (aNbParsed == 0)
       {
-        std::cout << "Syntax error at '" << aParam << "'\n";
+        Message::SendFail() << "Syntax error at '" << aParam << "'";
         return 1;
       }
       anArgIt += aNbParsed;
@@ -2404,7 +2431,7 @@ static int VDrawText (Draw_Interpretor& theDI,
     {
       if (++anArgIt >= theArgsNb)
       {
-        std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        Message::SendFail() << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'";
         return 1;
       }
 
@@ -2424,7 +2451,7 @@ static int VDrawText (Draw_Interpretor& theDI,
       }
       else
       {
-        std::cout << "Error: wrong syntax at '" << aParam.ToCString() << "'.\n";
+        Message::SendFail() << "Syntax error at '" << aParam << "'";
         return 1;
       }
     }
@@ -2432,7 +2459,7 @@ static int VDrawText (Draw_Interpretor& theDI,
     {
       if (++anArgIt >= theArgsNb)
       {
-        std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        Message::SendFail() << "Syntax error: wrong number of values for parameter '" << aParam << "'";
         return 1;
       }
 
@@ -2456,7 +2483,7 @@ static int VDrawText (Draw_Interpretor& theDI,
       }
       else
       {
-        std::cout << "Error: wrong syntax at '" << aParam.ToCString() << "'.\n";
+        Message::SendFail() << "Syntax error at '" << aParam << "'";
         return 1;
       }
     }
@@ -2464,7 +2491,7 @@ static int VDrawText (Draw_Interpretor& theDI,
     {
       if (++anArgIt >= theArgsNb)
       {
-        std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        Message::SendFail() << "Syntax error: wrong number of values for parameter '" << aParam << "'";
         return 1;
       }
 
@@ -2474,7 +2501,7 @@ static int VDrawText (Draw_Interpretor& theDI,
     {
       if (++anArgIt >= theArgsNb)
       {
-        std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        Message::SendFail() << "Syntax error: wrong number of values for parameter '" << aParam << "'";
         return 1;
       }
 
@@ -2484,7 +2511,7 @@ static int VDrawText (Draw_Interpretor& theDI,
     {
       if (++anArgIt >= theArgsNb)
       {
-        std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        Message::SendFail() << "Syntax error: wrong number of values for parameter '" << aParam << "'";
         return 1;
       }
 
@@ -2494,7 +2521,7 @@ static int VDrawText (Draw_Interpretor& theDI,
     {
       if (++anArgIt >= theArgsNb)
       {
-        std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        Message::SendFail() << "Syntax error: wrong number of values for parameter '" << aParam << "'";
         return 1;
       }
 
@@ -2503,7 +2530,7 @@ static int VDrawText (Draw_Interpretor& theDI,
       Font_FontAspect aFontAspect = Font_FA_Undefined;
       if (!parseFontStyle (anOption, aFontAspect))
       {
-        std::cout << "Error: unknown font aspect '" << anOption << "'.\n";
+        Message::SendFail() << "Syntax error: unknown font aspect '" << anOption << "'";
         return 1;
       }
       aTextPrs->SetFontAspect (aFontAspect);
@@ -2512,7 +2539,7 @@ static int VDrawText (Draw_Interpretor& theDI,
     {
       if (++anArgIt >= theArgsNb)
       {
-        std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        Message::SendFail() << "Syntax error: wrong number of values for parameter '" << aParam << "'";
         return 1;
       }
 
@@ -2522,7 +2549,7 @@ static int VDrawText (Draw_Interpretor& theDI,
     {
       if (anArgIt + 6 >= theArgsNb)
       {
-        std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        Message::SendFail() << "Syntax error: wrong number of values for parameter '" << aParam << "'";
         return 1;
       }
 
@@ -2542,12 +2569,21 @@ static int VDrawText (Draw_Interpretor& theDI,
     {
       aTextPrs->SetFlipping (Standard_True);
     }
+    else if (aParam == "-ownanchor")
+    {
+      if (++anArgIt >= theArgsNb)
+      {
+        std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        return 1;
+      }
+      aTextPrs->SetOwnAnchorPoint (Draw::Atoi (theArgVec[anArgIt]) == 1);
+    }
     else if (aParam == "-disptype"
           || aParam == "-displaytype")
     {
       if (++anArgIt >= theArgsNb)
       {
-        std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        Message::SendFail() << "Syntax error: wrong number of values for parameter '" << aParam << "'";
         return 1;
       }
       TCollection_AsciiString aType (theArgVec[anArgIt]);
@@ -2566,7 +2602,7 @@ static int VDrawText (Draw_Interpretor& theDI,
         aDisplayType = Aspect_TODT_SHADOW;
       else
       {
-        std::cout << "Error: wrong display type '" << aType << "'.\n";
+        Message::SendFail() << "Syntax error: wrong display type '" << aType << "'";
         return 1;
       }
     }
@@ -2579,7 +2615,7 @@ static int VDrawText (Draw_Interpretor& theDI,
                                                            aColor);
       if (aNbParsed == 0)
       {
-        std::cout << "Syntax error at '" << aParam << "'\n";
+        Message::SendFail() << "Syntax error at '" << aParam << "'";
         return 1;
       }
       anArgIt += aNbParsed;
@@ -2594,7 +2630,7 @@ static int VDrawText (Draw_Interpretor& theDI,
     {
       if (anArgIt + 2 >= theArgsNb)
       {
-        std::cerr << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        Message::SendFail() << "Error: wrong number of values for parameter '" << aParam << "'.";
         return 1;
       }
 
@@ -2604,7 +2640,7 @@ static int VDrawText (Draw_Interpretor& theDI,
       if (!aX.IsIntegerValue()
        || !aY.IsIntegerValue())
       {
-        std::cerr << "Error: wrong syntax at '" << aParam << "'.\n";
+        Message::SendFail() << "Error: wrong syntax at '" << aParam << "'.";
         return 1;
       }
       if (anArgIt + 1 < theArgsNb)
@@ -2621,7 +2657,7 @@ static int VDrawText (Draw_Interpretor& theDI,
     }
     else
     {
-      std::cout << "Error: unknown argument '" << aParam << "'\n";
+      Message::SendFail() << "Syntax error: unknown argument '" << aParam << "'";
       return 1;
     }
   }
@@ -2686,7 +2722,6 @@ static int VDrawText (Draw_Interpretor& theDI,
 #include <TopoDS_Shape.hxx>
 #include <TopExp_Explorer.hxx>
 #include <TopAbs.hxx>
-#include <StdSelect_ShapeTypeFilter.hxx>
 #include <AIS_InteractiveObject.hxx>
 
 
@@ -2930,13 +2965,13 @@ static int VDrawSphere (Draw_Interpretor& /*di*/, Standard_Integer argc, const c
   Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
   if (aContextAIS.IsNull())
   {
-    std::cout << "Call vinit before!\n";
+    Message::SendFail ("Error: no active viewer");
     return 1;
   }
   else if (argc < 3)
   {
-    std::cout << "Use: " << argv[0]
-              << " shapeName Fineness [X=0.0 Y=0.0 Z=0.0] [Radius=100.0] [ToShowEdges=0]\n";
+    Message::SendFail() << "Syntax error: wrong number of arguments.\n"
+                        << "Use: " << argv[0] << " shapeName Fineness [X=0.0 Y=0.0 Z=0.0] [Radius=100.0] [ToShowEdges=0]";
     return 1;
   }
 
@@ -3079,7 +3114,7 @@ static int VComputeHLR (Draw_Interpretor& ,
       }
       else
       {
-        std::cout << "Syntax error: unknown algo type '" << anArgNext << "'\n";
+        Message::SendFail() << "Syntax error: unknown algo type '" << anArgNext << "'";
         return 1;
       }
     }
@@ -3121,7 +3156,7 @@ static int VComputeHLR (Draw_Interpretor& ,
         BRepTools::Read (aSh, theArgVec[anArgIter], aBrepBuilder);
         if (aSh.IsNull())
         {
-          std::cout << "Syntax error: no shape with name " << theArgVec[anArgIter] << " found\n";
+          Message::SendFail() << "Syntax error: no shape with name " << theArgVec[anArgIter] << " found";
           return 1;
         }
       }
@@ -3145,7 +3180,7 @@ static int VComputeHLR (Draw_Interpretor& ,
     }
     else
     {
-      std::cout << "Syntax error: unknown argument '" << theArgVec[anArgIter] << "'\n";
+      Message::SendFail() << "Syntax error: unknown argument '" << theArgVec[anArgIter] << "'";
       return 1;
     }
   }
@@ -3153,7 +3188,7 @@ static int VComputeHLR (Draw_Interpretor& ,
   if (aHlrName.IsEmpty() || aSh.IsNull()
    || (ViewerTest::GetAISContext().IsNull() && hasViewDirArg))
   {
-    std::cout << "Syntax error: wrong number of arguments\n";
+    Message::SendFail ("Syntax error: wrong number of arguments");
     return 1;
   }
 
@@ -3436,7 +3471,7 @@ Standard_Boolean MyPArrayObject::Init (Graphic3d_TypeOfPrimitiveArray thePrimTyp
     || !myPArray->Attributes()->IsMutable()
     || (!myPArray->Indices().IsNull() && !myPArray->Indices()->IsMutable()))
     {
-      std::cout << "Syntax error: array cannot be patched\n";
+      Message::SendFail ("Syntax error: array cannot be patched");
       return Standard_False;
     }
 
@@ -3538,7 +3573,7 @@ Standard_Boolean MyPArrayObject::Init (Graphic3d_TypeOfPrimitiveArray thePrimTyp
     // unknown command
     else
     {
-      std::cout << "Syntax error: unknown argument '" << theDesc->Value(anArgIndex) << "'\n";
+      Message::SendFail() << "Syntax error: unknown argument '" << theDesc->Value(anArgIndex) << "'";
       return Standard_False;
     }
   }
@@ -3674,12 +3709,12 @@ static int VDrawPArray (Draw_Interpretor& di, Standard_Integer argc, const char*
   Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
   if (aContextAIS.IsNull())
   {
-    std::cout << "Error: no active Viewer\n";
+    Message::SendFail ("Error: no active Viewer");
     return 1;
   }
   else if (argc < 3)
   {
-    std::cout << "Syntax error: wrong number of arguments\n";
+    Message::SendFail ("Syntax error: wrong number of arguments");
     return 1;
   }
 
@@ -3696,12 +3731,12 @@ static int VDrawPArray (Draw_Interpretor& di, Standard_Integer argc, const char*
     Handle(Graphic3d_ArrayOfPrimitives) aTris = StdPrs_ShadedShape::FillTriangles (aShape);
     if (aShape.IsNull())
     {
-      std::cout << "Syntax error: shape '" << aShapeName << "' is not found\n";
+      Message::SendFail() << "Syntax error: shape '" << aShapeName << "' is not found";
       return 1;
     }
     else if (aTris.IsNull())
     {
-      std::cout << "Syntax error: shape '" << aShapeName << "' is not triangulated\n";
+      Message::SendFail() << "Syntax error: shape '" << aShapeName << "' is not triangulated";
       return 1;
     }
 
@@ -3725,7 +3760,7 @@ static int VDrawPArray (Draw_Interpretor& di, Standard_Integer argc, const char*
     }
     if (aPObject.IsNull())
     {
-      std::cout << "Syntax error: object '" << aName << "' cannot be found\n";
+      Message::SendFail() << "Syntax error: object '" << aName << "' cannot be found";
       return 1;
     }
   }
@@ -3771,7 +3806,7 @@ static int VDrawPArray (Draw_Interpretor& di, Standard_Integer argc, const char*
   }
   if (aPrimType == Graphic3d_TOPA_UNDEFINED)
   {
-    std::cout << "Syntax error: unexpected type of primitives array\n";
+    Message::SendFail ("Syntax error: unexpected type of primitives array");
     return 1;
   }
 
@@ -3871,7 +3906,7 @@ static Standard_Integer VSetLocation (Draw_Interpretor& theDI,
   ViewerTest_AutoUpdater anUpdateTool (aContext, ViewerTest::CurrentView());
   if (aContext.IsNull())
   {
-    std::cout << "Error: no active view!\n";
+    Message::SendFail ("Error: no active viewer");
     return 1;
   }
 
@@ -3893,7 +3928,7 @@ static Standard_Integer VSetLocation (Draw_Interpretor& theDI,
       GetMapOfAIS().Find2 (aName, anObj);
       if (anObj.IsNull())
       {
-        std::cout << "Error: object '" << aName << "' is not displayed!\n";
+        Message::SendFail() << "Error: object '" << aName << "' is not displayed";
         return 1;
       }
     }
@@ -3907,7 +3942,7 @@ static Standard_Integer VSetLocation (Draw_Interpretor& theDI,
     {
       if (anArgIter + 1 >= theArgNb)
       {
-        std::cout << "Syntax error at '" << anArg << "'\n";
+        Message::SendFail() << "Syntax error at '" << anArg << "'";
         return 1;
       }
 
@@ -3916,7 +3951,7 @@ static Standard_Integer VSetLocation (Draw_Interpretor& theDI,
       GetMapOfAIS().Find2 (aName2, anObj2);
       if (anObj2.IsNull())
       {
-        std::cout << "Error: object '" << aName2 << "' is not displayed!\n";
+        Message::SendFail() << "Error: object '" << aName2 << "' is not displayed";
         return 1;
       }
 
@@ -3928,7 +3963,7 @@ static Standard_Integer VSetLocation (Draw_Interpretor& theDI,
       toPrintInfo = Standard_False;
       if (anArgIter + 7 >= theArgNb)
       {
-        std::cout << "Syntax error at '" << anArg << "'\n";
+        Message::SendFail() << "Syntax error at '" << anArg << "'";
         return 1;
       }
 
@@ -3953,7 +3988,7 @@ static Standard_Integer VSetLocation (Draw_Interpretor& theDI,
       anArgIter += aNbParsed;
       if (aNbParsed == 0)
       {
-        std::cout << "Syntax error at '" << anArg << "'\n";
+        Message::SendFail() << "Syntax error at '" << anArg << "'";
         return 1;
       }
 
@@ -4017,7 +4052,7 @@ static Standard_Integer VSetLocation (Draw_Interpretor& theDI,
       {
         if (anArg == "-setscale")
         {
-          std::cout << "Syntax error at '" << anArg << "'\n";
+          Message::SendFail() << "Syntax error at '" << anArg << "'";
           return 1;
         }
 
@@ -4061,7 +4096,7 @@ static Standard_Integer VSetLocation (Draw_Interpretor& theDI,
       toPrintInfo = Standard_False;
       if (anArgIter + 6 >= theArgNb)
       {
-        std::cout << "Syntax error at '" << anArg << "'\n";
+        Message::SendFail() << "Syntax error at '" << anArg << "'";
         return 1;
       }
 
@@ -4112,7 +4147,7 @@ static Standard_Integer VSetLocation (Draw_Interpretor& theDI,
         }
         else if (anArg == "-setrotation")
         {
-          std::cout << "Syntax error at '" << anArg << "'\n";
+          Message::SendFail() << "Syntax error at '" << anArg << "'";
           return 1;
         }
       }
@@ -4137,7 +4172,7 @@ static Standard_Integer VSetLocation (Draw_Interpretor& theDI,
       }
       else if (anArg == "-setlocation")
       {
-        std::cout << "Syntax error at '" << anArg << "'\n";
+        Message::SendFail() << "Syntax error at '" << anArg << "'";
         return 1;
       }
 
@@ -4153,7 +4188,7 @@ static Standard_Integer VSetLocation (Draw_Interpretor& theDI,
       Standard_Integer aNbParsed = parseTranslationVec (theArgNb - anArgIter, theArgVec + anArgIter, aLocVec);
       if (aNbParsed == 0)
       {
-        std::cout << "Syntax error at '" << anArg << "'\n";
+        Message::SendFail() << "Syntax error at '" << anArg << "'";
         return 1;
       }
       anArgIter = anArgIter + aNbParsed - 1;
@@ -4165,14 +4200,14 @@ static Standard_Integer VSetLocation (Draw_Interpretor& theDI,
     }
     else
     {
-      std::cout << "Error: unknown argument '" << anArg << "'\n";
+      Message::SendFail() << "Error: unknown argument '" << anArg << "'";
       return 1;
     }
   }
 
   if (anObj.IsNull())
   {
-    std::cout << "Syntax error - wrong number of arguments\n";
+    Message::SendFail ("Syntax error - wrong number of arguments");
     return 1;
   }
   else if (!toPrintInfo)
@@ -4219,6 +4254,10 @@ static Handle(AIS_InteractiveObject) findConnectedObject (const TCollection_Asci
     aConnected->SetDisplayMode (aPrs->DisplayMode());
   }
   aConnected->Connect (aPrs, aPrs->LocalTransformationGeom());
+  if (!aPrs->TransformPersistence().IsNull())
+  {
+    aConnected->SetTransformPersistence (aPrs->TransformPersistence());
+  }
   ViewerTest::Display (theName, aConnected, false);
   return aConnected;
 }
@@ -4234,12 +4273,12 @@ static Standard_Integer VConnect (Draw_Interpretor& /*di*/,
   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
   if (aContext.IsNull())
   {
-    std::cout << "Error: no active view.\n";
+    Message::SendFail ("Error: no active viewer");
     return 1;
   }
   if (argc < 6)
   {
-    std::cout << "Syntax error: expect at least 5 arguments\n";
+    Message::SendFail ("Syntax error: expect at least 5 arguments");
     return 1;
   }
 
@@ -4264,7 +4303,7 @@ static Standard_Integer VConnect (Draw_Interpretor& /*di*/,
     Handle(AIS_InteractiveObject) anObject;
     if (aName.IsEqual (anOriginObjectName))
     {
-      std::cout << "Syntax error: equal names for connected objects\n";
+      Message::SendFail ("Syntax error: equal names for connected objects");
       continue;
     }
 
@@ -4274,7 +4313,7 @@ static Standard_Integer VConnect (Draw_Interpretor& /*di*/,
       TopoDS_Shape aTDShape = DBRep::Get (anOriginObjectName);
       if (aTDShape.IsNull())
       {
-        std::cout << "Syntax error: object " << anOriginObjectName << " doesn't exist\n";
+        Message::SendFail() << "Syntax error: object " << anOriginObjectName << " doesn't exist";
         return 1;
       }
       Handle(AIS_Shape) aShapePrs = new AIS_Shape (aTDShape);
@@ -4295,7 +4334,7 @@ static Standard_Integer VConnect (Draw_Interpretor& /*di*/,
   }
   if (aMultiConObject.IsNull())
   {
-    std::cout << "Syntax error: can't connect input objects\n";
+    Message::SendFail ("Syntax error: can't connect input objects");
     return 1;
   }
 
@@ -4325,12 +4364,12 @@ static Standard_Integer VConnectTo (Draw_Interpretor& /*di*/,
   ViewerTest_AutoUpdater anUpdateTool (aContext, ViewerTest::CurrentView());
   if (aContext.IsNull())
   {
-    std::cout << "Error: no active view.\n";
+    Message::SendFail ("Error: no active viewer");
     return 1;
   }
   if (argc != 6 && argc != 7)
   {
-    std::cout << "Syntax error: expect at least 5 arguments\n";
+    Message::SendFail ("Syntax error: expect at least 5 arguments");
     return 1;
   }
 
@@ -4341,7 +4380,7 @@ static Standard_Integer VConnectTo (Draw_Interpretor& /*di*/,
   TCollection_AsciiString anOriginObjectName(argv[5]);
   if (aName.IsEqual (anOriginObjectName))
   {
-    std::cout << "Syntax error: equal names for connected objects\n";
+    Message::SendFail ("Syntax error: equal names for connected objects");
     return 1;
   }
   anOriginObject = findConnectedObject (anOriginObjectName);
@@ -4350,7 +4389,7 @@ static Standard_Integer VConnectTo (Draw_Interpretor& /*di*/,
     TopoDS_Shape aTDShape = DBRep::Get (anOriginObjectName);
     if (aTDShape.IsNull())
     {
-      std::cout << "Syntax error: object " << anOriginObjectName << " doesn't exist\n";
+      Message::SendFail() << "Syntax error: object " << anOriginObjectName << " doesn't exist";
       return 1;
     }
 
@@ -4390,7 +4429,7 @@ static Standard_Integer VConnectTo (Draw_Interpretor& /*di*/,
 
     if (!anUpdateTool.parseRedrawMode (anArg))
     {
-      std::cout << "Syntax error: unknown argument '" << anArg << "'.\n";
+      Message::SendFail() << "Syntax error: unknown argument '" << anArg << "'";
       return 1;
     }
   }
@@ -4410,13 +4449,13 @@ static Standard_Integer VDisconnect (Draw_Interpretor& di,
   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
   if (aContext.IsNull())
   {
-    std::cout << argv[0] << "ERROR : use 'vinit' command before \n";
+    Message::SendFail( "Error: no active viewer");
     return 1;
   }
   
   if (argc != 3)
   {
-    std::cout << "ERROR : Usage : " << argv[0] << " name object\n";
+    Message::SendFail() << "Syntax error: wrong number of arguments.\nUsage: " << argv[0] << " name object";
     return 1;
   }
 
@@ -4429,7 +4468,7 @@ static Standard_Integer VDisconnect (Draw_Interpretor& di,
   Handle(AIS_MultipleConnectedInteractive) anAssembly;
   if (!aMap.IsBound2 (aName) )
   {
-    std::cout << "Use 'vdisplay' before\n";
+    Message::SendFail ("Error: no active viewer");
     return 1;
   }
 
@@ -4459,7 +4498,7 @@ static Standard_Integer VDisconnect (Draw_Interpretor& di,
     }
     else
     {
-      std::cout << "Use 'vdisplay' before\n";
+      Message::SendFail ("Error: no active viewer");
       return 1;
     }    
   }
@@ -4480,13 +4519,13 @@ static Standard_Integer VAddConnected (Draw_Interpretor& ,
   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
   if (aContext.IsNull())
   {
-    std::cout << "Error: no active view\n";
+    Message::SendFail ("Error: no active viewer");
     return 1;
   }
 
   if (argc != 6)
   {
-    std::cout << "Syntax error: expect 5 arguments\n";
+    Message::SendFail ("Syntax error: expect 5 arguments");
     return 1;
   }
 
@@ -4505,7 +4544,7 @@ static Standard_Integer VAddConnected (Draw_Interpretor& ,
     anAssembly = Handle(AIS_MultipleConnectedInteractive)::DownCast (aPrs);
     if (anAssembly.IsNull())
     {
-      std::cout << "Syntax error: '" << aName << "' is not an assembly\n";
+      Message::SendFail() << "Syntax error: '" << aName << "' is not an assembly";
       return 1;
     }
   }
@@ -4513,7 +4552,7 @@ static Standard_Integer VAddConnected (Draw_Interpretor& ,
   Handle(AIS_InteractiveObject) anIObj = findConnectedObject (anObjectName);
   if (anIObj.IsNull())
   {
-    std::cout << "Syntax error: '" << anObjectName << "' is not displayed\n";
+    Message::SendFail() << "Syntax error: '" << anObjectName << "' is not displayed";
     return 1;
   }
 
@@ -4538,13 +4577,13 @@ static Standard_Integer VListConnected (Draw_Interpretor& /*di*/,
   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
   if (aContext.IsNull())
   {
-    std::cout << argv[0] << "ERROR : use 'vinit' command before \n";
+    Message::SendFail ("Error: no active viewer");
     return 1;
   }
   
   if (argc != 2)
   {
-    std::cout << "ERROR : Usage : " << argv[0] << " name\n";
+    Message::SendFail() << "Syntax error: wrong number of arguments.\nUsage: " << argv[0] << " name";
     return 1;
   }
 
@@ -4555,14 +4594,14 @@ static Standard_Integer VListConnected (Draw_Interpretor& /*di*/,
   Handle(AIS_MultipleConnectedInteractive) anAssembly;
   if (!aMap.IsBound2 (aName) )
   {
-    std::cout << "Use 'vdisplay' before\n";
+    Message::SendFail ("Error: no active viewer");
     return 1;
   }
 
   anAssembly = Handle(AIS_MultipleConnectedInteractive)::DownCast (aMap.Find2 (aName));
   if (anAssembly.IsNull())
   {
-    std::cout << "Not an assembly\n";
+    Message::SendFail ("Syntax error: Not an assembly");
     return 1;
   }
 
@@ -4604,7 +4643,7 @@ static Standard_Integer VChild (Draw_Interpretor& ,
   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
   if (aContext.IsNull())
   {
-    std::cout << "Error: no active view\n";
+    Message::SendFail ("Error: no active viewer");
     return 1;
   }
 
@@ -4662,7 +4701,7 @@ static Standard_Integer VChild (Draw_Interpretor& ,
     Handle(AIS_InteractiveObject) aChild;
     if (!GetMapOfAIS().Find2 (theArgVec[anArgIter], aChild))
     {
-      std::cout << "Syntax error: object '" << theArgVec[anArgIter] << "' is not found\n";
+      Message::SendFail() << "Syntax error: object '" << theArgVec[anArgIter] << "' is not found";
       return 1;
     }
 
@@ -4672,7 +4711,7 @@ static Standard_Integer VChild (Draw_Interpretor& ,
     }
     else if (toAdd == -1)
     {
-      std::cout << "Syntax error: no action specified\n";
+      Message::SendFail ("Syntax error: no action specified");
       return 1;
     }
     else
@@ -4696,7 +4735,7 @@ static Standard_Integer VChild (Draw_Interpretor& ,
   }
   if (!hasActions)
   {
-    std::cout << "Syntax error: not enough arguments\n";
+    Message::SendFail ("Syntax error: not enough arguments");
     return 1;
   }
   return 0;
@@ -4713,13 +4752,13 @@ static Standard_Integer VParent(Draw_Interpretor&,
   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
   if (aContext.IsNull())
   {
-    std::cout << "Error: no active view\n";
+    Message::SendFail ("Error: no active viewer");
     return 1;
   }
 
   if (theNbArgs < 2 )
   {
-    std::cout << theArgVec[0] << " error: expect at least 2 arguments\n";
+    Message::SendFail ("Syntax error: wrong number of arguments");
     return 1;
   }
 
@@ -4727,7 +4766,7 @@ static Standard_Integer VParent(Draw_Interpretor&,
   Handle(AIS_InteractiveObject) aParent;
   if (!GetMapOfAIS().Find2(theArgVec[1], aParent))
   {
-    std::cout << "Syntax error: object '" << theArgVec[1] << "' is not found\n";
+    Message::SendFail() << "Syntax error: object '" << theArgVec[1] << "' is not found";
     return 1;
   }
 
@@ -4754,7 +4793,7 @@ static Standard_Integer VSetSelectionMode (Draw_Interpretor& /*di*/,
   Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
   if (anAISContext.IsNull())
   {
-    std::cout << "Error: no active Viewer\n";
+    Message::SendFail ("Error: no active Viewer");
     return 1;
   }
 
@@ -4793,7 +4832,7 @@ static Standard_Integer VSetSelectionMode (Draw_Interpretor& /*di*/,
   if (anObjNames.Size() < 2
   || !ViewerTest::ParseOnOff (anObjNames.Last().ToCString(), toTurnOn))
   {
-    std::cout << "Syntax error: wrong number of arguments\n";
+    Message::SendFail ("Syntax error: wrong number of arguments");
     return 1;
   }
   anObjNames.Remove (anObjNames.Upper());
@@ -4811,7 +4850,7 @@ static Standard_Integer VSetSelectionMode (Draw_Interpretor& /*di*/,
     }
     else
     {
-      std::cout << "Syntax error: unknown selection mode '" << aSelModeString  << "'\n";
+      Message::SendFail() << "Syntax error: unknown selection mode '" << aSelModeString  << "'";
       return 1;
     }
   }
@@ -4824,7 +4863,7 @@ static Standard_Integer VSetSelectionMode (Draw_Interpretor& /*di*/,
     GetMapOfAIS().Find2 (aNameIO, anIO);
     if (anIO.IsNull())
     {
-      std::cout << "Syntax error: undefined presentable object " << aNameIO << "\n";
+      Message::SendFail() << "Syntax error: undefined presentable object " << aNameIO;
       return 1;
     }
     aTargetIOs.Append (anIO);
@@ -4856,7 +4895,7 @@ static Standard_Integer VSelectionNext(Draw_Interpretor& /*theDI*/,
 
   if (anAISContext.IsNull())
   {
-    std::cerr << "Call vinit before!" << std::endl;
+    Message::SendFail ("Error: no active viewer");
     return 1;
   }
 
@@ -4878,7 +4917,7 @@ static Standard_Integer VSelectionPrevious(Draw_Interpretor& /*theDI*/,
 
   if (anAISContext.IsNull())
   {
-    std::cerr << "Call vinit before!" << std::endl;
+    Message::SendFail ("Error: no active viewer");
     return 1;
   }
 
@@ -4908,7 +4947,7 @@ static Standard_Integer VTriangle (Draw_Interpretor& /*di*/,
 
   if (argc != (2 + aPrims->VertexNumberAllocated()))
   {
-    std::cout << "Syntax error: wrong number of arguments\n";
+    Message::SendFail ("Syntax error: wrong number of arguments");
     return 1;
   }
 
@@ -4926,7 +4965,7 @@ static Standard_Integer VTriangle (Draw_Interpretor& /*di*/,
       if (aShape.IsNull()
        || aShape.ShapeType() != TopAbs_VERTEX)
       {
-        std::cout << "Syntax error: argument " << aName << " must be a point\n";
+        Message::SendFail() << "Syntax error: argument " << aName << " must be a point";
         return 1;
       }
       aPnts[aPntIter] = BRep_Tool::Pnt (TopoDS::Vertex (aShape));
@@ -4936,7 +4975,7 @@ static Standard_Integer VTriangle (Draw_Interpretor& /*di*/,
     {
       if (aPnts[aPnt2Iter].IsEqual (aPnts[aPntIter], Precision::Confusion()))
       {
-        std::cout << "Syntax error: points should not be equal\n";
+        Message::SendFail ("Syntax error: points should not be equal");
         return 1;
       }
     }
@@ -4966,7 +5005,7 @@ static Standard_Integer VObjZLayer (Draw_Interpretor& di,
   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
   if (aContext.IsNull())
   {
-    di << argv[0] << "Call 'vinit' before!\n";
+    Message::SendFail ("Error: no active viewer");
     return 1;
   }
 
@@ -4992,7 +5031,7 @@ static Standard_Integer VObjZLayer (Draw_Interpretor& di,
   GetMapOfAIS().Find2 (aName, anInterObj);
   if (anInterObj.IsNull())
   {
-    std::cout << "Syntax error: object '" << aName << "' is not displayed\n";
+    Message::SendFail() << "Syntax error: object '" << aName << "' is not displayed";
     return 1;
   }
 
@@ -5021,14 +5060,15 @@ static Standard_Integer VPolygonOffset(Draw_Interpretor& /*di*/,
   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
   if (aContext.IsNull())
   {
-    std::cout << argv[0] << " Call 'vinit' before!\n";
+    Message::SendFail ("Error: no active viewer");
     return 1;
   }
 
   if (argc > 2 && argc != 5)
   {
-    std::cout << "Usage : " << argv[0] << " [object [mode factor units]] - sets/gets polygon offset parameters for an object,"
-      "without arguments prints the default values" << std::endl;
+    Message::SendFail() << "Syntax error: wrong number of arguments.\n"
+                           "Usage: " << argv[0] << " [object [mode factor units]] - sets/gets polygon offset parameters for an object,"
+                           "without arguments prints the default values";
     return 1;
   }
 
@@ -5040,7 +5080,7 @@ static Standard_Integer VPolygonOffset(Draw_Interpretor& /*di*/,
     if (!GetMapOfAIS().Find2 (aName, anInterObj)
       || anInterObj.IsNull())
     {
-      std::cout << "Syntax error: object '" << aName << "' is not displayed\n";
+      Message::SendFail() << "Syntax error: object '" << aName << "' is not displayed";
       return 1;
     }
   }
@@ -5190,14 +5230,13 @@ static Standard_Integer VMarkersTest (Draw_Interpretor&,
   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
   if (aContext.IsNull())
   {
-    std::cerr << "Call 'vinit' before!\n";
+    Message::SendFail ("Error: no active viewer");
     return 1;
   }
 
   if (theArgNb < 5)
   {
-    std::cerr << "Usage :\n " << theArgVec[0]
-              << "name X Y Z [PointsOnSide=10] [MarkerType=0] [Scale=1.0] [FileName=ImageFile]\n";
+    Message::SendFail ("Syntax error: wrong number of arguments");
     return 1;
   }
 
@@ -5234,7 +5273,7 @@ static Standard_Integer VMarkersTest (Draw_Interpretor&,
     }
     else
     {
-      std::cerr << "Wrong argument: " << anArg << "\n";
+      Message::SendFail() << "Syntax error: wrong argument '" << anArg << "'";
       return 1;
     }
   }
@@ -5248,7 +5287,7 @@ static Standard_Integer VMarkersTest (Draw_Interpretor&,
     anImage = new Image_AlienPixMap();
     if (!anImage->Load (aFileName))
     {
-      std::cerr << "Could not load image from file '" << aFileName << "'!\n";
+      Message::SendFail() << "Error: could not load image from file '" << aFileName << "'!";
       return 1;
     }
     if (anImage->Format() == Image_Format_Gray)
@@ -5283,7 +5322,7 @@ static int TextToBRep (Draw_Interpretor& /*theDI*/,
   // Check arguments
   if (theArgNb < 3)
   {
-    std::cerr << "Error: " << theArgVec[0] << " - invalid syntax\n";
+    Message::SendFail() << "Error: " << theArgVec[0] << " - invalid syntax";
     return 1;
   }
 
@@ -5314,7 +5353,7 @@ static int TextToBRep (Draw_Interpretor& /*theDI*/,
     {
       if (anArgIt + 3 >= theArgNb)
       {
-        std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        Message::SendFail() << "Error: wrong number of values for parameter '" << aParam << "'";
         return 1;
       }
 
@@ -5326,7 +5365,7 @@ static int TextToBRep (Draw_Interpretor& /*theDI*/,
     {
       if (++anArgIt >= theArgNb)
       {
-        std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        Message::SendFail() << "Error: wrong number of values for parameter '" << aParam << "'";
         return 1;
       }
 
@@ -5346,7 +5385,7 @@ static int TextToBRep (Draw_Interpretor& /*theDI*/,
       }
       else
       {
-        std::cout << "Error: wrong syntax at '" << aParam.ToCString() << "'.\n";
+        Message::SendFail() << "Error: wrong syntax at '" << aParam << "'";
         return 1;
       }
     }
@@ -5354,7 +5393,7 @@ static int TextToBRep (Draw_Interpretor& /*theDI*/,
     {
       if (++anArgIt >= theArgNb)
       {
-        std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        Message::SendFail() << "Error: wrong number of values for parameter '" << aParam << "'";
         return 1;
       }
 
@@ -5378,7 +5417,7 @@ static int TextToBRep (Draw_Interpretor& /*theDI*/,
       }
       else
       {
-        std::cout << "Error: wrong syntax at '" << aParam.ToCString() << "'.\n";
+        Message::SendFail() << "Error: wrong syntax at '" << aParam << "'";
         return 1;
       }
     }
@@ -5386,7 +5425,7 @@ static int TextToBRep (Draw_Interpretor& /*theDI*/,
     {
       if (++anArgIt >= theArgNb)
       {
-        std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        Message::SendFail() << "Error: wrong number of values for parameter '" << aParam << "'";
         return 1;
       }
 
@@ -5396,7 +5435,7 @@ static int TextToBRep (Draw_Interpretor& /*theDI*/,
     {
       if (++anArgIt >= theArgNb)
       {
-        std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        Message::SendFail() << "Error: wrong number of values for parameter '" << aParam << "'";
         return 1;
       }
 
@@ -5404,7 +5443,7 @@ static int TextToBRep (Draw_Interpretor& /*theDI*/,
       anOption.LowerCase();
       if (!parseFontStyle (anOption, aFontAspect))
       {
-        std::cout << "Error: unknown font aspect '" << anOption << "'.\n";
+        Message::SendFail() << "Error: unknown font aspect '" << anOption << "'";
         return 1;
       }
     }
@@ -5412,7 +5451,7 @@ static int TextToBRep (Draw_Interpretor& /*theDI*/,
     {
       if (++anArgIt >= theArgNb)
       {
-        std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        Message::SendFail() << "Error: wrong number of values for parameter '" << aParam << "'";
         return 1;
       }
 
@@ -5428,7 +5467,7 @@ static int TextToBRep (Draw_Interpretor& /*theDI*/,
     {
       if (++anArgIt >= theArgNb)
       {
-        std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        Message::SendFail() << "Error: wrong number of values for parameter '" << aParam << "'";
         return 1;
       }
 
@@ -5438,7 +5477,7 @@ static int TextToBRep (Draw_Interpretor& /*theDI*/,
     {
       if (anArgIt + 6 >= theArgNb)
       {
-        std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        Message::SendFail() << "Error: wrong number of values for parameter '" << aParam << "'";
         return 1;
       }
 
@@ -5454,14 +5493,14 @@ static int TextToBRep (Draw_Interpretor& /*theDI*/,
     }
     else
     {
-      std::cerr << "Warning! Unknown argument '" << aParam << "'\n";
+      Message::SendFail() << "Warning! Unknown argument '" << aParam << "'";
     }
   }
 
   aFont.SetCompositeCurveMode (anIsCompositeCurve);
   if (!aFont.FindAndInit (aFontName.ToCString(), aFontAspect, aTextHeight, aStrictLevel))
   {
-    std::cout << "Error: unable to load Font\n";
+    Message::SendFail ("Error: unable to load Font");
     return 1;
   }
 
@@ -5587,7 +5626,7 @@ static int VFont (Draw_Interpretor& theDI,
       }
       else
       {
-        std::cout << "Error: font '" << aFontName << "' is not found!\n";
+        Message::SendFail() << "Error: font '" << aFontName << "' is not found";
       }
     }
     else if (anArgIter + 1 < theArgNb
@@ -5630,7 +5669,7 @@ static int VFont (Draw_Interpretor& theDI,
       Handle(Font_SystemFont) aFont = aMgr->CheckFont (aFontPath);
       if (aFont.IsNull())
       {
-        std::cerr << "Error: font '" << aFontPath << "' is not found!\n";
+        Message::SendFail() << "Error: font '" << aFontPath << "' is not found!";
         continue;
       }
 
@@ -5645,13 +5684,15 @@ static int VFont (Draw_Interpretor& theDI,
         Handle(Font_SystemFont) aFont2 = new Font_SystemFont (aName);
         if (aFontAspect != Font_FontAspect_UNDEFINED)
         {
-          aFont2->SetFontPath (aFontAspect, aFontPath);
+          aFont2->SetFontPath (aFontAspect, aFontPath, 0);
         }
         else
         {
           for (int anAspectIter = 0; anAspectIter < Font_FontAspect_NB; ++anAspectIter)
           {
-            aFont2->SetFontPath ((Font_FontAspect )anAspectIter, aFont->FontPath ((Font_FontAspect )anAspectIter));
+            aFont2->SetFontPath ((Font_FontAspect )anAspectIter,
+                                 aFont->FontPath ((Font_FontAspect )anAspectIter),
+                                 aFont->FontFaceId ((Font_FontAspect )anAspectIter));
           }
         }
         aFont = aFont2;
@@ -5689,7 +5730,7 @@ static int VFont (Draw_Interpretor& theDI,
     }
     else
     {
-      std::cerr << "Warning! Unknown argument '" << anArg << "'\n";
+      Message::SendFail() << "Warning! Unknown argument '" << anArg << "'";
     }
   }
 
@@ -5745,7 +5786,7 @@ static int VVertexMode (Draw_Interpretor& theDI,
   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
   if (aContext.IsNull())
   {
-    std::cout << "Error: no view available, call 'vinit' before!" << std::endl;
+    Message::SendFail ("Error: no active viewer");
     return 1;
   }
 
@@ -5763,8 +5804,8 @@ static int VVertexMode (Draw_Interpretor& theDI,
   {
     if (theArgNum == 2)
     {
-      std::cout << "Error: '-set' option not followed by the mode and optional object name(s)" << std::endl;
-      std::cout << "Type 'help vvertexmode' for usage hints" << std::endl;
+      Message::SendFail ("Error: '-set' option not followed by the mode and optional object name(s)\n"
+                         "Type 'help vvertexmode' for usage hints");
       return 1;
     }
 
@@ -5816,7 +5857,7 @@ static int VVertexMode (Draw_Interpretor& theDI,
   if (theArgNum > 2
   || !GetMapOfAIS().Find2 (aParam, anObject))
   {
-    std::cout << "Error: invalid number of arguments" << std::endl;
+    Message::SendFail ("Syntax error: invalid number of arguments");
     return 1;
   }
 
@@ -5837,7 +5878,7 @@ static Standard_Integer VPointCloud (Draw_Interpretor& theDI,
   Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
   if (anAISContext.IsNull())
   {
-    std::cerr << "Error: no active view!\n";
+    Message::SendFail ("Error: no active view!");
     return 1;
   }
 
@@ -5867,7 +5908,7 @@ static Standard_Integer VPointCloud (Draw_Interpretor& theDI,
     case 2  : aCmd = CloudForShape; break;
     case 7  : aCmd = CloudSphere; break;
     default :
-      std::cout << "Error: wrong number of arguments! See usage:\n";
+      Message::SendFail ("Syntax error: wrong number of arguments! See usage:");
       theDI.PrintHelp (theArgs[0]);
       return 1;
   }
@@ -5887,7 +5928,7 @@ static Standard_Integer VPointCloud (Draw_Interpretor& theDI,
     {
       if (isSetArgNorm && hasNormals)
       {
-        std::cout << "Error: wrong syntax - normals can not be enabled with colors at the same time\n";
+        Message::SendFail ("Syntax error: normals can not be enabled with colors at the same time");
         return 1;
       }
       toRandColors = Standard_True;
@@ -5898,7 +5939,7 @@ static Standard_Integer VPointCloud (Draw_Interpretor& theDI,
     {
       if (toRandColors)
       {
-        std::cout << "Error: wrong syntax - normals can not be enabled with colors at the same time\n";
+        Message::SendFail ("Syntax error: normals can not be enabled with colors at the same time");
         return 1;
       }
       isSetArgNorm = Standard_True;
@@ -5941,7 +5982,7 @@ static Standard_Integer VPointCloud (Draw_Interpretor& theDI,
 
     if (aShape.IsNull())
     {
-      std::cout << "Error: no shape with name '" << aShapeName << "' found\n";
+      Message::SendFail() << "Error: no shape with name '" << aShapeName << "' found";
       return 1;
     }
 
@@ -5959,7 +6000,7 @@ static Standard_Integer VPointCloud (Draw_Interpretor& theDI,
     }
     if (aNbPoints < 3)
     {
-      std::cout << "Error: shape should be triangulated!\n";
+      Message::SendFail ("Error: shape should be triangulated");
       return 1;
     }
 
@@ -6029,7 +6070,7 @@ static Standard_Integer VPointCloud (Draw_Interpretor& theDI,
     aDistribution.LowerCase();
     if ( aDistribution != "surface" && aDistribution != "volume" )
     {
-      std::cout << "Error: wrong arguments! See usage:\n";
+      Message::SendFail ("Syntax error: wrong arguments. See usage:");
       theDI.PrintHelp (theArgs[0]);
       return 1;
     }
@@ -6090,7 +6131,7 @@ static int VPriority (Draw_Interpretor& theDI,
   ViewerTest_AutoUpdater anUpdateTool (aContext, ViewerTest::CurrentView());
   if (aContext.IsNull())
   {
-    std::cout << "Error: no view available, call 'vinit' before!" << std::endl;
+    Message::SendFail ("Error: no active viewer");
     return 1;
   }
 
@@ -6103,8 +6144,8 @@ static int VPriority (Draw_Interpretor& theDI,
     --aNbArgs;
     if (aPriority < 0 || aPriority > 10)
     {
-      std::cout << "Error: the specified display priority value '" << aLastArg
-                << "' is outside the valid range [0..10]" << std::endl;
+      Message::SendFail() << "Syntax error: the specified display priority value '" << aLastArg
+                          << "' is outside the valid range [0..10]";
       return 1;
     }
   }
@@ -6115,7 +6156,7 @@ static int VPriority (Draw_Interpretor& theDI,
 
   if (aNbArgs < 2)
   {
-    std::cout << "Error: wrong number of arguments! See usage:\n";
+    Message::SendFail ("Syntax error: wrong number of arguments! See usage:");
     theDI.PrintHelp (theArgs[0]);
     return 1;
   }
@@ -6132,7 +6173,7 @@ static int VPriority (Draw_Interpretor& theDI,
     GetMapOfAIS().Find2 (aName, anIObj);
     if (anIObj.IsNull())
     {
-      std::cout << "Error: the object '" << theArgs[1] << "' is not displayed" << std::endl;
+      Message::SendFail() << "Error: the object '" << theArgs[1] << "' is not displayed";
       return 1;
     }
 
@@ -6231,12 +6272,12 @@ static int VNormals (Draw_Interpretor& theDI,
   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
   if (aContext.IsNull())
   {
-    std::cout << "Error: no view available, call 'vinit' before!\n";
+    Message::SendFail ("Error: no active viewer");
     return 1;
   }
   else if (theArgNum < 2)
   {
-    std::cout << "Error: wrong number of arguments! See usage:\n";
+    Message::SendFail ("Syntax error: wrong number of arguments. See usage:");
     theDI.PrintHelp (theArgs[0]);
     return 1;
   }
@@ -6247,7 +6288,7 @@ static int VNormals (Draw_Interpretor& theDI,
   Standard_Boolean isOn = Standard_True;
   if (aShape.IsNull())
   {
-    std::cout << "Error: shape with name '" << aShapeName << "' is not found\n";
+    Message::SendFail() << "Error: shape with name '" << aShapeName << "' is not found";
     return 1;
   }
 
@@ -6283,7 +6324,7 @@ static int VNormals (Draw_Interpretor& theDI,
       aLength = anArgIter < theArgNum ? Draw::Atof (theArgs[anArgIter]) : 0.0;
       if (Abs (aLength) <= gp::Resolution())
       {
-        std::cout << "Syntax error: length should not be zero\n";
+        Message::SendFail ("Syntax error: length should not be zero");
         return 1;
       }
     }
@@ -6304,7 +6345,7 @@ static int VNormals (Draw_Interpretor& theDI,
       aNbAlongU = anArgIter < theArgNum ? Draw::Atoi (theArgs[anArgIter]) : 0;
       if (aNbAlongU < 1)
       {
-        std::cout << "Syntax error: NbAlongU should be >=1\n";
+        Message::SendFail ("Syntax error: NbAlongU should be >=1");
         return 1;
       }
     }
@@ -6315,7 +6356,7 @@ static int VNormals (Draw_Interpretor& theDI,
       aNbAlongV = anArgIter < theArgNum ? Draw::Atoi (theArgs[anArgIter]) : 0;
       if (aNbAlongV < 1)
       {
-        std::cout << "Syntax error: NbAlongV should be >=1\n";
+        Message::SendFail ("Syntax error: NbAlongV should be >=1");
         return 1;
       }
     }
@@ -6327,13 +6368,13 @@ static int VNormals (Draw_Interpretor& theDI,
       aNbAlongV = aNbAlongU;
       if (aNbAlongU < 1)
       {
-        std::cout << "Syntax error: NbAlong should be >=1\n";
+        Message::SendFail ("Syntax error: NbAlong should be >=1");
         return 1;
       }
     }
     else
     {
-      std::cout << "Syntax error: unknwon argument '" << aParam << "'\n";
+      Message::SendFail() << "Syntax error: unknown argument '" << aParam << "'";
       return 1;
     }
   }
@@ -6445,9 +6486,11 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
     __FILE__,VAxisBuilder,group);
 
   theCommands.Add("vpoint",
-    "vpoint  PointName [Xa] [Ya] [Za] "
-    "\n\t\t: Creates a point from coordinates. If the values are not defined,"
-    "\n\t\t: a point is created by interactive selection of a vertice or an edge (in the center of the edge).",
+    "vpoint name [X Y [Z]] [-2d] [-nosel]"
+    "\n\t\t: Creates a point from coordinates."
+    "\n\t\t: If the values are not defined, a point is created from selected vertex or edge (center)."
+    "\n\t\t:  -2d    defines on-screen 2D point from top-left window corner"
+    "\n\t\t:  -nosel creates non-selectable presentation",
     __FILE__,VPointBuilder,group);
 
   theCommands.Add("vplane",
@@ -6514,6 +6557,7 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
                    "\n\t\t: [-noupdate]"
                    "\n\t\t: [-plane NormX NormY NormZ DirX DirY DirZ]"
                    "\n\t\t: [-flipping]"
+                   "\n\t\t: [-ownanchor {0|1}=1]"
                    "\n\t\t: Display text label at specified position.",
     __FILE__, VDrawText, group);