From ba590cbf1556d97c4c4d7f8a5ed8690223d03b9c Mon Sep 17 00:00:00 2001 From: kgv Date: Sat, 27 Feb 2021 10:48:32 +0300 Subject: [PATCH] 0032180: Visualization - StdSelect_BRepOwner::SetLocation() does not update selected sub-shape StdSelect_BRepOwner::SetLocation() now propagates location to sub-shape presentation instead of invalidating it. --- src/StdSelect/StdSelect_BRepOwner.cxx | 27 +++++++++------------------ tests/bugs/vis/bug27986_2 | 5 +++-- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/StdSelect/StdSelect_BRepOwner.cxx b/src/StdSelect/StdSelect_BRepOwner.cxx index 7498a784fa..0e19f0c5ee 100644 --- a/src/StdSelect/StdSelect_BRepOwner.cxx +++ b/src/StdSelect/StdSelect_BRepOwner.cxx @@ -114,21 +114,13 @@ void StdSelect_BRepOwner::HilightWithColor (const Handle(PrsMgr_PresentationMana // generate new presentable shape if (myPrsSh.IsNull()) { - if (HasLocation()) - { - TopLoc_Location lbid = Location() * myShape.Location(); - TopoDS_Shape ShBis = myShape.Located(lbid); - myPrsSh = new StdSelect_Shape (ShBis, theStyle); - } - else - { - myPrsSh = new StdSelect_Shape (myShape, theStyle); - } + myPrsSh = new StdSelect_Shape (myShape, theStyle); } // initialize presentation attributes of child presentation myPrsSh->SetZLayer (aSel->ZLayer()); myPrsSh->SetTransformPersistence (aSel->TransformPersistence()); + myPrsSh->SetLocalTransformation (Location()); myPrsSh->Attributes()->SetLink (theStyle); myPrsSh->Attributes()->SetColor (theStyle->Color()); myPrsSh->Attributes()->SetTransparency (theStyle->Transparency()); @@ -162,11 +154,10 @@ void StdSelect_BRepOwner::Clear(const Handle(PrsMgr_PresentationManager)& PM, void StdSelect_BRepOwner::SetLocation(const TopLoc_Location& aLoc) { SelectMgr_EntityOwner::SetLocation(aLoc); - // we must not nullify the myPrsSh here, because unhilight method - // will be working with wrong entity in this case, the best is to - // set the update flag and then recompute myPrsSh on hilighting if (!myPrsSh.IsNull()) - myPrsSh->SetToUpdate(); + { + myPrsSh->SetLocalTransformation (Location()); + } } //======================================================================= @@ -177,10 +168,10 @@ void StdSelect_BRepOwner::UpdateHighlightTrsf (const Handle(V3d_Viewer)& theView const Handle(PrsMgr_PresentationManager)& theManager, const Standard_Integer theDispMode) { - if (myPrsSh.IsNull() && Selectable().IsNull()) - return; - - theManager->UpdateHighlightTrsf (theViewer, Selectable(), theDispMode, myPrsSh); + if (!myPrsSh.IsNull() || HasSelectable()) + { + theManager->UpdateHighlightTrsf (theViewer, Selectable(), theDispMode, myPrsSh); + } } // ======================================================================= diff --git a/tests/bugs/vis/bug27986_2 b/tests/bugs/vis/bug27986_2 index 14e37a9cff..5ab52da678 100644 --- a/tests/bugs/vis/bug27986_2 +++ b/tests/bugs/vis/bug27986_2 @@ -1,6 +1,5 @@ puts "===========" -puts "OCC27986" -puts "Visualization - AIS_InteractiveContext::SetLocation() does not update dynamic highlighting" +puts "0027986: Visualization - AIS_InteractiveContext::SetLocation() does not update dynamic highlighting" puts "Test local selection" puts "===========" puts "" @@ -15,10 +14,12 @@ vdisplay -dispMode 0 -highMode 1 b vfit vzoom 0.5 vselmode b 4 1 +vselect 150 150 vmoveto 250 250 vsetlocation b 2 1 0 set aColor1 [vreadpixel 220 200 rgb name] set aColor2 [vreadpixel 350 220 rgb name] if { "$aColor1" != "BLACK" || "$aColor2" != "CYAN2" } { puts "Error: dynamic highlighting is not updated" } +if { "[vreadpixel 150 150 rgb name]" != "BLACK" } { puts "Error: sub-shape highlighting is not updated" } vdump $imagedir/${casename}.png