Salome HOME
Implementation of changing coordinates for array of points.
authorakl <akl@opencascade.com>
Fri, 22 Nov 2013 06:35:04 +0000 (06:35 +0000)
committerakl <akl@opencascade.com>
Fri, 22 Nov 2013 06:35:04 +0000 (06:35 +0000)
src/HYDROCurveCreator/CurveCreator_Curve.cxx
src/HYDROCurveCreator/CurveCreator_Widget.cxx

index 8572a116d99433a57ca2b838d3651ada532f8224..7732314881c16fce744807370401d6da9500067b 100644 (file)
@@ -918,7 +918,35 @@ bool CurveCreator_Curve::setPoint( const int theISection,
 //! Set coordinates of specified points from different sections
 bool CurveCreator_Curve::setSeveralPoints( const SectionToPointCoordsList &theSectionToPntCoords)
 {
-  return false;
+  bool res = false;
+  // Set the difference.
+  startOperation();
+  if (addEmptyDiff()) {
+    myListDiffs.back().init(this, CurveCreator_Operation::SetCoordinates,
+                            theSectionToPntCoords);
+  }
+  CurveCreator::SectionsMap aSectionsMap;
+  CurveCreator::PosPointsList aPosPoints;
+  CurveCreator_ICurve::SectionToPointCoordsList::const_iterator anIt = 
+    theSectionToPntCoords.begin(), aLast = theSectionToPntCoords.end();
+  int aSectionId, aPointId;
+  for ( ; anIt != aLast; anIt++ ) {
+    aPosPoints.clear();
+    aSectionId = anIt->first.first;
+    aPointId = anIt->first.second;
+    CurveCreator::Coordinates aNewCoords = anIt->second;
+    CurveCreator_PosPoint* aPosPoint = 
+      new CurveCreator_PosPoint( aPointId, aNewCoords );
+    if( aSectionsMap.find(aSectionId) != aSectionsMap.end() )
+      aPosPoints = aSectionsMap[aSectionId];
+    aPosPoints.push_back( aPosPoint );
+    aSectionsMap[aSectionId] = aPosPoints;
+    
+  }
+  res = setPointInternal( aSectionsMap );
+  finishOperation();
+
+  return res; 
 }
 
 //! For internal use only! Undo/Redo are not used here.
index 6c3343953a1e7845e43b08dfbaac3c69a06228cc..edcdb68c76598678b3d883ca7b3ad6325f28996c 100644 (file)
@@ -1121,11 +1121,17 @@ void CurveCreator_Widget::moveSelectedPoints( const int theXPosition,
   std::deque<float> aChangedPos;
   SectionToPointList::const_iterator anIt = myDragPoints.begin(), aLast = myDragPoints.end();
   for ( ; anIt != aLast; anIt++ ) {
-    aChangedPos = myCurve->getPoint( anIt->first, anIt->second );
+    int aSectionId = anIt->first;
+    int aPointId = anIt->second;
+    aChangedPos = myCurve->getPoint( aSectionId, aPointId );
     if ( aChangedPos.size() < 2 )
       continue;
     aChangedPos[0] = aChangedPos[0] - aXDelta;
     aChangedPos[1] = aChangedPos[1] - anYDelta;
+    
+    aCoordList.push_back(
+      std::make_pair(std::make_pair( aSectionId, aPointId ), 
+                     aChangedPos ));
   }
   myCurve->setSeveralPoints( aCoordList );