+
+ // Set redo.
+ myPRedo = new CurveCreator_Operation;
+
+ if (myPRedo->init(theType, theParamList1)) {
+ // Construct undo for different commands.
+ switch (theType) {
+ case CurveCreator_Operation::InsertPoints:
+ {
+ // Construct undo for RemovePoints command.
+ CurveCreator_ICurve::SectionToPointList aSectionToPointList;
+ CurveCreator_ICurve::SectionToPointCoordsList::const_iterator anIt = theParamList1.begin(), aLast = theParamList1.end();
+ int aSectionId, aPointId;
+ for ( ; anIt != aLast; anIt++ ) {
+ aSectionToPointList.push_back(anIt->first);
+ }
+ setNbUndos(1);
+ isOK = myPUndo[0].init(CurveCreator_Operation::RemovePoints,
+ aSectionToPointList);
+ }
+ break;
+ case CurveCreator_Operation::SetCoordinates:
+ {
+ // Construct undo for SetCoordinates command.
+ CurveCreator_ICurve::SectionToPointCoordsList aSectionToPointOldCoords;
+ CurveCreator_ICurve::SectionToPointCoordsList::const_iterator anIt = theParamList1.begin(), aLast = theParamList1.end();
+ for ( ; anIt != aLast; anIt++ ) {
+ CurveCreator::Coordinates anOldCoords = theCurve->getPoint(anIt->first.first, anIt->first.second);
+ aSectionToPointOldCoords.push_back(std::make_pair(anIt->first, anOldCoords));
+ }
+
+ setNbUndos(1);
+ isOK = myPUndo[0].init(CurveCreator_Operation::SetCoordinates,
+ aSectionToPointOldCoords);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (!isOK) {
+ clear();
+ }