0020716: Eliminate usage of "config.h" header file
[occt.git] / src / ViewerTest / ViewerTest_ObjectCommands.cxx
index 5878fe8..a05402d 100644 (file)
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
 #include <ViewerTest.hxx>
 
-#include <string.h>
-
 #include <Quantity_NameOfColor.hxx>
 #include <Draw_Interpretor.hxx>
 #include <Draw.hxx>
 #include <StdPrs_ShadedShape.hxx>
 #include <TopoDS_Wire.hxx>
 
-#include <AIS_ConnectedShape.hxx>
 #include <AIS_MultipleConnectedInteractive.hxx>
-#include <AIS_MultipleConnectedShape.hxx>
+#include <AIS_ConnectedInteractive.hxx>
 #include <TopLoc_Location.hxx>
 #include <TColStd_ListOfInteger.hxx>
 #include <TColStd_ListIteratorOfListOfInteger.hxx>
 #include <BRepExtrema_ExtPC.hxx>
 #include <BRepExtrema_ExtPF.hxx>
 
+#include <Prs3d_VertexDrawMode.hxx>
 #include <Prs3d_LineAspect.hxx>
 #include <Prs3d_PointAspect.hxx>
 
 #include <Image_AlienPixMap.hxx>
 #include <TColStd_HArray1OfAsciiString.hxx>
 
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-
-#ifdef WNT
-#define _CRT_SECURE_NO_DEPRECATE
-#pragma warning (disable:4996)
+#ifdef _WIN32
+# define _CRT_SECURE_NO_DEPRECATE
+# pragma warning (disable:4996)
 #endif
 
 extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
@@ -2182,7 +2172,7 @@ static int VCircleBuilder(Draw_Interpretor& /*di*/, Standard_Integer argc, const
         std::cout << "vcircle error: 2d element is a unexpected to be a point.\n"; 
         return 1; // TCL_ERROR 
       }
-      // Ñheck that the radius is >= 0
+      // Check that the radius is >= 0
       if (Draw::Atof(argv[4]) <= 0 ) 
       {
         std::cout << "vcircle error: the radius must be >=0.\n"; 
@@ -2379,7 +2369,7 @@ static int VCircleBuilder(Draw_Interpretor& /*di*/, Standard_Integer argc, const
       // Recover the center
       gp_Pnt theCenter = BRep_Tool::Pnt(TopoDS::Vertex(ShapeB));
 
-      // Ñonstruct the circle
+      // Construct the circle
       GC_MakeCircle Cir = GC_MakeCircle (theCenter, theDir ,theRad);
       Handle (Geom_Circle) theGeomCircle;
       try 
@@ -2419,7 +2409,6 @@ static int VCircleBuilder(Draw_Interpretor& /*di*/, Standard_Integer argc, const
 #include <Font_NameOfFont.hxx>
 
 #include <Visual3d_ViewManager.hxx>
-#include <ViewerTest_Tool.ixx>
 
 #include <Standard_DefineHandle.hxx>
 
@@ -2924,12 +2913,14 @@ static int VDrawSphere (Draw_Interpretor& /*di*/, Standard_Integer argc, const c
   Standard_Real aCenterY = (argc > 5) ? Draw::Atof (argv[4]) : 0.0;
   Standard_Real aCenterZ = (argc > 5) ? Draw::Atof (argv[5]) : 0.0;
   Standard_Real aRadius =  (argc > 6) ? Draw::Atof (argv[6]) : 100.0;
-  Standard_Boolean toShowEdges =  (argc > 7) ? Draw::Atoi (argv[7]) : Standard_False;
+  Standard_Boolean toShowEdges = (argc > 7) ? Draw::Atoi (argv[7]) == 1 : Standard_False;
+  Standard_Boolean toPrintInfo = (argc > 8) ? Draw::Atoi (argv[8]) == 1 : Standard_True;
 
   // remove AIS object with given name from map
   VDisplayAISObject (aShapeName, Handle(AIS_InteractiveObject)());
 
-  std::cout << "Compute Triangulation...\n";
+  if (toPrintInfo)
+    std::cout << "Compute Triangulation...\n";
   Handle(AIS_Triangulation) aShape
     = new AIS_Triangulation (CalculationOfSphere (aCenterX, aCenterY, aCenterZ,
                                                   aResolution,
@@ -2968,12 +2959,15 @@ static int VDrawSphere (Draw_Interpretor& /*di*/, Standard_Integer argc, const c
   aColorsSize >>= 20;
   aTrianglesSize >>= 20;
   aPolyConnectSize >>= 20;
-  std::cout << "NumberOfPoints:    " << aNumberPoints << "\n"
-            << "NumberOfTriangles: " << aNumberTriangles << "\n"
-            << "Amount of memory required for PolyTriangulation without Normals: " << (aTotalSize - aNormalsSize) << " Mb\n"
-            << "Amount of memory for colors: " << aColorsSize << " Mb\n"
-            << "Amount of memory for PolyConnect: " << aPolyConnectSize << " Mb\n"
-            << "Amount of graphic card memory required: " << aTotalSize << " Mb\n";
+  if (toPrintInfo)
+  {
+    std::cout << "NumberOfPoints:    " << aNumberPoints << "\n"
+      << "NumberOfTriangles: " << aNumberTriangles << "\n"
+      << "Amount of memory required for PolyTriangulation without Normals: " << (aTotalSize - aNormalsSize) << " Mb\n"
+      << "Amount of memory for colors: " << aColorsSize << " Mb\n"
+      << "Amount of memory for PolyConnect: " << aPolyConnectSize << " Mb\n"
+      << "Amount of graphic card memory required: " << aTotalSize << " Mb\n";
+  }
 
   // Setting material properties, very important for desirable visual result!
   Graphic3d_MaterialAspect aMat (Graphic3d_NOM_PLASTIC);
@@ -3486,20 +3480,20 @@ static int VDrawPArray (Draw_Interpretor& di, Standard_Integer argc, const char*
 //purpose  : Change location of AIS interactive object
 //=======================================================================
 
-static Standard_Integer VSetLocation (Draw_Interpretor& di,
+static Standard_Integer VSetLocation (Draw_Interpretor& /*di*/,
                                       Standard_Integer argc,
                                       const char ** argv)
 {
   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
   if (aContext.IsNull())
   {
-    di << argv[0] << "ERROR : use 'vinit' command before " << "\n";
+    std::cout << argv[0] << "ERROR : use 'vinit' command before " << "\n";
     return 1;
   }
 
   if (argc != 5)
   {
-    di << "ERROR : Usage : " << argv[0] << " name x y z; new location" << "\n";
+    std::cout << "ERROR : Usage : " << argv[0] << " name x y z; new location" << "\n";
     return 1;
   }
 
@@ -3513,7 +3507,7 @@ static Standard_Integer VSetLocation (Draw_Interpretor& di,
   Handle(AIS_InteractiveObject) anIObj;
   if (!aMap.IsBound2 (aName))
   {
-    di << "Use 'vdisplay' before" << "\n";
+    std::cout << "Use 'vdisplay' before" << "\n";
     return 1;
   }
   else
@@ -3523,7 +3517,7 @@ static Standard_Integer VSetLocation (Draw_Interpretor& di,
     // not an AIS_InteractiveObject
     if (anIObj.IsNull())
     {
-      di << argv[1] << " : Not an AIS interactive object" << "\n";
+      std::cout << argv[1] << " : Not an AIS interactive object" << "\n";
       return 1;
     }
 
@@ -3540,12 +3534,12 @@ static Standard_Integer VSetLocation (Draw_Interpretor& di,
 //===============================================================================================
 //function : VConnect
 //purpose  : Creates and displays AIS_ConnectedInteractive object from input object and location 
-//Draw arg : vconnect name Xo Yo Zo Xu Xv Xw Zu Zv Zw object1 object2 ... [color=NAME]
+//Draw arg : vconnect name Xo Yo Zo object1 object2 ... [color=NAME]
 //===============================================================================================
 
-static Standard_Integer VConnect(Draw_Interpretor& /*di*/, 
-                                 Standard_Integer argc, 
-                                 const char ** argv) 
+static Standard_Integer VConnect (Draw_Interpretor& /*di*/, 
+                                  Standard_Integer argc, 
+                                  const char ** argv) 
 {
   // Check the viewer
   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
@@ -3555,16 +3549,16 @@ static Standard_Integer VConnect(Draw_Interpretor& /*di*/,
     return 1; // TCL_ERROR
   }
   // Check argumnets 
-  if (argc < 12)
+  if (argc < 6)
   {
-    std::cout << "vconnect error: expect at least 11 arguments\n";
+    std::cout << "vconnect error: expect at least 5 arguments\n";
     return 1; // TCL_ERROR
   }
 
   // Get values
   Standard_Integer anArgIter = 1;
   TCollection_AsciiString aName (argv[anArgIter++]);
-  Handle(AIS_InteractiveObject) anOriginObject;
+  Handle(AIS_MultipleConnectedInteractive) anOriginObject;
   TCollection_AsciiString aColorString (argv[argc-1]);
   Standard_CString aColorName = "";
   Standard_Boolean hasColor = Standard_False;
@@ -3576,23 +3570,24 @@ static Standard_Integer VConnect(Draw_Interpretor& /*di*/,
   }
   Handle(AIS_InteractiveObject) anObject;
 
-  // AIS_ConnectedInteractive
-  if (argc == 12 || (argc == 13 && hasColor))
+  // AIS_MultipleConnectedInteractive
+  const Standard_Integer aNbShapes = hasColor ? (argc - 1) : argc;
+  for (Standard_Integer i = 5; i < aNbShapes; ++i)
   {
-    TCollection_AsciiString anOriginObjectName(argv[11]);
+    TCollection_AsciiString anOriginObjectName (argv[i]);
     if (aName.IsEqual (anOriginObjectName))
     {
-      std::cout << "vconnect error: equal names for connected objects\n"; 
-      return 1; // TCL_ERROR
+      std::cout << "vconnect error: equal names for connected objects\n";
+      continue;
     }
     if (GetMapOfAIS().IsBound2 (anOriginObjectName))
     {
       Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (anOriginObjectName);
-      anOriginObject = Handle(AIS_InteractiveObject)::DownCast(anObj);
-      if (anOriginObject.IsNull())
+      anObject = Handle(AIS_InteractiveObject)::DownCast(anObj);
+      if (anObject.IsNull())
       {
         std::cout << "Object " << anOriginObjectName << " is used for non AIS viewer\n";
-        return 1; // TCL_ERROR
+        continue;
       }
     }
     else
@@ -3602,101 +3597,38 @@ static Standard_Integer VConnect(Draw_Interpretor& /*di*/,
       if (aTDShape.IsNull())
       {
         std::cout << "vconnect error: object " << anOriginObjectName << " doesn't exist\n";
-        return 1; // TCL_ERROR
-      }
-      anOriginObject = new AIS_Shape (aTDShape);
-      if (hasColor)
-      {
-        anOriginObject->SetColor (ViewerTest::GetColorFromName (aColorName));
-      }
-    }
-  }
-  // AIS_MultipleConnectedInteractive
-  else
-  {
-    const Standard_Integer aNbShapes = hasColor ? (argc - 1) : argc;
-    for (Standard_Integer i = 11; i < aNbShapes; ++i)
-    {
-      TCollection_AsciiString anOriginObjectName (argv[i]);
-      if (aName.IsEqual (anOriginObjectName))
-      {
-        std::cout << "vconnect error: equal names for connected objects\n";
         continue;
       }
-      if (GetMapOfAIS().IsBound2 (anOriginObjectName))
-      {
-        Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (anOriginObjectName);
-        anObject = Handle(AIS_InteractiveObject)::DownCast(anObj);
-        if (anObject.IsNull())
-        {
-          std::cout << "Object " << anOriginObjectName << " is used for non AIS viewer\n";
-          continue;
-        }
-      }
-      else
-      {
-        Standard_CString aName = anOriginObjectName.ToCString();
-        TopoDS_Shape aTDShape = DBRep::Get (aName);
-        if (aTDShape.IsNull())
-        {
-          std::cout << "vconnect error: object " << anOriginObjectName << " doesn't exist\n";
-          continue;
-        }
-        anObject = new AIS_Shape (aTDShape);
-        anObject->SetColor (ViewerTest::GetColorFromName (aColorName));
-      }
-      if (anOriginObject.IsNull())
-      {
-        anOriginObject = new AIS_MultipleConnectedInteractive();
-        Handle(AIS_MultipleConnectedInteractive)::DownCast(anOriginObject)->Connect (anObject);
-      }
-      else
-      {
-        Handle(AIS_MultipleConnectedInteractive)::DownCast(anOriginObject)->Connect (anObject);
-      }
+      anObject = new AIS_Shape (aTDShape);
+      anObject->SetColor (ViewerTest::GetColorFromName (aColorName));
     }
+
     if (anOriginObject.IsNull())
     {
-      std::cout << "vconect error : can't connect input objects\n";
-      return 1; // TCL_ERROR
+      anOriginObject = new AIS_MultipleConnectedInteractive();
     }
+
+    anOriginObject->Connect (anObject);
+  }
+  if (anOriginObject.IsNull())
+  {
+    std::cout << "vconect error : can't connect input objects\n";
+    return 1; // TCL_ERROR
   }
 
   // Get location data
   Standard_Real aXo = Draw::Atof (argv[anArgIter++]);
   Standard_Real aYo = Draw::Atof (argv[anArgIter++]);
   Standard_Real aZo = Draw::Atof (argv[anArgIter++]);
-  Standard_Real aXu = Draw::Atof (argv[anArgIter++]);
-  Standard_Real aXv = Draw::Atof (argv[anArgIter++]);
-  Standard_Real aXw = Draw::Atof (argv[anArgIter++]);
-  Standard_Real aZu = Draw::Atof (argv[anArgIter++]);
-  Standard_Real aZv = Draw::Atof (argv[anArgIter++]);
-  Standard_Real aZw = Draw::Atof (argv[anArgIter++]);
 
   // Create transformation
-  gp_Pnt aPoint(aXo, aYo, aZo);
-  gp_Dir anXDir(aXu, aXv, aXw), aZDir(aZu, aZv, aZw);
-  if(!anXDir.IsNormal(aZDir, Precision::Angular()))
-  {
-    std::cout << "vconnect error : XDir expects to be normal to ZDir\n"; 
-    return 1; // TCL_ERROR
-  } 
-  gp_Ax3 anAx3(aPoint, aZDir, anXDir); 
+  gp_Vec aTranslation (aXo, aYo, aZo);
+
   gp_Trsf aTrsf; 
-  aTrsf.SetTransformation(anAx3); 
-  TopLoc_Location aLocation(aTrsf);
+  aTrsf.SetTranslationPart (aTranslation);
+  TopLoc_Location aLocation (aTrsf);
 
-  // Create connected object
-  Handle(AIS_ConnectedInteractive) aConnected = new AIS_ConnectedInteractive();
-  Handle(AIS_MultipleConnectedInteractive) anOrigin = Handle(AIS_MultipleConnectedInteractive)::DownCast(anOriginObject);
-  if (anOrigin.IsNull())
-  {
-    aConnected->Connect (anOriginObject, aLocation);
-  }
-  else
-  {
-    aConnected->Connect (anOrigin, aLocation);
-  }
+  anOriginObject->SetLocalTransformation (aTrsf);
 
   // Check if there is another object with given name
   // and remove it from context
@@ -3709,179 +3641,87 @@ static Standard_Integer VConnect(Draw_Interpretor& /*di*/,
   }
 
   // Bind connected object to its name
-  GetMapOfAIS().Bind (aConnected, aName);
+  GetMapOfAIS().Bind (anOriginObject, aName);
 
   // Display connected object
-  TheAISContext()->Display (aConnected);
+  TheAISContext()->Display (anOriginObject);
 
   return 0;
 }
 
 //===============================================================================================
-//function : VConnectShape
-//purpose  : Creates and displays AIS_ConnectedShape from input shape and location 
-//Draw arg : vconnectsh name Xo Yo Zo Xu Xv Xw Zu Zv Zw shape1 shape2 ... [color=NAME]
+//function : VConnectTo
+//purpose  : Creates and displays AIS_ConnectedInteractive object from input object and location 
+//Draw arg : vconnectto name Xo Yo Zo object
 //===============================================================================================
 
-static Standard_Integer VConnectShape(Draw_Interpretor& /*di*/, 
-                                      Standard_Integer argc, 
-                                      const char ** argv) 
+static Standard_Integer VConnectTo (Draw_Interpretor& /*di*/, 
+                                    Standard_Integer argc, 
+                                    const char ** argv) 
 {
   // Check the viewer
   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
   if (aContext.IsNull())
   {
-    std::cout << "vconnectsh error : call vinit before\n";
+    std::cout << "vconnect error : call vinit before\n";
     return 1; // TCL_ERROR
   }
-  // Check argumnets
-  if (argc < 12)
+  // Check argumnets 
+  if (argc != 6)
   {
-    std::cout << "vconnectsh error: expect at least 11 arguments\n";
+    std::cout << "vconnect error: expect at least 5 arguments\n";
     return 1; // TCL_ERROR
   }
 
   // Get values
   Standard_Integer anArgIter = 1;
   TCollection_AsciiString aName (argv[anArgIter++]);
-  Handle(AIS_InteractiveObject) anOriginShape;
-  TCollection_AsciiString aColorString(argv[argc-1]);
-  Standard_CString aColorName = "";
-  Standard_Boolean hasColor = Standard_False;
-  if (aColorString.Search ("color=") != -1)
+  Handle(AIS_InteractiveObject) anOriginObject;
+
+  TCollection_AsciiString anOriginObjectName(argv[5]);
+  if (aName.IsEqual (anOriginObjectName))
   {
-    hasColor = Standard_True;
-    aColorString.Remove (1, 6);
-    aColorName = aColorString.ToCString();
+    std::cout << "vconnect error: equal names for connected objects\n"; 
+    return 1; // TCL_ERROR
   }
-  Handle(AIS_Shape) aShape;
-
-  // AIS_ConnectedShape
-  if (argc == 12 || (argc == 13 && hasColor))
+  if (GetMapOfAIS().IsBound2 (anOriginObjectName))
   {
-    TCollection_AsciiString anOriginShapeName (argv[11]);
-    if (aName.IsEqual (anOriginShapeName))
+    Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (anOriginObjectName);
+    anOriginObject = Handle(AIS_InteractiveObject)::DownCast(anObj);
+    if (anOriginObject.IsNull())
     {
-      std::cout << "vconnectsh error: equal names for connected shapes\n";
+      std::cout << "Object " << anOriginObjectName << " is used for non AIS viewer\n";
       return 1; // TCL_ERROR
     }
-    if (GetMapOfAIS().IsBound2 (anOriginShapeName))
-    {
-      Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (anOriginShapeName);
-      anOriginShape = Handle(AIS_Shape)::DownCast(anObj);
-      if (anOriginShape.IsNull())
-      {
-        std::cout << "Shape " << anOriginShapeName << " is used for non AIS viewer\n!";
-        return 1; // TCL_ERROR
-      }
-    }
-    else
-    {
-      Standard_CString aName = anOriginShapeName.ToCString();
-      TopoDS_Shape aTDShape = DBRep::Get (aName);
-      if (aTDShape.IsNull())
-      {
-        std::cout << "vconnectsh error: object " << anOriginShapeName << " doesn't exist\n";
-        return 1; // TCL_ERROR
-      }
-      anOriginShape = new AIS_Shape (aTDShape);
-      if (hasColor)
-      {
-        anOriginShape->SetColor (ViewerTest::GetColorFromName (aColorName));
-      }
-    }
   }
-  // AIS_MultipleConnectedShape
   else
   {
-    const Standard_Integer aNbShapes = hasColor ? (argc - 1) : argc;
-    for (Standard_Integer i = 11; i < aNbShapes; ++i)
-    {
-      TCollection_AsciiString anOriginShapeName (argv[i]);
-      if (aName.IsEqual (anOriginShapeName))
-      {
-        std::cout << "vconnectsh error: equal names for connected shapes\n";
-        continue;
-      }
-      if (GetMapOfAIS().IsBound2 (anOriginShapeName))
-      {
-        Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (anOriginShapeName);
-        aShape = Handle(AIS_Shape)::DownCast(anObj);
-        if (aShape.IsNull())
-        {
-          std::cout << "Shape " << anOriginShapeName << " is used for non AIS viewer\n";
-          continue;
-        }
-      }
-      else
-      {
-        Standard_CString aName = anOriginShapeName.ToCString();
-        TopoDS_Shape aTDShape = DBRep::Get (aName);
-        if (aTDShape.IsNull())
-        {
-          std::cout << "vconnectsh error: object " << anOriginShapeName << " doesn't exist\n";
-          continue;
-        }
-        aShape = new AIS_Shape (aTDShape);
-        if (hasColor)
-        {
-          aShape->SetColor (ViewerTest::GetColorFromName (aColorName));
-        }
-      }
-      if (anOriginShape.IsNull())
-      {
-        anOriginShape = new AIS_MultipleConnectedShape (aShape->Shape());
-        Handle(AIS_MultipleConnectedShape)::DownCast(anOriginShape)->Connect (aShape);
-      }
-      else
-      {
-        Handle(AIS_MultipleConnectedShape)::DownCast(anOriginShape)->Connect (aShape);
-      }
-    }
-    if (anOriginShape.IsNull())
+    Standard_CString aName = anOriginObjectName.ToCString();
+    TopoDS_Shape aTDShape = DBRep::Get (aName);
+    if (aTDShape.IsNull())
     {
-      std::cout << "vconectsh error : can't connect input objects\n";
+      std::cout << "vconnect error: object " << anOriginObjectName << " doesn't exist\n";
       return 1; // TCL_ERROR
     }
+    anOriginObject = new AIS_Shape (aTDShape);
   }
-
-  // Get location data  
+  // Get location data
   Standard_Real aXo = Draw::Atof (argv[anArgIter++]);
   Standard_Real aYo = Draw::Atof (argv[anArgIter++]);
   Standard_Real aZo = Draw::Atof (argv[anArgIter++]);
-  Standard_Real aXu = Draw::Atof (argv[anArgIter++]);
-  Standard_Real aXv = Draw::Atof (argv[anArgIter++]);
-  Standard_Real aXw = Draw::Atof (argv[anArgIter++]);
-  Standard_Real aZu = Draw::Atof (argv[anArgIter++]);
-  Standard_Real aZv = Draw::Atof (argv[anArgIter++]);
-  Standard_Real aZw = Draw::Atof (argv[anArgIter++]);
 
   // Create transformation
-  gp_Pnt aPoint(aXo, aYo, aZo);
-  gp_Dir anXDir(aXu, aXv, aXw), aZDir(aZu, aZv, aZw);
-  if(!anXDir.IsNormal(aZDir, Precision::Angular()))
-  {
-    std::cout << "vconnectsh error : XDir expects to be normal to ZDir\n"; 
-    return 1; // TCL_ERROR
-  } 
-  gp_Ax3 anAx3(aPoint, aZDir, anXDir); 
-  gp_Trsf aTrsf; 
-  aTrsf.SetTransformation(anAx3); 
-  TopLoc_Location aLocation(aTrsf);
+  gp_Vec aTranslation (aXo, aYo, aZo);
 
-  // Create connected shape
+  gp_Trsf aTrsf; 
+  aTrsf.SetTranslationPart (aTranslation);
   Handle(AIS_ConnectedInteractive) aConnected;
-  Handle(AIS_Shape) anOrigin = Handle(AIS_Shape)::DownCast(anOriginShape);
-  if (!anOrigin.IsNull())
-  {
-    aConnected = new AIS_ConnectedShape (anOrigin);
-    aConnected->Connect (anOrigin, aLocation);
-  }
-  else
-  {
-    aConnected = new AIS_ConnectedInteractive();
-    aConnected->Connect (anOriginShape, aLocation);
-  }
+
+  aConnected = new AIS_ConnectedInteractive();
+
+  aConnected->Connect (anOriginObject, aTrsf);
 
   // Check if there is another object with given name
   // and remove it from context
@@ -3893,15 +3733,220 @@ static Standard_Integer VConnectShape(Draw_Interpretor& /*di*/,
     GetMapOfAIS().UnBind2(aName);
   }
 
-  // Bind connected shape to its name
+  // Bind connected object to its name
   GetMapOfAIS().Bind (aConnected, aName);
 
-  // Display connected shape
+  // Display connected object
   TheAISContext()->Display (aConnected);
 
   return 0;
 }
 
+//=======================================================================
+//function : VDisconnect
+//purpose  :
+//=======================================================================
+static Standard_Integer VDisconnect (Draw_Interpretor& di,
+                                     Standard_Integer argc,
+                                     const char ** argv)
+{
+  Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+  if (aContext.IsNull())
+  {
+    std::cout << argv[0] << "ERROR : use 'vinit' command before " << "\n";
+    return 1;
+  }
+  
+  if (argc != 3)
+  {
+    std::cout << "ERROR : Usage : " << argv[0] << " name object" << "\n";
+    return 1;
+  }
+
+  TCollection_AsciiString aName (argv[1]);
+  TCollection_AsciiString anObject (argv[2]);
+  Standard_Integer anObjectNumber = Draw::Atoi (argv[2]);
+
+  // find objects
+  ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
+  Handle(AIS_MultipleConnectedInteractive) anAssembly;
+  if (!aMap.IsBound2 (aName) )
+  {
+    std::cout << "Use 'vdisplay' before" << "\n";
+    return 1;
+  }
+
+  anAssembly = Handle(AIS_MultipleConnectedInteractive)::DownCast (aMap.Find2 (aName));
+  if (anAssembly.IsNull())
+  {
+    di << "Not an assembly" << "\n";
+    return 1;
+  }
+
+  Handle(AIS_InteractiveObject) anIObj;
+  if (!aMap.IsBound2 (anObject))
+  {
+    // try to interpret second argument as child number
+    if (anObjectNumber > 0 && anObjectNumber <= anAssembly->Children().Size())
+    {
+      Standard_Integer aCounter = 1;
+      for (PrsMgr_ListOfPresentableObjectsIter anIter (anAssembly->Children()); anIter.More(); anIter.Next())
+      {
+        if (aCounter == anObjectNumber)
+        {
+          anIObj = Handle(AIS_InteractiveObject)::DownCast (anIter.Value());
+          break;
+        }
+        ++aCounter;
+      }
+    }
+    else
+    {
+      std::cout << "Use 'vdisplay' before" << "\n";
+      return 1;
+    }    
+  }
+
+  // if object was found by name
+  if (anIObj.IsNull())
+  {
+    anIObj = Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (anObject));
+  }
+
+  anAssembly->Disconnect (anIObj);
+  aContext->UpdateCurrentViewer();
+
+  return 0;
+}
+
+//=======================================================================
+//function : VAddConnected
+//purpose  :
+//=======================================================================
+static Standard_Integer VAddConnected (Draw_Interpretor& di,
+                                       Standard_Integer argc,
+                                       const char ** argv)
+{
+  Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+  if (aContext.IsNull())
+  {
+    std::cout << argv[0] << "error : use 'vinit' command before " << "\n";
+    return 1;
+  }
+  
+  if (argc != 6)
+  {
+    std::cout << argv[0] << " error: expect 5 arguments\n";
+    return 1;
+  }
+
+  TCollection_AsciiString aName (argv[1]);
+  TCollection_AsciiString anObject (argv[5]);
+  Standard_Real aX = Draw::Atof (argv[2]);
+  Standard_Real aY = Draw::Atof (argv[3]);
+  Standard_Real aZ = Draw::Atof (argv[4]);
+
+  // find object
+  ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
+  Handle(AIS_MultipleConnectedInteractive) anAssembly;
+  if (!aMap.IsBound2 (aName) )
+  {
+    std::cout << "Use 'vdisplay' before" << "\n";
+    return 1;
+  }
+
+  anAssembly = Handle(AIS_MultipleConnectedInteractive)::DownCast (aMap.Find2 (aName));
+  if (anAssembly.IsNull())
+  {
+    di << "Not an assembly" << "\n";
+    return 1;
+  }
+
+  Handle(AIS_InteractiveObject) anIObj;
+  if (!aMap.IsBound2 (anObject))
+  {
+      std::cout << "Use 'vdisplay' before" << "\n";
+      return 1; 
+  }
+
+  anIObj = Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (anObject));
+
+  gp_Trsf aTrsf;
+  aTrsf.SetTranslation (gp_Vec (aX, aY, aZ));
+  anAssembly->Connect (anIObj, aTrsf);
+  TheAISContext()->Display (anAssembly);
+  TheAISContext()->RecomputeSelectionOnly (anAssembly);
+  aContext->UpdateCurrentViewer();
+
+  return 0;
+}
+
+//=======================================================================
+//function : VListConnected
+//purpose  :
+//=======================================================================
+static Standard_Integer VListConnected (Draw_Interpretor& /*di*/,
+                                        Standard_Integer argc,
+                                        const char ** argv)
+{
+  Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+  if (aContext.IsNull())
+  {
+    std::cout << argv[0] << "ERROR : use 'vinit' command before " << "\n";
+    return 1;
+  }
+  
+  if (argc != 2)
+  {
+    std::cout << "ERROR : Usage : " << argv[0] << " name" << "\n";
+    return 1;
+  }
+
+  TCollection_AsciiString aName (argv[1]);
+
+  // find object
+  ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
+  Handle(AIS_MultipleConnectedInteractive) anAssembly;
+  if (!aMap.IsBound2 (aName) )
+  {
+    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";
+    return 1;
+  }
+
+  std::cout << "Children of " << aName << ":\n";
+
+  Standard_Integer aCounter = 1;
+  for (PrsMgr_ListOfPresentableObjectsIter anIter (anAssembly->Children()); anIter.More(); anIter.Next())
+  {
+    if (GetMapOfAIS().IsBound1 (anIter.Value()))
+    {
+      TCollection_AsciiString aName = GetMapOfAIS().Find1 (anIter.Value());
+      std::cout << aCounter << ")  " << aName << "    (" << anIter.Value()->DynamicType()->Name() << ")";
+    }
+
+    std::cout << aCounter << ")  " << anIter.Value()->DynamicType()->Name();
+
+    Handle(AIS_ConnectedInteractive) aConnected = Handle(AIS_ConnectedInteractive)::DownCast (anIter.Value());
+    if (!aConnected.IsNull() && !aConnected->ConnectedTo().IsNull() && aMap.IsBound1 (aConnected->ConnectedTo()))
+    {
+      std::cout << " connected to " << aMap.Find1 (aConnected->ConnectedTo());
+    }
+    std::cout << std::endl;
+    
+    ++aCounter;
+  }
+
+  return 0;
+}
+
 namespace
 {
   //! Checks if theMode is already turned on for theObj.
@@ -5020,6 +5065,287 @@ static int VFont (Draw_Interpretor& theDI,
   return 0;
 }
 
+//=======================================================================
+//function : VSetEdgeType
+//purpose  : Edges type management
+//=======================================================================
+
+static int VSetEdgeType (Draw_Interpretor& theDI,
+                         Standard_Integer  theArgNum,
+                         const char**      theArgs)
+{
+  if (theArgNum < 4 || theArgNum > 9)
+  {
+    theDI << theArgs[0] << " error: wrong number of parameters. Type 'help "
+          << theArgs[0] << "' for more information.\n";
+    return 1;
+  }
+
+  Standard_Boolean isForceRedisplay = Standard_False;
+
+  // Get shape name
+  TCollection_AsciiString aName(theArgs[1]);
+  if (!GetMapOfAIS().IsBound2 (aName))
+  {
+    theDI <<  theArgs[0] << " error: wrong object name.\n";
+    return 1;
+  }
+  
+  Handle(AIS_InteractiveObject) anObject = 
+    Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(aName));
+  
+  // Enable trianle edge mode
+  anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeOn();
+
+  // Parse parameters
+  for (Standard_Integer anIt = 2; anIt < theArgNum; ++anIt)
+  {
+    TCollection_AsciiString aParam ((theArgs[anIt]));
+    if (aParam.Value (1) == '-' && !aParam.IsRealValue())
+    {
+      if (aParam.IsEqual ("-type"))
+      {
+        if (theArgNum <= anIt + 1)
+        {
+          theDI <<  theArgs[0] << " error: wrong number of values for parameter '"
+                << aParam.ToCString() << "'.\n";
+          return 1;
+        }
+
+        TCollection_AsciiString aType = theArgs[++anIt];
+        aType.UpperCase();
+
+        if (aType.IsEqual ("SOLID"))
+        {
+          anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeLineType(Aspect_TOL_SOLID);
+        }
+        else if (aType.IsEqual ("DASH"))
+        {
+          anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeLineType(Aspect_TOL_DASH);
+        }
+        else if (aType.IsEqual ("DOT"))
+        {
+          anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeLineType(Aspect_TOL_DOT);
+        }
+        else if (aType.IsEqual ("DOTDASH"))
+        {
+          anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeLineType(Aspect_TOL_DOTDASH);
+        }
+        else
+        {
+          theDI <<  theArgs[0] << " error: wrong line type: '" << aType.ToCString() << "'.\n";
+          return 1;
+        }
+        
+      }
+      else if (aParam.IsEqual ("-color"))
+      {
+        if (theArgNum <= anIt + 3)
+        {
+          theDI <<  theArgs[0] << " error: wrong number of values for parameter '"
+                << aParam.ToCString() << "'.\n";
+          return 1;
+        }
+
+        Quantity_Parameter aR = Draw::Atof(theArgs[++anIt]);
+        Quantity_Parameter aG = Draw::Atof(theArgs[++anIt]);
+        Quantity_Parameter aB = Draw::Atof(theArgs[++anIt]);
+        Quantity_Color aColor = Quantity_Color (aR > 1 ? aR / 255.0 : aR,
+                                                aG > 1 ? aG / 255.0 : aG,
+                                                aB > 1 ? aB / 255.0 : aB,
+                                                Quantity_TOC_RGB);
+
+        anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeColor (aColor);
+      }
+      else if (aParam.IsEqual ("-force"))
+      {
+        isForceRedisplay = Standard_True;
+      }
+      else
+      {
+        theDI <<  theArgs[0] << " error: unknown parameter '"
+              << aParam.ToCString() << "'.\n";
+        return 1;
+      }
+    }
+  }
+
+  // Update shape presentation as aspect parameters were changed
+  if (isForceRedisplay)
+  {
+    ViewerTest::GetAISContext()->Redisplay (anObject);
+  }
+  else
+  {
+    anObject->SetAspect (anObject->Attributes()->ShadingAspect());
+  }
+
+  //Update view
+  ViewerTest::CurrentView()->Redraw();
+
+  return 0;
+}
+
+//=======================================================================
+//function : VUnsetEdgeType
+//purpose  : Unsets edges visibility in shading mode
+//=======================================================================
+
+static int VUnsetEdgeType (Draw_Interpretor& theDI,
+                         Standard_Integer  theArgNum,
+                         const char**      theArgs)
+{
+  if (theArgNum != 2 && theArgNum != 3)
+  {
+    theDI << theArgs[0] << " error: wrong number of parameters. Type 'help "
+          << theArgs[0] << "' for more information.\n";
+    return 1;
+  }
+
+  Standard_Boolean isForceRedisplay = Standard_False;
+
+  // Get shape name
+  TCollection_AsciiString aName (theArgs[1]);
+  if (!GetMapOfAIS().IsBound2 (aName))
+  {
+    theDI <<  theArgs[0] << " error: wrong object name.\n";
+    return 1;
+  }
+
+  Handle(AIS_InteractiveObject) anObject = 
+    Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2(aName));
+
+  // Enable trianle edge mode
+  anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeOff();
+
+  // Parse parameters
+  if (theArgNum == 3)
+  {
+    TCollection_AsciiString aParam ((theArgs[2]));
+    if (aParam.IsEqual ("-force"))
+    {
+      isForceRedisplay = Standard_True;
+    }
+    else
+    {
+       theDI <<  theArgs[0] << " error: unknown parameter '"
+              << aParam.ToCString() << "'.\n";
+       return 1;
+    }
+  }
+
+  // Update shape presentation as aspect parameters were changed
+  if (isForceRedisplay)
+  {
+    ViewerTest::GetAISContext()->Redisplay (anObject);
+  }
+  else
+  {
+    anObject->SetAspect (anObject->Attributes()->ShadingAspect());
+  }
+
+  //Update view
+  ViewerTest::CurrentView()->Redraw();
+
+  return 0;
+}
+
+
+//=======================================================================
+//function : VVertexMode
+//purpose  : Switches vertex display mode for AIS_Shape or displays the current value
+//=======================================================================
+
+static int VVertexMode (Draw_Interpretor& theDI,
+                         Standard_Integer  theArgNum,
+                         const char**      theArgs)
+{
+  Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+  if (aContext.IsNull())
+  {
+    std::cout << "Error: no view available, call 'vinit' before!" << std::endl;
+    return 1;
+  }
+
+  // No arguments --> print the current default vertex draw mode
+  if (theArgNum == 1)
+  {
+    Prs3d_VertexDrawMode aCurrMode = aContext->DefaultDrawer()->VertexDrawMode();
+    theDI <<  "Default vertex draw mode: " << (aCurrMode == Prs3d_VDM_Isolated ? "'isolated'" : "'all'") << "\n";
+    return 0;
+  }
+
+  // -set argument --> change the default vertex draw mode and the mode for all displayed or given object(s)
+  TCollection_AsciiString aParam (theArgs[1]);
+  if (aParam == "-set")
+  {
+    if (theArgNum == 2)
+    {
+      std::cout << "Error: '-set' option not followed by the mode and optional object name(s)" << std::endl;
+      std::cout << "Type 'help vvertexmode' for usage hints" << std::endl;
+      return 1;
+    }
+
+    TCollection_AsciiString aModeStr (theArgs[2]);
+    Prs3d_VertexDrawMode aNewMode =
+       aModeStr == "isolated" ? Prs3d_VDM_Isolated :
+      (aModeStr == "all"      ? Prs3d_VDM_All :
+                                Prs3d_VDM_Inherited);
+
+    Standard_Boolean aRedrawNeeded = Standard_False;
+    AIS_ListOfInteractive anObjs;
+
+    // No object(s) specified -> use all displayed
+    if (theArgNum == 3)
+    {
+      theDI << "Setting the default vertex draw mode and updating all displayed objects...\n";
+      aContext->DisplayedObjects (anObjs);
+      aContext->DefaultDrawer()->SetVertexDrawMode (aNewMode);
+      aRedrawNeeded = Standard_True;
+    }
+
+    Handle(AIS_InteractiveObject) anObject;
+    for (Standard_Integer aCount = 3; aCount < theArgNum; aCount++)
+    {
+      TCollection_AsciiString aName (theArgs[aCount]);
+      if (!GetMapOfAIS().IsBound2 (aName))
+      {
+        theDI << "Warning: wrong object name ignored - " << theArgs[0] << "\n";
+        continue;
+      }
+      anObject = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2(aName));
+      anObjs.Append (anObject);
+    }
+
+    for (AIS_ListIteratorOfListOfInteractive anIt (anObjs); anIt.More(); anIt.Next())
+    {
+      anObject = anIt.Value();
+      anObject->Attributes()->SetVertexDrawMode (aNewMode);
+      aContext->Redisplay (anObject, Standard_False);
+      aRedrawNeeded = Standard_True;
+    }
+
+    if (aRedrawNeeded)
+      ViewerTest::CurrentView()->Redraw();
+
+    return 0;
+  }
+
+  if (theArgNum > 2)
+  {
+    std::cout << "Error: invalid number of arguments" << std::endl;
+    std::cout << "Type 'help vvertexmode' for usage hints" << std::endl;
+    return 1;
+  }
+
+  // One argument (object name) --> print the current vertex draw mode for the object
+  Handle(AIS_InteractiveObject) anObject =
+    Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aParam));
+  Prs3d_VertexDrawMode aCurrMode = anObject->Attributes()->VertexDrawMode();
+  theDI <<  "Object's vertex draw mode: " << (aCurrMode == Prs3d_VDM_Isolated ? "'isolated'" : "'all'") << "\n";
+  return 0;
+}
+
 //=======================================================================
 //function : ObjectsCommands
 //purpose  :
@@ -5099,7 +5425,7 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
     __FILE__,VDrawText,group);
 
   theCommands.Add("vdrawsphere",
-    "vdrawsphere: vdrawsphere shapeName Fineness [X=0.0 Y=0.0 Z=0.0] [Radius=100.0] [ToShowEdges=0]\n",
+    "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 ("vsetlocation",
@@ -5116,12 +5442,30 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
     __FILE__,VDrawPArray,group);
 
   theCommands.Add("vconnect", 
-    "vconnect : name Xo Yo Zo Xu Xv Xw Zu Zv Zw object1 object2 ... [color=NAME]", 
+    "vconnect : assembly_name Xo Yo Zo object1 object2 ..."
+    "  Makes an assembly of object instances located in point (Xo Yo Zo).",
     __FILE__, VConnect, group);
 
-  theCommands.Add("vconnectsh", 
-    "vconnectsh : name Xo Yo Zo Xu Xv Xw Zu Zv Zw shape1 shape2 ... [color=NAME]", 
-    __FILE__, VConnectShape, group);
+  theCommands.Add("vconnectto",
+    "vconnectto : instance_name Xo Yo Zo object"
+    "  Makes an instance 'instance_name' of 'object' with position (Xo Yo Zo).", 
+    __FILE__, VConnectTo,group);
+
+  theCommands.Add("vdisconnect",
+    "vdisconnect assembly_name (object_name | object_number | 'all')"
+    "  Disconnects all objects from assembly or disconnects object by name or number (use vlistconnected to enumerate assembly children).",
+    __FILE__,VDisconnect,group);
+
+  theCommands.Add("vaddconnected",
+    "vaddconnected assembly_name object_name"
+    "Adds object to assembly.",
+    __FILE__,VAddConnected,group);
+
+  theCommands.Add("vlistconnected",
+    "vlistconnected assembly_name"
+    "Lists objects in assembly.",
+    __FILE__,VListConnected,group);
+
 
   theCommands.Add("vselmode", 
     "vselmode : [object] mode_number is_turned_on=(1|0)\n"
@@ -5177,4 +5521,24 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
                             "vfont [add pathToFont [fontName] [regular,bold,italic,bolditalic=undefined]]"
                    "\n\t\t:        [find fontName [regular,bold,italic,bolditalic=undefined]]",
                    __FILE__, VFont, group);
+  
+  theCommands.Add ("vsetedgetype",
+                   "vsetedgetype usage:\n"
+                   "vsetedgetype ShapeName [-force] [-type {solid, dash, dot}] [-color R G B] "
+                   "\n\t\t:        Sets edges type and color for input shape",
+                   __FILE__, VSetEdgeType, group);
+
+  theCommands.Add ("vunsetedgetype",
+                   "vunsetedgetype usage:\n"
+                   "vunsetedgetype ShapeName [-force]"
+                   "\n\t\t:        Unsets edges type and color for input shape",
+                   __FILE__, VUnsetEdgeType, group);
+
+  theCommands.Add ("vvertexmode",
+                   "vvertexmode [name | -set {isolated | all | inherited} [name1 name2 ...]]\n"
+                   "vvertexmode - prints the default vertex draw mode\n"
+                   "vvertexmode name - prints the vertex draw mode of the given object\n"
+                   "vvertexmode -set {isolated | all | inherited} - sets the default vertex draw mode and updates the mode for all displayed objects\n"
+                   "vvertexmode -set {isolated | all | inherited} name1 name2 ... - sets the vertex draw mode for the specified object(s)\n",
+                   __FILE__, VVertexMode, group);
 }