0023234: Incorrect behavior of AIS_Trihedron
authorkgv <kgv@opencascade.com>
Fri, 5 Oct 2012 10:06:32 +0000 (14:06 +0400)
committerkgv <kgv@opencascade.com>
Fri, 5 Oct 2012 10:06:32 +0000 (14:06 +0400)
AIS_InteractiveContext::myLocalContexts map accessed before newly created AIS_LocalContext bound to it
Minor remarks: comments revised.
Adding test case
Adding new draw command
Small correction of tests

src/AIS/AIS_InteractiveContext_2.cxx
src/AIS/AIS_LocalContext.cxx
src/QABugs/QABugs_11.cxx
tests/bugs/end
tests/bugs/vis/CR23407_1
tests/bugs/vis/CR23407_2

index 629f497..4159a3b 100755 (executable)
@@ -77,14 +77,16 @@ OpenLocalContext(const Standard_Boolean UseDisplayedObjects,
                                                           UseDisplayedObjects,
                                                           AllowShapeDecomposition,
                                                           AcceptEraseOfTemporary);
-  NewLocal->MainSelector()->Set ((myLocalContexts.Extent() > 0)
+  // the AIS_LocalContext bind itself to myLocalContexts
+  // because procedures performed in AIS_LocalContext constructor
+  // already may access myLocalContexts(myCurLocalIndex) (like methods AIS_LocalContext::IsSelected()).
+  //myLocalContexts.Bind (myCurLocalIndex, NewLocal);
+  NewLocal->MainSelector()->Set ((myLocalContexts.Extent() > 1)
     ? myLocalContexts (untilnow)->MainSelector()->Projector()
     : myMainSel->Projector());
 
   NewLocal->MainSelector()->UpdateConversion();
 
-  myLocalContexts.Bind(myCurLocalIndex,NewLocal);
-
 #ifdef DEB
   cout<<"\tOpen Local Context No "<<myCurLocalIndex<<endl;
   if(UseDisplayedObjects){
index 07c494b..651fa30 100755 (executable)
@@ -119,6 +119,11 @@ myCurDetected(0)
 ,myAISCurDetected(0)
 #endif
 {
+  // bind self to AIS_InteractiveContext::myLocalContexts. Further, the
+  // constructor executes logic that implies that the context is already
+  // created and mapped.
+  aCtx->myLocalContexts.Bind (Index, this);
+
   myMainPM = aCtx->MainPrsMgr();
   mySelName = AIS_Local_SelName(this, Index);
   AIS_Selection::CreateSelection(mySelName.ToCString());
index 65440a7..947ef99 100755 (executable)
@@ -5403,6 +5403,59 @@ Standard_Integer CR23403 (Draw_Interpretor& di, Standard_Integer argc, const cha
   return 0;
 }
 
+#include <Quantity_NameOfColor.hxx>
+#include <TopAbs_ShapeEnum.hxx>
+Standard_Integer CR23234 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
+{
+  // Check the command arguments
+  if (argc != 2)
+  {
+    di <<"Error: "<<argv[0]<<" - invalid number of arguments"<< "\n";
+    di << "Usage : " << argv[0] << " mode(0/1)\n";
+    return 1; //TCL_ERROR
+  }
+
+  const Standard_Integer aMode = atoi(argv[1]);
+
+  //===================================================================
+
+  Handle(AIS_InteractiveContext) aisContext = ViewerTest::GetAISContext();
+  if (aisContext.IsNull())
+  {
+    di <<"Error: call 'vinit' first"<< "\n";
+    return 1; //TCL_ERROR
+  }
+
+  if (aisContext->HasOpenedContext())
+  {
+    aisContext->CloseAllContexts();
+    aisContext->RemoveAll(false);
+    aisContext->EraseSelected(false, false);
+  }
+  aisContext->EraseAll(false,false);
+  Handle(Geom_Axis2Placement) trihedronAxis = new Geom_Axis2Placement(gp::XOY());
+  Handle(AIS_Trihedron) trihedron = new AIS_Trihedron(trihedronAxis);
+  if (aMode)
+    trihedron->UnsetSelectionMode(); // this line causes an exception on OpenLocalContext
+  trihedron->SetSize(20);
+  trihedron->SetColor(Quantity_NOC_GRAY30);
+  trihedron->SetArrowColor(Quantity_NOC_GRAY30);
+  trihedron->SetTextColor(Quantity_NOC_DARKSLATEBLUE);
+
+  //trihedron->SetColor(Quantity_NameOfColor::Quantity_NOC_GRAY30);
+  //trihedron->SetArrowColor(Quantity_NameOfColor::Quantity_NOC_GRAY30);
+  //trihedron->SetTextColor(Quantity_NameOfColor::Quantity_NOC_DARKSLATEBLUE);
+
+
+  aisContext->Display(trihedron, true);
+  aisContext->OpenLocalContext();
+  //aisContext->ActivateStandardMode(TopAbs_ShapeEnum::TopAbs_EDGE);
+  aisContext->ActivateStandardMode(TopAbs_EDGE);
+  aisContext->SetSensitivity(8);
+
+  return 0; //TCL_OK
+}
+
 void QABugs::Commands_11(Draw_Interpretor& theCommands) {
   const char *group = "QABugs";
 
@@ -5514,5 +5567,6 @@ void QABugs::Commands_11(Draw_Interpretor& theCommands) {
   theCommands.Add("OCC22558", "OCC22558 x_vec y_vec z_vec x_dir y_dir z_dit x_pnt y_pnt z_pnt", __FILE__, OCC22558, group);
   theCommands.Add("CR23403", "CR23403 string", __FILE__, CR23403, group);
   theCommands.Add("OCC23429", "OCC23429 res shape tool [appr]", __FILE__, OCC23429, group);
+  theCommands.Add("CR23234", "CR23234 mode(0/1)", __FILE__, CR23234, group);
   return;
 }
index 796d195..014f78b 100755 (executable)
@@ -14,6 +14,12 @@ if { [isdraw result] } {
        vfit
        vdump $imagedir/${test_image}.gif
     }
+} else {
+    if { [info exists 3dviewer] } {
+       if { ${3dviewer} == 2 } {
+               vdump $imagedir/${test_image}.gif
+       }
+    }
 }
     if { [info exist only_xwd] } {
        xwd $imagedir/${test_image}.gif 
index 251c578..bacf808 100755 (executable)
@@ -31,10 +31,4 @@ if { $rd != $r_check || $gr != $g_check || $bl != $b_check } {
     puts "Error : Boundary of face is not changed"
 }
 
-set 3dviewer 1
-
-
-
-
-
-
+set 3dviewer 2
index 64f1335..522c5d5 100755 (executable)
@@ -31,9 +31,4 @@ if { $rd != $r_check || $gr != $g_check || $bl != $b_check } {
     puts "Error : Boundary of face is not changed"
 }
 
-set 3dviewer 1
-
-
-
-
-
+set 3dviewer 2