]> 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 09:15:16 +0000 (09:15 +0000)
committernds <nds@opencascade.com>
Tue, 3 Dec 2013 09:15:16 +0000 (09:15 +0000)
src/HYDROCurveCreator/CurveCreator_Utils.cxx
src/HYDROCurveCreator/CurveCreator_Utils.h
src/HYDROCurveCreator/CurveCreator_Widget.cxx

index 1fa61b3378265aaa96134014f620f2de147b8980..73b429b446db6a5a20047c7bf34a2f5c4d1163e4 100644 (file)
@@ -71,6 +71,50 @@ gp_Pnt CurveCreator_Utils::ConvertClickToPoint( int x, int y, Handle(V3d_View) a
   return GEOMUtils::ConvertClickToPoint( x, y, aView );
 }
 
+std::list<float> CurveCreator_Utils::getSelectedPoints( Handle(AIS_InteractiveContext) theContext )
+{
+  std::list<float> aSelectedPoints;
+
+  gp_Pnt aPnt;
+  for ( theContext->InitSelected(); theContext->MoreSelected(); theContext->NextSelected() ) {
+    TopoDS_Vertex aVertex;
+    TopoDS_Shape aShape = theContext->SelectedShape();
+    if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
+      aVertex = TopoDS::Vertex( theContext->SelectedShape() );
+    else {
+      Handle(SelectMgr_EntityOwner) anOwner = theContext->SelectedOwner();
+      if ( !anOwner.IsNull() ) {
+        Handle(AIS_InteractiveObject) anAIS = Handle(AIS_InteractiveObject)::DownCast( anOwner->Selectable() );
+        if ( !anAIS.IsNull() ) {
+          Handle(AIS_Point) aPoint = Handle(AIS_Point)::DownCast( anAIS);
+          if ( !aPoint.IsNull() )
+            aVertex = TopoDS::Vertex( aPoint->Vertex() );
+        }
+        if ( aVertex.IsNull() ) {
+          // the following happens if there are no points in the current curve, there is only a shape
+          /*Handle(StdSelect_BRepOwner) aBrepOwner = Handle(StdSelect_BRepOwner)::DownCast(anOwner);
+          if ( aBrepOwner.IsNull() )
+            continue;
+          if ( aBrepOwner->HasShape() ) {
+            const TopoDS_Shape& aShape = aBrepOwner->Shape();
+            if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
+            {
+              aVertex = TopoDS::Vertex( aShape );
+            }
+          }*/
+        }
+      }
+    }
+    if ( aVertex.IsNull() )
+      continue;
+    aPnt = BRep_Tool::Pnt( aVertex );
+    aSelectedPoints.push_back( aPnt.X() );
+    aSelectedPoints.push_back( aPnt.Y() );
+    aSelectedPoints.push_back( aPnt.Z() );
+  }
+
+  return aSelectedPoints;
+}
 //=======================================================================
 // function : setLocalPointContext
 // purpose  : Open/close the viewer local context
index c9ca61547e4862497bd9964a9d4c205da07123d1..5415214d888de43c4c6af2d82c8e1b600fe249a8 100644 (file)
@@ -27,6 +27,8 @@
 #include <gp_Pnt.hxx>
 #include <Geom_Curve.hxx>
 
+#include <list>
+
 class CurveCreator_Utils
 {
 public:
@@ -52,7 +54,14 @@ public:
    * \retval gp_Pnt Returns the point clicked in 3D view
    */
   CURVECREATOR_EXPORT static gp_Pnt ConvertClickToPoint( int x, int y,
-                                                       Handle(V3d_View) theView );
+                                                         Handle(V3d_View) theView );
+
+  /**
+   * Find selected points in the context
+   * \param theContext the viewer context
+   */
+  CURVECREATOR_EXPORT static std::list<float> getSelectedPoints(
+                                        Handle(AIS_InteractiveContext) theContext );
 
   /*!
    * \brief Sets the local point context for the 3D viewer.
index be18c55a75869a1e6838b44747ab681106d478bc..16a2da7942c38774237a96e625a9d34a1c47d376 100644 (file)
@@ -1234,42 +1234,21 @@ void CurveCreator_Widget::updateLocalPointView()
   if ( aContext.IsNull() )
     return;
 
+  std::list<float> aSelectedList = CurveCreator_Utils::getSelectedPoints( aContext );
+
+  std::list<float>::const_iterator anIt = aSelectedList.begin(), aLast = aSelectedList.end();
+  float aX, anY, aZ;
+
   bool isBlocked = myLocalPointView->blockSignals(true);
-  gp_Pnt aPnt;
   myLocalPointView->setRowCount( 0 );
-  for ( aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected() ) {
-    TopoDS_Vertex aVertex;
-    TopoDS_Shape aShape = aContext->SelectedShape();
-    if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
-      aVertex = TopoDS::Vertex( aContext->SelectedShape() );
-    else {
-      Handle(SelectMgr_EntityOwner) anOwner = aContext->SelectedOwner();
-      if ( !anOwner.IsNull() ) {
-        Handle(AIS_InteractiveObject) anAIS = Handle(AIS_InteractiveObject)::DownCast( anOwner->Selectable() );
-        if ( !anAIS.IsNull() ) {
-          Handle(AIS_Point) aPoint = Handle(AIS_Point)::DownCast( anAIS);
-          if ( !aPoint.IsNull() )
-            aVertex = TopoDS::Vertex( aPoint->Vertex() );
-        }
-        if ( aVertex.IsNull() ) {
-          // the following happens if there are no points in the current curve, there is only a shape
-          /*Handle(StdSelect_BRepOwner) aBrepOwner = Handle(StdSelect_BRepOwner)::DownCast(anOwner);
-          if ( aBrepOwner.IsNull() )
-            continue;
-          if ( aBrepOwner->HasShape() ) {
-            const TopoDS_Shape& aShape = aBrepOwner->Shape();
-            if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
-            {
-              aVertex = TopoDS::Vertex( aShape );
-            }
-          }*/
-        }
-      }
-    }
-    if ( aVertex.IsNull() )
-      continue;
-    aPnt = BRep_Tool::Pnt( aVertex );
-    addLocalPointToTable( aPnt.X(), aPnt.Y() );
+  for ( ; anIt != aLast; anIt++ )
+  {
+    aX = *anIt;
+    anIt++;
+    anY = *anIt;
+    anIt++;
+    aZ = *anIt;
+    addLocalPointToTable( aX, anY );
   }
   myLocalPointView->blockSignals(isBlocked);
 }