
Tue, 10/21/2008 - 17:37
Forums:
Hi how can I put text on occ screen? i am using sample qt-occ widget and I tried using QPainter (in paintEvent) to draw text. At first its fine, it draws the text but any change on screen (any dialog opened or any shape drawn) erases the text and I couldn't find a way to draw it back. Thanks for replies
Wed, 10/22/2008 - 11:49
Hi,
Are you talking about drawing the text in the OpenGl 3D viewer ? If so, I'm not sure if Qt's QPainter can be of any help here - you need to draw *within* the OpenGl context, not *on top* of it.
You can have a look at how Open CASCADE uses fonts to display text.
A few examples:
- AIS_Trihedron that displays X,Y,Z along the axes;
- XCAFPrs_AISObject that displays names of the entities stored in OCAF Document
Good luck.
Roman
Wed, 10/22/2008 - 15:19
Thanks, now I can handle texts with Prs3d_Presentation,_TextAspect and _Text classes. But what I want to do is to write something while a shape is highlighted i.e. while cursor is over the shape. How can I do that? Thanks again
Sun, 10/26/2008 - 11:56
Handle(Graphic3d_Structure) hStruct = new Graphic3d_Structure(m_pAISContext->CurrentViewer()->Viewer());
hStruct->SetVisual(Graphic3d_TOS_ALL);
Handle(Graphic3d_Group) pGr1 = new Graphic3d_Group(hStruct);
hGr1->SetPrimitivesAspect(TA);
hGr1->Text(TextBuffer, Graphic3d_Vertex(m_RotPoint.X(), m_RotPoint.Y(), m_RotPoint.Z()), 0.07, 0, Graphic3d_TP_RIGHT, Graphic3d_HTA_CENTER,Graphic3d_VTA_HALF) ;
Visual3d_TransientManager::BeginDraw(m_pV3dView->View(), Standard_False, Standard_True);
Visual3d_TransientManager::DrawStructure(hStruct);
Visual3d_TransientManager::EndDraw();
What about this? Sorry if there are some mistakes in the code, but it can give you the idea.