Hi, there are several ways of doing so.
Have a look at the documentation:
$CASROOT/OCCTDocumentation6.3.0/Visualization/html/classV3d__View.html
So, practically speaking:
pdb> view = display.GetView().GetObject()
ipdb> view.Convert(1,1)
Out[0]: (-49.84375, 37.34375)
ipdb>
What works well when debugging / working on interactive apps, is to
use ipython -wthread.
This way, once a program is in the gui event loop, it still is
responsive.
Really a huge help in general.
Curious to hear what you're working on.
For the moment there aren't that many examples / programs in pythonOCC
that use drawing / manipulators, so it be cool to see what you come up
with.
Welcome to pythonOCC Vladimir!
Cheers,
-jelle
Standard_EXPORT Quantity_Length Convert (const Standard_Integer Vp)
const
Converts the PIXEL value
to a value in the projection plane.
.
Standard_EXPORT void Convert (const Standard_Integer Xp, const
Standard_Integer Yp, V3d_Coordinate &Xv, V3d_Coordinate &Yv) const
Converts the point PIXEL into a point projected
in the reference frame of the projection plane.
.
Standard_EXPORT Standard_Integer Convert (const Quantity_Length Vv)
const
Converts tha value of the projection plane into
a PIXEL value.
.
Standard_EXPORT void Convert (const V3d_Coordinate Xv, const
V3d_Coordinate Yv, Standard_Integer &Xp, Standard_Integer &Yp) const
Converts the point defined in the reference frame
of the projection plane into a point PIXEL.
.
Standard_EXPORT void Convert (const Standard_Integer Xp, const
Standard_Integer Yp, V3d_Coordinate &X, V3d_Coordinate &Y,
V3d_Coordinate &Z) const
Converts the projected point into a point
in the reference frame of the view corresponding
to the intersection with the projection plane
of the eye/view point vector.
.
Standard_EXPORT void ConvertWithProj (const Standard_Integer Xp,
const Standard_Integer Yp, V3d_Coordinate &X, V3d_Coordinate
&Y,V3d_Coordinate &Z, Quantity_Parameter &Vx, Quantity_Parameter &Vy,
Quantity_Parameter &Vz) const
Converts the projected point into a point
in the reference frame of the view corresponding
to the intersection with the projection plane
of the eye/view point vector and returns the
projection ray for further computations.
.
Standard_EXPORT void ConvertToGrid (const Standard_Integer Xp, const
Standard_Integer Yp, V3d_Coordinate &Xg, V3d_Coordinate
&Yg,V3d_Coordinate &Zg) const
Converts the projected point into the nearest grid point
in the reference frame of the view corresponding
to the intersection with the projection plane
of the eye/view point vector and display the grid marker.
Warning: When the grid is not active the result is identical
to the above Convert() method.
How to use :
1) Enable the grid echo display
myViewer->SetGridEcho(Standard_True);
2) When application receive a move event :
2.1) Check if any object is detected
if( myInteractiveContext->MoveTo(x,y) == AIS_SOD_Nothing ) {
2.2) Check if the grid is active
if( myViewer->Grid()->IsActive() ) {
2.3) Display the grid echo and gets the grid point
myView->ConvertToGrid(x,y,X,Y,Z);
2.4) Else this is the standard case
} else myView->Convert(x,y,X,Y,Z);
.
Standard_EXPORT void ConvertToGrid (const V3d_Coordinate X, const
V3d_Coordinate Y, const V3d_Coordinate Z, V3d_Coordinate
&Xg,V3d_Coordinate &Yg, V3d_Coordinate &Zg) const
Converts the point into the nearest grid point
and display the grid marker.
.
Standard_EXPORT void Convert (const V3d_Coordinate X, const
V3d_Coordinate Y, const V3d_Coordinate Z, Standard_Integer &Xp,
Standard_Integer &Yp) const
Projects the point defined in the reference frame of
the view into the projected point in the associated window.
.
On Jun 14, 2009, at 3:33 PM, Владимир Суханов wrote:
Hi All!
I need convert display coordinates to 3D.
In wxDisplay.py
def OnLeftDown(self, evt):
if self.DinaLine:
pt = evt.GetPosition()
self.startPt = pt
return
self.dragStartPos = evt.GetPosition()
self._3dDisplay.StartRotation(self.dragStartPos.x,self.dragStartPos.y)
if self._3dDisplay.Select(self.dragStartPos.x,
self.dragStartPos.y):
selected_shape = self._3dDisplay.GetSelectedShape()
def OnLeftUp(self, evt):
if self.DinaLine:
self.DinaLine = False
pt1 = self.startPt
pt2 = evt.GetPosition()
# drow line from self.startPt to pt
X1, Y1, Z1 = self.?????.Convert(pt1.x, pt1.y)
X2, Y2, Z2 = self.?????.Convert(pt2.x, pt2.y)
WhiteEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(X1, Y1, Z1),
gp_Pnt(X2, Y2, Z2))
self._3dDisplay.DisplayColoredShape(WhiteEdge.Edge(),'WHITE')
return
--
С уважением, Суханов Владимир
_______________________________________________
Pythonocc-users mailing list
Pythonocc-users@gna.org
https://mail.gna.org/listinfo/pythonocc-users
_______________________________________________
Pythonocc-users mailing list
Pythonocc-users@gna.org
https://mail.gna.org/listinfo/pythonocc-users