Archived discussion

Selection Problem of MyAisObject in OCC7.7 turtorial

VisualizationMon, 11/28/2022 - 15:230 replies

Browse this forum
QuestionAuthor

The selection and pick of custom AIS objects in OOC is something I haven't quite figured out.

There is finally a section in occ7.7.0 that addresses this issue.(https://dev.opencascade.org/doc/overview/html/tutorials__ais_object.html)

I tried the example in the draw toolkit and it worked as described in the tutorial.

But if MyAisObject and MyAisOwner were stripped out and put into MFC's SDI program, it was not so lucky.

In this MFC program, I inherited the View from both CView and AIS_ViewController, and added the handlers to the mouse events as in OCC_BaseView. Then in a command handler, I added the following code as the tutorial example shows:

void CMyOccView::OnMyAisObject()
{
    Handle(AIS_InteractiveContext) theCtx = GetDocument()->GetContext();
    Handle(MyAisObject) aPrs = new MyAisObject();
    aPrs->SetAnimation (this->ObjectsAnimation());
    theCtx->Display (aPrs, MyAisObject::MyDispMode_Main, 0, false);
    myView->FitAll();
}

It didn't work.

So, after this code, I added:

...
theCtx->Deactivate();
theCtx->Activate(AIS_Shape::SelectionMode(TopoAbs_FACE));

And in the View's OnMouseMove function added:

theCtx->MoveTo(thePoint.x, thePoint.y, myView, Standard_False);
theCtx->SelectDetected();

Then, An error occurred accessing illegal memory.

Are there any mistakes in what I did above?

Thanks!

Discussion

No archived replies

Posts are displayed in their archived order.