Hi
@karim
In most cases, we hold some map of AIS_InteractiveObject to the model object (e.g., it might be the entry of OCAF object, or pointer to object if the architecture of the application data model has such one). When the selection happens, we get the selected interactive object and obtain the OCAF object from this map.
In addition, OCAF has a way to work with AIS_InteractiveObject itself through TPrsStd_AISPresentation object in connection to own Interactive Context. It might be useful to have a look at it. However, it is not very generic way and more for save/restore visual parameters of the presentation in OCAF document.
I prefer the first option as it is more straight forward. However, the process is a bit vague for now.
Iterating over the labels, I find the named shape, and create a AIS_Shape from it, then add it to the context like this:
for (TDF_ChildIterator it (root, Standard_True); it.More(); it.Next())
{
auto label = it.Value(); // get the label.
Handle(TNaming_NamedShape) namedshape;
if(label.FindAttribute(TNaming_NamedShape::GetID(), namedshape))
{
TopoDS_Shape shape = TNaming_Tool::GetShape(namedshape);
auto ais_shape = new AIS_Shape(shape);
// std::cout << label << ": adding shape to context" << std::endl;
child->getContext()->Display(ais_shape, Standard_False);
}
}
when I iterate over the selected objects with the below code:
for (myContext->InitSelected(); myContext->MoreSelected(); myContext->NextSelected())
{
Handle(AIS_InteractiveObject) selected = myContext->SelectedInteractive();
auto owner = selected->GetOwner();
Handle(AIS_Shape) aShape=Handle(AIS_Shape):
ownCast(selected);
TopoDS_Shape topShape = aShape->Shape();
}
I can get the owner of the selection. I dont know which pointers are the same in the above blocks of code ? In other words what pointers should go into the map<HANDLE<??> , LABEL> ?