HilightWithColor/Unhilight

Hello,
the call:

anOwner->HilightWithColor(occContext->MainPrsMgr(), aDrawer, ...);

in which

- anOwner is a StdSelect_BRepOwner,
- aDrawer is a Prs3d_Drawer
- occContext my interactive context

is able to highlight a subshape of a shape, in which anOwner is the
owner of the subshape.

In order to remove the highlight I scan ALL (for the moment)
the owners of the shape, stored into a map, using a for cycle.
At each pass each owner is checked: it must be not null,
and I must "have" a shape; if yes I use for unhilighting

owner->Unhilight(occContext->MainPrsMgr(), 9999); [*]

I symbolically use 9999 since the last parameter is not used:

void StdSelect_BRepOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& thePrsMgr, const Standard_Integer )

My code crashes at [*].

OpenCascade 7.3.0

Any idea?
Grazie
Giovanni

w d's picture

Hello, could you tell me if this problem was solved later? The problem on my side is that in the sub-shape selection mode, rectangle select will crash.

myAISContext->Activate(CADModelShape::SelectionMode(TopAbs_VERTEX));
myContext->SelectRectangle(Graphic3d_Vec2i(myXmin,myYmin),Graphic3d_Vec2i(point.X(),point.Y()),myView,AIS_SelectionScheme_Replace);

Giovanni Bettega's picture

Ciao
unfortunately not yet.
I stored ALL the owners into a map, then I scanned it and call unhilight on each owner:
but explosion.

Since from OCC doc:

//! Standard_EXPORT void EntityOwners (Handle(SelectMgr_IndexedMapOfOwner)& theOwners,
//! const Handle(AIS_InteractiveObject)& theIObj,
//! const Standard_Integer theMode = -1) const;
//! Returns a collection containing all entity owners created for the interactive object
//! in specified selection mode (in all active modes if the Mode == -1)

I tried as an alternative this snippet:

AIS_ListOfInteractive l;
occContext->ObjectsInside(l,AIS_KOI_Shape,-1);
for(AIS_ListIteratorOfListOfInteractive it(l); it.More(); it.Next())
{
occHandle(SelectMgr_IndexedMapOfOwner) theOwners;
occContext->EntityOwners(theOwners,it.Value(),-1);
for(int n=1; n<=theOwners->Extent(); n++)
theOwners->FindKey(n)->Unhilight(occContext->MainPrsMgr(), 9999);
}

This does not crash anymore, but does not unhilghit the owners.
Buona giornata
Giovanni

w d's picture

Yes, I re-implemented rectangle selection according to the SelectRectangle function of AIS_InteractiveContext, and commented the unhighlightOwners function inside, so that it didn't crash. It seems that there is something wrong with the unhighlightOwners interface of AIS.
but it was the same as what you encountered, so that you couldn't highlight the selected sub-shape.

// myContext->unhighlightOwners (anOwnersToUnhighlight);
// myContext->highlightOwners (anOwnersToHighlight, Handle(Prs3d_Drawer)());