0027530: Visualization - AIS_InteractiveContext::HilightNextDetected() doesn't work...
[occt.git] / src / ViewerTest / ViewerTest_ObjectCommands.cxx
index ab791f4..686ae6c 100644 (file)
@@ -27,7 +27,6 @@
 #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>
@@ -79,6 +78,7 @@
 #include <AIS_Trihedron.hxx>
 #include <AIS_Axis.hxx>
 #include <gp_Trsf.hxx>
+#include <gp_Quaternion.hxx>
 #include <TopLoc_Location.hxx>
 
 #include <HLRAlgo_Projector.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 <Image_AlienPixMap.hxx>
 #include <TColStd_HArray1OfAsciiString.hxx>
-
-#ifdef _WIN32
-# define _CRT_SECURE_NO_DEPRECATE
-# pragma warning (disable:4996)
-#endif
+#include <TColStd_HSequenceOfAsciiString.hxx>
 
 extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
 extern Standard_Boolean VDisplayAISObject (const TCollection_AsciiString& theName,
@@ -164,7 +161,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;
@@ -175,7 +172,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;
@@ -242,47 +239,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;
 }
@@ -308,7 +384,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;}
@@ -453,7 +529,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;
@@ -485,7 +561,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" };
@@ -540,7 +616,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;
 
@@ -575,7 +651,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;
@@ -597,7 +673,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 {
@@ -656,7 +732,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;
@@ -672,7 +748,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;
@@ -712,7 +788,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;
@@ -728,7 +804,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;
@@ -793,7 +869,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;
 
@@ -820,7 +896,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;
@@ -984,21 +1060,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();
@@ -1469,7 +1545,7 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
         }
         else
         {
-          std::cout<<" vplanepara: error"<<"\n";return 1;
+          std::cout<<" vplanepara: error\n";return 1;
         }
       }
     }
@@ -1770,7 +1846,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();
 
@@ -1792,11 +1868,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);
@@ -1811,7 +1887,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 );
@@ -1850,7 +1926,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;
@@ -1867,7 +1943,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 {
@@ -1902,7 +1978,7 @@ static int VLineBuilder(Draw_Interpretor& di, Standard_Integer argc, const char*
 
     }
     else  {
-      di<<"vline error."<<"\n";
+      di<<"vline error.\n";
     }
 
   }
@@ -1933,7 +2009,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);
@@ -1944,10 +2020,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;
@@ -2070,7 +2146,7 @@ static int VCircleBuilder(Draw_Interpretor& /*di*/, Standard_Integer argc, const
   {
     // Get arguments
     TCollection_AsciiString aName(argv[1]);
-    Standard_Boolean isFilled = (Standard_Boolean)Draw::Atoi(argv[5]);
+    Standard_Boolean isFilled = Draw::Atoi(argv[5]) != 0;
 
     Handle(AIS_InteractiveObject) theShapeA;
     Handle(AIS_InteractiveObject) theShapeB;
@@ -2416,23 +2492,24 @@ static int VDrawText (Draw_Interpretor& theDI,
   Handle(AIS_TextLabel)      aTextPrs;
   ViewerTest_AutoUpdater     anAutoUpdater (aContext, ViewerTest::CurrentView());
 
+  Standard_Boolean isNewPrs = Standard_False;
   if (GetMapOfAIS().IsBound2 (aName))
   {
-    aTextPrs  = Handle(AIS_TextLabel)::DownCast (GetMapOfAIS().Find2 (aName));
+    aTextPrs = Handle(AIS_TextLabel)::DownCast (GetMapOfAIS().Find2 (aName));
   }
-  else
+
+  if (aTextPrs.IsNull())
   {
+    isNewPrs = Standard_True;
     aTextPrs = new AIS_TextLabel();
     aTextPrs->SetFont ("Courier");
   }
 
   aTextPrs->SetText (aText);
 
-  Graphic3d_TransModeFlags aTrsfPersFlags = Graphic3d_TMF_None;
-  gp_Pnt aTPPosition;
+  Handle(Graphic3d_TransformPers) aTrsfPers;
   Aspect_TypeOfDisplayText aDisplayType = Aspect_TODT_NORMAL;
 
-
   Standard_Boolean aHasPlane = Standard_False;
   gp_Dir           aNormal;
   gp_Dir           aDirection;
@@ -2647,6 +2724,10 @@ static int VDrawText (Draw_Interpretor& theDI,
 
       aHasPlane = Standard_True;
     }
+    else if (aParam == "-flipping")
+    {
+      aTextPrs->SetFlipping (Standard_True);
+    }
     else if (aParam == "-disptype"
           || aParam == "-displaytype")
     {
@@ -2715,7 +2796,7 @@ static int VDrawText (Draw_Interpretor& theDI,
     }
     else if (aParam == "-2d")
     {
-      aTrsfPersFlags = Graphic3d_TMF_2d;
+      aTrsfPers = new Graphic3d_TransformPers (Graphic3d_TMF_2d);
     }
     else if (aParam == "-trsfperspos"
           || aParam == "-perspos")
@@ -2744,7 +2825,8 @@ static int VDrawText (Draw_Interpretor& theDI,
           ++anArgIt;
         }
       }
-      aTPPosition.SetCoord (aX.IntegerValue(), aY.IntegerValue(), aZ.IntegerValue());
+
+      aTrsfPers = Graphic3d_TransformPers::FromDeprecatedParams (Graphic3d_TMF_2d, gp_Pnt (aX.IntegerValue(), aY.IntegerValue(), aZ.IntegerValue()));
     }
     else
     {
@@ -2758,22 +2840,30 @@ static int VDrawText (Draw_Interpretor& theDI,
     aTextPrs->SetOrientation3D (gp_Ax2 (aPos, aNormal, aDirection));
   }
 
-  if (aTrsfPersFlags != Graphic3d_TMF_None)
+  aTextPrs->SetDisplayType (aDisplayType);
+
+  if (!aTrsfPers.IsNull())
   {
-    aTextPrs->SetTransformPersistence (aTrsfPersFlags, aTPPosition);
-    aTextPrs->SetDisplayType (aDisplayType);
+    aContext->SetTransformPersistence (aTextPrs, aTrsfPers);
     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)
+  else if (!aTextPrs->TransformPersistence().IsNull())
+  {
+    aContext->SetTransformPersistence (aTextPrs, Handle(Graphic3d_TransformPers)());
+  }
+
+  if (isNewPrs)
+  {
+    ViewerTest::Display (aName, aTextPrs, Standard_False);
+  }
+  else
   {
-    aTextPrs->SetTransformPersistence (aTrsfPersFlags);
-    aTextPrs->SetDisplayType (Aspect_TODT_NORMAL);
+    aContext->Redisplay (aTextPrs, Standard_False, Standard_True);
   }
-  ViewerTest::Display (aName, aTextPrs, Standard_False);
   return 0;
 }
 
@@ -3083,20 +3173,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);
 
@@ -3170,7 +3253,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"
@@ -3299,16 +3382,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,
@@ -3478,6 +3561,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);
 }
 
@@ -3626,12 +3711,47 @@ static int VDrawPArray (Draw_Interpretor& di, Standard_Integer argc, const char*
   return 0;
 }
 
+namespace
+{
+  //! Auxiliary function for parsing translation vector - either 2D or 3D.
+  static Standard_Integer parseTranslationVec (Standard_Integer theArgNb,
+                                               const char**     theArgVec,
+                                               gp_Vec&          theVec)
+  {
+    if (theArgNb < 2)
+    {
+      return 0;
+    }
+
+    TCollection_AsciiString anX (theArgVec[0]);
+    TCollection_AsciiString anY (theArgVec[1]);
+    if (!anX.IsRealValue()
+     || !anY.IsRealValue())
+    {
+      return 0;
+    }
+
+    theVec.SetX (anX.RealValue());
+    theVec.SetY (anY.RealValue());
+    if (theArgNb >= 3)
+    {
+      TCollection_AsciiString anZ (theArgVec[2]);
+      if (anZ.IsRealValue())
+      {
+        theVec.SetZ (anZ.RealValue());
+        return 3;
+      }
+    }
+    return 2;
+  }
+}
+
 //=======================================================================
 //function : VSetLocation
 //purpose  : Change location of AIS interactive object
 //=======================================================================
 
-static Standard_Integer VSetLocation (Draw_Interpretor& /*di*/,
+static Standard_Integer VSetLocation (Draw_Interpretor& theDI,
                                       Standard_Integer  theArgNb,
                                       const char**      theArgVec)
 {
@@ -3643,221 +3763,330 @@ static Standard_Integer VSetLocation (Draw_Interpretor& /*di*/,
     return 1;
   }
 
-  TCollection_AsciiString aName;
-  gp_Vec aLocVec;
-  Standard_Boolean isSetLoc = Standard_False;
-
-  Standard_Integer anArgIter = 1;
-  for (; anArgIter < theArgNb; ++anArgIter)
+  Standard_Boolean toPrintInfo = Standard_True;
+  Handle(AIS_InteractiveObject) anObj;
+  TCollection_AsciiString aCmdName (theArgVec[0]);
+  aCmdName.LowerCase();
+  for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
   {
-    Standard_CString anArg = theArgVec[anArgIter];
-    if (anUpdateTool.parseRedrawMode (theArgVec[anArgIter]))
+    TCollection_AsciiString anArg = theArgVec[anArgIter];
+    anArg.LowerCase();
+    if (anUpdateTool.parseRedrawMode (anArg))
     {
       continue;
     }
-    else if (aName.IsEmpty())
+    else if (anObj.IsNull())
+    {
+      const TCollection_AsciiString aName (theArgVec[anArgIter]);
+      const ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
+      if (aMap.IsBound2 (aName))
+      {
+        anObj = Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (aName));
+      }
+      if (anObj.IsNull())
+      {
+        std::cout << "Error: object '" << aName << "' is not displayed!\n";
+        return 1;
+      }
+    }
+    else if (anArg == "-reset")
     {
-      aName = anArg;
+      toPrintInfo = Standard_False;
+      aContext->SetLocation (anObj, gp_Trsf());
     }
-    else if (!isSetLoc)
+    else if (anArg == "-copyfrom"
+          || anArg == "-copy")
     {
-      isSetLoc = Standard_True;
       if (anArgIter + 1 >= theArgNb)
       {
-        std::cout << "Error: syntax error at '" << anArg << "'\n";
+        std::cout << "Syntax error at '" << anArg << "'\n";
         return 1;
       }
-      aLocVec.SetX (Draw::Atof (theArgVec[anArgIter++]));
-      aLocVec.SetY (Draw::Atof (theArgVec[anArgIter]));
-      if (anArgIter + 1 < theArgNb)
+
+      const TCollection_AsciiString aName2 (theArgVec[anArgIter + 1]);
+      const ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
+      Handle(AIS_InteractiveObject) anObj2;
+      if (aMap.IsBound2 (aName2))
+      {
+        anObj2 = Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (aName2));
+      }
+      if (anObj2.IsNull())
       {
-        aLocVec.SetZ (Draw::Atof (theArgVec[++anArgIter]));
+        std::cout << "Error: object '" << aName2 << "' is not displayed!\n";
+        return 1;
       }
+
+      ++anArgIter;
+      aContext->SetLocation (anObj, anObj2->LocalTransformation());
     }
-    else
+    else if (anArg == "-rotate")
     {
-      std::cout << "Error: unknown argument '" << anArg << "'\n";
-      return 1;
-    }
-  }
-
-  // find object
-  const ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
-  Handle(AIS_InteractiveObject) anIObj;
-  if (aMap.IsBound2 (aName))
-  {
-    anIObj = Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (aName));
-  }
-  if (anIObj.IsNull())
-  {
-    std::cout << "Error: object '" << aName << "' is not displayed!\n";
-    return 1;
-  }
-
-  gp_Trsf aTrsf;
-  aTrsf.SetTranslation (aLocVec);
-  TopLoc_Location aLocation (aTrsf);
-  aContext->SetLocation (anIObj, aLocation);
-  return 0;
-}
-
-//=======================================================================
-//function : TransformPresentation
-//purpose  : Change transformation of AIS interactive object
-//=======================================================================
-static Standard_Integer LocalTransformPresentation (Draw_Interpretor& /*theDi*/,
-                                                    Standard_Integer theArgNb,
-                                                    const char** theArgVec)
-{
-  if (theArgNb <= 1)
-  {
-    std::cout << "Error: too few arguments.\n";
-    return 1;
-  }
-
-  Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
-  ViewerTest_AutoUpdater anUpdateTool(aContext, ViewerTest::CurrentView());
-  if (aContext.IsNull())
-  {
-    std::cout << "Error: no active view!\n";
-    return 1;
-  }
-
-  gp_Trsf aTrsf;
-  Standard_Integer aLast = theArgNb;
-  const char* aName = theArgVec[0];
-
-  Standard_Boolean isReset = Standard_False;
-  Standard_Boolean isMove = Standard_False;
+      toPrintInfo = Standard_False;
+      if (anArgIter + 7 >= theArgNb)
+      {
+        std::cout << "Syntax error at '" << anArg << "'\n";
+        return 1;
+      }
 
-  // Prefix 'vloc'
-  aName += 4;
+      gp_Trsf aTrsf;
+      aTrsf.SetRotation (gp_Ax1 (gp_Pnt (Draw::Atof (theArgVec[anArgIter + 1]),
+                                         Draw::Atof (theArgVec[anArgIter + 2]),
+                                         Draw::Atof (theArgVec[anArgIter + 3])),
+                                 gp_Vec (Draw::Atof (theArgVec[anArgIter + 4]),
+                                         Draw::Atof (theArgVec[anArgIter + 5]),
+                                         Draw::Atof (theArgVec[anArgIter + 6]))),
+                                         Draw::Atof (theArgVec[anArgIter + 7]) * (M_PI / 180.0));
+      anArgIter += 7;
 
-  if (!strcmp (aName, "reset"))
-  {
-    isReset = Standard_True;
-  }
-  else if (!strcmp (aName, "move"))
-  {
-    if (theArgNb < 3)
-    {
-      std::cout << "Error: too few arguments.\n";
-      return 1;
+      aTrsf = anObj->LocalTransformation() * aTrsf;
+      aContext->SetLocation (anObj, aTrsf);
     }
-
-    const ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
-
-    Handle(AIS_InteractiveObject) anIObj;
-    if (aMap.IsBound2 (theArgVec[theArgNb - 1]))
+    else if (anArg == "-translate")
     {
-      anIObj = Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (theArgVec[theArgNb - 1]));
-    }
+      toPrintInfo = Standard_False;
+      gp_Vec aLocVec;
+      Standard_Integer aNbParsed = parseTranslationVec (theArgNb - anArgIter - 1, theArgVec + anArgIter + 1, aLocVec);
+      anArgIter += aNbParsed;
+      if (aNbParsed == 0)
+      {
+        std::cout << "Syntax error at '" << anArg << "'\n";
+        return 1;
+      }
 
-    if (anIObj.IsNull())
-    {
-      std::cout << "Error: object '" << theArgVec[theArgNb - 1] << "' is not displayed!\n";
-      return 1;
+      gp_Trsf aTrsf;
+      aTrsf.SetTranslationPart (aLocVec);
+      aTrsf = anObj->LocalTransformation() * aTrsf;
+      aContext->SetLocation (anObj, aTrsf);
     }
+    else if (anArg == "-scale"
+          || anArg == "-setscale")
+    {
+      toPrintInfo = Standard_False;
+      gp_XYZ aScaleLoc;
+      Standard_Real aScale = 1.0;
+      Standard_Boolean toPrintScale = Standard_True;
+      Standard_Boolean hasScaleLoc  = Standard_False;
+      if (anArgIter + 4 < theArgNb)
+      {
+        TCollection_AsciiString aScaleArgs[4] =
+        {
+          TCollection_AsciiString (theArgVec[anArgIter + 1]),
+          TCollection_AsciiString (theArgVec[anArgIter + 2]),
+          TCollection_AsciiString (theArgVec[anArgIter + 3]),
+          TCollection_AsciiString (theArgVec[anArgIter + 4])
+        };
+        Standard_Integer aScaleArgIter = 0;
+        for (; aScaleArgIter < 4; ++aScaleArgIter)
+        {
+          if (!aScaleArgs[aScaleArgIter].IsRealValue())
+          {
+            break;
+          }
+        }
+        if (aScaleArgIter == 4)
+        {
+          aScaleLoc.SetCoord (aScaleArgs[0].RealValue(), aScaleArgs[1].RealValue(), aScaleArgs[2].RealValue());
+          aScale = aScaleArgs[3].RealValue();
+          anArgIter += 4;
+          toPrintScale = Standard_False;
+          hasScaleLoc  = Standard_True;
+        }
+        else if (aScaleArgIter >= 1)
+        {
+          aScale = aScaleArgs[0].RealValue();
+          ++anArgIter;
+          toPrintScale = Standard_False;
+        }
+      }
+      else if (anArgIter + 1 < theArgNb)
+      {
+        TCollection_AsciiString aScaleArg (theArgVec[anArgIter + 1]);
+        if (aScaleArg.IsRealValue())
+        {
+          aScale = aScaleArg.RealValue();
+          ++anArgIter;
+          toPrintScale = Standard_False;
+        }
+      }
 
-    isMove = Standard_True;
+      if (toPrintScale)
+      {
+        if (anArg == "-setscale")
+        {
+          std::cout << "Syntax error at '" << anArg << "'\n";
+          return 1;
+        }
 
-    aTrsf = anIObj->Transformation();
-    aLast = theArgNb - 1;
-  }
-  else if (!strcmp (aName, "translate"))
-  {
-    if (theArgNb < 5)
-    {
-      std::cout << "Error: too few arguments.\n";
-      return 1;
+        char aText[1024];
+        Sprintf (aText, "%g ", anObj->LocalTransformation().ScaleFactor());
+        theDI << aText;
+        continue;
+      }
+
+      if (anArg == "-setscale")
+      {
+        gp_Trsf aTrsf = anObj->LocalTransformation();
+        if (hasScaleLoc)
+        {
+          aTrsf.SetScale (aScaleLoc, aScale);
+        }
+        else
+        {
+          aTrsf.SetScaleFactor (aScale);
+        }
+        aContext->SetLocation (anObj, aTrsf);
+      }
+      else
+      {
+        gp_Trsf aTrsf;
+        if (hasScaleLoc)
+        {
+          aTrsf.SetScale (aScaleLoc, aScale);
+          aTrsf = anObj->LocalTransformation() * aTrsf;
+        }
+        else
+        {
+          aTrsf = anObj->LocalTransformation();
+          aTrsf.SetScaleFactor (aTrsf.ScaleFactor() * aScale);
+        }
+        aContext->SetLocation (anObj, aTrsf);
+      }
     }
-    aTrsf.SetTranslation (gp_Vec (Draw::Atof (theArgVec[theArgNb - 3]),
-                                  Draw::Atof (theArgVec[theArgNb - 2]),
-                                  Draw::Atof (theArgVec[theArgNb - 1])));
-    aLast = theArgNb - 3;
-  }
-  else if (!strcmp (aName, "rotate"))
-  {
-    if (theArgNb < 9)
+    else if (anArg == "-mirror")
     {
-      std::cout << "Error: too few arguments.\n";
-      return 1;
-    }
-
-    aTrsf.SetRotation (
-      gp_Ax1 (gp_Pnt (Draw::Atof (theArgVec[theArgNb - 7]),
-                      Draw::Atof (theArgVec[theArgNb - 6]),
-                      Draw::Atof (theArgVec[theArgNb - 5])),
-              gp_Vec (Draw::Atof (theArgVec[theArgNb - 4]),
-                      Draw::Atof (theArgVec[theArgNb - 3]),
-                      Draw::Atof (theArgVec[theArgNb - 2]))),
-      Draw::Atof (theArgVec[theArgNb - 1]) * (M_PI / 180.0));
+      toPrintInfo = Standard_False;
+      if (anArgIter + 6 >= theArgNb)
+      {
+        std::cout << "Syntax error at '" << anArg << "'\n";
+        return 1;
+      }
 
-    aLast = theArgNb - 7;
-  }
-  else if (!strcmp (aName, "mirror"))
-  {
-    if (theArgNb < 8)
-    {
-      std::cout << "Error: too few arguments.\n";
-      return 1;
+      gp_Trsf aTrsf;
+      aTrsf.SetMirror (gp_Ax2 (gp_Pnt (Draw::Atof(theArgVec[theArgNb - 6]),
+                                       Draw::Atof(theArgVec[theArgNb - 5]),
+                                       Draw::Atof(theArgVec[theArgNb - 4])),
+                               gp_Vec (Draw::Atof(theArgVec[theArgNb - 3]),
+                                       Draw::Atof(theArgVec[theArgNb - 2]),
+                                       Draw::Atof(theArgVec[theArgNb - 1]))));
+      anArgIter += 6;
+      aTrsf = anObj->LocalTransformation() * aTrsf;
+      aContext->SetLocation (anObj, aTrsf);
     }
-
-    aTrsf.SetMirror (gp_Ax2 (gp_Pnt (Draw::Atof(theArgVec[theArgNb - 6]),
-                                     Draw::Atof(theArgVec[theArgNb - 5]),
-                                     Draw::Atof(theArgVec[theArgNb - 4])),
-                             gp_Vec (Draw::Atof(theArgVec[theArgNb - 3]),
-                                     Draw::Atof(theArgVec[theArgNb - 2]),
-                                     Draw::Atof(theArgVec[theArgNb - 1]))));
-    aLast = theArgNb - 6;
-  }
-  else if (!strcmp (aName, "scale"))
-  {
-    if (theArgNb < 6)
+    else if (anArg == "-setrotation"
+          || anArg == "-rotation")
     {
-      std::cout << "Error: too few arguments.\n";
-      return 1;
-    }
+      toPrintInfo = Standard_False;
+      if (anArgIter + 4 < theArgNb)
+      {
+        TCollection_AsciiString aQuatArgs[4] =
+        {
+          TCollection_AsciiString (theArgVec[anArgIter + 1]),
+          TCollection_AsciiString (theArgVec[anArgIter + 2]),
+          TCollection_AsciiString (theArgVec[anArgIter + 3]),
+          TCollection_AsciiString (theArgVec[anArgIter + 4])
+        };
+        Standard_Integer aQuatArgIter = 0;
+        for (; aQuatArgIter < 4; ++aQuatArgIter)
+        {
+          if (!aQuatArgs[aQuatArgIter].IsRealValue())
+          {
+            break;
+          }
+        }
 
-    aTrsf.SetScale (gp_Pnt (Draw::Atof(theArgVec[theArgNb - 4]),
-                            Draw::Atof(theArgVec[theArgNb - 3]),
-                            Draw::Atof(theArgVec[theArgNb - 2])),
-                    Draw::Atof(theArgVec[theArgNb - 1]));
-    aLast = theArgNb - 4;
-  }
+        if (aQuatArgIter == 4)
+        {
+          anArgIter += 4;
+          const gp_Quaternion aQuat (aQuatArgs[0].RealValue(),
+                                     aQuatArgs[1].RealValue(),
+                                     aQuatArgs[2].RealValue(),
+                                     aQuatArgs[3].RealValue());
+          gp_Trsf aTrsf = anObj->LocalTransformation();
+          aTrsf.SetRotation (aQuat);
+          aContext->SetLocation (anObj, aTrsf);
+          continue;
+        }
+        else if (anArg == "-setrotation")
+        {
+          std::cout << "Syntax error at '" << anArg << "'\n";
+          return 1;
+        }
+      }
 
-  for (Standard_Integer anIdx = 1; anIdx < aLast; anIdx++)
-  {
-    // find object
-    const ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
-    Handle(AIS_InteractiveObject) anIObj;
-    if (aMap.IsBound2 (theArgVec[anIdx]))
-    {
-      anIObj = Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (theArgVec[anIdx]));
-    }
-    if (anIObj.IsNull())
-    {
-      std::cout << "Error: object '" << theArgVec[anIdx] << "' is not displayed!\n";
-      return 1;
+      char aText[1024];
+      const gp_Quaternion aQuat = anObj->LocalTransformation().GetRotation();
+      Sprintf (aText, "%g %g %g %g ", aQuat.X(), aQuat.Y(), aQuat.Z(), aQuat.W());
+      theDI << aText;
     }
-    
-    if (isReset)
+    else if (anArg == "-setlocation"
+          || anArg == "-location")
     {
-      // aTrsf already identity
+      toPrintInfo = Standard_False;
+      gp_Vec aLocVec;
+      Standard_Integer aNbParsed = parseTranslationVec (theArgNb - anArgIter - 1, theArgVec + anArgIter + 1, aLocVec);
+      anArgIter += aNbParsed;
+      if (aNbParsed != 0)
+      {
+        gp_Trsf aTrsf = anObj->LocalTransformation();
+        aTrsf.SetTranslationPart (aLocVec);
+        aContext->SetLocation (anObj, aTrsf);
+      }
+      else if (anArg == "-setlocation")
+      {
+        std::cout << "Syntax error at '" << anArg << "'\n";
+        return 1;
+      }
+
+      char aText[1024];
+      const gp_XYZ aLoc = anObj->LocalTransformation().TranslationPart();
+      Sprintf (aText, "%g %g %g ", aLoc.X(), aLoc.Y(), aLoc.Z());
+      theDI << aText;
     }
-    else if (isMove)
+    else if (aCmdName == "vsetlocation")
     {
-      aTrsf = anIObj->LocalTransformation() * anIObj->Transformation().Inverted() * aTrsf;
+      // compatibility with old syntax
+      gp_Vec aLocVec;
+      Standard_Integer aNbParsed = parseTranslationVec (theArgNb - anArgIter, theArgVec + anArgIter, aLocVec);
+      if (aNbParsed == 0)
+      {
+        std::cout << "Syntax error at '" << anArg << "'\n";
+        return 1;
+      }
+      anArgIter = anArgIter + aNbParsed - 1;
+
+      gp_Trsf aTrsf;
+      aTrsf.SetTranslationPart (aLocVec);
+      aContext->SetLocation (anObj, aTrsf);
+      toPrintInfo = Standard_False;
     }
     else
     {
-      aTrsf = anIObj->LocalTransformation() * aTrsf;
+      std::cout << "Error: unknown argument '" << anArg << "'\n";
+      return 1;
     }
+  }
 
-    TopLoc_Location aLocation (aTrsf);
-    aContext->SetLocation (anIObj, aLocation);
+  if (anObj.IsNull())
+  {
+    std::cout << "Syntax error - wrong number of arguments\n";
+    return 1;
+  }
+  else if (!toPrintInfo)
+  {
+    return 0;
   }
 
+  const gp_Trsf       aTrsf = anObj->LocalTransformation();
+  const gp_XYZ        aLoc  = aTrsf.TranslationPart();
+  const gp_Quaternion aRot  = aTrsf.GetRotation();
+  char aText[4096];
+  Sprintf (aText, "Location: %g %g %g\n"
+                  "Rotation: %g %g %g %g\n"
+                  "Scale:    %g\n",
+                  aLoc.X(), aLoc.Y(), aLoc.Z(),
+                  aRot.X(), aRot.Y(), aRot.Z(), aRot.W(),
+                  aTrsf.ScaleFactor());
+  theDI << aText;
   return 0;
 }
 
@@ -4099,13 +4328,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;
   }
 
@@ -4118,14 +4347,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;
   }
 
@@ -4148,7 +4377,7 @@ static Standard_Integer VDisconnect (Draw_Interpretor& di,
     }
     else
     {
-      std::cout << "Use 'vdisplay' before" << "\n";
+      std::cout << "Use 'vdisplay' before\n";
       return 1;
     }    
   }
@@ -4176,7 +4405,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;
   }
   
@@ -4197,21 +4426,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; 
   }
 
@@ -4239,13 +4468,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;
   }
 
@@ -4256,14 +4485,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;
   }
 
@@ -4311,7 +4540,7 @@ namespace
     }
     return Standard_False;
   }
-};
+}
 
 //===============================================================================================
 //function : VSetSelectionMode
@@ -4366,7 +4595,7 @@ static Standard_Integer VSetSelectionMode (Draw_Interpretor& /*di*/,
   }
 
   const Standard_Integer aSelectionMode = Draw::Atoi (anArgNb == 3 ? theArgv[1] : theArgv[2]);
-  const Standard_Boolean toTurnOn       = Draw::Atoi (anArgNb == 3 ? theArgv[2] : theArgv[3]);
+  const Standard_Boolean toTurnOn       = Draw::Atoi (anArgNb == 3 ? theArgv[2] : theArgv[3]) != 0;
   if (aSelectionMode == 0 && anAISContext->HasOpenedContext())
   {
     anAISContext->CloseLocalContext();
@@ -4459,7 +4688,7 @@ static Standard_Integer VSelectionNext(Draw_Interpretor& /*theDI*/,
     return 1;
   }
 
-  anAISContext->HilightNextDetected(aView);
+  anAISContext->HilightNextDetected (aView);
   return 0;
 }
 
@@ -4481,7 +4710,7 @@ static Standard_Integer VSelectionPrevious(Draw_Interpretor& /*theDI*/,
     return 1;
   }
 
-  anAISContext->HilightPreviousDetected(aView);
+  anAISContext->HilightPreviousDetected (aView);
   return 0;
 }
 
@@ -4496,17 +4725,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;
@@ -4690,15 +4919,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;
@@ -4836,7 +5065,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;
   }
 
@@ -5079,16 +5308,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:
 
@@ -6224,39 +6453,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"
@@ -6274,19 +6519,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",
@@ -6309,6 +6559,7 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
                    "\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);
 
@@ -6316,9 +6567,29 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
     "vdrawsphere: vdrawsphere shapeName Fineness [X=0.0 Y=0.0 Z=0.0] [Radius=100.0] [ToShowEdges=0] [ToPrintInfo=1]\n",
     __FILE__,VDrawSphere,group);
 
+  theCommands.Add ("vlocation",
+                "vlocation name"
+      "\n\t\t:   [-reset]"
+      "\n\t\t:   [-copyFrom otherName]"
+      "\n\t\t:   [-translate X Y [Z]]"
+      "\n\t\t:   [-rotate x y z dx dy dz angle]"
+      "\n\t\t:   [-scale [X Y Z] scale]"
+      "\n\t\t:   [-mirror x y z dx dy dz]"
+      "\n\t\t:   [-setLocation X Y [Z]]"
+      "\n\t\t:   [-setRotation QX QY QZ QW]"
+      "\n\t\t:   [-setScale [X Y Z] scale]"
+      "\n\t\t: Object local transformation management:"
+      "\n\t\t:   -reset       reset transformation to identity"
+      "\n\t\t:   -translate   translate object"
+      "\n\t\t:   -rotate      applies rotation to local transformation"
+      "\n\t\t:   -scale       applies scale    to local transformation"
+      "\n\t\t:   -mirror      applies mirror   to local transformation"
+      "\n\t\t:   -setLocation assign object location"
+      "\n\t\t:   -setRotation assign object rotation (quaternion)"
+      "\n\t\t:   -setScale    assign object scale factor",
+        __FILE__, VSetLocation, group);
   theCommands.Add ("vsetlocation",
-                   "vsetlocation [-noupdate|-update] name x y z"
-                   "\n\t\t: Set new location for an interactive object.",
+                   "alias for vlocation",
         __FILE__, VSetLocation, group);
 
   theCommands.Add (
@@ -6331,8 +6602,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",
@@ -6387,11 +6658,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",
@@ -6465,36 +6738,6 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
                    "\n",
                    __FILE__, VPointCloud, group);
 
-  theCommands.Add("vlocreset",
-    "vlocreset name1 name2 ...\n\t\t  remove object local transformation",
-    __FILE__,
-    LocalTransformPresentation, group);
-
-  theCommands.Add("vlocmove",
-    "vlocmove name1 name2 ... name\n\t\t  set local transform to match transform of 'name'",
-    __FILE__,
-    LocalTransformPresentation, group);
-
-  theCommands.Add("vloctranslate",
-    "vloctranslate name1 name2 ... dx dy dz\n\t\t  applies translation to local transformation",
-    __FILE__,
-    LocalTransformPresentation, group);
-
-  theCommands.Add("vlocrotate",
-    "vlocrotate name1 name2 ... x y z dx dy dz angle\n\t\t  applies rotation to local transformation",
-    __FILE__,
-    LocalTransformPresentation, group);
-
-  theCommands.Add("vlocmirror",
-    "vlocmirror name x y z dx dy dz\n\t\t  applies mirror to local transformation",
-    __FILE__,
-    LocalTransformPresentation, group);
-
-  theCommands.Add("vlocscale",
-    "vlocscale name x y z scale\n\t\t  applies scale to local transformation",
-    __FILE__,
-    LocalTransformPresentation, group);
-
   theCommands.Add("vpriority",
     "vpriority [-noupdate|-update] name [value]\n\t\t  prints or sets the display priority for an object",
     __FILE__,