Salome HOME
Minor changes.
[modules/hydro.git] / src / HYDROCurveCreator / CurveCreator_Utils.h
index b81f4cf2bb9ff3ff96fc91d32162bdc0cf7cea0e..0cf2364da527f89f0bc1dbe20e233307dd90a5be 100644 (file)
@@ -21,6 +21,7 @@
 #define CURVECREATOR_UTILS_H
 
 #include "CurveCreator_Macro.hxx"
+#include "CurveCreator_ICurve.hxx"
 
 #include <AIS_InteractiveContext.hxx>
 #include <AIS_InteractiveObject.hxx> // TODO: remove
@@ -32,7 +33,6 @@
 #include <list>
 #include <vector> // TODO: remove
 
-class CurveCreator_ICurve;
 
 class CurveCreator_Utils
 {
@@ -62,57 +62,45 @@ public:
                                                          Handle(V3d_View) theView );
 
   /**
-   * Generates shape on the curve with a fixed section index
+   * Generates shape on the curve
    * \param theCurve a curve object, that contains data
-   * \param theISection a curve section index
    * \param theShape a generated shape
    */
   CURVECREATOR_EXPORT static void constructShape( const CurveCreator_ICurve* theCurve,
-                                                  const int theISection,
-                                                  TopoDS_Shape& theShape,
-                                                  std::vector<Handle_AIS_InteractiveObject>& theAdditional );
+                                                  TopoDS_Shape& theShape );
 
   /**
-   * Generates shape on the curve
+   * Find selected points in the context
+   * \param theContext the viewer context
    * \param theCurve a curve object, that contains data
-   * \param theShape a generated shape
    */
-  CURVECREATOR_EXPORT static void constructShape( const CurveCreator_ICurve* theCurve,
-                                                  TopoDS_Shape& theShape );
+  CURVECREATOR_EXPORT static void getSelectedPoints( Handle(AIS_InteractiveContext) theContext,
+                                         const CurveCreator_ICurve* theCurve,
+                                         CurveCreator_ICurve::SectionToPointList& thePoints );
 
   /**
-   * Find selected points in the context
+   * Set selected points to the context
    * \param theContext the viewer context
+   * \param theCurve a curve object, that contains data
+   * \param thePoints the curve point indices to be selected in the context
    */
-  CURVECREATOR_EXPORT static std::list<float> getSelectedPoints(
-                                        Handle(AIS_InteractiveContext) theContext );
+  CURVECREATOR_EXPORT static void setSelectedPoints(
+                                         Handle(AIS_InteractiveContext) theContext,
+                                         const CurveCreator_ICurve* theCurve,
+                                         const CurveCreator_ICurve::SectionToPointList& thePoints =
+                                               CurveCreator_ICurve::SectionToPointList() );
 
   /*!
    * \brief Sets the local point context for the 3D viewer.
+   * \param theCurve a curve object, that contains data
+   * \param theContext the viewer context
    * \param theOpen The flag to open or close the local context.
    */
   CURVECREATOR_EXPORT static void setLocalPointContext(
+                                        const CurveCreator_ICurve* theCurve,
                                         Handle(AIS_InteractiveContext) theContext,
                                         const bool theOpen );
 
-  /**
-   * Find the neighbour points by the clicked coordinates
-   * \param theContext the viewer context.
-   * \param theContext the V3D view.
-   * \param theX the X coordinate in the view.
-   * \param theY the Y coordinate in the view.
-   * \param thePoint the output point to be append to the model curve
-   * \param thePoint1 the output point to bound the line where a new point should be inserted
-   * \param thePoint2 the output point to bound the line where a new point should be inserted
-   */
-  CURVECREATOR_EXPORT static bool getNeighbourPoints(
-                                        Handle(AIS_InteractiveContext) theContext,
-                                        Handle(V3d_View) theView,
-                                        const int theX, const int theY,
-                                        gp_Pnt& thePoint, gp_Pnt& thePoint1,
-                                        gp_Pnt& thePoint2 );
-
-protected:
   /**
    * Checks whether the point belongs to the OCC object
    * \param theObject a line or shape with a bspline inside
@@ -128,6 +116,7 @@ protected:
                                                  gp_Pnt& thePoint, gp_Pnt& thePoint1,
                                                  gp_Pnt& thePoint2 );
 
+protected:
   /*
    * Returns whether the clicked point belong to the curve or has a very near projection
    * \param theX the X coordinate of a point clicked in the OCC viewer
@@ -139,8 +128,32 @@ protected:
                                                  Handle(V3d_View) theView,
                                                  const int theX, const int theY,
                                                  const Handle(Geom_Curve)& theCurve,
-                                                 Standard_Real& theParameter );
+                                                 Standard_Real& theParameter,
+                                                 int& theDelta );
+
+  /*
+   * Returns whether the X and Y coordinates is in the pixel tolerance
+   * \param theX the X coordinate of the first point
+   * \param theY the Y coordinate of the first point
+   * \param theOtherX the X coordinate of the second point
+   * \param theOtherY the Y coordinate of the second point
+   * \param theTolerance the tolerance to compare
+   * \param theDelta the sum of the a square of X and a square of Y
+   * \returns whether the points are provide to the pixel tolerance
+  */
+  CURVECREATOR_EXPORT static bool isEqualPixels( const int theX, const int theY,
+                                                 const int theOtherX, const int theOtherY,
+                                                 const double theTolerance, int& theDelta );
 
+
+  /*
+   * Returns whether the points are the same
+   * \param thePoint the first point
+   * \param theOtherPoint the second point
+   * \returns whether the points are provide to the pixel tolerance
+  */
+  CURVECREATOR_EXPORT static bool isEqualPoints( const gp_Pnt& thePoint,
+                                                 const gp_Pnt& theOtherPoint );
 };
 
 #endif // CURVECREATOR_UTILS_H