1 // Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "CurveCreator_Utils.h"
23 #include <ProjLib.hxx>
27 //=======================================================================
28 // function : ConvertClickToPoint()
29 // purpose : Returns the point clicked in 3D view
30 //=======================================================================
31 gp_Pnt CurveCreator_Utils::ConvertClickToPoint( int x, int y, Handle(V3d_View) aView )
33 V3d_Coordinate XEye, YEye, ZEye, XAt, YAt, ZAt;
34 aView->Eye( XEye, YEye, ZEye );
36 aView->At( XAt, YAt, ZAt );
37 gp_Pnt EyePoint( XEye, YEye, ZEye );
38 gp_Pnt AtPoint( XAt, YAt, ZAt );
40 gp_Vec EyeVector( EyePoint, AtPoint );
41 gp_Dir EyeDir( EyeVector );
43 gp_Pln PlaneOfTheView = gp_Pln( AtPoint, EyeDir );
44 Standard_Real X, Y, Z;
45 aView->Convert( x, y, X, Y, Z );
46 gp_Pnt ConvertedPoint( X, Y, Z );
48 gp_Pnt2d ConvertedPointOnPlane = ProjLib::Project( PlaneOfTheView, ConvertedPoint );
49 gp_Pnt ResultPoint = ElSLib::Value( ConvertedPointOnPlane.X(), ConvertedPointOnPlane.Y(), PlaneOfTheView );