Salome HOME
Fix Undo/Redo of removing of middle point.
[modules/hydro.git] / src / HYDROCurveCreator / CurveCreator_Utils.cxx
1 // Copyright (C) 2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "CurveCreator_Utils.h"
21
22 #include <GEOMUtils.hxx>
23
24 #include <gp_Pln.hxx>
25 #include <ProjLib.hxx>
26 #include <ElSLib.hxx>
27
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,
34                                               int& x, int& y )
35 {
36   theView->Convert(thePoint.X(), thePoint.Y(), thePoint.Z(), x, y );
37 }
38
39
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 )
45 {
46   return GEOMUtils::ConvertClickToPoint( x, y, aView );
47   /*
48   V3d_Coordinate XEye, YEye, ZEye, XAt, YAt, ZAt;
49   aView->Eye( XEye, YEye, ZEye );
50
51   aView->At( XAt, YAt, ZAt );
52   gp_Pnt EyePoint( XEye, YEye, ZEye );
53   gp_Pnt AtPoint( XAt, YAt, ZAt );
54
55   gp_Vec EyeVector( EyePoint, AtPoint );
56   gp_Dir EyeDir( EyeVector );
57
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 );
62
63   gp_Pnt2d ConvertedPointOnPlane = ProjLib::Project( PlaneOfTheView, ConvertedPoint );
64   gp_Pnt ResultPoint = ElSLib::Value( ConvertedPointOnPlane.X(), ConvertedPointOnPlane.Y(), PlaneOfTheView );
65   return ResultPoint;
66   */
67 }