X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROCurveCreator%2FCurveCreator_Curve.cxx;h=cccf4a20302532beeecfd8c54a4e79c9cc11cbc2;hb=e38481b5d965c3736d2c8eda39b1a30bd125147b;hp=c95d151ba70f7197e94e96e7acb64d30ddde17e4;hpb=b39007a5784e9dcbbae250bea4bca432f12244b9;p=modules%2Fhydro.git diff --git a/src/HYDROCurveCreator/CurveCreator_Curve.cxx b/src/HYDROCurveCreator/CurveCreator_Curve.cxx index c95d151b..cccf4a20 100644 --- a/src/HYDROCurveCreator/CurveCreator_Curve.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Curve.cxx @@ -400,7 +400,7 @@ bool CurveCreator_Curve::moveSection(const int theISection, } void CurveCreator_Curve::convert( const SectionToPointList& thePoints, - std::map>& theConvPoints ) + std::map< int, std::list >& theConvPoints ) { theConvPoints.clear(); @@ -520,12 +520,13 @@ bool CurveCreator_Curve::joinInternal( const int theISectionTo, return res; } -//! Join range of sections to one section (join all sections if -1 is passed in one of arguments) +//! Join range of sections to one section (join all sections if -1 is passed in theISectionFrom argument) bool CurveCreator_Curve::join( const int theISectionTo, const int theISectionFrom ) { + //TODO bool res = false; - if (theISectionTo != theISectionFrom) { + if ( theISectionTo != theISectionFrom ) { startOperation(); if (addEmptyDiff()) myListDiffs.back().init(this, CurveCreator_Operation::Join, theISectionTo, theISectionFrom); @@ -654,7 +655,8 @@ int CurveCreator_Curve::getNbPoints( const int theISection ) const aNbCoords += mySections[i]->myPoints.size(); } } else { - aNbCoords = mySections.at(theISection)->myPoints.size(); + if ( ( theISection >= 0 ) && ( theISection < mySections.size() ) ) + aNbCoords = mySections.at(theISection)->myPoints.size(); } return aNbCoords/myDimension; @@ -873,7 +875,8 @@ bool CurveCreator_Curve::setPointInternal( const CurveCreator::SectionsMap &theS for( ; aPntIt != aSectionPoints.end(); aPntIt++ ){ int anIPnt = (*aPntIt)->myID; CurveCreator::Coordinates aCoords = (*aPntIt)->myCoords; - aSection->myPoints.assign(aCoords.begin(), aCoords.end()); + for ( int i = 0; i < myDimension; i++) + aSection->myPoints.at(toICoord(anIPnt) + i) = aCoords[i]; } res = true; } @@ -904,7 +907,10 @@ bool CurveCreator_Curve::setPoint( const int theISection, aPoints.push_back( aPosPoint ); aSectionsMap[theISection] = aPoints; + int aSize1 = getNbPoints( theISection ); res = setPointInternal( aSectionsMap ); + int aSize2 = getNbPoints( theISection ); + finishOperation(); return res; @@ -913,7 +919,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. @@ -1002,7 +1036,12 @@ CurveCreator::Coordinates CurveCreator_Curve::getPoint( const int theISection, //======================================================================= CurveCreator::Coordinates CurveCreator_Curve::getPoints( const int theISection ) const { - return mySections.at(theISection)->myPoints; + CurveCreator::Coordinates aCoords; + if ( ( theISection >= 0 ) && ( theISection < mySections.size() ) ) + { + aCoords = mySections.at(theISection)->myPoints; + } + return aCoords; }