draw an ortho text

hi
my ocaf app contain four view front,top,side and an axo view
i want to draw a text caption in each view telling witch view iam in
so there is my code:
void CMfcCADView::OnDraw(CDC* pDC)
{
CRect aRect;
GetClientRect(&aRect);
if(myWidth != aRect.Width() || myHeight != aRect.Height())
{
myWidth = aRect.Width();
myHeight = aRect.Height();
::PostMessage ( GetSafeHwnd () , WM_SIZE , SW_SHOW , myWidth + myHeight*65536 );
}

myLayer=new Visual3d_Layer(myView->Viewer()->Viewer(),
Aspect_TOL_OVERLAY, Standard_False);

myLayer->SetViewport(myWidth,myHeight);
myLayer->SetOrtho(0,myWidth,myWidth,0,(Aspect_TypeOfConstraint)-1);

myLayer->Clear();
myLayer->Begin();

myLayer->SetTextAttributes(Graphic3d_NOF_ASCII_SIMPLEX,
Aspect_TODT_NORMAL,Quantity_Color(Quantity_NOC_WHITE));
myLayer->DrawText(aText,(float)rect.left + 10.,(float)rect.top + 10.,20.);

myLayer->End();
myView->Redraw();

}

but when i resize a view the text change its position

please can anyone tell me how fix this
or suggest me another methode

thank an advance

Paul Jimenez's picture

The problem is that the parameters you give to SetOrtho are not kept the way you pass them. Basically, the parameters are re-calculated to guarantee a 1:1 pixel aspect ratio everytime.

Check this thread for more information: http://www.opencascade.org/org/forum/thread_10090/

bens1404's picture

thanks in your replay
my second problem is
the text caption dont changed when switch between view type
i do it like that :
void CMfcCADView::OnBUTTONFront()
{
myView->SetProj(V3d_Yneg);
aText="Front";
}
but the Visual3d_Layer cant update the text captions

any help please

Paul Jimenez's picture

Are you sure OnDraw is being called right after modifying aText? I use layers to display arrows, and they are correctly updated once I change the view. You may want to force the re-calculation of the layer right after setting the projection.