Text detection in 3d view

We are trying to detect and select text using Prs3d_Text::Draw() in a 3d view, but it seems there is no way to detect the text presentation.
Here is the code we are using.

////--begin--////
TCollection_ExtendedString aTCoText("text to detect");
Handle(Prs3d_Presentation) aPresentation =
new Prs3d_Presentation(myContext->CurrentViewer()->Viewer(),Standard_True);
Handle(Prs3d_TextAspect) aTextAspect= new Prs3d_TextAspect();
//SetHeight doest NOT appear to work... see also http://www.opencascade.org/org/forum/thread_10845/
aTextAspect->SetHeight(20); aTextAspect->SetColor(Quantity_Color(1,0,0, Quantity_TOC_RGB));
gp_Pnt p(xx, yy, zz);
Prs3d_Text::Draw(aPresentation,aTextAspect,aTCoText, p);
aPresentation->SetPickable(); // aPresentation->Display();
////-- end --////

We have also tried to append the text presentation to the presentation of a line (AIS_Shape containg a TopoDS_Edge). In this case both the line and the text are highlighted when the line is detected, but not when the mouse is near the text (i.e., when the text should be detected...).
////--begin--////
TCollection_ExtendedString aTCoText("edge");
const Handle(Prs3d_Presentation)& aPresentation =
myContext->MainPrsMgr()->CastPresentation(aisShape,0)->Presentation();
Handle(Prs3d_TextAspect) aTextAspect= new Prs3d_TextAspect();
// XXX SetHeight has non effect.... see also http://www.opencascade.org/org/forum/thread_10845/
aTextAspect->SetHeight(20);
aTextAspect->SetColor(Quantity_Color(1,0,0, Quantity_TOC_RGB));
Prs3d_Text::Draw(aPresentation,aTextAspect,aTCoText, start);
////-- end --////

In effect, the same behavior happens with text in dimensions (e.g., AIS_RadiusDimension).
////--begin--////
TCollection_ExtendedString s("r=");
TCollection_ExtendedString s1(r); s+=s1;
Handle(AIS_RadiusDimension) rd = new AIS_RadiusDimension(myShape, r, s);
myContext->Display(rd);
////-- end --////

Is it an OCC (6.3.0) bug? Is the implemetation of, say, AIS_InteractiveText, the only workaround? (As in topic http://www.opencascade.org/org/forum/thread_8480/)

Thanks.

Paul Jimenez's picture

From what I see all you are doing is drawing text. Highlighting is also based on what is drawn. Being able to select it is a different story. I guess your best bet is to write your own class derived from AIS_InteractiveObject and add your own ComputeSelection method that will make text selectable.