- bool isFoundPoint = false;
- Handle(AIS_InteractiveContext) aContext = aViewer->getAISContext();
- for ( aContext->InitSelected(); aContext->MoreSelected() && !isFoundPoint;
- aContext->NextSelected() ) {
- TopoDS_Shape aTShape = aContext->SelectedShape();
- if ( !aTShape.IsNull() && aTShape.ShapeType() == TopAbs_VERTEX )
- continue;
- else {
- Handle(SelectMgr_EntityOwner) anOwner = aContext->SelectedOwner();
- if ( anOwner.IsNull() )
- continue;
- const TopLoc_Location& aLocation = anOwner->Location();
- Handle(AIS_InteractiveObject) anAIS = Handle(AIS_InteractiveObject)::DownCast( anOwner->Selectable() );
- isFoundPoint = pointOnObject( anAIS, theX, theY, aPoint, aPoint1, aPoint2 );
+ gp_Pnt aPoint1, aPoint2;
+ bool isFoundPoint = CurveCreator_Utils::getNeighbourPoints( aContext, aView, theX, theY,
+ aPoint, aPoint1, aPoint2 );
+ if ( !isFoundPoint )
+ return;
+
+ // insert the point to the model curve
+ CurveCreator_ICurve::SectionToPointList aSelPoints;
+ startCurveModification( aSelPoints );
+
+ CurveCreator::Coordinates aCoords;
+ aCoords.push_back( aPoint.X() );
+ aCoords.push_back( aPoint.Y() );
+
+ CurveCreator_ICurve::SectionToPointList aPoints1, aPoints2;
+ findSectionsToPoints( aPoint1.X(), aPoint1.Y(), aPoints1 );
+ findSectionsToPoints( aPoint2.X(), aPoint2.Y(), aPoints2 );
+ CurveCreator_ICurve::SectionToPointList::const_iterator anIt = aPoints1.begin(),
+ aLast = aPoints1.end();
+ int aSectionId = -1;
+ // there can be a case when a new point is added into two sections
+ int aPoint1Id = -1, aPoint2Id = -1;
+ for ( ; anIt != aLast && aSectionId < 0; anIt++ ) {
+ int aSectionCur = anIt->first;
+ CurveCreator_ICurve::SectionToPointList::const_iterator anIt2 = aPoints2.begin(),
+ aLast2 = aPoints2.end();
+ for ( ; anIt2 != aLast2 && aSectionId < 0; anIt2++ ) {
+ if ( anIt2->first == aSectionCur ) {
+ aSectionId = aSectionCur;
+ aPoint1Id = anIt->second;
+ aPoint2Id = anIt2->second;
+ }