For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings


Need to speed up your development?
Have a look at our:

Samples & Tools


Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

Convert 3d point into screen coordinate

Aurélien Schmit's picture


I am using OCCT 7.1 and Qt5.6.

I would like to display a Widget at a specific coordinate (2d). I use a QtWidget that a i move with 2d coordinate.

The position of the widget is computed from the position of an AIS_InteractiveObject displayed in the view. So i have to convert the 3d position of the interactive object into 2d screen coordinate. It's like making a projection of the 3d object from world coordinate to screen coordinate.

I found in occ sources this code 

gp_Pnt point3d;

Handle(V3d_View) myV3dView =  ...;
double Xv,Yv;
Standard_Integer p2dX p2dY;
myV3dView->Convert(Xv,Yv, p2dX,p2dY);

I think this code convert a 3d world coordinate into screen coordinate. I search on the internet and this solution seems to be ok. But my result is not ok.

Asume that the AIS_InteractiveObject is the representation of a point.

If the AIS_InteractiveObject 3d position is visible in the view, i think i can get the projected 2d screen coordinate of this position.

The 2d point must be :

0 < pnt2dX < viewWidth

0 < pnt2dY < viewHeigth​​

I dont get good result. For the same 3d position, if i change the zoomFactor (myView->SetZoom(...) ), i dont get the same 2d position.

What am i doing wrong ? Can you help me ?


Anton Poletaev's picture

Hello Aurélien,

Glad to see you on the forum.

The method with these parameters should apply to a 3d point visible from the view:
void V3d_View::Convert (const Standard_Real X, const Standard_Real Y, const Standard_Real Z, Standard_Integer& Xp, Standard_Integer& Yp);
It projects the 3d point from the world reference to the NDC space, adds bias and window scale to it. The method ends up with pixel coordinate of a point, likely you'll have to check whether the highest value of y is at the top or at the bottom of the window and swap it.

Contact us

Attention: DO NOT use this form for all kind of request for the removal of your personal data. Please follow this link for such cases.