Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[modules/shaper.git] / src / PartSet / PartSet_Tools.h
1 // File:        PartSet_Tools.h
2 // Created:     28 Apr 2014
3 // Author:      Natalia ERMOLAEVA
4
5 #ifndef PartSet_Tools_H
6 #define PartSet_Tools_H
7
8 #include "PartSet.h"
9
10 #include <gp_Pnt.hxx>
11
12 #include <QPoint>
13
14 #include <boost/shared_ptr.hpp>
15
16 #include <list>
17
18 class Handle_V3d_View;
19 class ModelAPI_Feature;
20 class XGUI_ViewerPrs;
21
22 /*!
23  \class PartSet_Tools
24  * \brief The operation for the sketch feature creation
25 */
26 class PARTSET_EXPORT PartSet_Tools
27 {
28 public:
29   /// Converts the 2D screen point to the 3D point on the view according to the point of view
30   /// \param thePoint a screen point
31   /// \param theView a 3D view
32   static gp_Pnt ConvertClickToPoint(QPoint thePoint, Handle_V3d_View theView);
33
34   /// \brief Converts the 3D point to the projected coodinates on the sketch plane.
35   /// \param thePoint the 3D point in the viewer
36   /// \param theSketch the sketch feature
37   /// \param theX the X coordinate
38   /// \param theY the Y coordinate
39   static void ConvertTo2D(const gp_Pnt& thePoint, boost::shared_ptr<ModelAPI_Feature> theSketch,
40                           Handle(V3d_View) theView, double& theX, double& theY);
41
42   /// Returns the point of intersection of the two lines, the first is (v0, v1), the second is (v2, v3),
43   /// where vi - {xi,yi}. If the v0 is on the second line, the result is a projection of the v1 to this line
44   /// \param theX0 the horizontal coordinate of 0 point
45   /// \param theY0 the vertical coordinate of 0 point
46   /// \param theX1 the horizontal coordinate of 1 point
47   /// \param theY1 the vertical coordinate of 1 point
48   /// \param theX2 the horizontal coordinate of 2 point
49   /// \param theY2 the vertical coordinate of 2 point
50   /// \param theX3 the horizontal coordinate of 3 point
51   /// \param theY3 the vertical coordinate of 3 point
52   /// \param theX the output horizontal coordinate of the intersection point
53   /// \param theY the outpup vertical coordinate of the intersection point
54   static void IntersectLines(double theX0, double theY0, double theX1, double theY1,
55                              double theX2, double theY2, double theX3, double theY3,
56                              double& theX, double& theY);
57
58   /// Returns the coordinates of projection of the point to the line
59   /// \param thePointX the projected point horizontal coordinate
60   /// \param thePointY the projected point vertictal coordinate
61   /// \param theX1 the horizontal coordinate of the first line point
62   /// \param theY1 the vertical coordinate of the first line point
63   /// \param theX2 the horizontal coordinate of the second line point
64   /// \param theY2 the vertical coordinate of the second line point
65   static void ProjectPointOnLine(double theX1, double theY1, double theX2, double theY2,
66                                  double thePointX, double thePointY, double& theX, double& theY);
67
68   /// Returns a feature that is under the mouse point
69   /// \param thePoint a screen point
70   /// \param theView a 3D view
71   /// \param theSketch the sketch feature
72   /// \param theFeatures the list of selected presentations
73   static boost::shared_ptr<ModelAPI_Feature> NearestFeature(QPoint thePoint, Handle_V3d_View theView,
74                                                      boost::shared_ptr<ModelAPI_Feature> theSketch,
75                                                      const std::list<XGUI_ViewerPrs>& theFeatures);
76 private:
77   /// Return the distance between the feature and the point
78   /// \param theFeature feature object
79   /// \param theX the horizontal coordinate of the point
80   /// \param theX the vertical coordinate of the point
81   static double DistanceToPoint(boost::shared_ptr<ModelAPI_Feature> theFeature,
82                                 double theX, double theY);
83 };
84
85 #endif