Forum archiveIssue archiveVisualization and 3D Viewer

Archived discussion

AIS_InteractiveContext returns zero Selected Shape when there is clearly a AISObject selected?

Visualization and 3D ViewerFri, 04/22/2022 - 06:271 reply

Browse this forum
QuestionAuthor

So I have the following code. I just override the HandleMouseClick, the virtual function of SelectMgr_EntityOwner, to make my own.

Standard_Boolean CustomizedOwner::HandleMouseClick(const Graphic3d_Vec2i & thePoint, Aspect_VKeyMouse theButton, Aspect_VKeyFlags theModifiers, bool theIsDoubleClick)
{

Handle(SelectMgr_SelectableObject) Obj = this->Selectable();
Handle(AIS_InteractiveObject) AISObj = Handle(AIS_InteractiveObject)::DownCast(Obj);

AIS_InteractiveContext* ctx = AISObj->InteractiveContext();

wprintf(L"selected elements: %d\n", ctx->NbSelected());
wprintf(L"are there more than own element: %s\n", ctx->MoreSelected()?L"true":L"false");

return false;
}

The PROBLEM is that AIS_InteractiveContext retrieved gives zero selected objects/elements. That is the print outs gives

"selected elements: 0"
"are there more than own element: false"

Discussion

1 archived reply

Posts are displayed in their archived order.

01Commenter-1

HandleMouseClick() is called before selection happens, moreover it's return value is used to decide if this object should be selected or not. If you want to track selection changes, you may override method AIS_ViewController::OnSelectionChanged().