From 54a16ee44718365886ebc88330613c58600a50c2 Mon Sep 17 00:00:00 2001 From: kgv Date: Thu, 16 Oct 2014 16:07:36 +0400 Subject: [PATCH] 0025340: Visualization, AIS_InteractiveContext - properly apply selection filters at Neutral point Do not use myMainSel->OnePicked() in AIS_InteractiveContext::MoveTo(). Test-case for issue #25340 --- src/AIS/AIS_InteractiveContext_1.cxx | 13 ++++++---- src/QABugs/QABugs_19.cxx | 17 +++++++++++++ tests/bugs/vis/bug25340 | 36 ++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 4 deletions(-) create mode 100644 tests/bugs/vis/bug25340 diff --git a/src/AIS/AIS_InteractiveContext_1.cxx b/src/AIS/AIS_InteractiveContext_1.cxx index 90168e831f..79b3463ef5 100644 --- a/src/AIS/AIS_InteractiveContext_1.cxx +++ b/src/AIS/AIS_InteractiveContext_1.cxx @@ -157,6 +157,7 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th // filling of myAISDetectedSeq sequence storing information about detected AIS objects // (the objects must be AIS_Shapes) const Standard_Integer aDetectedNb = myMainSel->NbPicked(); + Standard_Integer aNewDetected = 0; for (Standard_Integer aDetIter = 1; aDetIter <= aDetectedNb; ++aDetIter) { Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aDetIter); @@ -166,6 +167,10 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th continue; } + if (aNewDetected < 1) + { + aNewDetected = aDetIter; + } Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()); if (!anObj.IsNull()) { @@ -173,11 +178,11 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th } } - myMainSel->Init(); - if (myMainSel->More()) + if (aNewDetected >= 1) { // does nothing if previously detected object is equal to the current one - if (myMainSel->OnePicked()->Selectable() == myLastPicked) + Handle(SelectMgr_EntityOwner) aNewPickedOwner = myMainSel->Picked (aNewDetected); + if (aNewPickedOwner->Selectable() == myLastPicked) { return myLastPicked->State() == 1 ? AIS_SOD_Selected @@ -205,7 +210,7 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th } // initialize myLastPicked field with currently detected object - myLastPicked = Handle(AIS_InteractiveObject)::DownCast (myMainSel->OnePicked()->Selectable()); + myLastPicked = Handle(AIS_InteractiveObject)::DownCast (aNewPickedOwner->Selectable()); myLastinMain = myLastPicked; // highlight detected object if it is not selected or myToHilightSelected flag is true diff --git a/src/QABugs/QABugs_19.cxx b/src/QABugs/QABugs_19.cxx index 1dafb45bc5..80ea21785f 100755 --- a/src/QABugs/QABugs_19.cxx +++ b/src/QABugs/QABugs_19.cxx @@ -2882,6 +2882,22 @@ static Standard_Integer OCC7570 (Draw_Interpretor& di, Standard_Integer n, const return 0; } +#include +static Standard_Integer OCC25340 (Draw_Interpretor& /*theDI*/, + Standard_Integer /*theArgNb*/, + const char** /*theArgVec*/) +{ + Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext(); + if (aCtx.IsNull()) + { + std::cerr << "Error: No opened viewer!\n"; + return 1; + } + Handle(AIS_TypeFilter) aFilter = new AIS_TypeFilter (AIS_KOI_Shape); + aCtx->AddFilter (aFilter); + return 0; +} + /*****************************************************************************/ #include @@ -2978,5 +2994,6 @@ void QABugs::Commands_19(Draw_Interpretor& theCommands) { theCommands.Add ("OCC25202", "OCC25202 res shape numF1 face1 numF2 face2", __FILE__, OCC25202, group); theCommands.Add ("OCC7570", "OCC7570 shape", __FILE__, OCC7570, group); theCommands.Add ("OCC25100", "OCC25100 shape", __FILE__, OCC25100, group); + theCommands.Add ("OCC25340", "OCC25340", __FILE__, OCC25340, group); return; } diff --git a/tests/bugs/vis/bug25340 b/tests/bugs/vis/bug25340 new file mode 100644 index 0000000000..5402e44479 --- /dev/null +++ b/tests/bugs/vis/bug25340 @@ -0,0 +1,36 @@ +puts "========" +puts "OCC25340" +puts "========" +puts "" +############################################################################################# +# Visualization, AIS_InteractiveContext - properly apply selection filters at Neutral point +############################################################################################# + +pload QAcommands + +vinit + +box b 1 2 3 +vdisplay b +vfit +vtrihedron t +set color_1 [vreadpixel 87 25] + +OCC25340 +vselect 87 25 +set color_2 [vreadpixel 87 25] + +if {$color_2 != $color_1} { + puts "ERROR: OCC25340 is reproduced" + puts " initial color of trihedron is: $color_1" + puts " final color of trihedron is: $color_2" +} + +if {$color_2 != "0.43137255311012268 0.48235294222831726 0.54509806632995605 1"} { + puts "ERROR: OCC25340 is reproduced" + puts " additional investigation is needed" + puts " expected color is: 0.43137255311012268 0.48235294222831726 0.54509806632995605 1" + puts " current color is: $_color_2" +} + +set only_screen 1 -- 2.39.5