Draw text with Visual3d_Layer test in OCC6.5.1 not work

Hi,

I'm trying draw a text with Visual3d_Layer, but
I failed in OCC 6.5 (in OCC 6.2 work)

please help me

Test code is appended OpenCASCADE6.5.1/samples/mfc/04_Viewer3d/src/Viewer3DView.cpp.
-----------------------------------------------
#include
#include
#include
#include

void CViewer3dView::OnDraw(CDC* pDC)
{
CViewer3dDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CRect aRect;
GetWindowRect(aRect);
if(myWidth != aRect.Width() || myHeight != aRect.Height()) {
myWidth = aRect.Width();
myHeight = aRect.Height();
::PostMessage ( GetSafeHwnd () , WM_SIZE , SW_SHOW , myWidth + myHeight*65536 );
}
// add test code begin
Standard_Integer w,h;
Handle(Aspect_Window) hWin = myView->Window();
hWin->Size(w,h);

// Draw text with Visual3d_Layer test in OCC6.5.1
Handle(Visual3d_Layer) layer = myView->View()->OverLayer();
if( layer.IsNull() ){
layer = new Visual3d_Layer( myView->View()->ViewManager(), Aspect_TOL_OVERLAY, true);
layer->SetOrtho(-1, 1, -1, 1);
}

layer->Clear();

layer->Begin();
// Rectangle is OK
layer->SetColor(Quantity_NOC_WHITE);
layer->DrawRectangle(0,0,-0.1,-0.1);
// Test is not draw
layer->SetTextAttributes(Graphic3d_NOF_ASCII_MONO, Aspect_TODT_NORMAL, Quantity_NOC_WHITE );
layer->DrawText("Draw Text",0,0, 16);
layer->End();
// end
myView->Redraw();
}

Forum supervisor's picture

Dear Gen,
"vcolorscale" DRAW command displays a sample color scale with text labels using the overlayer.
The corresponding snapshot made with OCCT 6.5.1 is attached to the post, and obviously the text is there.
I can recommend the topic starter to study the code of "vcolorscale" command (see ViewerTest_ViewerCommands.cxx)in order to understand how to draw the text in Visual3d_Layer properly.
Regards

Attachments: 
GENZIN's picture

Thank you

Change SetViewport & SetOrtho uses have to same as V3d_LayerMgr.cxx,
Text is shown.

#my old code was read in this forum. may be it's