Salome HOME
Constraint: Check AIS dimension possibilities. Line edit appears by the text selectio...
[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   /// \brief Converts the 2D projected coodinates on the sketch plane to the 3D point.
43   /// \param theX the X coordinate
44   /// \param theY the Y coordinate
45   /// \param theSketch the sketch feature
46   /// \param thePoint the 3D point in the viewer
47   static void ConvertTo3D(const double theX, const double theY,
48                           boost::shared_ptr<ModelAPI_Feature> theSketch,
49                           gp_Pnt& thePoint);
50
51   /// Returns the point of intersection of the two lines, the first is (v0, v1), the second is (v2, v3),
52   /// where vi - {xi,yi}. If the v0 is on the second line, the result is a projection of the v1 to this line
53   /// \param theX0 the horizontal coordinate of 0 point
54   /// \param theY0 the vertical coordinate of 0 point
55   /// \param theX1 the horizontal coordinate of 1 point
56   /// \param theY1 the vertical coordinate of 1 point
57   /// \param theX2 the horizontal coordinate of 2 point
58   /// \param theY2 the vertical coordinate of 2 point
59   /// \param theX3 the horizontal coordinate of 3 point
60   /// \param theY3 the vertical coordinate of 3 point
61   /// \param theX the output horizontal coordinate of the intersection point
62   /// \param theY the outpup vertical coordinate of the intersection point
63   static void IntersectLines(double theX0, double theY0, double theX1, double theY1,
64                              double theX2, double theY2, double theX3, double theY3,
65                              double& theX, double& theY);
66
67   /// Returns the coordinates of projection of the point to the line
68   /// \param thePointX the projected point horizontal coordinate
69   /// \param thePointY the projected point vertictal coordinate
70   /// \param theX1 the horizontal coordinate of the first line point
71   /// \param theY1 the vertical coordinate of the first line point
72   /// \param theX2 the horizontal coordinate of the second line point
73   /// \param theY2 the vertical coordinate of the second line point
74   static void ProjectPointOnLine(double theX1, double theY1, double theX2, double theY2,
75                                  double thePointX, double thePointY, double& theX, double& theY);
76
77   /// Returns a feature that is under the mouse point
78   /// \param thePoint a screen point
79   /// \param theView a 3D view
80   /// \param theSketch the sketch feature
81   /// \param theFeatures the list of selected presentations
82   static boost::shared_ptr<ModelAPI_Feature> NearestFeature(QPoint thePoint, Handle_V3d_View theView,
83                                                      boost::shared_ptr<ModelAPI_Feature> theSketch,
84                                                      const std::list<XGUI_ViewerPrs>& theFeatures);
85 private:
86   /// Return the distance between the feature and the point
87   /// \param theFeature feature object
88   /// \param theX the horizontal coordinate of the point
89   /// \param theX the vertical coordinate of the point
90   static double DistanceToPoint(boost::shared_ptr<ModelAPI_Feature> theFeature,
91                                 double theX, double theY);
92 };
93
94 #endif