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

index e3bc69f8a29671b7bbd81446ea3d818a4f7cfa39..96a838c6d9352e69580ca41ce4e9cdbeb61711d9 100644 (file)
@@ -1354,6 +1354,32 @@ void CurveCreator_Widget::getSelectedPonts( CurveCreator_ICurve::SectionToPointL
     thePoints.push_back( std::make_pair( getSectionId( i ), getPointId( i ) ) );
 }
 
+
+bool CurveCreator_Widget::isIntersectVertexToPoint( const TopoDS_Vertex& theVertex,
+                               const CurveCreator_ICurve::SectionToPoint& theSToPoint )
+{
+  bool isIntersect = false;
+
+  if ( theVertex.IsNull() )
+    return isIntersect;
+
+  gp_Pnt aPnt = BRep_Tool::Pnt( theVertex );
+
+  CurveCreator_ICurve::SectionToPointList aPoints;
+  findSectionsToPoints( aPnt.X(), aPnt.Y(), aPoints );
+
+  CurveCreator_ICurve::SectionToPointList::const_iterator anIt = aPoints.begin(),
+                                                          aLast = aPoints.end();
+  CurveCreator_ICurve::SectionToPoint aPoint;
+  for ( ; anIt != aLast && !isIntersect; anIt++ ) {
+    aPoint = *anIt;
+    isIntersect = aPoint.first == theSToPoint.first && aPoint.second == theSToPoint.second;
+  }
+
+  return isIntersect;
+}
+
+
 void CurveCreator_Widget::setSelectedPonts( const CurveCreator_ICurve::SectionToPointList& thePoints )
 {
   if ( myDragStarted )
@@ -1366,10 +1392,12 @@ void CurveCreator_Widget::setSelectedPonts( const CurveCreator_ICurve::SectionTo
 
   AIS_ListOfInteractive aDisplayedList;
   ic->DisplayedObjects( aDisplayedList );
+  ic->ClearSelected( Standard_False );
 
   CurveCreator_ICurve::SectionToPointList::const_iterator anIt = thePoints.begin(),
                                                           aLast = thePoints.end();
   CurveCreator_ICurve::SectionToPoint aSToPoint;
+  bool isSelectedVertex = false;
   for( ; anIt != aLast; anIt++ ) {
     aSToPoint = *anIt;
 
@@ -1379,40 +1407,31 @@ void CurveCreator_Widget::setSelectedPonts( const CurveCreator_ICurve::SectionTo
       if ( anAIS.IsNull() )
         continue;
       Handle(AIS_Point) anAISPoint = Handle(AIS_Point)::DownCast( anAIS );
-      if ( anAISPoint.IsNull() )
-        continue;
-
-      TopoDS_Vertex aVertex = TopoDS::Vertex( anAISPoint->Vertex() );
-
-      if ( aVertex.IsNull() )
-        continue;
-
-      gp_Pnt aPnt = BRep_Tool::Pnt( aVertex );
-
-      CurveCreator_ICurve::SectionToPointList aPoints;
-      findSectionsToPoints( aPnt.X(), aPnt.Y(), aPoints );
-
-      CurveCreator_ICurve::SectionToPointList::const_iterator anIt = aPoints.begin(),
-                                                              aLast = aPoints.end();
-      CurveCreator_ICurve::SectionToPoint aPoint;
-      for ( ; anIt != aLast; anIt++ ) {
-        aPoint = *anIt;
-        if ( aPoint.first == aSToPoint.first && aPoint.second == aSToPoint.second )
+      if ( !anAISPoint.IsNull() ) {
+        TopoDS_Vertex aVertex = TopoDS::Vertex( anAISPoint->Vertex() );
+        if ( isIntersectVertexToPoint( aVertex, aSToPoint ) )
           aListToSelect.Append( anAIS );
       }
+      else {
+        Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast( anAIS );
+        if ( anAISShape.IsNull() )
+          continue;
+        const TopoDS_Shape& aShape = anAISShape->Shape();
+        TopExp_Explorer aExpV( aShape, TopAbs_VERTEX);
+        for ( ; aExpV.More(); aExpV.Next() )
+        {
+          const TopoDS_Vertex& aVertex = TopoDS::Vertex( aExpV.Current() );
+          if ( isIntersectVertexToPoint( aVertex, aSToPoint ) ) {
+            ic->AddOrRemoveSelected( aVertex, Standard_False );
+            isSelectedVertex = true;
+          }
+        }
+      }
     }
   }
-  if ( thePoints.size() > 0 && aListToSelect.First() == aListToSelect.Last() ) {
-    /*TopExp_Explorer aExpF(myShape,TopAbs_FACE);
-    for (; aExpF.More(); aExpF.Next())
-    {
-        const TopoDS_Face& aFace = TopoDS::Face(aExpF.Current());
-    }*/
-  }
-
-
-  ic->ClearSelected( Standard_False );
-  setObjectsSelected( aListToSelect );
+  ic->UpdateCurrentViewer();
+  if ( !isSelectedVertex )
+    setObjectsSelected( aListToSelect );
   updateLocalPointView();
 }
 
index 43fdb492fbc398e53fbd5ac11f2e3f506006e0ea..6f073f165f7696cc88b320f642f8dc03d0ff868d 100644 (file)
@@ -34,6 +34,7 @@
 #include <Geom_Curve.hxx>
 #include <V3d_View.hxx>
 #include <gp_Pnt.hxx>
+#include <TopoDS_Vertex.hxx> // TODO - remove
 
 class OCCViewer_Viewer;
 class OCCViewer_ViewPort3d;
@@ -168,6 +169,8 @@ private:
   void setDragStarted( const bool theState, const QPoint& thePoint = QPoint() );
 
   void getSelectedPonts( CurveCreator_ICurve::SectionToPointList& thePoints );
+  bool isIntersectVertexToPoint( const TopoDS_Vertex& theVertex,
+                               const CurveCreator_ICurve::SectionToPoint& theSToPoint );
   void setSelectedPonts( const CurveCreator_ICurve::SectionToPointList& =
                                CurveCreator_ICurve::SectionToPointList() );