0028643: Coding rules - eliminate GCC compiler warnings -Wmisleading-indentation
[occt.git] / src / QABugs / QABugs_19.cxx
index c2b8770..efe20de 100644 (file)
@@ -18,7 +18,7 @@
 #include <AIS_InteractiveContext.hxx>
 #include <AIS_LocalContext.hxx>
 #include <AIS_TexturedShape.hxx>
-#include <BRepAlgo_Cut.hxx>
+#include <BRepAlgoAPI_Cut.hxx>
 #include <BRepOffsetAPI_MakePipe.hxx>
 #include <BRepPrimAPI_MakeBox.hxx>
 #include <BRepPrimAPI_MakeSphere.hxx>
@@ -125,7 +125,7 @@ static Standard_Integer OCC23237 (Draw_Interpretor& di, Standard_Integer /*argc*
     // do some operation that will take considerable time compared with time of starting / stopping timers
     BRepPrimAPI_MakeBox aBox (10., 10., 10.);
     BRepPrimAPI_MakeSphere aSphere (10.);
-    BRepAlgo_Cut aCutter (aBox.Shape(), aSphere.Shape());
+    BRepAlgoAPI_Cut aCutter (aBox.Shape(), aSphere.Shape());
 
     aTM.Stop();
     aPM.Stop();
@@ -1285,8 +1285,8 @@ static Standard_Integer OCC24012 (Draw_Interpretor& di, Standard_Integer argc, c
     {
         TopoDS_Shape rshape = anormpro.Projection();
                Handle(AIS_InteractiveObject) myShape = new AIS_Shape (rshape);
-               myAISContext->SetColor(myShape, Quantity_Color(Quantity_NOC_YELLOW));
-               myAISContext->Display(myShape, Standard_True);
+               myAISContext->SetColor (myShape, Quantity_Color(Quantity_NOC_YELLOW), Standard_False);
+               myAISContext->Display (myShape, Standard_True);
     }
 
        return 0;
@@ -1774,6 +1774,7 @@ static Standard_Integer OCC23950 (Draw_Interpretor& di, Standard_Integer argc, c
   TDataStd_Name::Set(labelA0, "ASSEMBLY");
 
   TDF_Label component01 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->AddComponent (labelA0, lab1, location0);
+  XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->UpdateAssemblies();
 
   Quantity_Color yellow(1,1,0, Quantity_TOC_RGB);
   XCAFDoc_DocumentTool::ColorTool (labelA0)->SetColor (component01, yellow, XCAFDoc_ColorGen);
@@ -1822,11 +1823,11 @@ static Standard_Integer OCC24622 (Draw_Interpretor& /*theDi*/, Standard_Integer
   aTextureTypeArg.UpperCase();
   if (aTextureTypeArg == "1D")
   {
-    anImage->InitWrapper (Image_PixMap::ImgRGB, (Standard_Byte*)aBitmap, 8, 1);
+    anImage->InitWrapper (Image_Format_RGB, (Standard_Byte*)aBitmap, 8, 1);
   }
   else if (aTextureTypeArg == "2D")
   {
-    anImage->InitTrash (Image_PixMap::ImgRGB, 8, 8);
+    anImage->InitTrash (Image_Format_RGB, 8, 8);
     for (Standard_Integer aRow = 0; aRow < 8; ++aRow)
     {
       for (Standard_Integer aCol = 0; aCol < 8; ++aCol)
@@ -1845,7 +1846,7 @@ static Standard_Integer OCC24622 (Draw_Interpretor& /*theDi*/, Standard_Integer
 
   Handle(AIS_TexturedShape) aTexturedShape = new AIS_TexturedShape (aBlankShape);
   aTexturedShape->SetTexturePixMap (anImage);
-  anAISContext->Display (aTexturedShape, 3, 0);
+  anAISContext->Display (aTexturedShape, 3, 0, Standard_True);
 
   return 0;
 }
@@ -3304,7 +3305,7 @@ static Standard_Integer OCC26172 (Draw_Interpretor& theDI, Standard_Integer theA
   BRepBuilderAPI_MakeEdge anEdgeBuilder (aStart, anEnd);
   TopoDS_Edge anEdge = anEdgeBuilder.Edge();
   Handle(AIS_Shape) aTestAISShape = new AIS_Shape (anEdge);
-  anAISContext->Display (aTestAISShape);
+  anAISContext->Display (aTestAISShape, Standard_True);
 
   // 2. activate it in selection modes
   TColStd_SequenceOfInteger aModes;
@@ -3398,16 +3399,17 @@ static Standard_Integer OCC26284 (Draw_Interpretor& theDI, Standard_Integer theA
 
   BRepPrimAPI_MakeSphere aSphereBuilder (gp_Pnt (0.0, 0.0, 0.0), 1.0);
   Handle(AIS_Shape) aSphere = new AIS_Shape (aSphereBuilder.Shape());
-  anAISContext->Display (aSphere);
+  anAISContext->Display (aSphere, Standard_False);
   for (Standard_Integer aChildIdx = 0; aChildIdx < 5; ++aChildIdx)
   {
     BRepPrimAPI_MakeSphere aBuilder (gp_Pnt (1.0 + aChildIdx, 1.0 + aChildIdx, 1.0 + aChildIdx), 1.0);
     Handle(AIS_Shape) aChild = new AIS_Shape (aBuilder.Shape());
     aSphere->AddChild (aChild);
-    anAISContext->Display (aChild);
+    anAISContext->Display (aChild, Standard_False);
   }
 
   anAISContext->RecomputeSelectionOnly (aSphere);
+  anAISContext->UpdateCurrentViewer();
 
   return 0;
 }
@@ -4170,16 +4172,16 @@ static Standard_Integer OCC26462 (Draw_Interpretor& theDI, Standard_Integer /*th
   Handle(AIS_InteractiveObject) aBox2 = new AIS_Shape (aBuilder2.Shape());
 
   const Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
-  aCtx->Display (aBox1, 0, 2);
-  aCtx->Display (aBox2, 0, 2);
+  aCtx->Display (aBox1, 0, 2, Standard_False);
+  aCtx->Display (aBox2, 0, 2, Standard_False);
   ViewerTest::CurrentView()->FitAll();
-  aCtx->SetWidth (aBox1, 3);
-  aCtx->SetWidth (aBox2, 3);
+  aCtx->SetWidth (aBox1, 3, Standard_False);
+  aCtx->SetWidth (aBox2, 3, Standard_False);
 
-  aCtx->MoveTo (305, 322, ViewerTest::CurrentView());
-  aCtx->ShiftSelect();
-  aCtx->MoveTo (103, 322, ViewerTest::CurrentView());
-  aCtx->ShiftSelect();
+  aCtx->MoveTo (305, 322, ViewerTest::CurrentView(), Standard_False);
+  aCtx->ShiftSelect (Standard_False);
+  aCtx->MoveTo (103, 322, ViewerTest::CurrentView(), Standard_False);
+  aCtx->ShiftSelect (Standard_False);
   if (aCtx->NbSelected() != 0)
   {
     theDI << "ERROR: no boxes must be selected!\n";
@@ -4188,15 +4190,15 @@ static Standard_Integer OCC26462 (Draw_Interpretor& theDI, Standard_Integer /*th
 
   aCtx->SetSelectionSensitivity (aBox1, 2, 5);
 
-  aCtx->MoveTo (305, 322, ViewerTest::CurrentView());
-  aCtx->ShiftSelect();
+  aCtx->MoveTo (305, 322, ViewerTest::CurrentView(), Standard_False);
+  aCtx->ShiftSelect (Standard_False);
   if (aCtx->NbSelected() != 1)
   {
     theDI << "ERROR: b1 was not selected\n";
     return 1;
   }
-  aCtx->MoveTo (103, 322, ViewerTest::CurrentView());
-  aCtx->ShiftSelect();
+  aCtx->MoveTo (103, 322, ViewerTest::CurrentView(), Standard_False);
+  aCtx->ShiftSelect (Standard_True);
   if (aCtx->NbSelected() != 1)
   {
     theDI << "ERROR: b2 is selected after b1's tolerance increased\n";
@@ -4885,8 +4887,8 @@ static Standard_Integer BUC26658 (Draw_Interpretor& theDI,
   Standard_Integer Xp,Yp;
   myV3dView->Convert(Xv,Yv,Xp,Yp);
 
-  aContext->MoveTo(Xp,Yp, myV3dView);
-  aContext->Select();
+  aContext->MoveTo (Xp, Yp, myV3dView, Standard_False);
+  aContext->Select (Standard_False);
   bool aHasSelected = false;
   for (aContext->InitSelected(); aContext->MoreSelected() && !aHasSelected; aContext->NextSelected()) {
     Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
@@ -4912,7 +4914,7 @@ static Standard_Integer BUC26658 (Draw_Interpretor& theDI,
   Standard_ENABLE_DEPRECATION_WARNINGS
 
   // check that there are no selected vertices
-  aContext->Select();
+  aContext->Select (Standard_True);
   aHasSelected = false;
   for (aContext->InitSelected(); aContext->MoreSelected() && !aHasSelected; aContext->NextSelected()) {
     Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
@@ -5149,7 +5151,7 @@ static Standard_Integer OCC27523 (Draw_Interpretor& theDI, Standard_Integer theA
   BRepBuilderAPI_MakeEdge anEdgeBuilder (aStart, anEnd);
   TopoDS_Edge anEdge = anEdgeBuilder.Edge();
   Handle(AIS_InteractiveObject) aTestAISShape = new AIS_Shape (anEdge);
-  anAISContext->Display (aTestAISShape);
+  anAISContext->Display (aTestAISShape, Standard_False);
 
   // activate it in selection modes
   TColStd_SequenceOfInteger aModes;
@@ -5171,7 +5173,7 @@ static Standard_Integer OCC27523 (Draw_Interpretor& theDI, Standard_Integer theA
   Handle(AIS_Shape)::DownCast (aTestAISShape)->Set (aVertexShape);
   aTestAISShape->Redisplay();
 
-  anAISContext->AddOrRemoveSelected (aTestAISShape);
+  anAISContext->AddOrRemoveSelected (aTestAISShape, Standard_True);
 
   bool aValidShapeType = false;
   for (anAISContext->InitSelected(); anAISContext->MoreSelected(); anAISContext->NextSelected())
@@ -5252,7 +5254,7 @@ static Standard_Integer OCC27700 (Draw_Interpretor& /*theDI*/, Standard_Integer
     return 1;
   }
   Handle(OCC27700_Text) aPresentation = new OCC27700_Text();
-  aContext->Display (aPresentation);
+  aContext->Display (aPresentation, Standard_True);
   return 0;
 }
 
@@ -5309,10 +5311,21 @@ static Standard_Integer OCC27818 (Draw_Interpretor& /*theDI*/, Standard_Integer
     aBoxObjs[aBoxIdx]->SetHilightMode (AIS_Shaded);
   }
 
-  aBoxObjs[1]->HilightAttributes()->SetHighlightStyle (new Graphic3d_HighlightStyle (
-    Aspect_TOHM_COLOR, Quantity_NOC_RED, 0.8f));
-  aBoxObjs[2]->HilightAttributes()->SetSelectionStyle (new Graphic3d_HighlightStyle (
-    Aspect_TOHM_COLOR, Quantity_NOC_RED, 0.0f));
+  {
+    Handle(Prs3d_Drawer) aHiStyle = new Prs3d_Drawer();
+    aBoxObjs[1]->SetDynamicHilightAttributes (aHiStyle);
+    aHiStyle->SetDisplayMode (AIS_Shaded);
+    aHiStyle->SetColor (Quantity_NOC_RED);
+    aHiStyle->SetTransparency (0.8f);
+  }
+  {
+    Handle(Prs3d_Drawer) aSelStyle = new Prs3d_Drawer();
+    aBoxObjs[2]->SetHilightAttributes (aSelStyle);
+    aSelStyle->SetDisplayMode (AIS_Shaded);
+    aSelStyle->SetColor (Quantity_NOC_RED);
+    aSelStyle->SetTransparency (0.0f);
+    aSelStyle->SetZLayer (Graphic3d_ZLayerId_Topmost);
+  }
 
   for (Standard_Integer aBoxIdx = 0; aBoxIdx < 3; ++aBoxIdx)
   {
@@ -5345,6 +5358,41 @@ static Standard_Integer OCC27893 (Draw_Interpretor& /*theDI*/, Standard_Integer
   return 0;
 }
 
+//========================================================================
+//function : OCC28310
+//purpose  : Tests validness of iterator in AIS_InteractiveContext after
+// an removing object from it
+//========================================================================
+static Standard_Integer OCC28310 (Draw_Interpretor& /*theDI*/, Standard_Integer /*theArgc*/, const char** theArgv)
+{
+  const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
+  if (aCtx.IsNull())
+  {
+    std::cout << "No interactive context. Use 'vinit' command before " << theArgv[0] << "\n";
+    return 1;
+  }
+
+  TopoDS_Shape aBox = BRepPrimAPI_MakeBox (10.0, 10.0, 10.0).Shape();
+  Handle(AIS_InteractiveObject) aBoxObj = new AIS_Shape (aBox);
+  aCtx->Display (aBoxObj, AIS_Shaded, 0, Standard_False);
+  ViewerTest::CurrentView()->FitAll();
+  aCtx->MoveTo (200, 200, ViewerTest::CurrentView(), Standard_True);
+  aCtx->Select(Standard_True);
+
+  aCtx->Remove (aBoxObj, Standard_True);
+  // nullify the object explicitly to simulate situation in project,
+  // when ::Remove is called from another method and the object is destroyed
+  // before ::DetectedInteractive is called
+  aBoxObj.Nullify();
+
+  for (aCtx->InitDetected(); aCtx->MoreDetected(); aCtx->NextDetected())
+  {
+    Handle(AIS_InteractiveObject) anObj = aCtx->DetectedInteractive();
+  }
+
+  return 0;
+}
+
 //========================================================================
 //function : Commands_19
 //purpose  :
@@ -5481,5 +5529,8 @@ void QABugs::Commands_19(Draw_Interpretor& theCommands) {
   theCommands.Add ("OCC27893",
                    "OCC27893: Creates a box and selects it via AIS_InteractiveContext API",
                    __FILE__, OCC27893, group);
+  theCommands.Add("OCC28310",
+                  "OCC28310: Tests validness of iterator in AIS_InteractiveContext after an removing object from it",
+                  __FILE__, OCC28310, group);
   return;
 }