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;
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 );
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
// 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;
if ( !isRowLimit ) {
bool isBlocked = myLocalPointView->blockSignals(true);
- myLocalPointView->setRowCount( 0 );
- CurveCreator_ICurve::SectionToPointList::const_iterator anIt = myLocalPoints.begin(),
- aLast = myLocalPoints.end();
- for ( ; anIt != aLast; anIt++ )
- myLocalPointView->addLocalPointToTable( *anIt );
+
+ myLocalPointView->setLocalPointsToTable( myLocalPoints );
myLocalPointView->blockSignals( isBlocked );
}