0026641: Visualization, TKOpenGl - handle correctly transformation persistence within...
[occt.git] / src / ViewerTest / ViewerTest_ObjectCommands.cxx
index 55b7d0c..3ff3030 100644 (file)
 #include <DBRep.hxx>
 
 #include <Font_BRepFont.hxx>
+#include <Font_BRepTextBuilder.hxx>
 #include <Font_FontMgr.hxx>
 #include <OSD_Chronometer.hxx>
 #include <TCollection_AsciiString.hxx>
-#include <Visual3d_View.hxx>
 #include <V3d_Viewer.hxx>
 #include <V3d_View.hxx>
 #include <V3d.hxx>
 #include <BRepExtrema_ExtPC.hxx>
 #include <BRepExtrema_ExtPF.hxx>
 
+#include <Prs3d_DatumAspect.hxx>
 #include <Prs3d_Drawer.hxx>
 #include <Prs3d_VertexDrawMode.hxx>
 #include <Prs3d_LineAspect.hxx>
 #include <Prs3d_PointAspect.hxx>
+#include <Prs3d_TextAspect.hxx>
 
 #include <Image_AlienPixMap.hxx>
 #include <TColStd_HArray1OfAsciiString.hxx>
+#include <TColStd_HSequenceOfAsciiString.hxx>
 
-#ifdef _WIN32
+#if defined(_MSC_VER)
 # define _CRT_SECURE_NO_DEPRECATE
 # pragma warning (disable:4996)
 #endif
@@ -162,7 +165,7 @@ static int VTrihedron2D (Draw_Interpretor& di, Standard_Integer argc, const char
 
 {
   // Verification des arguments
-  if ( argc!=2) {di<<argv[0]<<" error"<<"\n"; return 1;}
+  if ( argc!=2) {di<<argv[0]<<" error\n"; return 1;}
 
   // Declarations
   Standard_Integer myCurrentIndex;
@@ -173,7 +176,7 @@ static int VTrihedron2D (Draw_Interpretor& di, Standard_Integer argc, const char
   myCurrentIndex=TheAISContext()->IndexOfCurrentLocal();
   // On active les modes de selections faces.
   TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4) );
-  di<<" Select a face ."<<"\n";
+  di<<" Select a face .\n";
 
   // Boucle d'attente waitpick.
   Standard_Integer argccc = 5;
@@ -240,47 +243,126 @@ static int VTrihedron2D (Draw_Interpretor& di, Standard_Integer argc, const char
 //Draw arg : vtrihedron  name  [Xo] [Yo] [Zo] [Zu] [Zv] [Zw] [Xu] [Xv] [Xw]
 //==============================================================================
 
-static int VTrihedron (Draw_Interpretor& theDi,
+static int VTrihedron (Draw_Interpretor& /*theDi*/,
                        Standard_Integer  theArgsNb,
                        const char**      theArgVec)
 {
-  if (theArgsNb != 2 && theArgsNb != 5 && theArgsNb != 11)
+  if (theArgsNb < 2 || theArgsNb > 11)
   {
-    theDi << theArgVec[0] << " Syntax error\n";
+    std::cout << theArgVec[0] << " syntax error\n";
     return 1;
   }
 
+  // Parse parameters
+  NCollection_DataMap<TCollection_AsciiString, Handle(TColStd_HSequenceOfAsciiString)> aMapOfArgs;
+  TCollection_AsciiString aParseKey;
+  for (Standard_Integer anArgIt = 1; anArgIt < theArgsNb; ++anArgIt)
+  {
+    TCollection_AsciiString anArg (theArgVec [anArgIt]);
+
+    if (anArg.Value (1) == '-' && !anArg.IsRealValue())
+    {
+      aParseKey = anArg;
+      aParseKey.Remove (1);
+      aParseKey.LowerCase();
+      aMapOfArgs.Bind (aParseKey, new TColStd_HSequenceOfAsciiString);
+      continue;
+    }
+
+    if (aParseKey.IsEmpty())
+    {
+      continue;
+    }
+
+    aMapOfArgs(aParseKey)->Append (anArg);
+  }
+
+  // Check parameters
+  if ( (aMapOfArgs.IsBound ("xaxis") && !aMapOfArgs.IsBound ("zaxis"))
+    || (!aMapOfArgs.IsBound ("xaxis") && aMapOfArgs.IsBound ("zaxis")) )
+  {
+    std::cout << theArgVec[0] << " error: -xaxis and -yaxis parameters are to set together.\n";
+    return 1;
+  }
+
+  for (NCollection_DataMap<TCollection_AsciiString, Handle(TColStd_HSequenceOfAsciiString)>::Iterator aMapIt (aMapOfArgs);
+       aMapIt.More(); aMapIt.Next())
+  {
+    const TCollection_AsciiString& aKey = aMapIt.Key();
+    const Handle(TColStd_HSequenceOfAsciiString)& anArgs = aMapIt.Value();
+
+    // Bool key, without arguments
+    if (aKey.IsEqual ("hidelabels") && anArgs->IsEmpty())
+    {
+      continue;
+    }
+
+    if ( (aKey.IsEqual ("xaxis") || aKey.IsEqual ("zaxis") || aKey.IsEqual ("origin")) && anArgs->Length() == 3
+      && anArgs->Value(1).IsRealValue() && anArgs->Value(2).IsRealValue() && anArgs->Value(3).IsRealValue() )
+    {
+      continue;
+    }
+  }
+
+  // Process parameters
   gp_Pnt anOrigin (0.0, 0.0, 0.0);
   gp_Dir aDirZ = gp::DZ();
   gp_Dir aDirX = gp::DX();
-  Standard_Integer anArgIter = 2; // 1st is an IO name
-  if (anArgIter < theArgsNb)
+
+  Handle(TColStd_HSequenceOfAsciiString) aValues;
+
+  if (aMapOfArgs.Find ("origin", aValues))
   {
-    anOrigin.SetX (Draw::Atof (theArgVec[anArgIter++]));
-    anOrigin.SetY (Draw::Atof (theArgVec[anArgIter++]));
-    anOrigin.SetZ (Draw::Atof (theArgVec[anArgIter++]));
-    if (anArgIter < theArgsNb)
-    {
-      Standard_Real aX = Draw::Atof (theArgVec[anArgIter++]);
-      Standard_Real aY = Draw::Atof (theArgVec[anArgIter++]);
-      Standard_Real aZ = Draw::Atof (theArgVec[anArgIter++]);
-      aDirZ.SetCoord (aX, aY, aZ);
+    anOrigin.SetX (aValues->Value(1).RealValue());
+    anOrigin.SetY (aValues->Value(2).RealValue());
+    anOrigin.SetZ (aValues->Value(3).RealValue());
+  }
 
-      aX = Draw::Atof (theArgVec[anArgIter++]);
-      aY = Draw::Atof (theArgVec[anArgIter++]);
-      aZ = Draw::Atof (theArgVec[anArgIter++]);
-      aDirX.SetCoord (aX, aY, aZ);
-    }
+  Handle(TColStd_HSequenceOfAsciiString) aValues2;
+  if (aMapOfArgs.Find ("xaxis", aValues) && aMapOfArgs.Find ("zaxis", aValues2))
+  {
+    Standard_Real aX = aValues->Value(1).RealValue();
+    Standard_Real aY = aValues->Value(2).RealValue();
+    Standard_Real aZ = aValues->Value(3).RealValue();
+    aDirX.SetCoord (aX, aY, aZ);
+
+    aX = aValues->Value(1).RealValue();
+    aY = aValues->Value(2).RealValue();
+    aZ = aValues->Value(3).RealValue();
+    aDirZ.SetCoord (aX, aY, aZ);
   }
 
   if (!aDirZ.IsNormal (aDirX, M_PI / 180.0))
   {
-    theDi << theArgVec[0] << " - VectorX is not normal to VectorZ\n";
+    std::cout << theArgVec[0] << " error - VectorX is not normal to VectorZ\n";
     return 1;
   }
 
   Handle(Geom_Axis2Placement) aPlacement = new Geom_Axis2Placement (anOrigin, aDirZ, aDirX);
   Handle(AIS_Trihedron) aShape = new AIS_Trihedron (aPlacement);
+
+  if (aMapOfArgs.Find ("hidelabels", aValues))
+  {
+    const Handle(Prs3d_Drawer)& aDrawer = aShape->Attributes();
+
+    if(!aDrawer->HasOwnDatumAspect())
+    {
+      Handle(Prs3d_DatumAspect) aDefAspect = ViewerTest::GetAISContext()->DefaultDrawer()->DatumAspect();
+
+      Handle(Prs3d_DatumAspect) aDatumAspect = new Prs3d_DatumAspect();
+      aDatumAspect->FirstAxisAspect()->SetAspect (aDefAspect->FirstAxisAspect()->Aspect());
+      aDatumAspect->SecondAxisAspect()->SetAspect (aDefAspect->SecondAxisAspect()->Aspect());
+      aDatumAspect->ThirdAxisAspect()->SetAspect (aDefAspect->ThirdAxisAspect()->Aspect());
+      aDatumAspect->SetAxisLength (aDefAspect->FirstAxisLength(),
+                                   aDefAspect->SecondAxisLength(),
+                                   aDefAspect->ThirdAxisLength());
+
+      aDrawer->SetDatumAspect (aDatumAspect);
+    }
+
+    aDrawer->DatumAspect()->SetToDrawLabels (Standard_False);
+  }
+
   VDisplayAISObject (theArgVec[1], aShape);
   return 0;
 }
@@ -306,7 +388,7 @@ static int VSize (Draw_Interpretor& di, Standard_Integer argc, const char** argv
   Quantity_NameOfColor         col = Quantity_NOC_BLACK ;
 
   // Verification des arguments
-  if ( argc>3 ) {di<<argv[0]<<" Syntaxe error"<<"\n"; return 1;}
+  if ( argc>3 ) {di<<argv[0]<<" Syntaxe error\n"; return 1;}
 
   // Verification du nombre d'arguments
   if (argc==1)      {ThereIsName=Standard_False;value=100;}
@@ -451,7 +533,7 @@ static int VPlaneTrihedron (Draw_Interpretor& di, Standard_Integer argc, const c
 
 {
   // Verification des arguments
-  if ( argc!=2) {di<<argv[0]<<" error"<<"\n"; return 1;}
+  if ( argc!=2) {di<<argv[0]<<" error\n"; return 1;}
 
   // Declarations
   Standard_Integer myCurrentIndex;
@@ -483,7 +565,7 @@ static int VPlaneTrihedron (Draw_Interpretor& di, Standard_Integer argc, const c
       it.Next();
   }
 
-  di<<" Select a plane."<<"\n";
+  di<<" Select a plane.\n";
   // Boucle d'attente waitpick.
   Standard_Integer argccc = 5;
   const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
@@ -538,7 +620,7 @@ static int VAxisBuilder(Draw_Interpretor& di, Standard_Integer argc, const char*
   Standard_Integer MyCurrentIndex;
 
   // Verification
-  if (argc<2 || argc>8 ) {di<<" Syntaxe error"<<"\n";return 1;}
+  if (argc<2 || argc>8 ) {di<<" Syntaxe error\n";return 1;}
   if (argc==8) HasArg=Standard_True;
   else HasArg=Standard_False;
 
@@ -573,7 +655,7 @@ static int VAxisBuilder(Draw_Interpretor& di, Standard_Integer argc, const char*
       // Active le mode edge et le mode vertex
       TheAISContext()->ActivateStandardMode(AIS_Shape::SelectionType(1) );
       TheAISContext()->ActivateStandardMode(AIS_Shape::SelectionType(2) );
-      di<<" Select an edge or a vertex."<<"\n";
+      di<<" Select an edge or a vertex.\n";
 
       // Boucle d'attente waitpick.
       Standard_Integer argcc = 5;
@@ -595,7 +677,7 @@ static int VAxisBuilder(Draw_Interpretor& di, Standard_Integer argc, const char*
       if (ShapeA.ShapeType()==TopAbs_VERTEX) {
         // on desactive le mode edge
         TheAISContext()->DeactivateStandardMode(AIS_Shape::SelectionType(2) );
-        di<<" Select a different vertex."<<"\n";
+        di<<" Select a different vertex.\n";
 
         TopoDS_Shape ShapeB;
         do {
@@ -654,7 +736,7 @@ static int VAxisBuilder(Draw_Interpretor& di, Standard_Integer argc, const char*
 
       // Active le mode edge
       TheAISContext()->ActivateStandardMode(AIS_Shape::SelectionType(2) );
-      di<<" Select an edge."<<"\n";
+      di<<" Select an edge.\n";
 
       // Boucle d'attente waitpick.
       Standard_Integer argcc = 5;
@@ -670,7 +752,7 @@ static int VAxisBuilder(Draw_Interpretor& di, Standard_Integer argc, const char*
       // Active le mode vertex et deactive edges
       TheAISContext()->DeactivateStandardMode(AIS_Shape::SelectionType(2) );
       TheAISContext()->ActivateStandardMode(AIS_Shape::SelectionType(1) );
-      di<<" Select a vertex."<<"\n";
+      di<<" Select a vertex.\n";
 
       // Boucle d'attente waitpick.
       Standard_Integer argccc = 5;
@@ -710,7 +792,7 @@ static int VAxisBuilder(Draw_Interpretor& di, Standard_Integer argc, const char*
 
       // Active le mode edge
       TheAISContext()->ActivateStandardMode(AIS_Shape::SelectionType(2) );
-      di<<" Select an edge."<<"\n";
+      di<<" Select an edge.\n";
 
       // Boucle d'attente waitpick.
       Standard_Integer argcc = 5;
@@ -726,7 +808,7 @@ static int VAxisBuilder(Draw_Interpretor& di, Standard_Integer argc, const char*
       // Active le mode vertex et deactive edges
       TheAISContext()->DeactivateStandardMode(AIS_Shape::SelectionType(2) );
       TheAISContext()->ActivateStandardMode(AIS_Shape::SelectionType(1) );
-      di<<" Slect a vertex."<<"\n";
+      di<<" Slect a vertex.\n";
 
       // Boucle d'attente waitpick.
       Standard_Integer argccc = 5;
@@ -791,7 +873,7 @@ static int VPointBuilder(Draw_Interpretor& di, Standard_Integer argc, const char
   Standard_Integer myCurrentIndex;
 
   // Verification
-  if (argc<2 || argc>5 ) {di<<" Syntaxe error"<<"\n";return 1;}
+  if (argc<2 || argc>5 ) {di<<" Syntaxe error\n";return 1;}
   if (argc==5) HasArg=Standard_True;
   else HasArg=Standard_False;
 
@@ -818,7 +900,7 @@ static int VPointBuilder(Draw_Interpretor& di, Standard_Integer argc, const char
     // Active le mode Vertex et Edges
     TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(1) );
     TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2) );
-    di<<" Select a vertex or an edge(build the middle)"<<"\n";
+    di<<" Select a vertex or an edge(build the middle)\n";
 
     // Boucle d'attente waitpick.
     Standard_Integer argcc = 5;
@@ -982,21 +1064,21 @@ 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;
+          std::cout<<"vplane error: same points\n";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;
+          std::cout<<"vplane error: same points\n";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;
+          std::cout<<"vplane error: same points\n";return 1;
         }
 
         gp_Pnt A = aCartPointA->Pnt();
@@ -1467,7 +1549,7 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
         }
         else
         {
-          std::cout<<" vplanepara: error"<<"\n";return 1;
+          std::cout<<" vplanepara: error\n";return 1;
         }
       }
     }
@@ -1768,7 +1850,7 @@ static int VLineBuilder(Draw_Interpretor& di, Standard_Integer argc, const char*
 {
   Standard_Integer myCurrentIndex;
   // Verifications
-  if (argc!=4 && argc!=8 && argc!=2 )  {di<<"vline error: number of arguments not correct "<<"\n";return 1; }
+  if (argc!=4 && argc!=8 && argc!=2 )  {di<<"vline error: number of arguments not correct \n";return 1; }
   // Fermeture des contextes
   TheAISContext()->CloseAllContexts();
 
@@ -1790,11 +1872,11 @@ static int VLineBuilder(Draw_Interpretor& di, Standard_Integer argc, const char*
         if (theShapeA.IsNull() ||
           (!(theShapeB->Type()==AIS_KOI_Datum && theShapeB->Signature()==1)))
         {
-          di <<"vline error: wrong type of 2de argument."<<"\n";
+          di <<"vline error: wrong type of 2de argument.\n";
           return 1;
         }
       }
-    else {di <<"vline error: wrong type of 1st argument."<<"\n";return 1; }
+    else {di <<"vline error: wrong type of 1st argument.\n";return 1; }
     // Les deux parametres sont du bon type. On verifie que les points ne sont pas confondus
     Handle(AIS_Point) theAISPointA= Handle(AIS_Point)::DownCast (theShapeA);
     Handle(AIS_Point) theAISPointB= Handle(AIS_Point)::DownCast (theShapeB);
@@ -1809,7 +1891,7 @@ static int VLineBuilder(Draw_Interpretor& di, Standard_Integer argc, const char*
 
     if (myCartPointB->X()==myCartPointA->X() && myCartPointB->Y()==myCartPointA->Y() && myCartPointB->Z()==myCartPointA->Z() ) {
       // B=A
-      di<<"vline error: same points"<<"\n";return 1;
+      di<<"vline error: same points\n";return 1;
     }
     // Les deux points sont OK...Construction de l'AIS_Line (en faite, le segment AB)
     Handle(AIS_Line) theAISLine= new AIS_Line(myCartPointA,myCartPointB );
@@ -1848,7 +1930,7 @@ static int VLineBuilder(Draw_Interpretor& di, Standard_Integer argc, const char*
 
     // Active le mode Vertex.
     TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(1) );
-    di<<" Select a vertex "<<"\n";
+    di<<" Select a vertex \n";
 
     // Boucle d'attente waitpick.
     Standard_Integer argcc = 5;
@@ -1865,7 +1947,7 @@ static int VLineBuilder(Draw_Interpretor& di, Standard_Integer argc, const char*
     // ShapeA est un Vertex
     if (ShapeA.ShapeType()==TopAbs_VERTEX ) {
 
-      di<<" Select a different vertex."<<"\n";
+      di<<" Select a different vertex.\n";
 
       TopoDS_Shape ShapeB;
       do {
@@ -1900,7 +1982,7 @@ static int VLineBuilder(Draw_Interpretor& di, Standard_Integer argc, const char*
 
     }
     else  {
-      di<<"vline error."<<"\n";
+      di<<"vline error.\n";
     }
 
   }
@@ -1931,7 +2013,7 @@ class FilledCircle : public AIS_InteractiveObject
 {
 public:
     // CASCADE RTTI
-    DEFINE_STANDARD_RTTI(FilledCircle, AIS_InteractiveObject); 
+    DEFINE_STANDARD_RTTI_INLINE(FilledCircle,AIS_InteractiveObject); 
 
     FilledCircle(gp_Pnt theCenter, Standard_Real theRadius);
     FilledCircle(Handle(Geom_Circle) theCircle);
@@ -1942,10 +2024,10 @@ private:
     // Virtual methods implementation
     void Compute (  const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
                   const Handle(Prs3d_Presentation)& thePresentation,
-                  const Standard_Integer theMode);
+                  const Standard_Integer theMode) Standard_OVERRIDE;
 
     void ComputeSelection (  const Handle(SelectMgr_Selection)& theSelection, 
-                           const Standard_Integer theMode);
+                           const Standard_Integer theMode) Standard_OVERRIDE;
 
 protected:
     Handle(Geom_Circle) myCircle;
@@ -2426,6 +2508,16 @@ static int VDrawText (Draw_Interpretor& theDI,
 
   aTextPrs->SetText (aText);
 
+  Graphic3d_TransModeFlags aTrsfPersFlags = Graphic3d_TMF_None;
+  gp_Pnt aTPPosition;
+  Aspect_TypeOfDisplayText aDisplayType = Aspect_TODT_NORMAL;
+
+
+  Standard_Boolean aHasPlane = Standard_False;
+  gp_Dir           aNormal;
+  gp_Dir           aDirection;
+  gp_Pnt           aPos;
+
   for (; anArgIt < theArgsNb; ++anArgIt)
   {
     TCollection_AsciiString aParam (theArgVec[anArgIt]);
@@ -2444,7 +2536,6 @@ static int VDrawText (Draw_Interpretor& theDI,
         return 1;
       }
 
-      gp_Pnt aPos;
       aPos.SetX (Draw::Atof (theArgVec[++anArgIt]));
       aPos.SetY (Draw::Atof (theArgVec[++anArgIt]));
       aPos.SetZ (Draw::Atof (theArgVec[++anArgIt]));
@@ -2539,6 +2630,10 @@ static int VDrawText (Draw_Interpretor& theDI,
       {
         aTextPrs->SetVJustification (Graphic3d_VTA_BOTTOM);
       }
+      else if (aType == "topfirstline")
+      {
+        aTextPrs->SetVJustification (Graphic3d_VTA_TOPFIRSTLINE);
+      }
       else
       {
         std::cout << "Error: wrong syntax at '" << aParam.ToCString() << "'.\n";
@@ -2612,6 +2707,129 @@ static int VDrawText (Draw_Interpretor& theDI,
 
       aTextPrs->SetFont (theArgVec[anArgIt]);
     }
+    else if (aParam == "-plane")
+    {
+      if (anArgIt + 6 >= theArgsNb)
+      {
+        std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        return 1;
+      }
+
+      Standard_Real aX = Draw::Atof (theArgVec[++anArgIt]);
+      Standard_Real aY = Draw::Atof (theArgVec[++anArgIt]);
+      Standard_Real aZ = Draw::Atof (theArgVec[++anArgIt]);
+      aNormal.SetCoord (aX, aY, aZ);
+
+      aX = Draw::Atof (theArgVec[++anArgIt]);
+      aY = Draw::Atof (theArgVec[++anArgIt]);
+      aZ = Draw::Atof (theArgVec[++anArgIt]);
+      aDirection.SetCoord (aX, aY, aZ);
+
+      aHasPlane = Standard_True;
+    }
+    else if (aParam == "-flipping")
+    {
+      aTextPrs->SetFlipping (Standard_True);
+    }
+    else if (aParam == "-disptype"
+          || aParam == "-displaytype")
+    {
+      if (++anArgIt >= theArgsNb)
+      {
+        std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        return 1;
+      }
+      TCollection_AsciiString aType (theArgVec[anArgIt]);
+      aType.LowerCase();
+      if (aType == "subtitle")
+        aDisplayType = Aspect_TODT_SUBTITLE;
+      else if (aType == "decal")
+        aDisplayType = Aspect_TODT_DEKALE;
+      else if (aType == "blend")
+        aDisplayType = Aspect_TODT_BLEND;
+      else if (aType == "dimension")
+        aDisplayType = Aspect_TODT_DIMENSION;
+      else if (aType == "normal")
+        aDisplayType = Aspect_TODT_NORMAL;
+      else
+      {
+        std::cout << "Error: wrong display type '" << aType << "'.\n";
+        return 1;
+      }
+    }
+    else if (aParam == "-subcolor"
+          || aParam == "-subtitlecolor")
+    {
+      if (anArgIt + 1 >= theArgsNb)
+      {
+        std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        return 1;
+      }
+
+      TCollection_AsciiString aColor (theArgVec[anArgIt + 1]);
+      Quantity_NameOfColor aNameOfColor = Quantity_NOC_BLACK;
+      if (Quantity_Color::ColorFromName (aColor.ToCString(), aNameOfColor))
+      {
+        anArgIt += 1;
+        aTextPrs->SetColorSubTitle (aNameOfColor);
+        continue;
+      }
+      else if (anArgIt + 3 >= theArgsNb)
+      {
+        std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        return 1;
+      }
+
+      TCollection_AsciiString aGreen (theArgVec[anArgIt + 2]);
+      TCollection_AsciiString aBlue  (theArgVec[anArgIt + 3]);
+      if (!aColor.IsRealValue()
+       || !aGreen.IsRealValue()
+       || !aBlue.IsRealValue())
+      {
+        std::cout << "Error: wrong syntax at '" << aParam.ToCString() << "'.\n";
+        return 1;
+      }
+
+      const Graphic3d_Vec3d anRGB (aColor.RealValue(),
+                                   aGreen.RealValue(),
+                                   aBlue.RealValue());
+
+      aTextPrs->SetColorSubTitle (Quantity_Color (anRGB.r(), anRGB.g(), anRGB.b(), Quantity_TOC_RGB));
+      anArgIt += 3;
+    }
+    else if (aParam == "-2d")
+    {
+      aTrsfPersFlags = Graphic3d_TMF_2d;
+    }
+    else if (aParam == "-trsfperspos"
+          || aParam == "-perspos")
+    {
+      if (anArgIt + 2 >= theArgsNb)
+      {
+        std::cerr << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        return 1;
+      }
+
+      TCollection_AsciiString aX (theArgVec[++anArgIt]);
+      TCollection_AsciiString aY (theArgVec[++anArgIt]);
+      TCollection_AsciiString aZ = "0";
+      if (!aX.IsIntegerValue()
+       || !aY.IsIntegerValue())
+      {
+        std::cerr << "Error: wrong syntax at '" << aParam << "'.\n";
+        return 1;
+      }
+      if (anArgIt + 1 < theArgsNb)
+      {
+        TCollection_AsciiString aTemp = theArgVec[anArgIt + 1];
+        if (aTemp.IsIntegerValue())
+        {
+          aZ = aTemp;
+          ++anArgIt;
+        }
+      }
+      aTPPosition.SetCoord (aX.IntegerValue(), aY.IntegerValue(), aZ.IntegerValue());
+    }
     else
     {
       std::cout << "Error: unknown argument '" << aParam << "'\n";
@@ -2619,6 +2837,26 @@ static int VDrawText (Draw_Interpretor& theDI,
     }
   }
 
+  if (aHasPlane)
+  {
+    aTextPrs->SetOrientation3D (gp_Ax2 (aPos, aNormal, aDirection));
+  }
+
+  aTextPrs->SetDisplayType (aDisplayType);
+
+  if (aTrsfPersFlags != Graphic3d_TMF_None)
+  {
+    aContext->SetTransformPersistence (aTextPrs, aTrsfPersFlags, aTPPosition);
+    aTextPrs->SetZLayer(Graphic3d_ZLayerId_TopOSD);
+    if (aTextPrs->Position().Z() != 0)
+    {
+      aTextPrs->SetPosition (gp_Pnt(aTextPrs->Position().X(), aTextPrs->Position().Y(), 0));
+    }
+  }
+  else if (aTrsfPersFlags != aTextPrs->TransformPersistence().Flags)
+  {
+    aContext->SetTransformPersistence (aTextPrs, aTrsfPersFlags);
+  }
   ViewerTest::Display (aName, aTextPrs, Standard_False);
   return 0;
 }
@@ -2636,7 +2874,7 @@ static int VDrawText (Draw_Interpretor& theDI,
 #include <TShort_HArray1OfShortReal.hxx>
 
 #include <AIS_Triangulation.hxx>
-#include <StdPrs_ToolShadedShape.hxx>
+#include <StdPrs_ToolTriangulatedShape.hxx>
 #include <Poly_Connect.hxx>
 #include <TColgp_Array1OfDir.hxx>
 #include <Graphic3d_GraphicDriver.hxx>
@@ -2871,11 +3109,11 @@ Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z
         Nor = gp_Dir(eqPlan);
       else
         Nor = gp_Dir(0., 0., 1.);
-
-      Standard_Integer j = (i - PointsOfArray.Lower()) * 3;
-      Normals->SetValue(j + 1, (Standard_ShortReal)Nor.X());
-      Normals->SetValue(j + 2, (Standard_ShortReal)Nor.Y());
-      Normals->SetValue(j + 3, (Standard_ShortReal)Nor.Z());
+      
+      Standard_Integer k = (i - PointsOfArray.Lower()) * 3;
+      Normals->SetValue(k + 1, (Standard_ShortReal)Nor.X());
+      Normals->SetValue(k + 2, (Standard_ShortReal)Nor.Y());
+      Normals->SetValue(k + 3, (Standard_ShortReal)Nor.Z());
   }
 
   delete pc;
@@ -2929,20 +3167,13 @@ static int VDrawSphere (Draw_Interpretor& /*di*/, Standard_Integer argc, const c
 
   // stupid initialization of Green color in RGBA space as integer
   // probably wrong for big-endian CPUs
-  Standard_Integer aRed    = 0;
-  Standard_Integer aGreen  = 255;
-  Standard_Integer aBlue   = 0;
-  Standard_Integer anAlpha = 0; // not used
-  Standard_Integer aColorInt = aRed;
-  aColorInt += aGreen  << 8;
-  aColorInt += aBlue   << 16;
-  aColorInt += anAlpha << 24;
+  const Graphic3d_Vec4ub aColor (0, 255, 0, 0);
 
   // setup colors array per vertex
   Handle(TColStd_HArray1OfInteger) aColorArray = new TColStd_HArray1OfInteger (1, aNumberPoints);
   for (Standard_Integer aNodeId = 1; aNodeId <= aNumberPoints; ++aNodeId)
   {
-    aColorArray->SetValue (aNodeId, aColorInt);
+    aColorArray->SetValue (aNodeId, *reinterpret_cast<const Standard_Integer*> (&aColor));
   }
   aShape->SetColors (aColorArray);
 
@@ -3016,7 +3247,7 @@ static int VComputeHLR (Draw_Interpretor& di,
   if ( argc != 3 &&  argc != 12 )
   {
     di << "Usage: " << argv[0] << " ShapeName HlrName "
-       << "[ eye_x eye_y eye_z dir_x dir_y dir_z upx upy upz ]" << "\n"
+       << "[ eye_x eye_y eye_z dir_x dir_y dir_z upx upy upz ]\n"
        << "                    ShapeName - name of the initial shape\n"
        << "                    HlrName - result hlr object from initial shape\n"
        << "                    eye, dir are eye position and look direction\n"
@@ -3145,16 +3376,16 @@ public:
     myMarkerAspect = theMarkerAspect;
   }
 
-  DEFINE_STANDARD_RTTI(MyPArrayObject, AIS_InteractiveObject);
+  DEFINE_STANDARD_RTTI_INLINE(MyPArrayObject,AIS_InteractiveObject);
 
 private:
 
   void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
                 const Handle(Prs3d_Presentation)& aPresentation,
-                const Standard_Integer aMode);
+                const Standard_Integer aMode) Standard_OVERRIDE;
 
   void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
-                         const Standard_Integer /*theMode*/);
+                         const Standard_Integer /*theMode*/) Standard_OVERRIDE;
 
   bool CheckInputCommand (const TCollection_AsciiString theCommand,
                           const Handle(TColStd_HArray1OfAsciiString) theArgsArray,
@@ -3324,6 +3555,8 @@ void MyPArrayObject::Compute (const Handle(PrsMgr_PresentationManager3d)& /*aPre
   {
     Prs3d_Root::CurrentGroup (aPresentation)->SetGroupPrimitivesAspect (myMarkerAspect);
   }
+  Prs3d_Root::CurrentGroup (aPresentation)->SetGroupPrimitivesAspect (myDrawer->LineAspect()->Aspect());
+  Prs3d_Root::CurrentGroup (aPresentation)->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
   Prs3d_Root::CurrentGroup (aPresentation)->AddPrimitiveArray (anArray);
 }
 
@@ -3768,8 +4001,8 @@ static Standard_Integer VConnect (Draw_Interpretor& /*di*/,
     }
     else
     {
-      Standard_CString aName = anOriginObjectName.ToCString();
-      TopoDS_Shape aTDShape = DBRep::Get (aName);
+      Standard_CString aOriginName = anOriginObjectName.ToCString();
+      TopoDS_Shape aTDShape = DBRep::Get (aOriginName);
       if (aTDShape.IsNull())
       {
         std::cout << "vconnect error: object " << anOriginObjectName << " doesn't exist\n";
@@ -3874,8 +4107,8 @@ static Standard_Integer VConnectTo (Draw_Interpretor& /*di*/,
   }
   else
   {
-    Standard_CString aName = anOriginObjectName.ToCString();
-    TopoDS_Shape aTDShape = DBRep::Get (aName);
+    Standard_CString aOriginName = anOriginObjectName.ToCString();
+    TopoDS_Shape aTDShape = DBRep::Get (aOriginName);
     if (aTDShape.IsNull())
     {
       std::cout << "vconnect error: object " << anOriginObjectName << " doesn't exist\n";
@@ -3945,13 +4178,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";
+    std::cout << argv[0] << "ERROR : use 'vinit' command before \n";
     return 1;
   }
   
   if (argc != 3)
   {
-    std::cout << "ERROR : Usage : " << argv[0] << " name object" << "\n";
+    std::cout << "ERROR : Usage : " << argv[0] << " name object\n";
     return 1;
   }
 
@@ -3964,14 +4197,14 @@ static Standard_Integer VDisconnect (Draw_Interpretor& di,
   Handle(AIS_MultipleConnectedInteractive) anAssembly;
   if (!aMap.IsBound2 (aName) )
   {
-    std::cout << "Use 'vdisplay' before" << "\n";
+    std::cout << "Use 'vdisplay' before\n";
     return 1;
   }
 
   anAssembly = Handle(AIS_MultipleConnectedInteractive)::DownCast (aMap.Find2 (aName));
   if (anAssembly.IsNull())
   {
-    di << "Not an assembly" << "\n";
+    di << "Not an assembly\n";
     return 1;
   }
 
@@ -3994,7 +4227,7 @@ static Standard_Integer VDisconnect (Draw_Interpretor& di,
     }
     else
     {
-      std::cout << "Use 'vdisplay' before" << "\n";
+      std::cout << "Use 'vdisplay' before\n";
       return 1;
     }    
   }
@@ -4022,7 +4255,7 @@ static Standard_Integer VAddConnected (Draw_Interpretor& di,
   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
   if (aContext.IsNull())
   {
-    std::cout << argv[0] << "error : use 'vinit' command before " << "\n";
+    std::cout << argv[0] << "error : use 'vinit' command before \n";
     return 1;
   }
   
@@ -4043,21 +4276,21 @@ static Standard_Integer VAddConnected (Draw_Interpretor& di,
   Handle(AIS_MultipleConnectedInteractive) anAssembly;
   if (!aMap.IsBound2 (aName) )
   {
-    std::cout << "Use 'vdisplay' before" << "\n";
+    std::cout << "Use 'vdisplay' before\n";
     return 1;
   }
 
   anAssembly = Handle(AIS_MultipleConnectedInteractive)::DownCast (aMap.Find2 (aName));
   if (anAssembly.IsNull())
   {
-    di << "Not an assembly" << "\n";
+    di << "Not an assembly\n";
     return 1;
   }
 
   Handle(AIS_InteractiveObject) anIObj;
   if (!aMap.IsBound2 (anObject))
   {
-      std::cout << "Use 'vdisplay' before" << "\n";
+      std::cout << "Use 'vdisplay' before\n";
       return 1; 
   }
 
@@ -4085,13 +4318,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";
+    std::cout << argv[0] << "ERROR : use 'vinit' command before \n";
     return 1;
   }
   
   if (argc != 2)
   {
-    std::cout << "ERROR : Usage : " << argv[0] << " name" << "\n";
+    std::cout << "ERROR : Usage : " << argv[0] << " name\n";
     return 1;
   }
 
@@ -4102,14 +4335,14 @@ static Standard_Integer VListConnected (Draw_Interpretor& /*di*/,
   Handle(AIS_MultipleConnectedInteractive) anAssembly;
   if (!aMap.IsBound2 (aName) )
   {
-    std::cout << "Use 'vdisplay' before" << "\n";
+    std::cout << "Use 'vdisplay' before\n";
     return 1;
   }
 
   anAssembly = Handle(AIS_MultipleConnectedInteractive)::DownCast (aMap.Find2 (aName));
   if (anAssembly.IsNull())
   {
-    std::cout << "Not an assembly" << "\n";
+    std::cout << "Not an assembly\n";
     return 1;
   }
 
@@ -4120,8 +4353,8 @@ static Standard_Integer VListConnected (Draw_Interpretor& /*di*/,
   {
     if (GetMapOfAIS().IsBound1 (anIter.Value()))
     {
-      TCollection_AsciiString aName = GetMapOfAIS().Find1 (anIter.Value());
-      std::cout << aCounter << ")  " << aName << "    (" << anIter.Value()->DynamicType()->Name() << ")";
+      TCollection_AsciiString aCuurrentName = GetMapOfAIS().Find1 (anIter.Value());
+      std::cout << aCounter << ")  " << aCuurrentName << "    (" << anIter.Value()->DynamicType()->Name() << ")";
     }
 
     std::cout << aCounter << ")  " << anIter.Value()->DynamicType()->Name();
@@ -4157,7 +4390,7 @@ namespace
     }
     return Standard_False;
   }
-};
+}
 
 //===============================================================================================
 //function : VSetSelectionMode
@@ -4342,17 +4575,17 @@ class Triangle: public AIS_InteractiveObject
 {
 public: 
   // CASCADE RTTI
-  DEFINE_STANDARD_RTTI(Triangle, AIS_InteractiveObject);
+  DEFINE_STANDARD_RTTI_INLINE(Triangle,AIS_InteractiveObject);
   Triangle (const gp_Pnt& theP1, 
             const gp_Pnt& theP2, 
             const gp_Pnt& theP3);
 protected:
   void Compute (  const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
                   const Handle(Prs3d_Presentation)& thePresentation,
-                  const Standard_Integer theMode);
+                  const Standard_Integer theMode) Standard_OVERRIDE;
 
   void ComputeSelection (  const Handle(SelectMgr_Selection)& theSelection, 
-                           const Standard_Integer theMode);
+                           const Standard_Integer theMode) Standard_OVERRIDE;
 private: 
   gp_Pnt myPoint1;
   gp_Pnt myPoint2;
@@ -4536,15 +4769,15 @@ class SegmentObject: public AIS_InteractiveObject
 {
 public:
   // CASCADE RTTI
-  DEFINE_STANDARD_RTTI(SegmentObject, AIS_InteractiveObject); 
+  DEFINE_STANDARD_RTTI_INLINE(SegmentObject,AIS_InteractiveObject); 
   SegmentObject (const gp_Pnt& thePnt1, const gp_Pnt& thePnt2);
 protected:
   void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
                 const Handle(Prs3d_Presentation)& thePresentation,
-                const Standard_Integer theMode);
+                const Standard_Integer theMode) Standard_OVERRIDE;
 
   void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, 
-                         const Standard_Integer theMode);
+                         const Standard_Integer theMode) Standard_OVERRIDE;
 private:
   gp_Pnt myPoint1;
   gp_Pnt myPoint2;
@@ -4682,7 +4915,7 @@ static Standard_Integer VObjZLayer (Draw_Interpretor& di,
   ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
   if (!aMap.IsBound2 (aName))
   {
-    di << "Use 'vdisplay' before" << "\n";
+    di << "Use 'vdisplay' before\n";
     return 1;
   }
 
@@ -4925,16 +5158,16 @@ public:
     myMarkerAspect = theMarkerAspect;
   }
 
-  DEFINE_STANDARD_RTTI(MyPArrayObject, AIS_InteractiveObject);
+  DEFINE_STANDARD_RTTI_INLINE(MyPArrayObject,AIS_InteractiveObject);
 
 private:
 
   void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
                 const Handle(Prs3d_Presentation)& aPresentation,
-                const Standard_Integer aMode);
+                const Standard_Integer aMode) Standard_OVERRIDE;
 
   void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
-                         const Standard_Integer /*theMode*/);
+                         const Standard_Integer /*theMode*/) Standard_OVERRIDE;
 
 protected:
 
@@ -5146,69 +5379,210 @@ static TCollection_AsciiString fontStyleString (const Font_FontAspect theAspect)
 //function : TextToBrep
 //purpose  : Tool for conversion text to occt-shapes
 //=======================================================================
-
 static int TextToBRep (Draw_Interpretor& /*theDI*/,
                        Standard_Integer  theArgNb,
                        const char**      theArgVec)
 {
   // Check arguments
-  if (theArgNb < 5)
+  if (theArgNb < 3)
   {
     std::cerr << "Error: " << theArgVec[0] << " - invalid syntax\n";
     return 1;
   }
 
-  Standard_Integer    anArgIter = 1;
-  Standard_CString    aResName  = theArgVec[anArgIter++];
-  Standard_CString    aText     = theArgVec[anArgIter++];
-  Standard_CString    aFontName = theArgVec[anArgIter++];
-  const Standard_Real aSize     = Atof (theArgVec[anArgIter++]);
+  Standard_Integer anArgIt = 1;
+  Standard_CString aName   = theArgVec[anArgIt++];
+  Standard_CString aText   = theArgVec[anArgIt++];
+
+  Font_BRepFont           aFont;
+  TCollection_AsciiString aFontName ("Courier");
+  Standard_Real           aTextHeight        = 16.0;
+  Font_FontAspect         aFontAspect        = Font_FA_Regular;
+  Standard_Boolean        anIsCompositeCurve = Standard_False;
+  gp_Ax3                  aPenAx3    (gp::XOY());
+  gp_Dir                  aNormal    (0.0, 0.0, 1.0);
+  gp_Dir                  aDirection (1.0, 0.0, 0.0);
+  gp_Pnt                  aPenLoc;
+
+  Graphic3d_HorizontalTextAlignment aHJustification = Graphic3d_HTA_LEFT;
+  Graphic3d_VerticalTextAlignment   aVJustification = Graphic3d_VTA_BOTTOM;
 
-  Font_BRepFont    aFont;
-  Font_FontAspect  aFontAspect      = Font_FA_Regular;
-  Standard_Boolean isCompositeCurve = Standard_False;
-  gp_Ax3           aPenAx3 (gp::XOY());
-  gp_Pnt           aPenLoc;
-  while (anArgIter < theArgNb)
+  for (; anArgIt < theArgNb; ++anArgIt)
   {
-    const TCollection_AsciiString anArg (theArgVec[anArgIter++]);
-    TCollection_AsciiString anArgCase (anArg);
-    anArgCase.LowerCase();
-    if (anArgCase.Search ("x=") > -1)
+    TCollection_AsciiString aParam (theArgVec[anArgIt]);
+    aParam.LowerCase();
+
+    if (aParam == "-pos"
+     || aParam == "-position")
+    {
+      if (anArgIt + 3 >= theArgNb)
+      {
+        std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        return 1;
+      }
+
+      aPenLoc.SetX (Draw::Atof(theArgVec[++anArgIt]));
+      aPenLoc.SetY (Draw::Atof(theArgVec[++anArgIt]));
+      aPenLoc.SetZ (Draw::Atof(theArgVec[++anArgIt]));
+    }
+    else if (aParam == "-halign")
+    {
+      if (++anArgIt >= theArgNb)
+      {
+        std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        return 1;
+      }
+
+      TCollection_AsciiString aType (theArgVec[anArgIt]);
+      aType.LowerCase();
+      if (aType == "left")
+      {
+        aHJustification = Graphic3d_HTA_LEFT;
+      }
+      else if (aType == "center")
+      {
+        aHJustification = Graphic3d_HTA_CENTER;
+      }
+      else if (aType == "right")
+      {
+        aHJustification = Graphic3d_HTA_RIGHT;
+      }
+      else
+      {
+        std::cout << "Error: wrong syntax at '" << aParam.ToCString() << "'.\n";
+        return 1;
+      }
+    }
+    else if (aParam == "-valign")
+    {
+      if (++anArgIt >= theArgNb)
+      {
+        std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        return 1;
+      }
+
+      TCollection_AsciiString aType (theArgVec[anArgIt]);
+      aType.LowerCase();
+      if (aType == "top")
+      {
+        aVJustification = Graphic3d_VTA_TOP;
+      }
+      else if (aType == "center")
+      {
+        aVJustification = Graphic3d_VTA_CENTER;
+      }
+      else if (aType == "bottom")
+      {
+        aVJustification = Graphic3d_VTA_BOTTOM;
+      }
+      else if (aType == "topfirstline")
+      {
+        aVJustification = Graphic3d_VTA_TOPFIRSTLINE;
+      }
+      else
+      {
+        std::cout << "Error: wrong syntax at '" << aParam.ToCString() << "'.\n";
+        return 1;
+      }
+    }
+    else if (aParam == "-height")
     {
-      aPenLoc.SetX (anArg.Token ("=", 2).RealValue());
+      if (++anArgIt >= theArgNb)
+      {
+        std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        return 1;
+      }
+
+      aTextHeight = Draw::Atof(theArgVec[anArgIt]);
     }
-    else if (anArgCase.Search ("y=") > -1)
+    else if (aParam == "-aspect")
     {
-      aPenLoc.SetY (anArg.Token ("=", 2).RealValue());
+      if (++anArgIt >= theArgNb)
+      {
+        std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        return 1;
+      }
+
+      TCollection_AsciiString anOption (theArgVec[anArgIt]);
+      anOption.LowerCase();
+
+      if (anOption.IsEqual ("regular"))
+      {
+        aFontAspect = Font_FA_Regular;
+      }
+      else if (anOption.IsEqual ("bold"))
+      {
+        aFontAspect = Font_FA_Bold;
+      }
+      else if (anOption.IsEqual ("italic"))
+      {
+        aFontAspect = Font_FA_Italic;
+      }
+      else if (anOption.IsEqual ("bolditalic"))
+      {
+        aFontAspect = Font_FA_BoldItalic;
+      }
+      else
+      {
+        std::cout << "Error: wrong syntax at '" << aParam.ToCString() << "'.\n";
+        return 1;
+      }
     }
-    else if (anArgCase.Search ("z=") > -1)
+    else if (aParam == "-font")
     {
-      aPenLoc.SetZ (anArg.Token ("=", 2).RealValue());
+      if (++anArgIt >= theArgNb)
+      {
+        std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        return 1;
+      }
+
+      aFontName = theArgVec[anArgIt];
     }
-    else if (anArgCase.Search ("composite=") > -1)
+    else if (aParam == "-composite")
     {
-      isCompositeCurve = (anArg.Token ("=", 2).IntegerValue() == 1);
+      if (++anArgIt >= theArgNb)
+      {
+        std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        return 1;
+      }
+
+      ViewerTest::ParseOnOff (theArgVec[anArgIt], anIsCompositeCurve);
     }
-    else if (parseFontStyle (anArgCase, aFontAspect))
+    else if (aParam == "-plane")
     {
-      //
+      if (anArgIt + 6 >= theArgNb)
+      {
+        std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
+        return 1;
+      }
+
+      Standard_Real aX = Draw::Atof (theArgVec[++anArgIt]);
+      Standard_Real aY = Draw::Atof (theArgVec[++anArgIt]);
+      Standard_Real aZ = Draw::Atof (theArgVec[++anArgIt]);
+      aNormal.SetCoord (aX, aY, aZ);
+
+      aX = Draw::Atof (theArgVec[++anArgIt]);
+      aY = Draw::Atof (theArgVec[++anArgIt]);
+      aZ = Draw::Atof (theArgVec[++anArgIt]);
+      aDirection.SetCoord (aX, aY, aZ);
     }
     else
     {
-      std::cerr << "Warning! Unknown argument '" << anArg.ToCString() << "'\n";
+      std::cerr << "Warning! Unknown argument '" << aParam << "'\n";
     }
   }
 
-  aFont.SetCompositeCurveMode (isCompositeCurve);
-  if (!aFont.Init (aFontName, aFontAspect, aSize))
+  aFont.SetCompositeCurveMode (anIsCompositeCurve);
+  if (!aFont.Init (aFontName.ToCString(), aFontAspect, aTextHeight))
   {
     std::cerr << "Font initialization error\n";
     return 1;
   }
 
-  aPenAx3.SetLocation (aPenLoc);
-  DBRep::Set (aResName, aFont.RenderText (aText, aPenAx3));
+  aPenAx3 = gp_Ax3 (aPenLoc, aNormal, aDirection);
+
+  Font_BRepTextBuilder aBuilder;
+  DBRep::Set (aName, aBuilder.Perform (aFont, aText, aPenAx3, aHJustification, aVJustification));
   return 0;
 }
 
@@ -5729,7 +6103,7 @@ static Standard_Integer VPointCloud (Draw_Interpretor& theDI,
     for (TopExp_Explorer aFaceIt (aShape, TopAbs_FACE); aFaceIt.More(); aFaceIt.Next())
     {
       const TopoDS_Face& aFace = TopoDS::Face (aFaceIt.Current());
-      Handle(Poly_Triangulation) aTriangulation = StdPrs_ToolShadedShape::Triangulation (aFace, aLocation);
+      Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation (aFace, aLocation);
       if (!aTriangulation.IsNull())
       {
         aNbPoints += aTriangulation->NbNodes();
@@ -5745,7 +6119,7 @@ static Standard_Integer VPointCloud (Draw_Interpretor& theDI,
     for (TopExp_Explorer aFaceIt (aShape, TopAbs_FACE); aFaceIt.More(); aFaceIt.Next())
     {
       const TopoDS_Face& aFace = TopoDS::Face (aFaceIt.Current());
-      Handle(Poly_Triangulation) aTriangulation = StdPrs_ToolShadedShape::Triangulation (aFace, aLocation);
+      Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation (aFace, aLocation);
       if (aTriangulation.IsNull())
       {
         continue;
@@ -5759,7 +6133,7 @@ static Standard_Integer VPointCloud (Draw_Interpretor& theDI,
       if (hasNormals)
       {
         Poly_Connect aPolyConnect (aTriangulation);
-        StdPrs_ToolShadedShape::Normal (aFace, aPolyConnect, aNormals);
+        StdPrs_ToolTriangulatedShape::Normal (aFace, aPolyConnect, aNormals);
       }
 
       for (Standard_Integer aNodeIter = aNodes.Lower(); aNodeIter <= aNodes.Upper(); ++aNodeIter)
@@ -5929,39 +6303,55 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
 {
   const char *group ="AISObjects";
   theCommands.Add("vtrihedron",
-    "vtrihedron         : vtrihedron name [Xo] [Yo] [Zo] [Zu] [Zv] [Zw] [Xu] [Xv] [Xw] ",
+    "vtrihedron         : vtrihedron name [ -origin x y z ] [ -zaxis u v w -xaxis u v w ] [ -hidelabels ]"
+    "\n\t\t: Creates a new *AIS_Trihedron* object. If no argument is set, the default trihedron (0XYZ) is created."
+     "\n\t\t: -hidelabels allows to draw trihedron without axes labels. By default, they are displayed.",
     __FILE__,VTrihedron,group);
 
   theCommands.Add("vtri2d",
-    "vtri2d Name Selection in the viewer only ",
+    "vtri2d Name"
+    "\n\t\t: Creates a plane with a 2D trihedron from an interactively selected face.",
     __FILE__,VTrihedron2D ,group);
 
   theCommands.Add("vplanetri",
-    "vplanetri Name Selection in the viewer only ",
+    "vplanetri name"
+    "\n\t\t: Create a plane from a trihedron selection. If no arguments are set, the default",
     __FILE__,VPlaneTrihedron ,group);
 
   theCommands.Add("vsize",
-    "vsize       : vsize [name(Default=Current)] [size(Default=100)] ",
+    "vsize       : vsize [name(Default=Current)] [size(Default=100)] "
+    "\n\t\t: Changes the size of a named or selected trihedron."
+    "\n\t\t: If the name is not defined: it affects the selected trihedrons otherwise nothing is done."
+    "\n\t\t: If the value is not defined: it is set to 100 by default.",
     __FILE__,VSize,group);
 
   theCommands.Add("vaxis",
-    "vaxis nom [Xa] [Ya] [Za] [Xb] [Yb] [Zb]",
+    "vaxis name [Xa] [Ya] [Za] [Xb] [Yb] [Zb]"
+    "\n\t\t: Creates an axis. If  the values are not defined, an axis is created by interactive selection of two vertices or one edge",
     __FILE__,VAxisBuilder,group);
 
   theCommands.Add("vaxispara",
-    "vaxispara  nom ",
+    "vaxispara name "
+    "\n\t\t: Creates an axis by interactive selection of an edge and a vertex.",
     __FILE__,VAxisBuilder,group);
 
   theCommands.Add("vaxisortho",
-    "vaxisotho  nom ",
+    "vaxisortho name "
+    "\n\t\t: Creates an axis by interactive selection of an edge and a vertex. The axis will be orthogonal to the selected edge.",
     __FILE__,VAxisBuilder,group);
 
   theCommands.Add("vpoint",
-    "vpoint  PointName [Xa] [Ya] [Za] ",
+    "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).",
     __FILE__,VPointBuilder,group);
 
   theCommands.Add("vplane",
-    "vplane  PlaneName [AxisName/PlaneName/PointName] [PointName/PointName/PointName] [Nothing/Nothing/PointName] [TypeOfSensitivity]",
+    "vplane  PlaneName [AxisName/PlaneName/PointName] [PointName/PointName/PointName] [Nothing/Nothing/PointName] [TypeOfSensitivity {0|1}]"
+    "\n\t\t: Creates a plane from named or interactively selected entities."
+    "\n\t\t: TypeOfSensitivity:"
+    "\n\t\t:   0 - Interior"
+    "\n\t\t:   1 - Boundary",
     __FILE__,VPlaneBuilder,group);
 
   theCommands.Add ("vchangeplane", "vchangeplane usage: \n"
@@ -5979,19 +6369,24 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
     __FILE__, VChangePlane, group);
 
   theCommands.Add("vplanepara",
-    "vplanepara  PlaneName  ",
+    "vplanepara  PlaneName  "
+    "\n\t\t: Creates a plane from interactively selected vertex and face.",
     __FILE__,VPlaneBuilder,group);
 
   theCommands.Add("vplaneortho",
-    "vplaneortho  PlaneName  ",
+    "vplaneortho  PlaneName  "
+    "\n\t\t: Creates a plane from interactive selected face and coplanar edge. ",
     __FILE__,VPlaneBuilder,group);
 
   theCommands.Add("vline",
-    "vline: vline LineName [Xa/PointName] [Ya/PointName] [Za] [Xb] [Yb] [Zb]  ",
+    "vline LineName [Xa/PointName] [Ya/PointName] [Za] [Xb] [Yb] [Zb]  "
+    "\n\t\t: Creates a line from coordinates, named or interactively selected vertices. ",
     __FILE__,VLineBuilder,group);
 
   theCommands.Add("vcircle",
-    "vcircle CircleName [PointName PointName PointName IsFilled]\n\t\t\t\t\t[PlaneName PointName Radius IsFilled]",
+    "vcircle CircleName [PointName PointName PointName IsFilled]\n\t\t\t\t\t[PlaneName PointName Radius IsFilled]"
+    "\n\t\t: Creates a circle from named or interactively selected entities."
+    "\n\t\t: Parameter IsFilled is defined as 0 or 1.",
     __FILE__,VCircleBuilder,group);
 
   theCommands.Add ("vdrawtext",
@@ -5999,13 +6394,22 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
                    "\n\t\t: [-pos X=0 Y=0 Z=0]"
                    "\n\t\t: [-color {R G B|name}=yellow]"
                    "\n\t\t: [-halign {left|center|right}=left]"
-                   "\n\t\t: [-valign {top|center|bottom}=bottom}]"
+                   "\n\t\t: [-valign {top|center|bottom|topfirstline}=bottom}]"
                    "\n\t\t: [-angle angle=0]"
                    "\n\t\t: [-zoom {0|1}=0]"
                    "\n\t\t: [-height height=16]"
                    "\n\t\t: [-aspect {regular|bold|italic|bolditalic}=regular]"
                    "\n\t\t: [-font font=Times]"
+                   "\n\t\t: [-2d]"
+                   "\n\t\t: [-perspos {X Y Z}=0 0 0], where"
+                   "\n\t\t X and Y define the coordinate origin in 2d space relative to the view window"
+                   "\n\t\t Example: X=0 Y=0 is center, X=1 Y=1 is upper right corner etc..."
+                   "\n\t\t Z coordinate defines the gap from border of view window (except center position)."
+                   "\n\t\t: [-disptype {blend|decal|subtitle|dimension|normal}=normal}"
+                   "\n\t\t: [-subcolor {R G B|name}=white]"
                    "\n\t\t: [-noupdate]"
+                   "\n\t\t: [-plane NormX NormY NormZ DirX DirY DirZ]"
+                   "\n\t\t: [-flipping]"
                    "\n\t\t: Display text label at specified position.",
     __FILE__, VDrawText, group);
 
@@ -6028,8 +6432,8 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
     __FILE__,VDrawPArray,group);
 
   theCommands.Add("vconnect", 
-    "vconnect : assembly_name Xo Yo Zo object1 object2 ..."
-    "  Makes an assembly of object instances located in point (Xo Yo Zo).",
+    "vconnect name Xo Yo Zo object1 object2 ... [color=NAME]"
+    "\n\t\t: Creates and displays AIS_ConnectedInteractive object from input object and location.",
     __FILE__, VConnect, group);
 
   theCommands.Add("vconnectto",
@@ -6084,11 +6488,13 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
     __FILE__, VSelectionPrevious, group);
 
   theCommands.Add("vtriangle",
-    "vtriangle Name PointName PointName PointName", 
+    "vtriangle Name PointName PointName PointName"
+    "\n\t\t: Creates and displays a filled triangle from named points.", 
     __FILE__, VTriangle,group);
 
   theCommands.Add("vsegment",
-    "vsegment Name PointName PointName", 
+    "vsegment Name PointName PointName"
+    "\n\t\t: Creates and displays a segment from named points.", 
     __FILE__, VSegment,group);
 
   theCommands.Add("vobjzlayer",
@@ -6110,7 +6516,15 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
                    __FILE__, VMarkersTest, group);
 
   theCommands.Add ("text2brep",
-                   "text2brep: res text fontName fontSize [x=0.0 y=0.0 z=0.0 composite=1 {regular,bold,italic,bolditalic=regular}]\n",
+                   "text2brep: name text"
+                   "\n\t\t: [-pos X=0 Y=0 Z=0]"
+                   "\n\t\t: [-halign {left|center|right}=left]"
+                   "\n\t\t: [-valign {top|center|bottom|topfirstline}=bottom}]"
+                   "\n\t\t: [-height height=16]"
+                   "\n\t\t: [-aspect {regular|bold|italic|bolditalic}=regular]"
+                   "\n\t\t: [-font font=Courier]"
+                   "\n\t\t: [-composite {on|off}=off]"
+                   "\n\t\t: [-plane NormX NormY NormZ DirX DirY DirZ]",
                    __FILE__, TextToBRep, group);
   theCommands.Add ("vfont",
                             "vfont [add pathToFont [fontName] [regular,bold,italic,bolditalic=undefined]]"