1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-16 10:08:36 +03:00

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.
This commit is contained in:
kgv 2021-02-27 10:48:32 +03:00
parent bc0711a5c3
commit ba590cbf15
2 changed files with 12 additions and 20 deletions

View File

@ -113,22 +113,14 @@ void StdSelect_BRepOwner::HilightWithColor (const Handle(PrsMgr_PresentationMana
// generate new presentable shape // generate new presentable shape
if (myPrsSh.IsNull()) 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 // initialize presentation attributes of child presentation
myPrsSh->SetZLayer (aSel->ZLayer()); myPrsSh->SetZLayer (aSel->ZLayer());
myPrsSh->SetTransformPersistence (aSel->TransformPersistence()); myPrsSh->SetTransformPersistence (aSel->TransformPersistence());
myPrsSh->SetLocalTransformation (Location());
myPrsSh->Attributes()->SetLink (theStyle); myPrsSh->Attributes()->SetLink (theStyle);
myPrsSh->Attributes()->SetColor (theStyle->Color()); myPrsSh->Attributes()->SetColor (theStyle->Color());
myPrsSh->Attributes()->SetTransparency (theStyle->Transparency()); 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) void StdSelect_BRepOwner::SetLocation(const TopLoc_Location& aLoc)
{ {
SelectMgr_EntityOwner::SetLocation(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()) 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 Handle(PrsMgr_PresentationManager)& theManager,
const Standard_Integer theDispMode) const Standard_Integer theDispMode)
{ {
if (myPrsSh.IsNull() && Selectable().IsNull()) if (!myPrsSh.IsNull() || HasSelectable())
return; {
theManager->UpdateHighlightTrsf (theViewer, Selectable(), theDispMode, myPrsSh); theManager->UpdateHighlightTrsf (theViewer, Selectable(), theDispMode, myPrsSh);
}
} }
// ======================================================================= // =======================================================================

View File

@ -1,6 +1,5 @@
puts "===========" puts "==========="
puts "OCC27986" puts "0027986: Visualization - AIS_InteractiveContext::SetLocation() does not update dynamic highlighting"
puts "Visualization - AIS_InteractiveContext::SetLocation() does not update dynamic highlighting"
puts "Test local selection" puts "Test local selection"
puts "===========" puts "==========="
puts "" puts ""
@ -15,10 +14,12 @@ vdisplay -dispMode 0 -highMode 1 b
vfit vfit
vzoom 0.5 vzoom 0.5
vselmode b 4 1 vselmode b 4 1
vselect 150 150
vmoveto 250 250 vmoveto 250 250
vsetlocation b 2 1 0 vsetlocation b 2 1 0
set aColor1 [vreadpixel 220 200 rgb name] set aColor1 [vreadpixel 220 200 rgb name]
set aColor2 [vreadpixel 350 220 rgb name] set aColor2 [vreadpixel 350 220 rgb name]
if { "$aColor1" != "BLACK" || "$aColor2" != "CYAN2" } { puts "Error: dynamic highlighting is not updated" } 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 vdump $imagedir/${casename}.png