From 250cc05073a53b76e9636df07bb6dace89a1e094 Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 20 Nov 2013 08:54:51 +0000 Subject: [PATCH] Extending the modification mode for a lot of sections. --- src/HYDROCurveCreator/CurveCreator_Widget.cxx | 48 ++++++++++++++----- src/HYDROCurveCreator/CurveCreator_Widget.h | 2 + 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/src/HYDROCurveCreator/CurveCreator_Widget.cxx b/src/HYDROCurveCreator/CurveCreator_Widget.cxx index 94f41248..5df7014e 100644 --- a/src/HYDROCurveCreator/CurveCreator_Widget.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Widget.cxx @@ -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 > aConvPoints; + convert( aPoints, aConvPoints ); + QMap >::const_iterator anIt = aConvPoints.begin(), + aLast = aConvPoints.end(); + for ( ; anIt != aLast; anIt++ ) { + int aSectionId = anIt.key(); + + QList 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 >& theConvPoints ) +{ + theConvPoints.clear(); + + SectionToPointList::const_iterator anIt = thePoints.begin(), aLast = thePoints.end(); + QList 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; } diff --git a/src/HYDROCurveCreator/CurveCreator_Widget.h b/src/HYDROCurveCreator/CurveCreator_Widget.h index 93c839be..2ca9f1d6 100644 --- a/src/HYDROCurveCreator/CurveCreator_Widget.h +++ b/src/HYDROCurveCreator/CurveCreator_Widget.h @@ -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 >& theConvPoints ); // OCC algorithm bool pointOnObject( Handle(AIS_InteractiveObject) theObject, -- 2.39.2