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"
22 #include <GEOMUtils.hxx>
25 #include <ProjLib.hxx>
28 //=======================================================================
29 // function : ConvertClickToPoint()
30 // purpose : Returns the point clicked in 3D view
31 //=======================================================================
32 void CurveCreator_Utils::ConvertPointToClick( const gp_Pnt& thePoint,
33 Handle(V3d_View) theView,
36 theView->Convert(thePoint.X(), thePoint.Y(), thePoint.Z(), x, y );
40 //=======================================================================
41 // function : ConvertClickToPoint()
42 // purpose : Returns the point clicked in 3D view
43 //=======================================================================
44 gp_Pnt CurveCreator_Utils::ConvertClickToPoint( int x, int y, Handle(V3d_View) aView )
46 return GEOMUtils::ConvertClickToPoint( x, y, aView );
48 V3d_Coordinate XEye, YEye, ZEye, XAt, YAt, ZAt;
49 aView->Eye( XEye, YEye, ZEye );
51 aView->At( XAt, YAt, ZAt );
52 gp_Pnt EyePoint( XEye, YEye, ZEye );
53 gp_Pnt AtPoint( XAt, YAt, ZAt );
55 gp_Vec EyeVector( EyePoint, AtPoint );
56 gp_Dir EyeDir( EyeVector );
58 gp_Pln PlaneOfTheView = gp_Pln( AtPoint, EyeDir );
59 Standard_Real X, Y, Z;
60 aView->Convert( x, y, X, Y, Z );
61 gp_Pnt ConvertedPoint( X, Y, Z );
63 gp_Pnt2d ConvertedPointOnPlane = ProjLib::Project( PlaneOfTheView, ConvertedPoint );
64 gp_Pnt ResultPoint = ElSLib::Value( ConvertedPointOnPlane.X(), ConvertedPointOnPlane.Y(), PlaneOfTheView );