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 <AIS_InteractiveObject.hxx> // TODO: remove
27 #include <V3d_View.hxx>
29 #include <Geom_Curve.hxx>
30 #include <TopoDS_Shape.hxx>
33 #include <vector> // TODO: remove
35 class CurveCreator_ICurve;
37 class CurveCreator_Utils
42 * \brief Returns the point clicked in 3D view.
44 * \param x The X coordinate in the view.
45 * \param y The Y coordinate in the view.
46 * \param theView View where the given point takes place.
47 * \retval gp_Pnt Returns the point clicked in 3D view
49 CURVECREATOR_EXPORT static void ConvertPointToClick( const gp_Pnt& thePoint,
50 Handle(V3d_View) theView,
54 * \brief Returns the point clicked in 3D view.
56 * \param x The X coordinate in the view.
57 * \param y The Y coordinate in the view.
58 * \param theView View where the given point takes place.
59 * \retval gp_Pnt Returns the point clicked in 3D view
61 CURVECREATOR_EXPORT static gp_Pnt ConvertClickToPoint( int x, int y,
62 Handle(V3d_View) theView );
65 * Generates shape on the curve
66 * \param theCurve a curve object, that contains data
67 * \param theISection a curve section index
68 * \param theShape a generated shape
70 CURVECREATOR_EXPORT static void constructShape( const CurveCreator_ICurve* theCurve,
71 const int theISection,
72 TopoDS_Shape& theShape,
73 std::vector<Handle_AIS_InteractiveObject>& theAdditional );
76 * Find selected points in the context
77 * \param theContext the viewer context
79 CURVECREATOR_EXPORT static std::list<float> getSelectedPoints(
80 Handle(AIS_InteractiveContext) theContext );
83 * \brief Sets the local point context for the 3D viewer.
84 * \param theOpen The flag to open or close the local context.
86 CURVECREATOR_EXPORT static void setLocalPointContext(
87 Handle(AIS_InteractiveContext) theContext,
91 * Find the neighbour points by the clicked coordinates
92 * \param theContext the viewer context.
93 * \param theContext the V3D view.
94 * \param theX the X coordinate in the view.
95 * \param theY the Y coordinate in the view.
96 * \param thePoint the output point to be append to the model curve
97 * \param thePoint1 the output point to bound the line where a new point should be inserted
98 * \param thePoint2 the output point to bound the line where a new point should be inserted
100 CURVECREATOR_EXPORT static bool getNeighbourPoints(
101 Handle(AIS_InteractiveContext) theContext,
102 Handle(V3d_View) theView,
103 const int theX, const int theY,
104 gp_Pnt& thePoint, gp_Pnt& thePoint1,
109 * Checks whether the point belongs to the OCC object
110 * \param theObject a line or shape with a bspline inside
111 * \param theX the X coordinate in the view.
112 * \param theY the Y coordinate in the view.
113 * \param thePoint the output point to be append to the model curve
114 * \param thePoint1 the output point to bound the line where a new point should be inserted
115 * \param thePoint2 the output point to bound the line where a new point should be inserted
117 CURVECREATOR_EXPORT static bool pointOnObject( Handle(V3d_View) theView,
118 Handle(AIS_InteractiveObject) theObject,
119 const int theX, const int theY,
120 gp_Pnt& thePoint, gp_Pnt& thePoint1,
124 * Returns whether the clicked point belong to the curve or has a very near projection
125 * \param theX the X coordinate of a point clicked in the OCC viewer
126 * \param theY the Y coordinate of a point clicked in the OCC viewer
127 * \param theCurve a geometry curve
128 * \param theOutPoint a found projected point on the curve
130 CURVECREATOR_EXPORT static bool hasProjectPointOnCurve(
131 Handle(V3d_View) theView,
132 const int theX, const int theY,
133 const Handle(Geom_Curve)& theCurve,
134 Standard_Real& theParameter );
138 #endif // CURVECREATOR_UTILS_H