1 // Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef CURVECREATOR_UTILS_H
21 #define CURVECREATOR_UTILS_H
23 #include "CurveCreator_Macro.hxx"
25 #include <AIS_InteractiveContext.hxx>
26 #include <V3d_View.hxx>
28 #include <Geom_Curve.hxx>
29 #include <TopoDS_Shape.hxx>
33 class CurveCreator_ICurve;
35 class CurveCreator_Utils
40 * \brief Returns the point clicked in 3D view.
42 * \param x The X coordinate in the view.
43 * \param y The Y coordinate in the view.
44 * \param theView View where the given point takes place.
45 * \retval gp_Pnt Returns the point clicked in 3D view
47 CURVECREATOR_EXPORT static void ConvertPointToClick( const gp_Pnt& thePoint,
48 Handle(V3d_View) theView,
52 * \brief Returns the point clicked in 3D view.
54 * \param x The X coordinate in the view.
55 * \param y The Y coordinate in the view.
56 * \param theView View where the given point takes place.
57 * \retval gp_Pnt Returns the point clicked in 3D view
59 CURVECREATOR_EXPORT static gp_Pnt ConvertClickToPoint( int x, int y,
60 Handle(V3d_View) theView );
63 * Generates shape on the curve
64 * \param theCurve a curve object, that contains data
65 * \param theISection a curve section index
66 * \param theShape a generated shape
68 CURVECREATOR_EXPORT static void constructShape( const CurveCreator_ICurve* theCurve,
69 const int theISection,
70 TopoDS_Shape& theShape );
73 * Find selected points in the context
74 * \param theContext the viewer context
76 CURVECREATOR_EXPORT static std::list<float> getSelectedPoints(
77 Handle(AIS_InteractiveContext) theContext );
80 * \brief Sets the local point context for the 3D viewer.
81 * \param theOpen The flag to open or close the local context.
83 CURVECREATOR_EXPORT static void setLocalPointContext(
84 Handle(AIS_InteractiveContext) theContext,
88 * Find the neighbour points by the clicked coordinates
89 * \param theContext the viewer context.
90 * \param theContext the V3D view.
91 * \param theX the X coordinate in the view.
92 * \param theY the Y coordinate in the view.
93 * \param thePoint the output point to be append to the model curve
94 * \param thePoint1 the output point to bound the line where a new point should be inserted
95 * \param thePoint2 the output point to bound the line where a new point should be inserted
97 CURVECREATOR_EXPORT static bool getNeighbourPoints(
98 Handle(AIS_InteractiveContext) theContext,
99 Handle(V3d_View) theView,
100 const int theX, const int theY,
101 gp_Pnt& thePoint, gp_Pnt& thePoint1,
106 * Checks whether the point belongs to the OCC object
107 * \param theObject a line or shape with a bspline inside
108 * \param theX the X coordinate in the view.
109 * \param theY the Y coordinate in the view.
110 * \param thePoint the output point to be append to the model curve
111 * \param thePoint1 the output point to bound the line where a new point should be inserted
112 * \param thePoint2 the output point to bound the line where a new point should be inserted
114 CURVECREATOR_EXPORT static bool pointOnObject( Handle(V3d_View) theView,
115 Handle(AIS_InteractiveObject) theObject,
116 const int theX, const int theY,
117 gp_Pnt& thePoint, gp_Pnt& thePoint1,
121 * Returns whether the clicked point belong to the curve or has a very near projection
122 * \param theX the X coordinate of a point clicked in the OCC viewer
123 * \param theY the Y coordinate of a point clicked in the OCC viewer
124 * \param theCurve a geometry curve
125 * \param theOutPoint a found projected point on the curve
127 CURVECREATOR_EXPORT static bool hasProjectPointOnCurve(
128 Handle(V3d_View) theView,
129 const int theX, const int theY,
130 const Handle(Geom_Curve)& theCurve,
131 Standard_Real& theParameter );
135 #endif // CURVECREATOR_UTILS_H