Salome HOME
c9ca61547e4862497bd9964a9d4c205da07123d1
[modules/hydro.git] / src / HYDROCurveCreator / CurveCreator_Utils.h
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 #ifndef CURVECREATOR_UTILS_H
21 #define CURVECREATOR_UTILS_H
22
23 #include "CurveCreator_Macro.hxx"
24
25 #include <AIS_InteractiveContext.hxx>
26 #include <V3d_View.hxx>
27 #include <gp_Pnt.hxx>
28 #include <Geom_Curve.hxx>
29
30 class CurveCreator_Utils
31 {
32 public:
33
34     /*!
35    * \brief Returns the point clicked in 3D view.
36    *
37    * \param x The X coordinate in the view.
38    * \param y The Y coordinate in the view.
39    * \param theView View where the given point takes place.
40    * \retval gp_Pnt Returns the point clicked in 3D view
41    */
42   CURVECREATOR_EXPORT static void ConvertPointToClick( const gp_Pnt& thePoint,
43                                                        Handle(V3d_View) theView,
44                                                        int& x, int& y );
45
46   /*!
47    * \brief Returns the point clicked in 3D view.
48    *
49    * \param x The X coordinate in the view.
50    * \param y The Y coordinate in the view.
51    * \param theView View where the given point takes place.
52    * \retval gp_Pnt Returns the point clicked in 3D view
53    */
54   CURVECREATOR_EXPORT static gp_Pnt ConvertClickToPoint( int x, int y,
55                                                        Handle(V3d_View) theView );
56
57   /*!
58    * \brief Sets the local point context for the 3D viewer.
59    * \param theOpen The flag to open or close the local context.
60    */
61   CURVECREATOR_EXPORT static void setLocalPointContext(
62                                         Handle(AIS_InteractiveContext) theContext,
63                                         const bool theOpen );
64
65   /**
66    * Find the neighbour points by the clicked coordinates
67    * \param theContext the viewer context.
68    * \param theContext the V3D view.
69    * \param theX the X coordinate in the view.
70    * \param theY the Y coordinate in the view.
71    * \param thePoint the output point to be append to the model curve
72    * \param thePoint1 the output point to bound the line where a new point should be inserted
73    * \param thePoint2 the output point to bound the line where a new point should be inserted
74    */
75   CURVECREATOR_EXPORT static bool getNeighbourPoints(
76                                         Handle(AIS_InteractiveContext) theContext,
77                                         Handle(V3d_View) theView,
78                                         const int theX, const int theY,
79                                         gp_Pnt& thePoint, gp_Pnt& thePoint1,
80                                         gp_Pnt& thePoint2 );
81   /**
82    * Checks whether the point belongs to the OCC object
83    * \param theObject a line or shape with a bspline inside
84    * \param theX the X coordinate in the view.
85    * \param theY the Y coordinate in the view.
86    * \param thePoint the output point to be append to the model curve
87    * \param thePoint1 the output point to bound the line where a new point should be inserted
88    * \param thePoint2 the output point to bound the line where a new point should be inserted
89    */
90   CURVECREATOR_EXPORT static bool pointOnObject( Handle(V3d_View) theView,
91                                                  Handle(AIS_InteractiveObject) theObject,
92                                                  const int theX, const int theY,
93                                                  gp_Pnt& thePoint, gp_Pnt& thePoint1,
94                                                  gp_Pnt& thePoint2 );
95
96   /*
97    * Returns whether the clicked point belong to the curve or has a very near projection
98    * \param theX the X coordinate of a point clicked in the OCC viewer
99    * \param theY the Y coordinate of a point clicked in the OCC viewer
100    * \param theCurve a geometry curve
101    * \param theOutPoint a found projected point on the curve
102   */
103   CURVECREATOR_EXPORT static bool hasProjectPointOnCurve(
104                                                  Handle(V3d_View) theView,
105                                                  const int theX, const int theY,
106                                                  const Handle(Geom_Curve)& theCurve,
107                                                  Standard_Real& theParameter );
108
109 };
110
111 #endif // CURVECREATOR_UTILS_H