From 71c7f6877e2dff0da906ecf16373ca94c93b7d67 Mon Sep 17 00:00:00 2001 From: mzn Date: Wed, 11 Dec 2013 07:58:54 +0000 Subject: [PATCH] Bug #205: Undo On Profile. --- .../CurveCreator_Profile.cxx | 28 +++++++++++++++++++ .../CurveCreator_Profile.hxx | 9 ++++++ 2 files changed, 37 insertions(+) diff --git a/src/HYDROCurveCreator/CurveCreator_Profile.cxx b/src/HYDROCurveCreator/CurveCreator_Profile.cxx index c857fd20..69e60486 100644 --- a/src/HYDROCurveCreator/CurveCreator_Profile.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Profile.cxx @@ -249,4 +249,32 @@ void CurveCreator_Profile::convert( const CurveCreator::PosPointsList& thePoints bool CurveCreator_Profile::canPointsBeSorted() { return true; +} + +/** + * Add one point to the specified section starting from the given theIPnt index + * (or at the end of points if \a theIPnt is -1). + */ +bool CurveCreator_Profile::addPoints( const CurveCreator::Coordinates& theCoords, + const int theISection, + const int theIPnt ) +{ + int anIPnt = theIPnt; + + if ( anIPnt == - 1 && theCoords.size() > 1 ) { + CurveCreator::Coordinates aCoords; + for ( int i = 0, aNb = getNbPoints( theISection ); i < aNb; i++ ) { + aCoords = getPoint( theISection, i ); + if ( aCoords.size() < 2 ) { + continue; + } + + if ( theCoords[0] < aCoords[0] ) { + anIPnt = i; + break; + } + } + } + + return CurveCreator_Curve::addPoints( theCoords, theISection, anIPnt ); } \ No newline at end of file diff --git a/src/HYDROCurveCreator/CurveCreator_Profile.hxx b/src/HYDROCurveCreator/CurveCreator_Profile.hxx index d544c87c..67461a42 100644 --- a/src/HYDROCurveCreator/CurveCreator_Profile.hxx +++ b/src/HYDROCurveCreator/CurveCreator_Profile.hxx @@ -110,6 +110,15 @@ public: //! For internal use only! Undo/Redo are not used here. virtual bool setPointInternal( const CurveCreator::SectionsMap &theSectionsMap ); + /** + * Add one point to the specified section starting from the given theIPnt index. + * Contrary to CurveCreator_Curve::addPoints(...) if \a theIPnt is -1 the right index + * will be calculated automatically in accordance with X coordinate value of the point. + */ + virtual bool addPoints( const CurveCreator::Coordinates &theCoords, + const int theISection, + const int theIPnt = -1 ); + /** * Indicates whether the points can be sorted. */ -- 2.39.2