]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_Tools.cpp
Salome HOME
refs #30 - Sketch base GUI: create, draw lines
[modules/shaper.git] / src / PartSet / PartSet_Tools.cpp
1 // File:        PartSet_Tools.h
2 // Created:     28 Apr 2014
3 // Author:      Natalia ERMOLAEVA
4
5 #include <PartSet_Tools.h>
6
7 #include <V3d_View.hxx>
8 #include <gp_Pln.hxx>
9 #include <ProjLib.hxx>
10 #include <ElSLib.hxx>
11
12 #ifdef _DEBUG
13 #include <QDebug>
14 #endif
15
16 gp_Pnt PartSet_Tools::ConvertClickToPoint(QPoint thePoint, Handle(V3d_View) theView)
17 {
18   V3d_Coordinate XEye, YEye, ZEye, XAt, YAt, ZAt;
19   theView->Eye( XEye, YEye, ZEye );
20
21   theView->At( XAt, YAt, ZAt );
22   gp_Pnt EyePoint( XEye, YEye, ZEye );
23   gp_Pnt AtPoint( XAt, YAt, ZAt );
24
25   gp_Vec EyeVector( EyePoint, AtPoint );
26   gp_Dir EyeDir( EyeVector );
27
28   gp_Pln PlaneOfTheView = gp_Pln( AtPoint, EyeDir );
29   Standard_Real X, Y, Z;
30   theView->Convert( thePoint.x(), thePoint.y(), X, Y, Z );
31   gp_Pnt ConvertedPoint( X, Y, Z );
32
33   gp_Pnt2d ConvertedPointOnPlane = ProjLib::Project( PlaneOfTheView, ConvertedPoint );
34   gp_Pnt ResultPoint = ElSLib::Value( ConvertedPointOnPlane.X(), ConvertedPointOnPlane.Y(), PlaneOfTheView );
35   return ResultPoint;
36 }