]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Fix fo bug: when move profile point and sorting - undo works incorrect (restore posit...
authormzn <mzn@opencascade.com>
Fri, 13 Dec 2013 11:03:46 +0000 (11:03 +0000)
committermzn <mzn@opencascade.com>
Fri, 13 Dec 2013 11:03:46 +0000 (11:03 +0000)
src/HYDROCurveCreator/CurveCreator_Widget.cxx
src/HYDROCurveCreator/CurveCreator_Widget.h

index 6961f01b44933e1707915be691da17cc9dcdd09f..5fdb921d28de21b5c9065dfc83344833641964c2 100644 (file)
@@ -977,7 +977,7 @@ void CurveCreator_Widget::onMouseRelease( SUIT_ViewWindow*, QMouseEvent* theEven
   if ( myDragStarted ) {
     bool isDragged = myDragged;
     CurveCreator_ICurve::SectionToPointList aDraggedPoints;
-    CurveCreator_ICurve::SectionToPointCoordsList anInitialDragPointsCoords;
+    QMap<CurveCreator_ICurve::SectionToPoint, std::deque< float >> anInitialDragPointsCoords;
     if ( myDragged ) {
       aDraggedPoints = myDragPoints;
       anInitialDragPointsCoords = myInitialDragPointsCoords;
@@ -986,7 +986,31 @@ void CurveCreator_Widget::onMouseRelease( SUIT_ViewWindow*, QMouseEvent* theEven
     setDragStarted( false );
 
     if ( aDraggedPoints.size() > 0 ) {
+      // Collect old coordinates of the dragged points
+      CurveCreator_ICurve::SectionToPointCoordsList anOldPoints;
+      foreach ( const CurveCreator_ICurve::SectionToPoint aSectionToPoint, anInitialDragPointsCoords.keys() ) {
+        CurveCreator::Coordinates aCoords = anInitialDragPointsCoords.value( aSectionToPoint );
+        anOldPoints.push_back( std::make_pair( aSectionToPoint, aCoords ) );
+      }
+
       if ( myCurve->canPointsBeSorted() ) {
+        // Add old coordinates of the curve points (except the dragged points) to the list
+        for( int aSectionId = 0 ; aSectionId < myCurve->getNbSections() ; aSectionId++ ) {
+          CurveCreator::Coordinates aCoords;
+          for ( int aPointId = 0, aNb = myCurve->getNbPoints( aSectionId ); aPointId < aNb; aPointId++ ) {
+            aCoords = myCurve->getPoint( aSectionId, aPointId );
+            if ( aCoords.size() < 2 ) {
+              continue;
+            }
+            
+            CurveCreator_ICurve::SectionToPoint aSectionToPoint = std::make_pair( aSectionId, aPointId );
+
+            if ( !anInitialDragPointsCoords.contains( aSectionToPoint ) ) {
+              anOldPoints.push_back( std::make_pair( aSectionToPoint, aCoords ) );
+            }
+          }
+        }
+        
         // Apply points sorting
         CurveCreator_ICurve::SectionToPointList aPoints;
         startCurveModification( aPoints, false );
@@ -1010,15 +1034,13 @@ void CurveCreator_Widget::onMouseRelease( SUIT_ViewWindow*, QMouseEvent* theEven
         finishCurveModification( aDraggedPoints );
       } else {
         // if the drag of some points has happened, restore the drag selection
-        if ( aDraggedPoints.size() > 0 ) {
-          START_MEASURE_TIME;
-          setSelectedPoints( aDraggedPoints );
-          END_MEASURE_TIME( "drop" );
-        }
+        START_MEASURE_TIME;
+        setSelectedPoints( aDraggedPoints );
+        END_MEASURE_TIME( "drop" );
       }
 
       // Save drag difference
-      myCurve->saveCoordDiff( anInitialDragPointsCoords );
+      myCurve->saveCoordDiff( anOldPoints );
     }
   }
   else // check whether the segment is clicked an a new point should be added to the segment
@@ -1253,9 +1275,7 @@ void CurveCreator_Widget::moveSelectedPoints( const int theXPosition,
 
     // Remember drag points coordinates
     if ( !myDragged ) {
-      myInitialDragPointsCoords.push_back(
-        std::make_pair(std::make_pair( aSectionId, aPointId ), 
-                       aChangedPos ));
+      myInitialDragPointsCoords.insert( std::make_pair( aSectionId, aPointId ), aChangedPos );
     }
 
     aChangedPos[0] = aChangedPos[0] - aXDelta;
index a5e8ba136c99997d3c1f7835080697523112aeb7..2d8a3e02171b5d8743545f0d1fd99241237e76f7 100644 (file)
@@ -216,7 +216,7 @@ private:
   QPoint                      myDragStartPosition;
   int                         myDragInteractionStyle;
   CurveCreator_ICurve::SectionToPointList myDragPoints;
-  CurveCreator_ICurve::SectionToPointCoordsList myInitialDragPointsCoords;
+  QMap<CurveCreator_ICurve::SectionToPoint, CurveCreator::Coordinates> myInitialDragPointsCoords;
   bool                        myDragged;
   QByteArray                  myGuiState;
 };