]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Extending the modification mode for a lot of sections.
authornds <nds@opencascade.com>
Wed, 20 Nov 2013 08:54:51 +0000 (08:54 +0000)
committernds <nds@opencascade.com>
Wed, 20 Nov 2013 08:54:51 +0000 (08:54 +0000)
src/HYDROCurveCreator/CurveCreator_Widget.cxx
src/HYDROCurveCreator/CurveCreator_Widget.h

index 94f41248773476f7ddaa35ab4782afb0d6bccc93..5df7014e834f9399a68e66b8e35f477818c4b016 100644 (file)
@@ -993,15 +993,22 @@ void CurveCreator_Widget::removePoint()
   startCurveModification( aSelPoints, false );
 
   // the points should be removed in a decreased order
-  qSort( aPoints );
-  SectionToPointList::const_iterator anIt = aPoints.end(), aFirst = aPoints.begin();
-  anIt--;
-  for ( ; anIt != aFirst; anIt-- ) {
-    int aSectionId = anIt->first;
-    int aPointId = anIt->second;
-    myCurve->removePoint( aSectionId, aPointId );
-    mySectionView->pointsRemoved( aSectionId, aPointId );
+  QMap<int, QList<int> > aConvPoints;
+  convert( aPoints, aConvPoints );
+  QMap<int, QList<int> >::const_iterator anIt = aConvPoints.begin(),
+                                          aLast = aConvPoints.end();
+  for ( ; anIt != aLast; anIt++ ) {
+    int aSectionId = anIt.key();
+
+    QList<int> aSectionPoints = anIt.value();
+    qSort( aPoints );
+    for( int i = aSectionPoints.size()-1; i >= 0; i-- ){
+      int aPntIndx = aSectionPoints[i];
+      myCurve->removePoint( aSectionId, aPntIndx );
+      mySectionView->pointsRemoved( aSectionId, aPntIndx );
+    }
   }
+
   finishCurveModification( SectionToPointList() );
 }
 
@@ -1418,6 +1425,27 @@ void CurveCreator_Widget::findSectionsToPoints( const double theX, const double
   }
 }
 
+void CurveCreator_Widget::convert( const SectionToPointList& thePoints,
+                                   QMap<int, QList<int> >& theConvPoints )
+{
+  theConvPoints.clear();
+
+  SectionToPointList::const_iterator anIt = thePoints.begin(), aLast = thePoints.end();
+  QList<int> aPoints;
+  int aSectionId, aPointId;
+  for ( ; anIt != aLast; anIt++ ) {
+    aSectionId = anIt->first;
+    aPointId = anIt->second;
+    aPoints.clear();
+    if ( theConvPoints.contains( aSectionId ) )
+      aPoints = theConvPoints[aSectionId];
+    if ( aPoints.contains( aPointId ) )
+      continue;
+    aPoints.append( aPointId );
+    theConvPoints[aSectionId] = aPoints;
+  }
+}
+
 /**
  * Checks whether the point belongs to the OCC object
  * \param theObject a line or shape with a bspline inside
@@ -1495,12 +1523,8 @@ bool CurveCreator_Widget::pointOnObject( Handle(AIS_InteractiveObject) theObject
   }
   if ( isFound ) {
     thePoint = aPoint;
-
     thePoint1 = aPnt1;
     thePoint2 = aPnt2;
-    //thePoint1 = findLocalPointIndex( 0, aPnt1.X(), aPnt1.Y() );
-    //thePoint2 = findLocalPointIndex( 0, aPnt2.X(), aPnt2.Y() );
-    //isFound = thePoint1 >= 0 && thePoint2 >= 0;
   }
   return isFound;
 }
index 93c839bef13803b320472ad636cc38c2fc5863ee..2ca9f1d6190832091d02603068ad1821a67ac67a 100644 (file)
@@ -163,6 +163,8 @@ private:
   int  findLocalPointIndex( int theSectionId, float theX, float theY );
   void findSectionsToPoints( const double theX, const double theY,
                              SectionToPointList& thePoints );
+  void convert( const SectionToPointList& thePoints,
+                QMap<int, QList<int> >& theConvPoints );
 
   // OCC algorithm
   bool pointOnObject( Handle(AIS_InteractiveObject) theObject,