Open CASCADE, the 3D modelling kernel
3D modeling & numerical simulation

Open CASCADEShowroomGet it!Developer CornerSupportAbout us
Technical overview
Areas of use
Advantages
FAQ
Screenshots
Shape factory
Shape gallery
Demonstrations
What's new
System requirements
Download Center
Public license
Documentation
Getting started
Forum
Open Source community
Training and e-learning
A la Carte Support
Value-added software
CD-ROM
Company Profile
Contacts and Locations
Customers
News
Home / Developer Corner / Forum / Text detection in 3d view

Forum

Text detection in 3d view
ArchIntelligence2009/07/01 17:30
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(); //<<<active by default, but does NOT seem to work
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 Jimenez2009/07/02 07:30
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.
 
 
Latest news
  • Open CASCADE Technology: Ten Years in Open Source
  • Principia - AvPro Success Story
  • AREVA NP - Charm Success Story

  • © Open CASCADE 2000 - 2010  |  Search  |  Contacts