]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
OCC functionality moving out from the widget
authornds <nds@opencascade.com>
Tue, 3 Dec 2013 08:42:47 +0000 (08:42 +0000)
committernds <nds@opencascade.com>
Tue, 3 Dec 2013 08:42:47 +0000 (08:42 +0000)
src/HYDROCurveCreator/CurveCreator_Utils.cxx
src/HYDROCurveCreator/CurveCreator_Utils.h
src/HYDROCurveCreator/CurveCreator_Widget.cxx

index 1775167850ea90c1f35e20cca96947adf9fc4922..1fa61b3378265aaa96134014f620f2de147b8980 100644 (file)
@@ -48,7 +48,7 @@
 #include <ElSLib.hxx>
 
 const double LOCAL_SELECTION_TOLERANCE = 0.0001;
-const int SCENE_PIXEL_TOLERANCE = 10;
+const int    SCENE_PIXEL_TOLERANCE = 10;
 
 //=======================================================================
 // function : ConvertClickToPoint()
@@ -69,26 +69,6 @@ void CurveCreator_Utils::ConvertPointToClick( const gp_Pnt& thePoint,
 gp_Pnt CurveCreator_Utils::ConvertClickToPoint( int x, int y, Handle(V3d_View) aView )
 {
   return GEOMUtils::ConvertClickToPoint( x, y, aView );
-  /*
-  V3d_Coordinate XEye, YEye, ZEye, XAt, YAt, ZAt;
-  aView->Eye( XEye, YEye, ZEye );
-
-  aView->At( XAt, YAt, ZAt );
-  gp_Pnt EyePoint( XEye, YEye, ZEye );
-  gp_Pnt AtPoint( XAt, YAt, ZAt );
-
-  gp_Vec EyeVector( EyePoint, AtPoint );
-  gp_Dir EyeDir( EyeVector );
-
-  gp_Pln PlaneOfTheView = gp_Pln( AtPoint, EyeDir );
-  Standard_Real X, Y, Z;
-  aView->Convert( x, y, X, Y, Z );
-  gp_Pnt ConvertedPoint( X, Y, Z );
-
-  gp_Pnt2d ConvertedPointOnPlane = ProjLib::Project( PlaneOfTheView, ConvertedPoint );
-  gp_Pnt ResultPoint = ElSLib::Value( ConvertedPointOnPlane.X(), ConvertedPointOnPlane.Y(), PlaneOfTheView );
-  return ResultPoint;
-  */
 }
 
 //=======================================================================
index 52d34e6325b66990cd104e380c0c776a57bfb2a3..c9ca61547e4862497bd9964a9d4c205da07123d1 100644 (file)
@@ -62,6 +62,22 @@ public:
                                         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 );
   /**
    * Checks whether the point belongs to the OCC object
    * \param theObject a line or shape with a bspline inside
index a19fbeade899d55d4dffe5a478d7c713221a8097..be18c55a75869a1e6838b44747ab681106d478bc 100644 (file)
@@ -468,7 +468,7 @@ void CurveCreator_Widget::onAdditionMode(bool checked)
     return;
 
   Handle(AIS_InteractiveContext) aContext = getAISContext();
-  if( !myCurve || !aContext )
+  if( !myCurve || aContext.IsNull() )
     return;
 
   mySection= -1;
@@ -925,7 +925,7 @@ void CurveCreator_Widget::onGetCoordsByClick( QMouseEvent* pe )
 
   if ( pe->modifiers() != Qt::ControlModifier ) {
     Handle(AIS_InteractiveContext) ic = getAISContext();
-    if ( !ic )
+    if ( ic.IsNull() )
       return;
 
     gp_Pnt aPnt;    
@@ -1128,35 +1128,18 @@ void CurveCreator_Widget::insertPointToSelectedSegment( const int theX,
                                                         const int theY )
 {
   Handle(AIS_InteractiveContext) aContext = getAISContext();
-  if ( !aContext )
-    return;
-  gp_Pnt aPoint;
-  gp_Pnt aPoint1, aPoint2;
-  bool isFoundPoint = false;
 
   OCCViewer_ViewPort3d* aViewPort = getViewPort();
   Handle(V3d_View) aView;
   if ( aViewPort )
     aView = aViewPort->getView();
-  if ( aView.IsNull() )
-    return;
-
-  for ( aContext->InitSelected(); aContext->MoreSelected() && !isFoundPoint;
-        aContext->NextSelected() ) {
-    TopoDS_Shape aTShape = aContext->SelectedShape();
-    if ( !aTShape.IsNull() && aTShape.ShapeType() == TopAbs_VERTEX )
-      continue;
-    else {
-      Handle(SelectMgr_EntityOwner) anOwner = aContext->SelectedOwner();
-      if ( anOwner.IsNull() )
-        continue;
-      const TopLoc_Location& aLocation = anOwner->Location();
-      Handle(AIS_InteractiveObject) anAIS = Handle(AIS_InteractiveObject)::DownCast( anOwner->Selectable() );
 
-      isFoundPoint = CurveCreator_Utils::pointOnObject( aView, anAIS, theX, theY, aPoint,
-                                                        aPoint1, aPoint2 );
-    }
-  }
+  if ( aContext.IsNull() || aView.IsNull() )
+    return;
+  gp_Pnt aPoint;
+  gp_Pnt aPoint1, aPoint2;
+  bool isFoundPoint = CurveCreator_Utils::getNeighbourPoints( aContext, aView, theX, theY,
+                                                              aPoint, aPoint1, aPoint2 );
   if ( !isFoundPoint )
     return;
 
@@ -1248,7 +1231,7 @@ void CurveCreator_Widget::updateLocalPointView()
   if ( myDragStarted )
     return;
   Handle(AIS_InteractiveContext) aContext = getAISContext();
-  if ( !aContext )
+  if ( aContext.IsNull() )
     return;
 
   bool isBlocked = myLocalPointView->blockSignals(true);
@@ -1393,7 +1376,7 @@ void CurveCreator_Widget::setSelectedPonts( const CurveCreator_Widget::SectionTo
   if ( myDragStarted )
     return;
   Handle(AIS_InteractiveContext) ic = getAISContext();
-  if ( !ic || !ic->HasOpenedContext() )
+  if ( ic.IsNull() || !ic->HasOpenedContext() )
     return;
 
   AIS_ListOfInteractive aListToSelect;