0028306: Visualization - viewer crashes if style for shaded display is set to HATCH
[occt.git] / src / ViewerTest / ViewerTest.cxx
index c49692c..bdb5c6f 100644 (file)
@@ -27,6 +27,7 @@
 #include <ViewerTest.hxx>
 #include <ViewerTest_CmdParser.hxx>
 
+#include <Draw.hxx>
 #include <TopLoc_Location.hxx>
 #include <TopTools_HArray1OfShape.hxx>
 #include <TColStd_HArray1OfTransient.hxx>
@@ -173,6 +174,63 @@ Standard_Boolean ViewerTest::ParseOnOff (Standard_CString  theArg,
   return Standard_False;
 }
 
+//=======================================================================
+//function : GetSelectedShapes
+//purpose  :
+//=======================================================================
+void ViewerTest::GetSelectedShapes (TopTools_ListOfShape& theSelectedShapes)
+{
+  for (GetAISContext()->InitSelected(); GetAISContext()->MoreSelected(); GetAISContext()->NextSelected())
+  {
+    TopoDS_Shape aShape = GetAISContext()->SelectedShape();
+    if (!aShape.IsNull())
+    {
+      theSelectedShapes.Append (aShape);
+    }
+  }
+}
+
+//=======================================================================
+//function : ParseLineType
+//purpose  :
+//=======================================================================
+Standard_Boolean ViewerTest::ParseLineType (Standard_CString   theArg,
+                                            Aspect_TypeOfLine& theType)
+{
+  TCollection_AsciiString aTypeStr (theArg);
+  aTypeStr.LowerCase();
+  if (aTypeStr == "empty")
+  {
+    theType = Aspect_TOL_EMPTY;
+  }
+  else if (aTypeStr == "solid")
+  {
+    theType = Aspect_TOL_SOLID;
+  }
+  else if (aTypeStr == "dot")
+  {
+    theType = Aspect_TOL_DOT;
+  }
+  else if (aTypeStr == "dash")
+  {
+    theType = Aspect_TOL_DASH;
+  }
+  else if (aTypeStr == "dotdash")
+  {
+    theType = Aspect_TOL_DOTDASH;
+  }
+  else
+  {
+    const int aTypeInt = Draw::Atoi (theArg);
+    if (aTypeInt < -1 || aTypeInt >= Aspect_TOL_USERDEFINED)
+    {
+      return Standard_False;
+    }
+    theType = (Aspect_TypeOfLine )aTypeInt;
+  }
+  return Standard_True;
+}
+
 //=======================================================================
 //function : GetTypeNames
 //purpose  :
@@ -484,8 +542,6 @@ Handle(AIS_Shape) GetAISShapeFromName(const char* name)
 void ViewerTest::Clear()
 {
   if ( !a3DView().IsNull() ) {
-    if (TheAISContext()->HasOpenedContext())
-      TheAISContext()->CloseLocalContext();
     ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it(GetMapOfAIS());
     while ( it.More() ) {
       cout << "Remove " << it.Key2() << endl;
@@ -504,12 +560,15 @@ void ViewerTest::Clear()
 //purpose  : Activate a selection mode, vertex, edge, wire ..., in a local
 //           Context
 //==============================================================================
+Standard_DISABLE_DEPRECATION_WARNINGS
 void ViewerTest::StandardModeActivation(const Standard_Integer mode )
 {
   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
   if(mode==0) {
     if (TheAISContext()->HasOpenedContext())
+    {
       aContext->CloseLocalContext();
+    }
   } else {
 
     if(!aContext->HasOpenedContext()) {
@@ -518,14 +577,16 @@ void ViewerTest::StandardModeActivation(const Standard_Integer mode )
       // Open a local Context in order to be able to select subshape from
       // the selected shape if any or for all if there is no selection
       if (!aContext->FirstSelectedObject().IsNull()){
-       aContext->OpenLocalContext(Standard_False);
+        aContext->OpenLocalContext(Standard_False);
 
        for(aContext->InitSelected();aContext->MoreSelected();aContext->NextSelected()){
          aContext->Load(       aContext->SelectedInteractive(),-1,Standard_True);
        }
       }
       else
-       aContext->OpenLocalContext();
+      {
+        aContext->OpenLocalContext();
+      }
     }
 
     const char *cmode="???";
@@ -543,19 +604,20 @@ void ViewerTest::StandardModeActivation(const Standard_Integer mode )
     }
 
     if(theactivatedmodes.Contains(mode))
-      { // Desactivate
-       aContext->DeactivateStandardMode(AIS_Shape::SelectionType(mode));
-       theactivatedmodes.Remove(mode);
-       cout<<"Mode "<< cmode <<" OFF"<<endl;
-      }
+    { // Desactivate
+      aContext->DeactivateStandardMode(AIS_Shape::SelectionType(mode));
+      theactivatedmodes.Remove(mode);
+      cout<<"Mode "<< cmode <<" OFF"<<endl;
+    }
     else
-      { // Activate
-       aContext->ActivateStandardMode(AIS_Shape::SelectionType(mode));
-       theactivatedmodes.Add(mode);
-       cout<<"Mode "<< cmode << " ON" << endl;
-      }
+    { // Activate
+      aContext->ActivateStandardMode(AIS_Shape::SelectionType(mode));
+      theactivatedmodes.Add(mode);
+      cout<<"Mode "<< cmode << " ON" << endl;
+    }
   }
 }
+Standard_ENABLE_DEPRECATION_WARNINGS
 
 //==============================================================================
 //function : CopyIsoAspect
@@ -652,7 +714,7 @@ static int visos (Draw_Interpretor& di, Standard_Integer argc, const char** argv
           CurDrawer->SetVIsoAspect(CopyIsoAspect(aVIso, aNbVIsos));
           TheAISContext()->SetLocalAttributes
                   (aShape, CurDrawer, Standard_False);
-          TheAISContext()->Redisplay(aShape);
+          TheAISContext()->Redisplay (aShape, Standard_False);
         } else {
           di << "Number of isos for " << argv[i] << " : "
              << aUIso->Number() << " " << aVIso->Number() << "\n";
@@ -924,13 +986,11 @@ static Standard_Integer VDump (Draw_Interpretor& theDI,
   }
 
   Image_AlienPixMap aPixMap;
-
-  bool isBigEndian = Image_PixMap::IsBigEndianHost();
   Image_PixMap::ImgFormat aFormat = Image_PixMap::ImgUNKNOWN;
   switch (aParams.BufferType)
   {
-    case Graphic3d_BT_RGB:   aFormat = isBigEndian ? Image_PixMap::ImgRGB  : Image_PixMap::ImgBGR;  break;
-    case Graphic3d_BT_RGBA:  aFormat = isBigEndian ? Image_PixMap::ImgRGBA : Image_PixMap::ImgBGRA; break;
+    case Graphic3d_BT_RGB:   aFormat = Image_PixMap::ImgRGB;   break;
+    case Graphic3d_BT_RGBA:  aFormat = Image_PixMap::ImgRGBA;  break;
     case Graphic3d_BT_Depth: aFormat = Image_PixMap::ImgGrayF; break;
   }
 
@@ -985,9 +1045,9 @@ static Standard_Integer VDump (Draw_Interpretor& theDI,
       }
 
       Image_PixMap aPixMapL, aPixMapR;
-      aPixMapL.InitWrapper (aFormat, aPixMap.ChangeData(),
+      aPixMapL.InitWrapper (aPixMap.Format(), aPixMap.ChangeData(),
                             aParams.Width, aParams.Height, aPixMap.SizeRowBytes());
-      aPixMapR.InitWrapper (aFormat, aPixMap.ChangeData() + aPixMap.SizeRowBytes() * aParams.Height,
+      aPixMapR.InitWrapper (aPixMap.Format(), aPixMap.ChangeData() + aPixMap.SizeRowBytes() * aParams.Height,
                             aParams.Width, aParams.Height, aPixMap.SizeRowBytes());
 
       aParams.StereoOptions = V3d_SDO_LEFT_EYE;
@@ -1165,9 +1225,9 @@ static int VSubInt(Draw_Interpretor& di, Standard_Integer argc, const char** arg
       IO = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
       if (!IO.IsNull()) {
         if(On==1)
-          Ctx->SubIntensityOn(IO);
+          Ctx->SubIntensityOn(IO, Standard_True);
         else
-          Ctx->SubIntensityOff(IO);
+          Ctx->SubIntensityOff(IO, Standard_True);
       }
     }
     else return 1;
@@ -1380,39 +1440,44 @@ static int VSetInteriorStyle (Draw_Interpretor& theDI,
     theDI.PrintHelp (theArgVec[0]);
     return 1;
   }
-  Standard_Integer        anInterStyle = Aspect_IS_SOLID;
+  Aspect_InteriorStyle    anInterStyle = Aspect_IS_SOLID;
   TCollection_AsciiString aStyleArg (theArgVec[anArgIter++]);
   aStyleArg.LowerCase();
   if (aStyleArg == "empty")
   {
-    anInterStyle = 0;
+    anInterStyle = Aspect_IS_EMPTY;
   }
   else if (aStyleArg == "hollow")
   {
-    anInterStyle = 1;
+    anInterStyle = Aspect_IS_HOLLOW;
   }
   else if (aStyleArg == "hatch")
   {
-    anInterStyle = 2;
+    anInterStyle = Aspect_IS_HATCH;
   }
   else if (aStyleArg == "solid")
   {
-    anInterStyle = 3;
+    anInterStyle = Aspect_IS_SOLID;
   }
   else if (aStyleArg == "hiddenline")
   {
-    anInterStyle = 4;
+    anInterStyle = Aspect_IS_HIDDENLINE;
   }
-  else
+  else if (aStyleArg == "point")
   {
-    anInterStyle = aStyleArg.IntegerValue();
+    anInterStyle = Aspect_IS_POINT;
   }
-  if (anInterStyle < Aspect_IS_EMPTY
-   || anInterStyle > Aspect_IS_HIDDENLINE)
+  else
   {
-    std::cout << "Error: style must be within a range [0 (Aspect_IS_EMPTY), "
-              << Aspect_IS_HIDDENLINE << " (Aspect_IS_HIDDENLINE)]\n";
-    return 1;
+    const Standard_Integer anIntStyle = aStyleArg.IntegerValue();
+    if (anIntStyle < Aspect_IS_EMPTY
+     || anIntStyle > Aspect_IS_POINT)
+    {
+      std::cout << "Error: style must be within a range [0 (Aspect_IS_EMPTY), "
+                << Aspect_IS_POINT << " (Aspect_IS_POINT)]\n";
+      return 1;
+    }
+    anInterStyle = (Aspect_InteriorStyle )anIntStyle;
   }
 
   if (!aName.IsEmpty()
@@ -1422,10 +1487,6 @@ static int VSetInteriorStyle (Draw_Interpretor& theDI,
     return 1;
   }
 
-  if (aCtx->HasOpenedContext())
-  {
-    aCtx->CloseLocalContext();
-  }
   for (ViewTest_PrsIter anIter (aName); anIter.More(); anIter.Next())
   {
     const Handle(AIS_InteractiveObject)& anIO = anIter.Current();
@@ -1434,7 +1495,12 @@ static int VSetInteriorStyle (Draw_Interpretor& theDI,
       const Handle(Prs3d_Drawer)& aDrawer        = anIO->Attributes();
       Handle(Prs3d_ShadingAspect) aShadingAspect = aDrawer->ShadingAspect();
       Handle(Graphic3d_AspectFillArea3d) aFillAspect = aShadingAspect->Aspect();
-      aFillAspect->SetInteriorStyle ((Aspect_InteriorStyle )anInterStyle);
+      aFillAspect->SetInteriorStyle (anInterStyle);
+      if (anInterStyle == Aspect_IS_HATCH
+       && aFillAspect->HatchStyle().IsNull())
+      {
+        aFillAspect->SetHatchStyle (Aspect_HS_VERTICAL);
+      }
       aCtx->RecomputePrsOnly (anIO, Standard_False, Standard_True);
     }
   }
@@ -1480,6 +1546,10 @@ struct ViewerTest_AspectsChangeSet
   Standard_Integer         SelectionMode;
   Standard_Integer         Sensitivity;
 
+  Standard_Integer         ToSetHatch;
+  Standard_Integer         StdHatchStyle;
+  TCollection_AsciiString  PathToHatchPattern;
+
   //! Empty constructor
   ViewerTest_AspectsChangeSet()
   : ToSetVisibility   (0),
@@ -1504,7 +1574,10 @@ struct ViewerTest_AspectsChangeSet
     MaxParamValue (500000),
     ToSetSensitivity (0),
     SelectionMode (-1),
-    Sensitivity (-1) {}
+    Sensitivity (-1),
+    ToSetHatch (0),
+    StdHatchStyle (-1)
+    {}
 
   //! @return true if no changes have been requested
   Standard_Boolean IsEmpty() const
@@ -1518,7 +1591,8 @@ struct ViewerTest_AspectsChangeSet
         && ToSetFreeBoundaryColor == 0
         && ToSetFreeBoundaryWidth == 0
         && ToSetMaxParamValue     == 0
-        && ToSetSensitivity       == 0;
+        && ToSetSensitivity       == 0
+        && ToSetHatch             == 0;
   }
 
   //! @return true if properties are valid
@@ -1570,6 +1644,11 @@ struct ViewerTest_AspectsChangeSet
       std::cout << "Error: sensitivity parameter value should be positive (specified " << Sensitivity << ")\n";
       isOk = Standard_False;
     }
+    if (ToSetHatch == 1 && StdHatchStyle < 0 && PathToHatchPattern == "")
+    {
+      std::cout << "Error: hatch style must be specified\n";
+      isOk = Standard_False;
+    }
     return isOk;
   }
 
@@ -1882,27 +1961,7 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
         std::cout << "Error: wrong syntax at " << anArg << "\n";
         return 1;
       }
-
-      TCollection_AsciiString aValue (theArgVec[anArgIter]);
-      aValue.LowerCase();
-
-      if (aValue.IsEqual ("solid"))
-      {
-        aChangeSet->TypeOfLine = Aspect_TOL_SOLID;
-      }
-      else if (aValue.IsEqual ("dot"))
-      {
-        aChangeSet->TypeOfLine = Aspect_TOL_DOT;
-      }
-      else if (aValue.IsEqual ("dash"))
-      {
-        aChangeSet->TypeOfLine = Aspect_TOL_DASH;
-      }
-      else if (aValue.IsEqual ("dotdash"))
-      {
-        aChangeSet->TypeOfLine = Aspect_TOL_DOTDASH;
-      }
-      else
+      if (!ViewerTest::ParseLineType (theArgVec[anArgIter], aChangeSet->TypeOfLine))
       {
         std::cout << "Error: wrong syntax at " << anArg << "\n";
         return 1;
@@ -2098,6 +2157,9 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       aChangeSet->FreeBoundaryColor = DEFAULT_FREEBOUNDARY_COLOR;
       aChangeSet->ToSetFreeBoundaryWidth = -1;
       aChangeSet->FreeBoundaryWidth = 1.0;
+      aChangeSet->ToSetHatch = -1;
+      aChangeSet->StdHatchStyle = -1;
+      aChangeSet->PathToHatchPattern.Clear();
     }
     else if (anArg == "-isoontriangulation"
           || anArg == "-isoontriang")
@@ -2158,6 +2220,38 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       aChangeSet->SelectionMode = Draw::Atoi (theArgVec[++anArgIter]);
       aChangeSet->Sensitivity = Draw::Atoi (theArgVec[++anArgIter]);
     }
+    else if (anArg == "-sethatch")
+    {
+      if (isDefaults)
+      {
+        std::cout << "Error: wrong syntax. -setHatch can not be used together with -defaults call!\n";
+        return 1;
+      }
+
+      if (aNames.IsEmpty())
+      {
+        std::cout << "Error: object should be specified explicitly when -setHatch is used!\n";
+        return 1;
+      }
+
+      aChangeSet->ToSetHatch = 1;
+      TCollection_AsciiString anArgHatch (theArgVec[++anArgIter]);
+      if (anArgHatch.Length() <= 2)
+      {
+        const Standard_Integer anIntStyle = Draw::Atoi (anArgHatch.ToCString());
+        if (anIntStyle < 0
+         || anIntStyle >= Aspect_HS_NB)
+        {
+          std::cout << "Error: hatch style is out of range [0, " << (Aspect_HS_NB - 1) << "]!\n";
+          return 1;
+        }
+        aChangeSet->StdHatchStyle = anIntStyle;
+      }
+      else
+      {
+        aChangeSet->PathToHatchPattern = anArgHatch;
+      }
+    }
     else
     {
       std::cout << "Error: wrong syntax at " << anArg << "\n";
@@ -2176,11 +2270,6 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
     isFirst = Standard_False;
   }
 
-  if (aCtx->HasOpenedContext())
-  {
-    aCtx->CloseLocalContext();
-  }
-
   // special case for -defaults parameter.
   // all changed values will be set to DefaultDrawer.
   if (isDefaults)
@@ -2383,6 +2472,42 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
         {
           aDrawer->SetMaximalParameterValue (aChangeSet->MaxParamValue);
         }
+        if (aChangeSet->ToSetHatch != 0)
+        {
+          if (!aDrawer->HasOwnShadingAspect())
+          {
+            aDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
+            *aDrawer->ShadingAspect()->Aspect() = *aCtx->DefaultDrawer()->ShadingAspect()->Aspect();
+          }
+
+          Handle(Graphic3d_AspectFillArea3d) anAsp = aDrawer->ShadingAspect()->Aspect();
+          if (aChangeSet->ToSetHatch == -1)
+          {
+            anAsp->SetInteriorStyle (Aspect_IS_SOLID);
+          }
+          else
+          {
+            anAsp->SetInteriorStyle (Aspect_IS_HATCH);
+            if (!aChangeSet->PathToHatchPattern.IsEmpty())
+            {
+              Handle(Image_AlienPixMap) anImage = new Image_AlienPixMap();
+              if (anImage->Load (TCollection_AsciiString (aChangeSet->PathToHatchPattern.ToCString())))
+              {
+                anAsp->SetHatchStyle (new Graphic3d_HatchStyle (anImage));
+              }
+              else
+              {
+                std::cout << "Error: cannot load the following image: " << aChangeSet->PathToHatchPattern << std::endl;
+                return 1;
+              }
+            }
+            else if (aChangeSet->StdHatchStyle != -1)
+            {
+              anAsp->SetHatchStyle (new Graphic3d_HatchStyle ((Aspect_HatchStyle)aChangeSet->StdHatchStyle));
+            }
+          }
+          toRedisplay = Standard_True;
+        }
       }
 
       for (aChangesIter.Next(); aChangesIter.More(); aChangesIter.Next())
@@ -2456,10 +2581,12 @@ static int VDonly2 (Draw_Interpretor& ,
     return 1;
   }
 
+  Standard_DISABLE_DEPRECATION_WARNINGS
   if (aCtx->HasOpenedContext())
   {
     aCtx->CloseLocalContext();
   }
+  Standard_ENABLE_DEPRECATION_WARNINGS
 
   Standard_Integer anArgIter = 1;
   for (; anArgIter < theArgNb; ++anArgIter)
@@ -2581,6 +2708,7 @@ int VRemove (Draw_Interpretor& theDI,
     return 1;
   }
 
+  Standard_DISABLE_DEPRECATION_WARNINGS
   if (toRemoveLocal && !aCtx->HasOpenedContext())
   {
     std::cerr << "Error: local selection context is not open.\n";
@@ -2590,6 +2718,7 @@ int VRemove (Draw_Interpretor& theDI,
   {
     aCtx->CloseAllContexts (Standard_False);
   }
+  Standard_ENABLE_DEPRECATION_WARNINGS
 
   NCollection_List<TCollection_AsciiString> anIONameList;
   if (toRemoveAll)
@@ -2657,11 +2786,13 @@ int VRemove (Draw_Interpretor& theDI,
 
   // Close local context if it is empty
   TColStd_MapOfTransient aLocalIO;
+  Standard_DISABLE_DEPRECATION_WARNINGS
   if (aCtx->HasOpenedContext()
    && !aCtx->LocalContext()->DisplayedObjects (aLocalIO))
   {
     aCtx->CloseAllContexts (Standard_False);
   }
+  Standard_ENABLE_DEPRECATION_WARNINGS
 
   return 0;
 }
@@ -2719,6 +2850,7 @@ int VErase (Draw_Interpretor& theDI,
     return 1;
   }
 
+  Standard_DISABLE_DEPRECATION_WARNINGS
   if (toEraseLocal && !aCtx->HasOpenedContext())
   {
     std::cerr << "Error: local selection context is not open.\n";
@@ -2728,6 +2860,7 @@ int VErase (Draw_Interpretor& theDI,
   {
     aCtx->CloseAllContexts (Standard_False);
   }
+  Standard_ENABLE_DEPRECATION_WARNINGS
 
   if (!aNamesOfEraseIO.IsEmpty())
   {
@@ -2851,6 +2984,7 @@ static int VDisplayAll (Draw_Interpretor& ,
     return 1;
   }
 
+  Standard_DISABLE_DEPRECATION_WARNINGS
   if (toDisplayLocal && !aCtx->HasOpenedContext())
   {
     std::cerr << "Error: local selection context is not open.\n";
@@ -2860,6 +2994,7 @@ static int VDisplayAll (Draw_Interpretor& ,
   {
     aCtx->CloseLocalContext (Standard_False);
   }
+  Standard_ENABLE_DEPRECATION_WARNINGS
 
   for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
        anIter.More(); anIter.Next())
@@ -2920,13 +3055,13 @@ inline void bndPresentation (Draw_Interpretor&                         theDI,
                              const Standard_Integer                    theDispMode,
                              const TCollection_AsciiString&            theName,
                              const ViewerTest_BndAction                theAction,
-                             const Handle(Graphic3d_HighlightStyle)&   theStyle)
+                             const Handle(Prs3d_Drawer)&               theStyle)
 {
   switch (theAction)
   {
     case BndAction_Hide:
     {
-      theMgr->Unhighlight (theObj, theDispMode);
+      theMgr->Unhighlight (theObj);
       break;
     }
     case BndAction_Show:
@@ -2973,7 +3108,7 @@ int VBounding (Draw_Interpretor& theDI,
   ViewerTest_BndAction anAction = BndAction_Show;
   Standard_Integer     aMode    = -1;
 
-  Handle(Graphic3d_HighlightStyle) aStyle;
+  Handle(Prs3d_Drawer) aStyle;
 
   Standard_Integer anArgIter = 1;
   for (; anArgIter < theArgNb; ++anArgIter)
@@ -3008,7 +3143,11 @@ int VBounding (Draw_Interpretor& theDI,
   }
 
   if (anAction == BndAction_Show)
-    aStyle = new Graphic3d_HighlightStyle (Aspect_TOHM_BOUNDBOX, Quantity_NOC_GRAY99, 0.0);
+  {
+    aStyle = new Prs3d_Drawer();
+    aStyle->SetMethod (Aspect_TOHM_BOUNDBOX);
+    aStyle->SetColor  (Quantity_NOC_GRAY99);
+  }
 
   Standard_Integer aHighlightedMode = -1;
   if (anArgIter < theArgNb)
@@ -3251,7 +3390,7 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
       anAISContext->SetDisplayMode (aTexturedIO, AIS_Shaded, Standard_False);
       if (aPreviousMode == 3)
       {
-        anAISContext->RecomputePrsOnly (aTexturedIO);
+        anAISContext->RecomputePrsOnly (aTexturedIO, Standard_False);
       }
 
       anAISContext->Display (aTexturedIO, Standard_True);
@@ -3346,7 +3485,7 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
 
   if (aTexturedIO->DisplayMode() == 3 || aPreviousMode == 3)
   {
-    anAISContext->RecomputePrsOnly (aTexturedIO);
+    anAISContext->RecomputePrsOnly (aTexturedIO, Standard_True);
   }
   else
   {
@@ -3702,6 +3841,7 @@ static int VDisplay2 (Draw_Interpretor& theDI,
   }
 
   // Prepare context for display
+  Standard_DISABLE_DEPRECATION_WARNINGS
   if (toDisplayLocal && !aCtx->HasOpenedContext())
   {
     aCtx->OpenLocalContext (Standard_False);
@@ -3710,6 +3850,7 @@ static int VDisplay2 (Draw_Interpretor& theDI,
   {
     aCtx->CloseAllContexts (Standard_False);
   }
+  Standard_ENABLE_DEPRECATION_WARNINGS
 
   // Display interactive objects
   for (Standard_Integer anIter = 1; anIter <= aNamesOfDisplayIO.Length(); ++anIter)
@@ -3833,7 +3974,7 @@ static int VDisplay2 (Draw_Interpretor& theDI,
 
       if (aSelMode == -1)
       {
-        aCtx->Erase (aShape);
+        aCtx->Erase (aShape, Standard_False);
       }
       aCtx->Display (aShape, aDispMode, aSelMode,
                      Standard_False, aShape->AcceptShapeDecomposition(),
@@ -3901,78 +4042,6 @@ static int VUpdate (Draw_Interpretor& /*theDi*/, Standard_Integer theArgsNb, con
   return 0;
 }
 
-//==============================================================================
-//function : VPerf
-//purpose  : Test the annimation of an object along a
-//           predifined trajectory
-//Draw arg : vperf ShapeName 1/0(Transfo/Location) 1/0(Primitives sensibles ON/OFF)
-//==============================================================================
-
-static int VPerf(Draw_Interpretor& di, Standard_Integer , const char** argv) {
-
-  OSD_Timer myTimer;
-  if (TheAISContext()->HasOpenedContext())
-    TheAISContext()->CloseLocalContext();
-
-  Standard_Real Step=4*M_PI/180;
-  Standard_Real Angle=0;
-
-  Handle(AIS_InteractiveObject) aIO;
-  if (GetMapOfAIS().IsBound2(argv[1]))
-    aIO = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(argv[1]));
-  if (aIO.IsNull())
-    return 1;
-
-  Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(aIO);
-
-  myTimer.Start();
-
-  if (Draw::Atoi(argv[3])==1 ) {
-    di<<" Primitives sensibles OFF\n";
-    TheAISContext()->Deactivate(aIO);
-  }
-  else {
-    di<<" Primitives sensibles ON\n";
-  }
-  // Movement par transformation
-  if(Draw::Atoi(argv[2]) ==1) {
-    di<<" Calcul par Transformation\n";
-    for (Standard_Real myAngle=0;Angle<10*2*M_PI; myAngle++) {
-
-      Angle=Step*myAngle;
-      gp_Trsf myTransfo;
-      myTransfo.SetRotation(gp_Ax1(gp_Pnt(0,0,0),gp_Dir(0,0,1) ) ,Angle );
-      TheAISContext()->SetLocation(aShape,myTransfo);
-      TheAISContext() ->UpdateCurrentViewer();
-
-    }
-  }
-  else {
-    di<<" Calcul par Locations\n";
-    gp_Trsf myAngleTrsf;
-    myAngleTrsf.SetRotation(gp_Ax1(gp_Pnt(0,0,0),gp_Dir(0,0,1) ), Step  );
-    TopLoc_Location myDeltaAngle (myAngleTrsf);
-    TopLoc_Location myTrueLoc;
-
-    for (Standard_Real myAngle=0;Angle<10*2*M_PI; myAngle++) {
-
-      Angle=Step*myAngle;
-      myTrueLoc=myTrueLoc*myDeltaAngle;
-      TheAISContext()->SetLocation(aShape,myTrueLoc );
-      TheAISContext() ->UpdateCurrentViewer();
-    }
-  }
-  if (Draw::Atoi(argv[3])==1 ){
-    // On reactive la selection des primitives sensibles
-    TheAISContext()->Activate(aIO,0);
-  }
-  a3DView() -> Redraw();
-  myTimer.Stop();
-  di<<" Temps ecoule \n";
-  myTimer.Show();
-  return 0;
-}
-
 //==============================================================================
 //function : VShading
 //purpose  : Sharpen or roughten the quality of the shading
@@ -3985,10 +4054,6 @@ static int VShading(Draw_Interpretor& ,Standard_Integer argc, const char** argv)
 
   // Verifications
   const Standard_Boolean HaveToSet = (strcasecmp(argv[0],"vsetshading") == 0);
-
-  if (TheAISContext()->HasOpenedContext())
-    TheAISContext()->CloseLocalContext();
-
   if (argc < 3) {
     myDevCoef  = 0.0008;
   } else {
@@ -4006,7 +4071,7 @@ static int VShading(Draw_Interpretor& ,Standard_Integer argc, const char** argv)
   else
     TheAISContext()->SetDeviationCoefficient(TheAisIO,0.0008,Standard_True);
 
-  TheAISContext()->Redisplay(TheAisIO);
+  TheAISContext()->Redisplay (TheAisIO, Standard_True);
   return 0;
 }
 //==============================================================================
@@ -4054,15 +4119,20 @@ static int VActivatedMode (Draw_Interpretor& di, Standard_Integer argc, const ch
       if (argc<2||argc>3) { di<<" Syntaxe error\n";return 1;}
       ThereIsName = (argc == 3);
     }
-    else {
+    else
+    {
+      Standard_DISABLE_DEPRECATION_WARNINGS
       // vunsetam
       if (argc>1) {di<<" Syntaxe error\n";return 1;}
       else {
         di<<" R.A.Z de tous les modes de selecion\n";
         di<<" Fermeture du Context local\n";
         if (TheAISContext()->HasOpenedContext())
+        {
           TheAISContext()->CloseLocalContext();
+        }
       }
+      Standard_ENABLE_DEPRECATION_WARNINGS
     }
 
     // IL n'y a aps de nom de shape passe en argument
@@ -4095,7 +4165,9 @@ static int VActivatedMode (Draw_Interpretor& di, Standard_Integer argc, const ch
          }
        }
 
+  Standard_DISABLE_DEPRECATION_WARNINGS
        TheAISContext()->OpenLocalContext(Standard_False);
+  Standard_ENABLE_DEPRECATION_WARNINGS
        ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
           it (GetMapOfAIS());
        while(it.More()){
@@ -4198,7 +4270,9 @@ static int VActivatedMode (Draw_Interpretor& di, Standard_Integer argc, const ch
         }
 
         if( !TheAISContext()->HasOpenedContext() ) {
+          Standard_DISABLE_DEPRECATION_WARNINGS
           TheAISContext()->OpenLocalContext(Standard_False);
+          Standard_ENABLE_DEPRECATION_WARNINGS
           // On charge tous les objets de la map
           ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS());
           while(it.More()){
@@ -4399,7 +4473,9 @@ static Standard_Integer VState (Draw_Interpretor& theDI,
   if (toPrintEntities)
   {
     theDI << "Detected entities:\n";
+    Standard_DISABLE_DEPRECATION_WARNINGS
     Handle(StdSelect_ViewerSelector3d) aSelector = aCtx->HasOpenedContext() ? aCtx->LocalSelector() : aCtx->MainSelector();
+    Standard_ENABLE_DEPRECATION_WARNINGS
     SelectMgr_SelectingVolumeManager aMgr = aSelector->GetManager();
     for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter)
     {
@@ -4449,10 +4525,12 @@ static Standard_Integer VState (Draw_Interpretor& theDI,
   }
 
   NCollection_Map<Handle(AIS_InteractiveObject)> aDetected;
+  Standard_DISABLE_DEPRECATION_WARNINGS
   for (aCtx->InitDetected(); aCtx->MoreDetected(); aCtx->NextDetected())
   {
     aDetected.Add (aCtx->DetectedCurrentObject());
   }
+  Standard_ENABLE_DEPRECATION_WARNINGS
 
   const Standard_Boolean toShowAll = (theArgNb >= 2 && *theArgVec[1] == '*');
   if (theArgNb >= 2
@@ -4518,8 +4596,10 @@ static Standard_Integer VState (Draw_Interpretor& theDI,
     theDI << "\n";
   }
   printLocalSelectionInfo (aCtx, theDI);
+  Standard_DISABLE_DEPRECATION_WARNINGS
   if (aCtx->HasOpenedContext())
     printLocalSelectionInfo (aCtx->LocalContext(), theDI);
+  Standard_ENABLE_DEPRECATION_WARNINGS
   return 0;
 }
 
@@ -4533,7 +4613,9 @@ Standard_Boolean  ViewerTest::PickObjects(Handle(TColStd_HArray1OfTransient)& ar
                                          const Standard_Integer MaxPick)
 {
   Handle(AIS_InteractiveObject) IO;
+  Standard_DISABLE_DEPRECATION_WARNINGS
   Standard_Integer curindex = (TheType == AIS_KOI_None) ? 0 : TheAISContext()->OpenLocalContext();
+  Standard_ENABLE_DEPRECATION_WARNINGS
 
   // step 1: prepare the data
   if(curindex !=0){
@@ -4573,9 +4655,12 @@ Standard_Boolean  ViewerTest::PickObjects(Handle(TColStd_HArray1OfTransient)& ar
     arr->SetValue(i,IO2);
   }
 
-
-  if(curindex>0)
+  Standard_DISABLE_DEPRECATION_WARNINGS
+  if (curindex > 0)
+  {
     TheAISContext()->CloseLocalContext(curindex);
+  }
+  Standard_ENABLE_DEPRECATION_WARNINGS
 
   return Standard_True;
 }
@@ -4590,7 +4675,9 @@ Handle(AIS_InteractiveObject) ViewerTest::PickObject(const AIS_KindOfInteractive
                                                     const Standard_Integer MaxPick)
 {
   Handle(AIS_InteractiveObject) IO;
+  Standard_DISABLE_DEPRECATION_WARNINGS
   Standard_Integer curindex = (TheType == AIS_KOI_None) ? 0 : TheAISContext()->OpenLocalContext();
+  Standard_ENABLE_DEPRECATION_WARNINGS
 
   // step 1: prepare the data
 
@@ -4621,8 +4708,12 @@ Handle(AIS_InteractiveObject) ViewerTest::PickObject(const AIS_KindOfInteractive
     IO = TheAISContext()->SelectedInteractive();
   }
 
-  if(curindex!=0)
+  Standard_DISABLE_DEPRECATION_WARNINGS
+  if (curindex != 0)
+  {
     TheAISContext()->CloseLocalContext(curindex);
+  }
+  Standard_ENABLE_DEPRECATION_WARNINGS
   return IO;
 }
 
@@ -4637,8 +4728,9 @@ TopoDS_Shape ViewerTest::PickShape(const TopAbs_ShapeEnum TheType,
 {
 
   // step 1: prepare the data
-
+  Standard_DISABLE_DEPRECATION_WARNINGS
   Standard_Integer curindex = TheAISContext()->OpenLocalContext();
+  Standard_ENABLE_DEPRECATION_WARNINGS
   TopoDS_Shape result;
 
   if(TheType==TopAbs_SHAPE){
@@ -4648,8 +4740,9 @@ TopoDS_Shape ViewerTest::PickShape(const TopAbs_ShapeEnum TheType,
   else{
     Handle(StdSelect_ShapeTypeFilter) TF = new StdSelect_ShapeTypeFilter(TheType);
     TheAISContext()->AddFilter(TF);
+    Standard_DISABLE_DEPRECATION_WARNINGS
     TheAISContext()->ActivateStandardMode(TheType);
-
+    Standard_ENABLE_DEPRECATION_WARNINGS
   }
 
 
@@ -4681,8 +4774,12 @@ TopoDS_Shape ViewerTest::PickShape(const TopAbs_ShapeEnum TheType,
     }
   }
 
-  if(curindex>0)
+  Standard_DISABLE_DEPRECATION_WARNINGS
+  if (curindex > 0)
+  {
     TheAISContext()->CloseLocalContext(curindex);
+  }
+  Standard_ENABLE_DEPRECATION_WARNINGS
 
   return result;
 }
@@ -4702,7 +4799,9 @@ Standard_Boolean ViewerTest::PickShapes (const TopAbs_ShapeEnum TheType,
     cout<<" WARNING : Pick with Shift+ MB1 for Selection of more than 1 object\n";
 
   // step 1: prepare the data
+  Standard_DISABLE_DEPRECATION_WARNINGS
   Standard_Integer curindex = TheAISContext()->OpenLocalContext();
+  Standard_ENABLE_DEPRECATION_WARNINGS
   if(TheType==TopAbs_SHAPE){
     Handle(AIS_TypeFilter) F1 = new AIS_TypeFilter(AIS_KOI_Shape);
     TheAISContext()->AddFilter(F1);
@@ -4710,8 +4809,9 @@ Standard_Boolean ViewerTest::PickShapes (const TopAbs_ShapeEnum TheType,
   else{
     Handle(StdSelect_ShapeTypeFilter) TF = new StdSelect_ShapeTypeFilter(TheType);
     TheAISContext()->AddFilter(TF);
+    Standard_DISABLE_DEPRECATION_WARNINGS
     TheAISContext()->ActivateStandardMode(TheType);
-
+    Standard_ENABLE_DEPRECATION_WARNINGS
   }
 
   // step 2 : wait for the selection...
@@ -4748,7 +4848,9 @@ Standard_Boolean ViewerTest::PickShapes (const TopAbs_ShapeEnum TheType,
     }
   }
 
+  Standard_DISABLE_DEPRECATION_WARNINGS
   TheAISContext()->CloseLocalContext(curindex);
+  Standard_ENABLE_DEPRECATION_WARNINGS
   return Standard_True;
 }
 
@@ -4806,7 +4908,7 @@ static int VPickShape( Draw_Interpretor& di, Standard_Integer argc, const char**
 
     Handle(AIS_Shape) newsh = new AIS_Shape(PickSh);
     GetMapOfAIS().Bind(newsh, name);
-    TheAISContext()->Display(newsh);
+    TheAISContext()->Display (newsh, Standard_True);
     di<<"Nom de la shape pickee : "<<name.ToCString()<<"\n";
   }
 
@@ -4836,9 +4938,10 @@ static int VPickShape( Draw_Interpretor& di, Standard_Integer argc, const char**
        Handle(AIS_Shape) newsh = new AIS_Shape(PickSh);
        GetMapOfAIS().Bind(newsh, name);
        di<<"display of picke shape #"<<i<<" - nom : "<<name.ToCString()<<"\n";
-       TheAISContext()->Display(newsh);
+       TheAISContext()->Display (newsh, Standard_False);
 
       }
+      TheAISContext()->UpdateCurrentViewer();
     }
   }
   return 0;
@@ -4886,9 +4989,11 @@ static int VPickSelected (Draw_Interpretor& , Standard_Integer theArgNb, const c
 
     Handle(AIS_Shape) aNewShape = new AIS_Shape (aShape);
     GetMapOfAIS().Bind (aNewShape, aCurrentName);
-    TheAISContext()->Display (aNewShape);
+    TheAISContext()->Display (aNewShape, Standard_False);
   }
 
+  TheAISContext()->UpdateCurrentViewer();
+
   return 0;
 }
 
@@ -5078,7 +5183,7 @@ static Standard_Integer vr(Draw_Interpretor& , Standard_Integer , const char** a
   DBRep::Set(a[1], shape);
   Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
   Handle(AIS_Shape) ais = new AIS_Shape(shape);
-  Ctx->Display(ais);
+  Ctx->Display (ais, Standard_True);
   return 0;
 }
 
@@ -5361,6 +5466,7 @@ static Standard_Integer VLoadSelection (Draw_Interpretor& /*theDi*/,
   }
 
   // Prepare context
+  Standard_DISABLE_DEPRECATION_WARNINGS
   if (isLocal && !aCtx->HasOpenedContext())
   {
     aCtx->OpenLocalContext (Standard_False);
@@ -5369,6 +5475,7 @@ static Standard_Integer VLoadSelection (Draw_Interpretor& /*theDi*/,
   {
     aCtx->CloseAllContexts (Standard_False);
   }
+  Standard_ENABLE_DEPRECATION_WARNINGS
 
   // Load selection of interactive objects
   for (Standard_Integer anIter = 1; anIter <= aNamesOfIO.Length(); ++anIter)
@@ -5562,6 +5669,7 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
       "\n\t\t:          [-isoontriangulation 0|1]"
       "\n\t\t:          [-setMaxParamValue {value}]"
       "\n\t\t:          [-setSensitivity {selection_mode} {value}]"
+      "\n\t\t:          [-setHatch HatchStyle]"
       "\n\t\t: Manage presentation properties of all, selected or named objects."
       "\n\t\t: When -subshapes is specified than following properties will be"
       "\n\t\t: assigned to specified sub-shapes."
@@ -5639,11 +5747,6 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
       "vsensera : erase active entities",
       __FILE__,VClearSensi,group);
 
-  theCommands.Add("vperf",
-      "vperf: vperf  ShapeName 1/0(Transfo/Location) 1/0(Primitives sensibles ON/OFF)"
-      "\n\t\t: Tests the animation of an object along a predefined trajectory.",
-      __FILE__,VPerf,group);
-
   theCommands.Add("vsetshading",
       "vsetshading  : vsetshading name Quality(default=0.0008) "
       "\n\t\t: Sets deflection coefficient that defines the quality of the shape representation in the shading mode.",